#mod_development

1 messages · Page 45 of 1

ancient grail
#

On lua console
Might work. I just noticed that the function does it on an instance..maybe if u do it on the actual player

#

Then it might work.. idk

gilded hawk
#

Moddata might be the best and easiest option

safe silo
#

The UseDelta variable in drainable items such as batteries. Are they transferred over?

Like could I in theory create a "Infinite Battery" item with UseDelta = 0?

I'm assuming the second I put it into a Flashlight or w/e the UseDelta will be overwritten by the Flashlight's.

gilded hawk
#

Eg:

local player = getPlayer()
local modData = player:getModData()
ancient grail
safe silo
# ancient grail making infinite flashlight is easier

Hmm.. Looking into some adjustments to the Electrician skills and such and wanted to create stronger batteries.

So I assume the go-to would be to include my "stronger" batteries in a recipe to create a "stronger" flashlight that has a lower UseDelta than the original flashlight

ancient grail
#

what abt

if getUseDelta==0; then setUseDelta(10) end
safe silo
#

Oh my infinite flashlight was just an example, I basically just want to create flashlights that drain 25%/50%/75% slower

ancient grail
#

wait let me find it

#
item GlytchLightSmall
    {
        DisplayCategory     =     LightSource,
        LightDistance        =    25,
        Weight                =    0.7,
        DisappearOnUse        =    FALSE,
        Type                =    Drainable,
        TorchCone            =    TRUE,
        UseDelta            =    0.0000000001,
        LightStrength        =    22,
        TorchDot             =     0.76,
        DisplayName            =    Glytch Light 2,
        ActivatedItem        =    TRUE,
        Tooltip             =     SOS Admin Almost Unlimited Flashlight,
        Icon                =    TorchSOS,
        MetalValue             =     10,
        cantBeConsolided     =     TRUE,
        primaryAnimMask     =     HoldingTorchRight,
        secondaryAnimMask     =     HoldingTorchLeft,
        WorldStaticModel = Lollipop,
        AttachmentType    = Knife,     
    }
#

UseDelta = 0.0000000001,

safe silo
#

Lmao nice, WordStaticModel = Lollipop lol

ancient grail
#

haha

safe silo
#

Would your UseDelta technically be infinite? Wouldn't it just take a long ass time to drain?

ancient grail
#

well as an admin i nver die and i had it on and never once saw it reduced

#

just add more zero if youre skeptic hehe but i asure you this will never die

safe silo
#

Oh yeah 100% I wasn't trying to be technically I just wanted to make sure that it was draining hahah, I'm sure it will take like a year IRL for it to drain anyways

halcyon tide
#

Is there a way for me to make a mod pack of my own for all the mods I like using?

ancient grail
#

lol idk about that but yeah thats possible i guess or if you do the math atleast to compute how long will it really take before it depleate

halcyon tide
#

I want to do it to save time for making a server for friends

ancient grail
bronze yoke
civic lava
#

will try now, i've tested over 200 dif ways in the past 7 days, been trying to learn lua 8 hours a day for no reason at all... i could use all the help i can get, my goal is to create a mod called "HyperRealism" which will overhaul & planned to be 10,000 of code +
But as im noob this may take months to years

#

do i leave the () empty or add a function or value in that

weak sierra
#

lmao

#

that's a silly concept

#

things take however much they take

#

you don't get points for making it longer

#

nor shorter, tbh

#

not sure what your mod will contain but i applaud you for trying to dive in and do it

#

often the best way to learn shrugIDK

astral dune
#

Been doing research on the relationship between torque/hp/accel/etc for vehicle modding and if I've done my math right my IRL car should be able to get to 370km/h 🤔

halcyon tide
bronze yoke
#

well one that you should always read the relevant policy before you do something in general, but particularly that glytcher told you 'as long as its unlisted i don't see why not' which may imply there are no restrictions on unlisted modpacks when there are

#

not large ones, but it's best to be aware of these things

young grotto
#

Hello gentlemen

#

is there a way to reduce modded zombie spawn?

#

like for example under modname\media\lua\shared\NPCs

#

table.insert(ZombiesZoneDefinition.Army, {name = "Brita_Gorka", chance = 10})

#

I would like to reduce this chance to very rare like 0.01

#

is there a way to do that through lua with another mod?

#

currently brita's zed is spawning too much in the game after the latest update

#

if I create a new mod and load it after brita's, placing the lua at same path "modname\media\lua\shared\NPCs" with the same lua name, and same table.insert, will that work?

ancient grail
#

But your reply is definitely the best answer

ancient grail
young grotto
ancient grail
#

in lua u use table.remove()

young grotto
#

alright, will research about it

ancient grail
#

Goodluck hope this helps

ancient grail
young grotto
young grotto
ancient grail
#

no i dont think so 🙂 since its a new table entry

bronze yoke
astral dune
#

ya, its Shared, then Client, then Server in stages, with each stage doing vanilla, then modded in alphabetical order, with duplicates going by mod load order. Not entirely certain how subfolders factor in

bronze yoke
#

messing with already added distribution entries through lua is really annoying, so overriding the file is usually the preferred method of doing this

young grotto
#

I see that table insert only requires a single line in the lua, I'm not sure if it will work if I do something like this.
In Shared (since brita is using Shared for zomb distribution):

table.remove(ZombiesZoneDefinition.Police, {name = "Brita_Sheriff"})

then in Server I add

table.insert(ZombiesZoneDefinition.Police, {name = "Brita_Sheriff", chance = 0.05})
bronze yoke
#

i thought we were talking about item distributions 🤦 even though you made it very clear what you were talking about

civic lava
#

any & all help such a links to helpful pages with all lua & PZ code commands would be a great help
:Edit: also just naturally enjoy coding & like running ideas around, if anyone is interested in VC to talk about code or idea / help eachother im open for it

bronze yoke
young grotto
#

or should I just create new mod and create lua called BritaZeds.lua in Shared and override it to 0

weak sierra
#

like for a server or sp game

#

ah

#

someone already got onto that.

bronze yoke
#
for i = 1,#ZombiesZoneDefinition.Police do
  if ZombiesZoneDefinition.Police[i].name == 'Brita_Sheriff' then
    ZombiesZoneDefinition.Police[i].chance = 0.05
  end
end
```is basically how you'd do it without overriding
#

of course if you're changing multiple you want a table of stuff to change

astral dune
#

you'd think they would have just used the name as the key

smoky meadow
#

guys where to report a bug in zomboid?

young grotto
bronze yoke
#

i.e.

local nameToChance = {['Brita_Sheriff'] = 0.05, ['Brita_SomethingElse'] = 0.65}

for i = 1,#ZombiesZoneDefinition.Police do
  local chance = nameToChance[ZombiesZoneDefinition.Police[i].name]
  if chance then
    ZombiesZoneDefinition.Police[i].chance = chance
  end
end
young grotto
#

hmmm, interesting

#

Thank you thank you

#

I would go with overriding method since that is easier

astral dune
#

easiest to implement, hardest to maintain

young grotto
#

so what I need is to just create the same file name "BritaZeds.lua" in media\lua\shared\NPCs and change the chance. Put the mod to load after brita. Is that correct?

table.insert(ZombiesZoneDefinition.Police, {name = "Brita_Sheriff", chance = 0.05})
the rest of the stuff
bronze yoke
#

yeah pretty much

young grotto
#

Thank you all, I really appreciate it

ancient grail
weak sierra
#

personally

#

not that i've never just copypasted the file and changed the values

#

i def have..

#
require 'Items/ProceduralDistributions'

UdderlyRP = UdderlyRP or {}
UdderlyRP.Books = 
{
    "UdderlyRP.SneakingVol1",
    "UdderlyRP.SneakingVol2",
    "UdderlyRP.SneakingVol3",
    "UdderlyRP.SneakingVol4",
    "UdderlyRP.SneakingVol5",
    "UdderlyRP.LightfootedVol1",
    "UdderlyRP.LightfootedVol2",
    "UdderlyRP.LightfootedVol3",
    "UdderlyRP.LightfootedVol4",
    "UdderlyRP.LightfootedVol5",
    "UdderlyRP.NimbleVol1",
    "UdderlyRP.NimbleVol2",
    "UdderlyRP.NimbleVol3",
    "UdderlyRP.NimbleVol4",
    "UdderlyRP.NimbleVol5",
}

for _,book in pairs(UdderlyRP.Books) do
    table.insert(ProceduralDistributions.list["BookstoreBooks"].items, book);
    table.insert(ProceduralDistributions.list["BookstoreBooks"].items, 1);
    table.insert(ProceduralDistributions.list["LibraryBooks"].items, book);
    table.insert(ProceduralDistributions.list["LibraryBooks"].items, 1);
    table.insert(ProceduralDistributions.list["ShelfGeneric"].items, book);
    table.insert(ProceduralDistributions.list["ShelfGeneric"].items, .1);
end```
#

this isnt an override but this is the kind of stuff i will do

#

if necessary i mix that with a table with name as key to chance as value

#

if it's not as uniform

#

it's hard to rewrite someone else's thing into something like this unless it's shorter

#

but it's so much nicer

#

hell when there's a lot of spawn locations ill make that a list too

ancient grail
#

Wow

weak sierra
#
local ammoCans = 
{
    "Base.AmmoCan22",
    "Base.AmmoCan9",
    "Base.AmmoCan45",
    "Base.AmmoCan38",
    "Base.AmmoCan44",
    "Base.AmmoCan223",
    "Base.AmmoCan308",
    "Base.AmmoCan12",
    "Base.AmmoCan556",
    "Base.AmmoCan762",
}

local ammoCansSmall =
{
    "Base.AmmoCanSmall22",
    "Base.AmmoCanSmall9",
    "Base.AmmoCanSmall45",
    "Base.AmmoCanSmall38",
    "Base.AmmoCanSmall44",
    "Base.AmmoCanSmall223",
    "Base.AmmoCanSmall308",
    "Base.AmmoCanSmall12",
    "Base.AmmoCanSmall556",
    "Base.AmmoCanSmall762",
}

local ammoSpawns =
{
    "PoliceStorageAmmunition",
    "GunStoreAmmunition",
    "ArmyStorageAmmunition",
    --"GunStoreCounter", --This is substituting for DisplayCase since it makes more sense for cans.
    --"GunStoreDisplayCase" --This only makes sense for non-ammo-can ammo.
    --"GunStoreShelf", --Redundant, things have this + ammo usually.
    --"PoliceStorageGuns", --Use ammo one instead.. will include both normally on a container.
    --"ArmyStorageGuns", --Use ammo one instead.. will include both normally on a container.
}

for _,can in pairs(ammoCans) do
    for _,spawn in pairs(ammoSpawns) do
        table.insert(ProceduralDistributions.list[spawn].items, can)
        table.insert(ProceduralDistributions.list[spawn].items, .0000000025 / #ammoCans)
    end
end


for _,can in pairs(ammoCansSmall) do
    for _,spawn in pairs(ammoSpawns) do
        table.insert(ProceduralDistributions.list[spawn].items, can)
        table.insert(ProceduralDistributions.list[spawn].items, .000000075 / #ammoCansSmall)
    end
end```
#

example

#

this one has hardcoded spawn chances but separate loops for the diff spawn chances since there's just two

#

but with a loop for the locations

#

u can combine all this shit together into one loop that covers chance-to-itemname and list of spawns

#

if necessary

ancient grail
#

Can i please copy your method for future distrib codes?

weak sierra
#

yeah

#

it's just.. nice

#

lol

ancient grail
#

Thnx a bunch evelyn!

weak sierra
#

it's just loops not some proprietary shit

ancient grail
#

Yeah but i sooo pretty to look at and so neat hehe .

weak sierra
#

ive been coding for like two decades

#

this is what happens

#

lol

ancient grail
#

And i dont see anyone do this

#

Yepf yepf learned alot from you

weak sierra
#

:)

orchid moth
#

What are the use of ammo canisters

ancient grail
orchid moth
#

Oh ok

tardy wren
#

These are actually mass storage that takes less space. It's like putting bullets in boxes... You're putting boxes in canisters.
Helps storing mass amount of items, as well as server performance

sour island
#

Anyone know if distributions have a way to ignore loot probability?

astral dune
ancient grail
#

i believe this was just discussed earlier by evelyn. and i recall buffy showed her work a while back thats all about loot distrib..

weak sierra
#

cuz id rather have to manually approve a new item being added to my server's loot pool than have it happen quietly

#

if it's the type of mod where im tweaking it already

#

worth thinking about, if ur rebalancing a mod's spawns already

#

u might not want, say, a new gun added to be super common if u nerfed spawn rates of 10 guns already

#

but yeah if it's not about distributions that's another story

#

then u 100% don't wanna override it too readily

weak sierra
#

they exist primarily to reduce N ammo to a single item

#

they spawn by default too, but they're not containers x3

young edge
#

So I tried VisualVM to check what's going on with the memory leak, but honestly that stuff is about 3 layers too deep for me.

Separately, I've also checked the timing of when the memory leak happens. It's hard to put it down to the Tee, but here's what I have

[02-11-22 14:19:31.280] WARN : Lua         , 1667395171280> 0> LuaManager$GlobalObject.require> require("Vehicle/Vehicles") failed.
[02-11-22 14:20:59.057] ERROR: General     , 1667395259057> 0> LuaManager.getFunctionObject> no such function "Recipe.OnGiveXP.None
        Sound".
[02-11-22 14:20:59.057] ERROR: General     , 1667395259057> 0> RecipeManager.LoadedAfterLua> no such function LuaGiveXP = "Recipe.OnGiveXP.None
        Sound" in recipe "Grind Coffee Beans".
[02-11-22 14:21:02.850] WARN : General     , 1667395262850> 0> ItemPickerJava.ExtractContainersFromLua> ignoring invalid ItemPicker item type "SMUIClothing.Hat_OG106".
[02-11-22 14:21:02.850] WARN : General     , 1667395262850> 0> ItemPickerJava.ExtractContainersFromLua> ignoring invalid ItemPicker item type "AuthenticZClothing.ChickenHatJacket".
[02-11-22 14:21:03.556] ERROR: Mod         , 1667395263556> 0> ZomboidFileSystem.loadModTileDefs> tiledef fileNumber 216 used by more than one mod.
[02-11-22 14:21:03.570] ERROR: Mod         , 1667395263570> 0> ZomboidFileSystem.loadModTileDefs> tiledef fileNumber 5001 used by more than one mod.
[02-11-22 14:21:13.155] WARN : General     , 1667395273155> 0> SpawnPoints.initSpawnBuildings> initSpawnBuildings: no room or building at 12700,1645,0.
[02-11-22 14:21:13.155] WARN : General     , 1667395273155> 0> SpawnPoints.initSpawnBuildings> initSpawnBuildings: no room or building at 13617,1344,5.

There's more of every type except the LuaGiveXP error, which only appears once.

weak sierra
#

ur missing a comma

#

probably

#

the newline and Sound are included

#

"Recipe.OnGiveXP.None
Sound"

#

shud be a comma after "None"

#

it probably means the sound wont play and it won't give xp

#

it MIGHT stop any further recipes from loading from that file too

#

perhaps

young edge
#

will check. Kinda doubt it causes memory leaks, though PepeChrist

young edge
#
local function sortOutNils(tbl)
    local newTbl = {}
    for k,v in pairs(tbl) do if(v ~= nil) then newTbl[k] = v end end
    tbl = newTbl
end

if VehicleZoneDistribution then -- check if the table exists for backwards compatibility

    VehicleZoneDistribution.trafficjams.vehicles["Base.CarLightsSmashedFront"] = nil;
    VehicleZoneDistribution.trafficjams.vehicles["Base.CarLightsSmashedLeft"] = nil;
[...]
(no end)

This looks like it could cause one, though Thonk

finite radish
#

for java modding, does reflection work? or does zomboid have protections/managers in place to prevent modifier resets/accessibility changes?

weak sierra
#

for java modding there's no restrictions, for lua you can only read fields afaik

weak sierra
jaunty marten
tardy wren
#

Please, you can do line breaks

young edge
#

Neither of those codes are mine x)
One is from Sapph's, one is from Cyt's Kentucky Overhaul

#

but I left a report on Sapph's. There was one on Cyt's already

frosty estuary
#

There is some mod clothing that use a Custom Body Location, but because of that, any of the protection to scratch, bite ou bullets are been applied to any Body Part protection. Is there a way to make this work for custom Body locations?

trail lotus
#

Does anyone know anything about selling fuel to players (server based) was thinking about making a gas station players could buy fuel from. Also a cool additional thing I thought about was making it where players can get fuel then sell it to the gas station. If anyone is interested in making something like that I’d pay for it, just give me a price.

ruby urchin
frosty estuary
#

So to the protection be applied it's just setting the blood locations?

weak sierra
#

yes

frosty estuary
#

Thanks

alpine plinth
#

Is there any mod to make PZ like tarkov, ie remove the zombies from the world and add dangerous human rebels etc?

weak sierra
#

no

#

you can remove the zombies out of the box

#

and u can add survivors

#

but

#

they aren't deangerous rebels

#

they're more like incompetent derps

#

added by mods

alpine plinth
#

Aw ok, would love to fake hostile players

summer rune
#

How can i put multiple items in the Result: field of a recipe ?

weak sierra
#

use OnCreate

#

and attach a lua function

#

which will give the player the other items

#

no other way

#

hope they add multiple results as part of the recipe overhaul tbh

#

tedious to do that

summer rune
#

thank you that worked fine

#
recipe BerryWine
{
    Berry1/Berry2=5
    Result:BerryWine,
    Time:50.0,
}

Follow up question. What does this do Berry1/Berry2=5. Can it be a mixture of Berry1 and Berry2. Or does it have to be 5 from one specific ItemType.

summer rune
#

I figured it out. You can tag the items u want. And then make recipes based on the tags.

ruby urchin
#
---server.lua
if isServer() then
    RegisterServerCallback("Server:Example", function(cb)
    print(cb)
    end)
end

Why I need confirm that a thing is server side, in a server side file?

tardy wren
#

I don't think server means that it's executed by the server per say... More that it's affecting the world as a general?

bronze yoke
drifting stump
#

servers only run code in server or shared

#

clients run code in client server and shared

#

why?

astral dune
#

probably to help with SP/MP compatibility

ruby urchin
astral dune
#

any file you really really don't want to be loaded client side just throw if isClient() then return end at the top. As far as I'm aware the whole file will then be ignored

bronze yoke
#

yeah, isClient() is usually better than isServer() as generally you still want server things to run in singleplayer

weak sierra
#

isServer() and not isClient() for dedicated server only, isClient() and isServer() for sp/coop, isClient() and not isServer() for dedicated client

weak sierra
#

afaik

#

cuz both return true on sp

astral dune
#

ya, that's why you'd have to really really be sure

weak sierra
#

that's why i recommend compound statements

#

cuz if u dont want it to run on a client... in dedicated, but work in sp

#

then u want something different from don't run on a client ever

quasi geode
#

isClient should not return true in SP. its used in the vanilla files this way too (see SFarmingSystem.lua and SMetalDrumSystem.lua for examples)

#

its explicitly set to true in 2 spots from my quick checking, both in LuaManager:
serverConnect() and serverConnectCoop()
and set to false in backToSinglePlayer()

hearty dew
#
    --                             | isClient() | isServer() |
    -- Singleplayer                | false      | false      |
    -- Multiplayer Client          | true       | false      |
    -- Co-op Host (client process) | true       | false      |
    -- Co-op Host (server process) | false      | true       |
    -- Dedicated Server            | false      | true       |
#
YourUtils.isServerOrSinglePlayer = function()
    --                             | isClient() | isServer() |
    -- Singleplayer                | false      | false      |
    -- Multiplayer Client          | true       | false      |
    -- Co-op Host (client process) | true       | false      |
    -- Co-op Host (server process) | false      | true       |
    -- Dedicated Server            | false      | true       |
    --
    -- This is a single player game or is a coop host server process or is a dedicated server
    return not isClient()
end

YourUtils.isClientOrSinglePlayer = function()
    -- This is a single player game or is a coop host client process or is a client connected to a remote server
    return not isServer()
end

YourUtils.isSinglePlayer = function()
    -- This is a single player game
    return not isServer() and not isClient()
end
ruby urchin
#

callback event

-- client.lua
local _ENV = require 'DislaikLibrary';
_ENV.CreateENV();

local onKeyStartPressed = function(key)
    local source = getPlayer(); if not source then return end

    if key == Keyboard.KEY_NUMPAD0 then
        TriggerServerCallback("ServerCallback:Example", function (fromServer)

            print(fromServer)

        end, "THIS IS FROM CLIENT")
    end

end

Events.OnKeyStartPressed.Add(onKeyStartPressed);
#
-- server.lua
local _ENV = require 'DislaikLibrary';
_ENV.CreateENV();

if isClient() then return end;

RegisterServerCallback("ServerCallback:Example", function(source, cb, p1)
    print(p1)

    cb("THIS IS FROM SERVER, " .. p1)
end)
weak sierra
#

i was misled by things

safe silo
#

How would I overwrite vanilla items?

Want to overwrite the Battery, just by icon and some variables

weak sierra
#

u can change things without overwriting it entirely to play nice

#

but

#

to overwrite u just copy it into ur own script

#

with module set to Base

#

and then tweak what u wanna tweak

#

to just tweak stuff u can use DoParam on the item object or use ItemTweaker

civic lava
#

how do i find a list or even link my file to a "call list" that relates to PZ natural entities

#

ex: _player:getdata() or some list like that with all possible commands that PZ will just "get"

weak sierra
#

i think what u need is to look at the java docs

#

(this is the most current one to my knowledge, the versionless one is older)

#

alternatively you can of course decompile the game and reference/search the results.

civic lava
#

YES!!! thank you!

weak sierra
#

xD

#

i assume what u mean by "link my file" you mean autocomplete/suggestion/etc.?

#

u can do that in some way with intelliJ or vscode i think

#

i haven't ever bothered

civic lava
#

yo ty for the help, im really dedicated to my overhaul idea of HyperRealism mod, a 1 mod overhaul, yet i know nothing of lua & have been coding 10 hours a day for 7 days now lolol

ancient grail
#

Still waiting here @civic lava

civic lava
#

_
Also is anyone willing to help me with some code? either thru text or screen share. the more help i get from knowledgable people the less work i have to do reading hours of shit i hardly understand, i learn much faster with a "lack of better word" tutor

#

if _player:panic > 50 then Trip = Trip - 2000; end
if _player:panic < 50 then Trip = Trip + 200; end
_
Is this proper, will this change the trip value relative to panic state?

#

now i understand all those "depressed coder" memes

ancient grail
thick karma
#

Anyone have experience with Anti-Cheat Type 21?

bronze yoke
#

strange: does anyone have any idea why ModData.add(WaterGoesBad) (and similar calls), specifically without quotation marks, was working? it was not a variable, there were no errors and it was working and persisting as expected

#

i would never have noticed if i weren't rewriting it...

#

maybe it was being stored under a key 'nil' lol?

strong vortex
#

does some1 know why i cant go in the back in the rv

#

i just move to the back seet with v

#

i have the mod installed

jaunty marten
hearty dew
#

If a function runs for too long (like a few frames, e.g. 30 ms, to where the game stutters) it will cause it to fail and kick the player

civic lava
#

local Roll = ZombRand(1, 200);

"how do i add without error another math to this EX:"
_
local Roll = ZombRand(1, 200(math.random(20, 50));

Would this be correct? if not could someone fix it?

civic lava
#

oh so the ( "brackets are fine" )( but the zombrand should be used instead of math.random()

fast galleon
#

need to add + or * in between the numbers, no idea what you're going for

civic lava
#

regardless i got the info i needed, TY!

fast galleon
#

e.g 200 + ZombRand(20,50)

civic lava
#

im new to lua. i just started coding & have been doing so for 7 days about 8 hours a day, its like a game & it feels like a beat a dark souls boss when i get something to work, so i've decided to dedicate myself to making an overhaul mod "HyperRealism" (detailed plans are too long to type) so ill be in here asking dumb stuff & looking for help most of the time

jaunty marten
jaunty marten
ruby urchin
jaunty marten
jaunty marten
ruby urchin
#

xd

jaunty marten
#

at least ur lib even have no check if trigger was registered

dusk sonnet
fast galleon
#

I was hopping for another literature mod 😅

limpid moon
#

hello was just wondering if anyone could tell me if anything is wrong with this because my mod wont show up on my mod list in pz. im still new to coding in lua and modding in general so please be patient with me

ruby urchin
limpid moon
#

in zomboid

#

mods

jaunty marten
#

check ModTemplate in c:\Users\admin\Zomboid\Workshop\

ruby urchin
# limpid moon in zomboid

You should put it on something like C:\Users\YOURPCNAME\Zomboid\Workshop there you find a mod example

limpid moon
#

ooohhhh

jaunty marten
limpid moon
#

oh I didnt have that in a previous mod I made and it worked. I will look into this in the example

#

thank you very much kind sirs

#

i really do appreciate the help

jaunty marten
limpid moon
#

ahhh maybe maybe. honestly i watched a very old video to make that little tiny demo mod i first made

#

just added a single item

jaunty marten
#

he-he

limpid moon
#

ok it still wont show up

#

maybe i named something wrong

#

or wrong syntax on something

ruby urchin
dusty oriole
#

where are the zombie textures stored?

ruby urchin
dusty oriole
#

thanks bestie

civic lava
#

100+ hours in, been doing it dialy

#

even paid for some tutoring

#

im very dedicated about my vision

#

i also have a question, i forgot how to print
is it
Print(trip)

#

is i want to print my trip value for debug

civic lava
#

so the code would look like
_
print trip

jaunty marten
#

print(val)

civic lava
#

no space?

#

sorry im noob

#

very dumb i know

jaunty marten
#

better to close pz yet and just read smth about lua

#

to know base

civic lava
#

nvm ill ask someone else

#

thanks for advice

jaunty marten
#

if u have 100+ hours and problem with print and brackets > feels bad M_Dogpoop

civic lava
#

patronizing me is always fun, i simply forgot, i dont need to prove my skills & u can lack at my forgetfullness of () placement all day, this changes nothing, im making an overhaul mod & it may take months but i will do it, & some people are nice enough to simply just answer a question

ruby urchin
#

just ignore that nasty guy

civic lava
#

local stats = _player:getStats();
local panic = stats:getPanic();
local stress = stats:getStress();
local boredom = stats:getBoredomLevel();
local wet = _playerdata:wet();
local inja = _playerdata:injured() + _playerdata:injured();
local hype = _playerdata:unhappiness();
local pain = stats:getPain() + stats:getPain(); --negas 900
local hp = stats:getHealth(); -- possas 500
local endur = stats:getEndurance() + stats:getEndurance(); -- sp trip 3000 min 900 max 500 begin 3500 rv
local tired = stats:getFatigue() + stats:getFatigue(); -- +0,200 fr endur & tired
local hung = stats:_playerdata:hunger();
local Trip = 3000 - panic - stress - boredom - wet - inja - hype - pain + endur + tired + hung;

I want to debug the trip rate is all

jaunty marten
civic lava
#

makre sure my math is right

jaunty marten
#

m8 if u think I'm hate ur addon, I don't

civic lava
#

hard to do when dealing with uneven changing values

jaunty marten
#

I'm just trying to give u some help how to do better

civic lava
#

CAN SOMEONE JUST .... ok ill get back to coding without the print in my debug.. w.e... i got lots to change

young orchid
#

he is maybe one of those who say they have a girlfriend before the girl knows about it.

civic lava
#

i dont have time to read pages

#

i just need a qucikm reminder

#

that is all

jaunty marten
#

you don't have to stick to what I say but insult me for it is cringe)

jaunty marten
#

print(val)

civic lava
#

missed it

#

ok ty

jaunty marten
fast galleon
#

PZ modding, because paying for psychologists is overrated.

young orchid
#

hehe

ruby urchin
#

lol that was a good one

civic lava
#

memories

#

i learned ALLOT since then tho

#

even tho me forgetting print code might make u doubt it

young orchid
#

maybe his logic is that he has always heard from successful people that it was not easy and no one believed that he/she could make it. so he provokes negative comments and hate to be able to say the same thing later.

dusk sonnet
dusk sonnet
# civic lava i dont have time to read pages

The most important skill you need to acquire for programming is how to problem solve. This means trying to find the answer on your own through exhaustive research before asking someone else directly. Especially for something as basic as how to print a variable in Lua. Programmers are generally willing to help each other, but that can quickly go away if it appears you haven't put any effort in on your end. And saying "I've been programming 100+ hours over the past week" is not proof that makes asking "how to print " okay

#

And if you've spent 100+ hours over the past week working on your mod, then you definitely have time to Google your questions first.

ancient grail
#

Let him be guys.
I understand how you feel tho but
Lets keep the channel non toxic if thats ok with you guys.
I mean dont hate me for saying this. I have much respect for you guys

#

Anyways let me help u @limpid moon
Youve been trying for over a week now and i feel bad that you still havent been able to do the mod. Pm me

limpid moon
#

oooo ok interesting

dusk sonnet
ancient grail
#

I understand sir but there must be some way of doing this that doesnt involve shaming

#

Goodluck @limpid moon 🫡

limpid moon
#

thank you kind sir. i will do my best 🫡

thick karma
thick karma
#

Y'all can anyone identify the file that generates the lefthand clickable sidebar in the UI? I have always hidden it by looping getUI() without knowing exactly what it is, but in order to fix certain conflict issues in a more rigorous way I think I need to know the precise object so I can check its visibility without needing to know its index...

alpine scroll
#

I've been trying to implement this but no success so far

pine patio
#

Where should I look to learn how to make a generator? I'm trying to make a simple, non craftable, non movable tile that generates power. I'm reading the code of different mods with generators but those are overly complicated compared to what I'm trying to do

calm depot
#

steam powered generator

#

I use a custom tile for it

alpine scroll
#

I have a variable called container that derives from isoObject that comes fom a square:getObjects, so my container var is actually an ItemContainer. So I tried doing local test = getContainerOverlays():updateContainerOverlaysSprite(container:getParent()) but it gives an error java.lang.RuntimeException: Object tried to call nil in container

#

Any ideas what is going on?

jaunty marten
#

it returns literally all objects on square

alpine scroll
#

I do filter per object that is a container

#

I may have skipped a bit, but I do

local size = objects:size()
            if size == 0 then return nil end
            local LastIndex = size -1
            for i = 0, LastIndex, 1 do
                    local object = objects:get(i)
                    local s = tostring(object)
                    local container = object:getContainer()
                    if container then
                        return container
                    end
            end```
#

So it becomes an ItemContainer in the end

jaunty marten
#

try to just print it

print(container, container.getParent)
alpine scroll
#

Wait

#

getParent or getParent() ?

#

Does it make it a difference?

jaunty marten
#

getParent() > invokes func

#

getParent it's just func variable

alpine scroll
#

Maybe is that then

jaunty marten
#

container < table
container.getParent < index func
container.getParent() < invoke this func

jaunty marten
alpine scroll
#

Thats why its returning nil

jaunty marten
#

getParent is func

#

it needs to be invoked

#

not just get

alpine scroll
#

I'll do that

#

Just a moment

jaunty marten
#

k

fast galleon
#

not sure if it matters, first object is usually the floor and I've had some errors from that

alpine scroll
#

I'm restarting my server here, but I can try to filter if the ItemContainer is floor

jaunty marten
#

it's pz but I think have to be there

fast galleon
#

or it returns nil most likely

jaunty marten
alpine scroll
#

Im loggin on my server here

#

Since this mod is focused for MP I test it on a dedicated server, so thats why its taking so long

alpine scroll
jaunty marten
#

function exists

alpine scroll
#

This item is a bookshelf if it matters

jaunty marten
#

wut

#

try container.getParent() instead container:getParent()

#

I don't remember how getParent invokes

alpine scroll
#

I do use container:getParent() before on the same code and its working, but I am willing to try your suggestion

#

Container do have a .parent field

jaunty marten
#

As Ik it's working by this way

alpine scroll
#

Being honest, I do know little about lua and java

#

My expertise lays on VB mostly, and some python

fast galleon
alpine scroll
#

But its the line I need to add and make it work

#

as far as @jaunty marten is helping me, its something to do on how I am passing the IsoObject

jaunty marten
#

it's strange cos in print u got function

fast galleon
#

I'm looking at my code I use container:getParent() and container:getParent():getTextureName() and it works

alpine scroll
#

Maybe it works now

jaunty marten
#

but :getParent() and .getParent() never will call error like ur if getParent function existed

alpine scroll
#

Maybe it errors because it requires a var and I was passing a function?

#

I dunno

#

My server just restarted

#

I'll test this version now

jaunty marten
alpine scroll
#

oh

#

dang it

jaunty marten
fast galleon
#

open admin chat and do
/reloadlua MyFile.lua

jaunty marten
alpine scroll
#

I am uploading to the workshop and restarting the server on every change

calm acorn
#

doesnt reloading lua on servers usually crash them?

fast galleon
#

ah, I'm usually testing from same machine

calm acorn
#

maybe its just hosting via the client that does it

alpine scroll
#

I'll go back to the starting point and going to paste the entire stack error

#

Maybe I am reading the errors wrong

blissful salmon
#

I tried to check if the player is on a new square and then do some checks. So far I tried this:

local function OnObjectCollide(character, door, IsoGridSquare, IsoThumpable, IsoWindow, IsoZombie)

  print("collided")

  if IsoThumpable ~= nil then
    print("isoThumpeble")
  end

  if SoulMod.shared.isSoloGame and IsoGridSquare ~= nil then
    print("collided: " .. IsoGridSquare.getX() .. " / " .. IsoGridSquare.getY())
  end
end

Events.OnObjectCollide.Add(OnObjectCollide)

I never get "isoThumable" or "collided: x / y" in the console. But the "collided" trigger when I hit a door or window. Does someone have experience with this. The primary goal is to detect when a player or zombie (does this even trigger?) gits a certain object (fence or an object on the square)...

alpine scroll
#

I mean.. doors and windows are thumpable

#

Technically its not wrong

#

Maybe add extra filters to ignore doors and windows

calm acorn
#

isochracter and player dont inherit from thumpable

#

maybne isoobject if you really want to go that far

blissful salmon
#

but why is the square always nil?

calm acorn
#

getCell():getGridSquare(x, y, z)

jaunty marten
blissful salmon
#

the lua event gives me the variables. so I expected it triggers on every square... but this doesn't seem to be the case...

alpine scroll
#
function: onServerCommand -- file: clientupdate.lua line # 62 | MOD: ExtrasDescoladosCMDFORCEITEMRESPAWN

ERROR: General     , 1667494627806> 68.793.510> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: Object tried to call nil in container at KahluaUtil.fail line:82.
ERROR: General     , 1667494627807> 68.793.510> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: Object tried to call nil in container
    at se.krka.kahlua.vm.KahluaUtil.fail(KahluaUtil.java:82)
    at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:973)
    at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:163)
    at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1980)
    at se.krka.kahlua.vm.KahluaThread.pcallvoid(KahluaThread.java:1812)
    at se.krka.kahlua.integration.LuaCaller.pcallvoid(LuaCaller.java:66)
    at se.krka.kahlua.integration.LuaCaller.protectedCallVoid(LuaCaller.java:139)
    at zombie.Lua.Event.trigger(Event.java:64)
    at zombie.Lua.LuaEventManager.triggerEvent(LuaEventManager.java:173)
    at zombie.network.GameClient.receiveClientCommand(GameClient.java:1453)
    at zombie.network.PacketTypes$PacketType.onMainLoopHandlePacketInternal(PacketTypes.java:1022)
    at zombie.network.GameClient.mainLoopHandlePacketInternal(GameClient.java:638)
    at zombie.network.GameClient.mainLoopDealWithNetData(GameClient.java:615)
    at zombie.network.GameClient.update(GameClient.java:426)
    at zombie.GameWindow.logic(GameWindow.java:231)
    at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
    at zombie.GameWindow.frameStep(GameWindow.java:764)
    at zombie.GameWindow.run_ez(GameWindow.java:666)
    at zombie.GameWindow.mainThread(GameWindow.java:494)
    at java.base/java.lang.Thread.run(Unknown Source)
#

local test = getContainerOverlays():updateContainerOverlaysSprite(container:getParent()) this is line 52

jaunty marten
#

why 52 line

#

if it's

#

82 line

calm acorn
#

you should be able to get the square off the character character:getCurrentSquare()

blissful salmon
#

what i hoped for is that the first parameter "character" can also be a zombie which steps on a specific square or thumpable...

jaunty marten
#

or stop, I forgot how pz prints error

#

yea, check 82 line

blissful salmon
#

I'll test that. But I'm not sure if this helps, because if I walk into a fence or door. I'm on the square right next to it.

astral dune
alpine scroll
#

Ok

#

Just a moment

#
    local player = getPlayer()
    if player:getOnlineID() == args.playerID then
    local containers = getNearbyContainerscli(player:getX(), player:getY(), player:getZ(), args.range)
    for i = 1, #containers, 1 do
      local container = containers[i]
      local items = container:getItems()
      if items:size() == 0 then                
        local sq = container:getSourceGrid()
        local cIndex = -1
        for i = 0, container:getParent():getContainerCount()-1 do
            if container:getParent():getContainerByIndex(i) == container then
                cIndex = i
            end
        end
        local info = { x = sq:getX(), y = sq:getY(), z = sq:getZ(), index = container:getParent():getObjectIndex(), containerIndex = cIndex }
        sendClientCommand(player, 'object', 'clearContainerExplore', info)
        container:removeItemsFromProcessItems()
        container:clear()
        container:requestServerItemsForContainer()
        print(container, container:getParent())
        local test = getContainerOverlays():updateContainerOverlaysSprite(container:getParent()) << 52
        end
    end
    player:Say('O chat respawnou os containers perto de mim')
    end
end


local onServerCommand = function(module, command, args)
 if Commands[module] and Commands[module][command] then
 Commands[module][command](args) << 62
 end
end

Events.OnServerCommand.Add(onServerCommand)```
alpine scroll
#

There is no line 82

jaunty marten
#

serverside file

alpine scroll
#

Oh

#

Also doesnt have line 82

jaunty marten
#

wtf

astral dune
#

line 82 is in the kahlua files, you don't have access to that

fast galleon
#

@alpine scroll could be typo

jaunty marten
#

kk, thx

fast galleon
#

updateContainerOverlaySprite

blissful salmon
#

How to I know when something is a thumpable?

alpine scroll
#

Oh god

#

Is a typo

#

HAHAHAH

#

God dammit

#

I BLAME YOUUUUUU (thx for the help haha)

astral dune
#

the container bit was a red herring, it says that because you named your function container, not because of the container variable in the container function (you probably shouldn't have overlapping names like that, lmao)

alpine scroll
#

I have to study lua a bit more

astral dune
#

its just good practice to make sure you name your variables and functions in a way that is recognizable, and not to name them the same thing

jaunty marten
astral dune
#

to prevent this exact thing

alpine scroll
#

Is container something that zomboid uses?

jaunty marten
#

I don't get

alpine scroll
#

It didnt error anymore

#

But it didnt work anyway

#

Emtpy

jaunty marten
#

what did u change

alpine scroll
#

It was updateContainerOverlaysSprite before

#

with 2 s

#

The correct is only one

jaunty marten
#

ah

alpine scroll
#

However it is still not updating the overlay

#

@fast galleon Any suggestion?

jaunty marten
alpine scroll
#

Sorry, I dont get it

#

what you would want me to do?

jaunty marten
#

fk pz wiki

#

sec

#

I a bit didn't get ur code

#

what are u doing?

#

if container_items:size() == 0 then clear container

alpine scroll
#

I basically copy pasted the admin code to respawn items on a container

#

The admin command clears the container before respawning items

#

I just forgot to remove the clear items part

#

container:requestServerItemsForContainer() is the relevant part

jaunty marten
alpine scroll
#

All I want is to be able to force a respawn of items on containers near the player

#

And update its visual

deft falcon
#

yo guys

#

OnPlayerGetDamage event doesnt work for me

#

it just errors and says it adds something of non-table in console log

#

the function is above the event ofc and its the correct name, spelling etc.

#

@frosty falcon you've sent me the entire list of events before, do you have any idea for this

#

wait fuck im an idiot its unstable LOL

ancient grail
alpine scroll
bronze yoke
#

item:getContainer():setDrawDirty(true)

#

or container:setDrawDirty(true) since it seems like you already have that

fast galleon
#

@alpine scroll

                if container then
                    --print("zx filling container: ", container:getType(), container)
                    container:emptyIt()
                    ItemPicker.fillContainer(container,nil)
                    --ItemPickerJava.updateOverlaySprite(container:getParent())
                    getContainerOverlays():updateContainerOverlaySprite(container:getParent())
                    container:getParent():sendObjectChange("containers")
                end

I do this from server and it works

alpine scroll
#

SendObjectChange

#

Thats different

#

However you do it on the server side, right?

#

My code right now is on the client side

#

But i'll try to implement it

fast galleon
#

last one updates the items inside container, though client will need to move or update the inventory to see the change

#

this is where the render dirty comes in play

alpine scroll
#

Render dirty updated the inventory pages, but not the overlay

#

I think I need to pass it back to the server and trigger the overlay

summer rune
#

Can I get a tileIsoObject from some sort of static manager class by handing it an ID ?

I want to save references of tileIsoObject in a text document, maybe csv. And later load the document and delete all tileIsoObjects that are older than 3 RL days.

ancient grail
summer rune
#

yeah that would be one solution, looping through all objects if a grid square gets loaded and then checking the mod data. however i want to directly get the reference of one tileIsoObject by either looking through a hashmap or using some sort of manger, that returns the object as is, without looping through everything.

#

but i dont see any unique identifier.

swift sequoia
#

Is there a way to expose the traits menu mid-game? I'm thinking about making a mod that gives 1 trait point every 30 days the character is alive.

ancient grail
#

im not sure but it could be global object or something

quasi geode
ancient grail
quasi geode
#

it was actually done as a joke for a friend a while back XD

#

they dropped the skill point system with build 41 though so it never got updated

ancient grail
#

are you planning to make one that works with current build? sure hope so

quasi geode
#

considered it, but would need some sort of replacement point system. unlikely i'll get around to it though

ancient grail
#

but how do you just open the panel mid game?

#

like Felkami's question

quasi geode
#

technically it doesnt open the panel, since the trait selection stuff its just various listviews on the character creation screen, it builds a additional tab in the skills/health panel and adds the list views there

ancient grail
#

ahh isee

lyric bolt
#

Hey how do I use an item from another mod in my recipe?

quasi geode
lyric bolt
#

Like I want to make a recipe using items from my mod, spit out items from a different mod, is there a way to do that?

ancient grail
#

can you give an example of what item which recipe?

lyric bolt
ancient grail
#

you can find the module name when you look at the mods script or itemviewer ingame or if you edit the item on the inventory if your admin

#

when you right click on the item then edit you see the module name there

lyric bolt
#

Yea I am looking at scripts but most start like this

module Base
{

ancient grail
#

then thats the module 🙂

lyric bolt
#

I am still getting an error though.... does every script file you have need that import?

#

Mine starts like this,

module Base
{
imports
{
Base
}

ancient grail
#

if you defclare a module then yes

lyric bolt
#

Ok, do I need to be calling it via it's full descriptor maybe? Like Base.Stimpak ?

ancient grail
#

yes

lyric bolt
#

ok that is probably why, let me try that

#

Same error :/

ancient grail
#

well what does your recipe look like

lyric bolt
#
        10Money=3,
        Result:Base.Stimpack,
        Time:10,
        keep WalkieTalkie1/WalkieTalkie2/WalkieTalkie3/WalkieTalkie4/WalkieTalkie5/HamRadio1/HamRadio2/RadioMakeShift/HamRadioMakeShift/WalkieTalkieMakeShift,
        CanBeDoneFromFloor:true,
        Category: SShop Medical,
    }
ancient grail
#
recipe Buy Drugs Stimpack: $30 
{
Base.10Money=3,
keep Radio.WalkieTalkie1/Radio.WalkieTalkie2/Radio.WalkieTalkie3/Radio.WalkieTalkie4/Radio.WalkieTalkie5,Radio.WalkieTalkieMakeShift,
Result:Base.Stimpack,
CanBeDoneFromFloor:true,
Time:80.0,
Category:Survivalist,
}
lyric bolt
#

The mod does seem to work with base items at least

ancient grail
#

pls try this before you edit anything

#

10Money is an item right?

lyric bolt
#

In the SShop mod

ancient grail
#

and its base?

lyric bolt
#

So it's an internal one, the stimpack is external

#

No, its added by this mod, let me get the block

ancient grail
#

ye well what is the mods module for 10Money

lyric bolt
#
module Base {
    imports
    {
        Base
    }
    item Money
    {
        DisplayCategory = Junk,
        Weight    =    0.001,
        Type    =    Normal,
        DisplayName    =    1 Dollar,
        Icon    =    Money,
        WorldStaticModel = Money,
    }
    item 5Money
    {
        DisplayCategory = Junk,
        Weight    =    0.001,
        Type    =    Normal,
        DisplayName    =    5 Dollars,
        Icon    =    Money,
        WorldStaticModel = Money,
    }
    item 10Money
    {
        DisplayCategory = Junk,
        Weight    =    0.001,
        Type    =    Normal,
        DisplayName    =    10 Dollars,
        Icon    =    Money,
        WorldStaticModel = Money,
    }

#

I added the import, but otherwise it's as it was

ancient grail
#

there so its Base

#

so yeh try that

lyric bolt
#

Same error

#

hold on.. the other mod disabled itself somehow

#

that might cause an issue....

swift sequoia
lyric bolt
# ancient grail this

God damn it lol, it was the disabled mod... Welp. At least I got it lol, thanks for the help

#

This does help with another mod I was trying to make though so it wasn't in vain 👍

#

Yea I'm gonna try to make Brita's attachments work with the fallout weapons, last time was a shit show, broke britas by doing whatever I did somehow... so we'll see lol

lyric bolt
#

Hmmm 🤔

Would there be a way to make someone scream for a certain period of time after ingesting something? Like just keep shouting HEY! HEY YOU! etc

ancient grail
#

yeah you have to have a delay function tho

#
        playerObj:Callout()
swift sequoia
#

I'm trying to find the source code that runs when a character is initially infected with the zombie virus, and then sets level, mortality, and mortalityDuration. What I've gathered thus far is its a loop of code that checks isInfected on the bodyparts, then kicks everything off. Anyone know where that code is?

lyric bolt
#

What is the syntax for multiple imports in a script file? I tried

        
    imports
    {
        module1,
        module2
    }
ancient grail
lyric bolt
#

its for another thing I want to sell that uses the module name "DW"

ancient grail
#

If u import the module you dont need to add the module on the items
If you dont then you need to add them
Which is why theres really no need to do this esp with your specific situation whereas all of your items are base anyways

#

@ruby urchin dude! How did you figure out how to do the animation! So awsome man

trail lotus
#

can anyone tell me if i do 26 does that mean a 24 hour day cycle real life time.

ancient grail
# trail lotus \

25 is the max as indicated on the comment. Your going to tell to do something it doesnt recognize. Idk what will happen since i havent tried doing something like this. But mostlikely theres going to be an error

ruby urchin
astral dune
#

what animation are we talking about?

astral dune
#

nice

weak sierra
ancient grail
#

Is it possible to make onTest function check if a certain tile is near

fast galleon
ancient grail
#

Thnx

civic lava
#

ok so i cant get my debug menu to print the rolls

#

i have the code in the area after the if

#

print(chance)
print(chanceinx)

#

but

#

when in debug i cannot see a roll, how to enable?

ancient grail
#

You have to put the print within the lua file cuz the variable is local and only happens within the function it exisits only there. So you can print it externally like from debug.

civic lava
#

uhhhh

#

its in the file like this
_
if player:isSprinting() == true then
print(chance)
print(chanceinx)
chancemod = chancemod + 12;
elseif player:IsRunning() == true then
print(chance)
print(chanceinx)
chancemod = chancemod + 4;
_

#

so its within the trait

bronze yoke
#

are you adding random tripping 😟

#

if your prints aren't showing up i would suspect the issue is elsewhere and this portion of code isn't being run in the first place

fast galleon
#

ok so i cant get my debug menu to print the rolls
he's back, I almost drowned with coffee

civic lava
civic lava
# civic lava its in the file like this _ if player:isSprinting() == true then ...

i'm new to code, i want to make something called "Hyper Realism" (regardless) i can do all the math in my head, it would just be nice to see the print to get the math understood faster, rather then using my brainpower & time to do math on actually physical paper to reveal the odds of what im tying to have happen or % chance under a condition

fast galleon
lunar anchor
ancient grail
# civic lava i'm new to code, i want to make something called "Hyper Realism" (regardless) i ...

You cant skip the process
Learn lua then Learn pz api lua
Thats the only way you will understand how print works.
You can use debug to print out each of your variables like your sprintinglvl
Only if you understand what sprintinglvl represents on your code cuz the debug wont recognize it since its declared as a local variable within your function
Meaning it only exsist there
So you have to find out what exactly local sprintinglvl is
Which is the getPlayer():getStats(Perks.Spriting)

I just typed this and im using mobile without reference so if im wrong pls dont blame me. Its just for you to understand where the variables point out

I even spelled sprinting wrong but im not gona correct that.

Anyways
As i recall you had
Local stress= _player:getStress()

So if you print this in debug it wont work

You have to use
print(getPlayer():getStress())

You have to understand how print works
How variables work
How function works
And which are the parts that is unique to pz
What lua specific stuff that doesnt exist aswell
Like your
Math random
Which is zombrand()

Hope this helps goodluck

civic lava
#

i never showed aggression or angry in any way

#

i only said you are patronizing me

#

it doesnt make me "mad", it just shows who you are & how you think about people trying to learn

#

i come here to ask a question, i get better daily & work with this constantly, i assumed this channel was for getting answers to questions/help in some way. not to copy paste my messages to insinuate that im incapable of getting my dream to work

lunar anchor
ancient grail
grim rose
#

im trying to understand this thing as i have ran into same problem

#

anyone would care to explain to me

blissful salmon
#

of course you can use the time to calculate instead of counting ticks... maybe this would make more sense...

#

I want to add a scratch to the right hand. So from LUA I call:
getPlayer:getBodyDamage()
and then? Can I somehow directly get the hand? or do I have to loop through the parts?

ancient grail
#

To further explain ny objective.
I made a mod that dig for ores
Then i added tile sprite to look more realistic but it will eventually make the world messy and so i need to be able to remove the tile after a few seconds of spawining it

#

So the i need the square and the obj variables

This api works but it creates another function which dont recognize my variables

blissful salmon
#

Hmm... ok... what about storing them in an global "array" with the needed stats. for example removeTime, square, object and then check if there is an item that has to be removed...
Or maybe there's a more complex part in your question that I don't understand...

blissful salmon
ancient grail
ancient grail
#

actually im stupid

#

the reason why the delay couldnt recognize the var cuz it was outside of the parent function lol

#

i does recognize the var imean the api

#

so i guess thats that 🙂 thnx anyways @blissful salmon

grim rose
#

is any chance this works?

    function ()
    function player:getFoodSicknessLevel()
    return getSpecificPlayer(0):getBodyDamage():getFoodSicknessLevel()
    end
    player:getBodyDamage():setFoodSicknessLevel(player:getBodyDamage():getFoodSicknessLevel() + 20);
    player:Say("I feel bit better")```
dapper geode
#

Hi, How to make tooltip show on admin only?

fast galleon
dapper geode
trail lotus
#

Is there a way to alter the in game map? I wanna add labels or draw borders and name things, on a custom server. so when players join they can press M and see where safe areas are, stores, buildings, and so on.

blissful salmon
#

I'm trying to set a scratch on the hand without the bleeding effect. I use this code:

      hand_r:setBleeding(false)```
But I still get the bleeding. What am I doing wrong?
#

Found the solution... I added
hand_r:setBleedingTime(0)

steep copper
#

Hi, i don't really understand how colors work on clothes.
I try to add a red variant to the cowboy hat, i've made the textures, i've remake the script :
module Base { item Hat_Cowboy { DisplayCategory = Accessory, Type = Clothing, DisplayName = Cowboy Hat, ClothingItem = Hat_Cowboy, BodyLocation = Hat, IconsForTexture = HatCowboyBlack;HatCowboyBrown;HatCowboyWhite;HatCowboyRed, CanHaveHoles = false, ChanceToFall = 50, Insulation = 0.3, WindResistance = 0.2, BloodLocation = Head, } }

And the GUID :
<?xml version="1.0" encoding="utf-8"?> <clothingItem> <m_MaleModel>static\clothes\m_cowboyhat</m_MaleModel> <m_FemaleModel>static\clothes\f_cowboyhat</m_FemaleModel> <m_GUID>ae7791f9-a5df-48d8-882f-a0749b8af2b1</m_GUID> <m_Static>true</m_Static> <m_AllowRandomHue>false</m_AllowRandomHue> <m_AllowRandomTint>false</m_AllowRandomTint> <m_AttachBone>Bip01_Head</m_AttachBone> <m_HatCategory>Group02</m_HatCategory> <m_MasksFolder>media/textures/Clothes/Hat/Masks</m_MasksFolder> <textureChoices>cowboyhat_black</textureChoices> <textureChoices>cowboyhat_brown</textureChoices> <textureChoices>cowboyhat_white</textureChoices> <textureChoices>cowboyhat_red</textureChoices> </clothingItem>

#

but How the game know what texture/color to put on the item ? And how the information is passed on the 3D model ?

Maybe i need to remake the tint system with lua ?

#

Actually only brown, white and black cowboy hat are presents in the game

#

But the kahlua table is fine, there's my red texture in it

gilded hawk
#

IIRC the texture, color and hue is randomly picked once the game spawns the item

steep copper
#

Okay, so why he doesn't take my new color ? 🤔

blissful salmon
#

Is there a way to get the weight of an item without having an instance of it? So for example when I have a Thread then I want do get 0.1. As far as I know then drained items change their weight if they are not full...

    item Thread
    {
        DisplayCategory = Material,
        Weight    =    0.1,
        Type                =            Drainable,
        UseWhileEquipped    =    FALSE,
        UseDelta            =            0.1,
        DisplayName    =    Thread,
        Icon    =    Thread,
        ConsolidateOption = ContextMenu_Merge,
        SurvivalGear = TRUE,
        WorldStaticModel = Thread,
    }

My primary goal is to create the right amount of an item when I got a weight based on other factors. So in the case of a thread I want to be able to use weight = 0.325 and based on that create 3 full threads and a fourth of a thread. So I need to know the full weight of a thread.

quasi geode
blissful salmon
quasi geode
#

should be ya

blissful salmon
#

ok... Trial and error 😄
thx for help. I think I'm on the right way now...

trail lotus
#

Is it possible for a server to limit the player to one character, by this i mean like limit a player to the character and even if he dies he still has to play as that character. And remove the option to create new character? It would simply be “respawn” option only.

grand sleet
swift sequoia
#

Oh man, I almost ended up spending one of my lazy tokens by asking a question in here. I decided to look up the answer instead. wipes brow that got close.

quasi geode
swift sequoia
#

Woohoo! I rule the wooooooooooorld.

blissful salmon
#

I have some functions which I save in a variable und replace the original to add some checks and call the original in the replaced function. For example:

SoulMod.ISEatFoodAction.perform_orig = ISEatFoodAction.perform
function SoulMod.ISEatFoodAction.perform(mySelf)
-- doStuff
  return SoulMod.ISEatFoodAction.perform_orig(mySelf);
end

Now I tried the same with the following code:

SoulMod.Recipe.OnCreate.CutFish_orig = Recipe.OnCreate.CutFish

I assume there is something special with Recipe. My goal is to overwrite the function CutFish in the file server\recipecode.lua
function Recipe.OnCreate.CutFish(items, result, player)
Anyone has an idea?
Forgot to paste the error:

function: SoulMod_FishOil.lua -- file: SoulMod_FishOil.lua line # 7 | MOD: Soul Mod

ERROR: General     , 1667575169563> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: CutFish of non-table: null at KahluaThread.tableget line:1689.
ERROR: General     , 1667575169564> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: attempted index: CutFish of non-table: null
bronze yoke
#

what is line 7?

dusk saddle
#

Howdy there, Zomboid modding folk. Incompetent scripting guy here again.

I recently made some more collectible items for my Pomp's mod and was curious on how to get an item that gives you something random upon opening it. I assume I'd make some sort of array list, though I wouldn't know how to get the script to function for a recipe. Would somebody be able to walk me through the process?

swift sequoia
#

@blissful salmon Looks like you're trying to access an item in a variable you expect to be a table, but its a null value.

blissful salmon
#

line 7 is this:

sorry for being unclear...

blissful salmon
#

I assume Recipe.X does not lead me to the function I want. So I assume that the problem is in this part: = Recipe.OnCreate.CutFish

true vault
# dusk saddle Howdy there, Zomboid modding folk. Incompetent scripting guy here again. I rece...

Pomp!! Love your mod; we use it on every instance of our community server >.>

That said, yeah that's the best way I can think of; make an array of items you want to spawn, and use the ZombRand() function to select one (or more) of the indices from that array (just use random number from total length, so you can keep adding to the array without changing any other code), and call it from a recipe via OnCreate().

#

I can probably whip up some psuedocode quick to illustrate that, if needed.

dusk saddle
#

That would definitely be handy, I know very little about coding lol. And thanks for the kind words!

#

Feel free to DM me about it too, I didn't mean to take away from Soul's discussion

true vault
#

❤️ pony haters gonna hate

And cool, mind if I DM you it so as to... okay lolz, already answered that haha

swift sequoia
bronze yoke
#

yeah i was immediately going to suggest that you make sure you're not running any other mods

blissful salmon
#

Ok. I try to disable the other mods. But this already happens on startup... Give me a second...

quasi geode
blissful salmon
# quasi geode error is pretty clear, the `Recipe` table seems to not have a `OnCreate` table i...

As your stating the Recipe table seems not to have OnCreate but I don't know why. It's defined in the mentioned file. I also thought about that it's maybe an loading order so I already moved it from client so server to test, but the same error happened (I'll retest this again in the next minutes). So to answer your questions:
a. It is currently on client because as far as I know the order is: Base stuff (all) -> shared -> client -> server
b. not that I know, based on the other replies I removed every mod than mine...

For info I'm testing on Solo right now...

bronze yoke
#

i moved some of my own recipe code into client and it totally broke, so that's your issue

quasi geode
#

it needs to be in server

#

the Recipe table is defined in a file in server folder, the server files are loaded last, so trying to reference it before its loaded (from client/shared) will cause it to error

blissful salmon
#

Ok... I move it again...

#

I still get the same error when the file is on server...

true vault
#

Side comment, if anyone can point me in the right direction.

Need to figure out how to save a single int to a persistent storage, to track a counter between sessions. Prefer it to be both MP/SP compatible, though with MP, others don't actually need to access the data of other players.

young edge
#

@weak sierra @hearty dew So I've conducted a binary search on the mods and I've come to the conclusion that it's mostly https://steamcommunity.com/sharedfiles/filedetails/?id=2809058492 causing it.
But I'm not sure if it's just the size of the mod causing it or if it's actual genuine errors causing memory leaks. There's still a visible spike in ram, but it's more like 5gigs, rather than it just nuking all of the ram on the system

blissful salmon
#

Isn't there a kind of namespace conflict between java object and Lua Recipes? (asking just to be sure)

young edge
#

I have noticed that there are multiple vehicles which are broken in one way or another or not made properly, but I'm not sure if that could cause leaks

weak sierra
#

"Motorious Zone" one

#

idk if the american-only 1993 one has issues

young edge
#

fhq and 1993 pack are 2 different packs

#

fhq is arguably just.. better

#

but a 223MB mod causing 10gig of RAM to just be erased is a bit confusing

bronze yoke
quasi geode
true vault
swift sequoia
ancient grail
#

Imean color

ancient grail
#

Oops sorry someone already answered the question

swift sequoia
#

Actually no, that doesn't fill my needs. Guess I still have to dive into old notes again. 😦 If I don't come back, send a rescue squad.

blissful salmon
#

Sorry, I think I fucked up my testing... It has to be on the server but when I tested I moved the file to server. But somehow I generated a second one in the client folder. I don't exactly know how. Maybe already opened tab in VS Code and saved again or something like this.
Thx @quasi geode was a stupid issue. Today seems to be not my day... I already asked a lot of stupid questions...

dusk saddle
#

Maybe I should start taking down notes for modding like I do for my geology class lol. Maybe then I wouldn't be quite as big of a dummy haha

ancient grail
dusk saddle
#

Ah I'm currently working on getting the models themselves into the game right quick, fixing sizing, etc. I'll let you know later on if I need help!

blissful salmon
fast galleon
#

Lol is somebody keeping a list of people with stupid questions?
oops now I am in it

ancient grail
#

What qualifies as a stupid question?
(Damn this question is going to add me to that list . But i cant help it)

blissful salmon
#

Yes, give it to me :-p but sometime I have some expections to myself. So if I ask something that I think I should have known...
What ever.... Thx for your help 👍

quasi geode
blissful salmon
quasi geode
#

ya i use both but mostly linux for any dev stuff

blissful salmon
true vault
bronze yoke
#

yeah i just have a bunch of git repos in the workshop folder

true vault
#

I don't even bother with Git for them; I'm not currently collabing with someone nor need access when away from PC, so no need for the extra clutter files from Git, IMO (your mileage may vary based on if you actually need access away from main PC or if you collab, for example).

bronze yoke
#

i haven't had anyone collaborate with me yet, it's just that it allows me to use github as a portfolio

true vault
#

That's fair; not a terrible idea either.

#

BTW that suggestion worked like a charm @bronze yoke, thanks again ♡

bronze yoke
#

i'm glad that worked ^_^

true vault
#

Cash mod is almost complete lolz

#

Now the actual hard part... figuring out how to make use of the ATM objects..

swift sequoia
swift sequoia
#

Ooooh. Have you thought about trying to implement the fact that credit cards are droppable items? So like, guess their pin number and get mola.

true vault
#

Nah, making it easy on players. Well, relatively easy. They're gonna have to create a credit card skimmer/hacker. High elec skill, a cash register, and several materials will combine into one.

#

Then they can skim the cards that get dropped/found in wallets.

#

I certainly wouldn't be opposed to looking into that idea though; but I would need to also learn more about how to attach a random pin number to each card item, and have that saved across instances.

swift sequoia
#

Make 20% of the pin numbers == 1234

bronze yoke
#

out of curiosity, how does this differ from better money system?

true vault
true vault
# bronze yoke out of curiosity, how does this differ from better money system?

Can't say as though I've looked into the details, but the premise is to make the one I'm working on as compatible as I can with both vanilla and other mods, as well as I'm using it in conjunction with other mods I have, as a modular mod system; it can be used as a base for a storefront, when combined with some of my crafting things, for example.

As to specific differences... c_shrug no clue lolz

bronze yoke
#

hmm yeah, better money system isn't the most compatible as it uses its own money items

true vault
# bronze yoke hmm yeah, better money system isn't the most compatible as it uses its own money...

As does mine, however it lets you convert between the vanilla "Money" item, and the one dollar bills mine adds; no cost, almost instant. Can convert back and forth for compatibility.

To expand on this.. mine lets you search wallets to find cash, but if you use some other store/trade/whatever system that uses the vanilla money item, you can always right-click the modded bills, and convert them to vanilla of the same amount... a 20 bill converts to 20 "money" for example.

swift sequoia
#

Bottlecaps!

true vault
true vault
swift sequoia
#

Considering the lack of contextual entry, you'll probably have to use the chat dialog to guess the number.

true vault
#

Yeah, that's the thing I think will be the hardest with an ATM, even with just withdraw/deposit.

#

I have no idea how to do a thing with UI elements yet lolz

swift sequoia
#

I'd say just use chat instead of trying to make a custom UI.

#

Add a contextual menu option (right-click menu) to start the interaction, then read chat text input by the interacting user. In the future, provide a custom UI, but that's probably daunting enough that it'll cause you to drop the project if you're like me.

true vault
#

Chat could be an option too, yeah. Still, another area I'm unfamiliar with in the slightest, so no matter which way I go on it, it'll have some learning involved haha. Which I def don't mind; I just love making mods people will enjoy. But I wanna make it easy to use, which is why I was leaning towards the UI idea. Players are familiar with right-click on an object to use, etx.

swift sequoia
#

There are a lot of examples of adding a button to the contextual menu. Its the graphical UI thing that'll be super daunting.

bronze yoke
#

ui is a nightmare

true vault
#

- nod, nod -

Yeah, I don't disagree there. I might have the first released version of the mod be a bit cheesy to start, and work on it from there. V1 might simply let you withdraw the entire balance from the hacked reader, and deposit individual bills from inventory.

#

Immersion-breaking for sure... but then again, being able to craft a card skimmer is kinda fantasy in the first place lolz... at least for the average person IRL

astral dune
#

in the 90s you would have needed a dialup connection to even handle the transaction anyway

swift sequoia
#

I've never worked with containers, but another UI option is to have the ATM be a container object that's populated with dollars based on the account, then it reads amount added/removed to update the internal value.

drifting stump
#

👀

#

someone say ui

true vault
swift sequoia
bronze yoke
#

my work on your mod is part of why i say that lol

true vault
#

....we'll just pretend they're all satellite connection, and infinite batteries >.>

drifting stump
swift sequoia
#

And matter transporters for infinite bills!

drifting stump
#

well minus the function overrides to fix bugs in the vanilla code

bronze yoke
#

it is very intentional that none of my mods interact with ui in a major way

true vault
#

So yeah, immersion isn't exactly required for how to withdraw/deposit funds I suppose LMAO

swift sequoia
#

lol

bronze yoke
#

as soon as i start doing ui everything becomes insane and there's massive blocks of code to do literally one thing

true vault
#

I wonder... I could probably make a requirement that the skimmer needs to be near power. That would solve that realism aspect at least.

astral dune
#

now, if they had to find an ATM and power it to take the money out, and each atm only has so much money 👌

true vault
astral dune
#

that being said, the best way to get the money out of the ATM is probably the propane torch

swift sequoia
#

Honestly realism is overrated. What's the point in pushing realism in a video game if I can literally go to a restaurant and see people wearing photoshopped hats?

drifting stump
astral dune
#

all depends on what you want out of the game, I only select mods that are "believable", if not entirely "realistic"

swift sequoia
bronze yoke
#

there's a mod to open doors and windows with crowbars, don't think it works on trunks though

#

oh, nope, it does work on trunks

swift sequoia
#

Oooh, where is this mod?

#

More power to the crowbar!

bronze yoke
#

looks like it doesn't actually work on windows but everything else

astral dune
#

you can use a crowbar to remove the entire window in vanilla iirc

true vault
#

lolz... why open a window, when you can simply remove it?

Just replace it after ya climb in, and boom, same thing.. kinda hehehe giggle

swift sequoia
#

You can also use a hammer and screwdriver to dissassemble a locked door.

bronze yoke
#

personally i don't like that it works on garage doors, that sounds like a huge stretch to me, so i've stayed away from the mod

true vault
astral dune
#

it only opens the 1/2 or 1/3 of the garage door you're using it on too, lol, its a little jank

swift sequoia
#

"A burglar can open a garage door from the outside in a matter of seconds with nothing more than a wire coat hanger. All they have to do is use a tool to pry open the top edge of the door, drive the hanger through the opening, grab the cord with the hook and pull."

#

Coat hangers, what can't they do?

astral dune
#

"nothing more than a coat hanger", "need a pry tool"

#

🤔

bronze yoke
#

if it is possible, i still don't like it from a balance standpoint, garage doors usually guard higher tier loot, but you could say it just brings the crowbar closer to the axe which can get through garage doors pretty easily too

swift sequoia
#

Hmm, didn't know the axe could take them down.

astral dune
#

most of the residential garages have windows anyway

bronze yoke
#

well they don't usually have great loot, but stuff like the lockups

astral dune
#

true true

swift sequoia
#

Makes sense I guess. I was surprised when zombies broke down a garage door, last I remembered garage doors were impenetrable.

true vault
#

Would be nice if the military-style lockers had actual locks on them sometimes. Kinda the point of them in the first place; secured storage containers.

bronze yoke
#

i wouldn't mind something like that

astral dune
#

crates can have locks like that, it should work on all containers imo

true vault
#

Would be especially nice for MP servers so we can turn looting on for safehouses (I mainly keep looting and fire off, for reasons), and have players still able to securely store things in their safehouses. Would allow me to have players buy the safehouses ("rent" basically), and only leave the respawn and fireproof settings on.

swift sequoia
#

Does anyone know where the code is that detects if isInfected is true and manages the zombie infection progression? I've been trying for 3 days to find that code.

#

I want to find the list of variables modified and their initial values when an infection just starts.

swift sequoia
#

I think part of my problem is I don't understand the Lua event system and how it operates.

safe silo
#

Does items consume energy when the chunk isn't loaded? ie. generators, car batteries, flashlights etc.

bronze yoke
# swift sequoia Does anyone know where the code is that detects if isInfected is true and manage...

it seems to be this section in zombie.characters.BodyDamage

int var13;
if (!this.isInfected()) {
   for(var13 = 0; var13 < BodyPartType.ToIndex(BodyPartType.MAX); ++var13) {
      if (this.IsInfected(var13)) {
         this.setInfected(true);
         if (this.IsFakeInfected(var13)) {
            this.DisableFakeInfection(var13);
            this.setInfectionLevel(this.getFakeInfectionLevel());
            this.setFakeInfectionLevel(0.0F);
            this.setIsFakeInfected(false);
            this.setReduceFakeInfection(false);
         }
      }
   }

   if (this.isInfected() && this.getInfectionTime() < 0.0F && SandboxOptions.instance.Lore.Mortality.getValue() != 7) {
      this.setInfectionTime(this.getCurrentTimeForInfection());
      this.setInfectionMortalityDuration(this.pickMortalityDuration());
   }
}

if (!this.isInfected() && !this.isIsFakeInfected()) {
   for(var13 = 0; var13 < BodyPartType.ToIndex(BodyPartType.MAX); ++var13) {
      if (this.IsFakeInfected(var13)) {
         this.setIsFakeInfected(true);
         break;
      }
   }
}
#

oh, sorry, actually, this is something you were asking about the other day

#

i didn't read it fully and assumed it was the same 😅

#

that part is in the same file though

fast galleon
safe silo
#

How does it handle time passed?

#

I leave generator running, leave town for 2 irl days, return - should be 0% fuel right?

fast galleon
#

generator saves last time updated, think food does too

safe silo
#

Alright, would DRAINABLE items do so too or should I code it in myself?

fast galleon
#

generator has a loop for passed hours and loops that many times

astral dune
#

I wonder how newly generated items handle rot 🤔 , if its been so much time since the power went out they rot immediately I guess, since the game can assume there was no refrigeration all that time

#

Can you freeze food in game by putting it outside in the winter?

fast galleon
safe silo
#

It's a custom one, I have code that drains it

#

But doesn't keep track

astral dune
#

also, looping the generator so many times seems kinda silly, lol. Coulda just done some quickmaffs

fast galleon
astral dune
#

If you leave while the washer/dryer is running, does it figure out when the cycle is done and draw less power after that?

fast galleon
#

It updates devices before loop, so probably the washer wouldn't count at all? Or more likely counts to be running all the time, considering it only updates it's list and not the actual devices.

swift sequoia
fast galleon
#

For instance, you come back and it decides the freshness based only on the current state of the generator so it's either frozen all time or not.

astral dune
#

hmm, so if you're moments from running out of power you should drive away and not come back until you have more fuel

#

I was considering figuring out a way to attach fuel barrels to the generator, but this makes things more challenging

fast galleon
astral dune
#

well if it calculates the amount of rot based on the "current" state of the generator when you reload, is that current state before the generator does its cycles or after. If its before, as long as there was at least one cycle of power left then you're fine

bronze yoke
#

driving away will actually make your food rot marginally more

astral dune
#

that would prevent abuse, so it makes sense

swift onyx
#

Is there a way to schedule a function to run without using the timed action events?

astral dune
#

I've seen people subscribe to the OnTick event and then have it trigger your function when you want it to. Dislaik or Tyrir may have even made an api for it by now

quasi geode
#

theres probably a few api's for it. heres mine.. bit dated now, that theres a event every minute (making its OnTick use redundant), should probably update it

bronze yoke
#

is there a unique persistent identifier for a character, not an account? steamid and username are account wide and the same for splitscreen characters, and player num and online id aren't persistent

#

i'm considering just keeping my own identifier in player mod data, but is there a better way than that?

hearty dew
#

Does sqlID fit those requirements? I don't actually know

#

If not, I was going to say I think you'd have to create your own. Can generate a guid/uuid and stash it in player moddata

#

(or similar random number)

bronze yoke
#

i don't know actually, i know new characters replace old ones in the sql but i don't know if the sqlid stays the same when that happens

astral dune
#

do characters have a sqlID like vehicles do? I bet that would work

ancient grail
hearty dew
#

Can use getFieldValue to retrieve it

bronze yoke
#

no good :( guess i'll just use a guid then

hearty dew
#

I was hoping there was a creation timestamp or something similar so you could use a tuple, e.g. (username, creation timestamp), but don't see anything usable in that way

bronze yoke
#

i'm guessing from the way the sql is formatted that you might be able to consistently get the same splitscreen player with that, as new characters overwrite your old one - if a splitscreen player died and then left the server it would probably get lost though

#

look at me writing all this code for splitscreen when nobody in the universe, myself included, plays splitscreen

#

playerindex might do that anyway actually...

astral dune
#

I didn't think anyone played with a controller either, but...

steep copper
#

Hi, i search to modify items in container each time an item is removed from/added in a container

I tried these events : OnContainerUpdate and OnRefreshInventoryWindowContainers

None of them seems to work for this

I don't even know how to trigger them

bronze yoke
#

for controller i know burryaga exists at least, but i don't know about splitscreen

thick karma
#

When an admin activates SendCommandToServer("/reloadoptions"), can I catch that in my client folder? Or would I have to catch the command server-side and send a command to the clients from there? And would I catch it with OnServerCommand or OnClientCommand? I'm not sure, but as I'm reading the Lua Events page, it sounds like I would catch it serverside with OnClientCommand, and then I could use the global sendClientCommand to reply to the client, and I could catch that in a client file... Is this how it works? Anyone care to enlighten me?

astral dune
steep copper
#

How can i do this ?

astral dune
hearty dew
astral dune
#

Actually I'm wrong, if you want to catch the command BEFORE it gets sent to the server, then you'd do it clientside

#

by decorating SendCommandToServer, if possible

hearty dew
#

Also, do you need to catch the function call, SendCommandToServer, only? Or also an admin typing /reloadoptions in the admin chat tab?

#
    if not chatCommand then
        if luautils.stringStarts(command, "/") then
            SendCommandToServer(command);

Oh, the chat tab input is converted to a call to SendCommandToServer lua-side. I had thought it was done in the Admin chat tab object java-side. nm

#

so I'd expect the approach of decorating as described above would work

astral dune
# steep copper How can i do this ?

Again, I don't know the best answer. I'm fairly certain that transferring items to or from a container is a timed action, so if I wanted to figure out how to change that I'd find the action first in the code and come up with a plan.

#

most likely I'd decorate the action, or the function that calls it, but maybe it actually does throw an event you can listen for, I really don't know

thick karma
#

I am confused, sorry... you're saying I need to use OnServerCommand to reply to an admin sending /reloadoptions?

#

@hearty dew

hearty dew
#

No. OnServerCommand is an event for SendServerCommand. OnClientCommand is an event for SendClientCommand.. SendCommandToServer is unrelated, despite the name similarities

dreamy shell
#

Hey everyone, looking for a way to get the moodle sprites from the game, cant find much documentation on it though

hearty dew
thick karma
#

I seeeee.... anyone happen to know where to find SendCommandToServer?

#

I'm seeing calls to it but not the def

hearty dew
#

It's a function exposed from the GlobalObject

#

in LuaManager.java iirc

thick karma
#

Ohhhh, so I need to patch it

hearty dew
#

Yea

astral dune
#

On a related note, anyone remember the way to call servermsg without doing SendCommandToServer("/servermsg")? someone posted it here and I was dumb enough to not write it down

hearty dew
#

You only need this handled on the admin's client, I'm presuming

astral dune
#

I don't understand the question, what pop up?

thick karma
#

I was hoping that when the admin sends /reloadoptions, I could have the server send a client command signal to every client, and have every client react

bronze yoke
#

you'd probably have to patch SendCommandToServer to SendClientCommand to then SendServerCommand... that is a lot of commands

astral dune
#

found it, you posted it right here

hearty dew
thick karma
bronze yoke
#

yeah that's really ugly, i hope there's a better way of doing things

hearty dew
# astral dune found it, you posted it right here

yea, that just creates a client-side text popup```lua
AnonymousUtils.showNotification = function(message, durationInMs)
ISChat.instance.servermsgTimer = durationInMs or 5000
ISChat.instance.servermsg = message
end

bronze yoke
#

i've gathered that intercepting chat commands is a nightmare though

#

or like, anything to do with them really

astral dune
hearty dew
#

nope

astral dune
#

Bummer, but I can still use it

thick karma
#

My concern is that I still don't know a very key step in my goal... I still don't know how to update my mod options setting in-game and then hop into the menu and see that change reflected.

hearty dew
#

You can do something using SendServerCommand and OnServerCommand with an event handler that calls showNotification

thick karma
astral dune
#

SendServerCommand allows you to direct a command to a particular client, right? Does it have broadcast capabilities or do you have to loop through the users yourself?

hearty dew
#

I have a few functions that make sending server/client commands like this a bit easier, if it'd help

thick karma
#

I won't turn down learning from ya @hearty dew, though I do not know whether or not the code you have will make the difference or not. If I can't figure out how to make my mod options updates show up live in the options window when I open pause menu, the rest of my ideas won't get the job done...

#

That key final piece of the puzzle still eludes me

hearty dew
hearty dew
thick karma
hearty dew
thick karma
#

Oh good idea

ruby urchin
hearty dew
#

sec, I posted it some time ago actually

thick karma
#

Thanks

dreamy shell
hearty dew
#

.

astral dune
bronze yoke
#

yeah the events page is getting a little outdated and is just inaccurate sometimes

#

i sent a pull request to clean up some of the omissions/errors i've noticed but it doesn't look like the host uses github very often anymore

hearty dew
# hearty dew I have a few functions that make sending server/client commands like this a bit ...
local info = function(tag, s)
  print(tag..s)
end
local debug = function(tag, s)
  print(tag..s)
end
local error = function(tag, s)
  error(tag..s)
end


YourUtils = YourUtils or {}

--[[
    Server/Client Communication APIs
]]

YourUtils.CommandModules = YourUtils.CommandModules or {}
YourUtils.CommandModules.YourUtils = YourUtils.CommandModules.YourUtils or {}

if YourUtils.onClientCommand then Events.OnClientCommand.Remove(YourUtils.onClientCommand) end
if YourUtils.onServerCommand then Events.OnServerCommand.Remove(YourUtils.onServerCommand) end

YourUtils.onClientCommand = function(module, command, player, args)
    local commandModule = YourUtils.CommandModules[module]
    if commandModule then
        local commandFunction = commandModule[command]
        if commandFunction then
            if isDebugEnabled() then
                local playerName = player and player:getDisplayName()
                local playerID = player and player:getID()
                local playerOnlineID = player and player:getOnlineID()
                debug("YourUtils.onClientCommand", string.format("Client->server command (%s.%s) received "..
                        "with player (%s, ID=%s OnlineID=%s) and the following parameter:",
                        module, command, tostring(playerName), tostring(playerID), tostring(playerOnlineID)))
                --YourUtils.inspectAll(args)
            end
            local results = { commandFunction(args, player) }
            if isDebugEnabled() then
                debug("YourUtils.onClientCommand", string.format("Client->server command (%s.%s) return values:",
                        module, command))
                --YourUtils.inspectAll(unpack(results))
            end
        else
            error("YourUtils.onClientCommand", string.format("Unknown client command (%s.%s)", module, command))
        end
    end
end

YourUtils.onServerCommand = function(module, command, args)
    local commandModule = YourUtils.CommandModules[module]
    if commandModule then
        local commandFunction = commandModule[command]
        if commandFunction then
            if isDebugEnabled() then
                debug("YourUtils.onServerCommand", string.format("Server->client command (%s.%s) received "..
                        "with the following parameter:", module, command))
                --YourUtils.inspectAll(args)
            end
            local results = { commandFunction(args) }
            if isDebugEnabled() then
                debug("YourUtils.onServerCommand", string.format("Server->client command (%s.%s) return values:",
                        module, command))
                --YourUtils.inspectAll(unpack(results))
            end
        else
            error("YourUtils.onServerCommand", string.format("Unknown server command (%s.%s)", module, command))
        end
    end
end

Events.OnClientCommand.Add(YourUtils.onClientCommand)
Events.OnServerCommand.Add(YourUtils.onServerCommand)
#
--[[
    Usage example:

    YourUtils.CommandModules.MyModule = YourUtils.CommandModules.MyModule or {}
    YourUtils.CommandModules.MyModule.myCommand = function(args, player)
        for k, v in pairs(args) do
            print(string.format("args key=%s value=%s", tostring(k), tostring(v)))
        end
    end

    local function myFunctionThatDoesBigThings(some, things, player)
        -- Do big things ...

        -- Only basic lua objects can be passed inside args. Java objects, like a player object, cannot.
        -- But an online player id can be transmitted because it is simply a number.
        local args = {
            importantThing = "whatever",
            otherThing = 25,
        }
        YourUtils.sendRemoteCommand("MyModule", "myCommand", args, player)
    end


    Notes:
    If server-side provides a player parameter, the command is sent to the udp connection
    that player is on. However, the receiving client does not receive that same player object
    in its command function.
    
    If server-side provides nil for the player parameter, the command is sent to
    every udp connection (That means only _one_ event per client, even if that client has
    multiple split screen players).
    
    If client-side provides a player parameter, it must be a local player (one of the 4 possible
    local split screen players), otherwise the command will not be sent. When the server-side
    receives the command, the provided player object is used to distinguish which of the 4 local
    split screen players the command is tied to by providing the player object as a parameter to
    the server-side command function.
    
    If client-side provides nil for the player parameter, the server side command receives an
    unspecified local player object in the command callback. If there are multiple local
    players (e.g. split screen), any of the local players may be used, which may cause issues
    in split screen multiplayer if this command expects the player object to be set to a specific
    player.
]]
#
YourUtils.sendRemoteCommand = function(module, command, args, player, sendClientCommandEvenInSinglePlayer)
    if isServer() then
        if isDebugEnabled() then
            info("YourUtils.sendRemoteCommand", string.format("Server->client command (%s.%s) sent", module, command))
        end
        if player then
            sendServerCommand(player, module, command, args)
        else
            sendServerCommand(module, command, args)
        end
    elseif isClient() then
        if isDebugEnabled() then
            info("YourUtils.sendRemoteCommand", string.format("Client->server command (%s.%s) sent", module, command))
        end
        if player and not player:isLocalPlayer() then
            local playerName = player:getDisplayName()
            local playerID = player:getID()
            local playerOnlineID = player:getOnlineID()
            error("YourUtils.sendRemoteCommand", string.format("The player object parameter "..
                    "(%s, ID=%s OnlineID=%s) provided to command (%s.%s) is invalid because it is not a "..
                    "local player (e.g. one of the split screen players). This will cause the command "..
                    "to fail to send. A local player should be provided or nil if the receiving "..
                    "server-side command does not need a player object.",
                    tostring(playerName), tostring(playerID), tostring(playerOnlineID), module, command))
        end
        if player then
            sendClientCommand(player, module, command, args)
        else
            if isDebugEnabled() then
                debug("YourUtils.sendRemoteCommand", string.format("No player object provided for "..
                        "command (%s.%s). An unspecified local player (e.g. one of the split screen players) "..
                        "will show up as the player object to the server-side command.", module, command))
            end
            sendClientCommand(module, command, args)
        end
    else -- Single player
        if not sendClientCommandEvenInSinglePlayer then
            error("YourUtils.sendRemoteCommand", string.format("Command (%s.%s) called in singleplayer",
                    module, command))
        else
            -- Calling sendClientCommand appears to work in singleplayer (but sendServerCommand does notthing).
            if player then
                sendClientCommand(player, module, command, args)
            else
                sendClientCommand(module, command, args)
            end

            -- Alternatively, we could invoke the command directly, but if the receiver modifies args,
            -- the sender would be affected by those changes, so the semantics aren't quite identical.
            --YourUtils.CommandModules[module][command](args, player)
        end
    end
end
#

Sec, I was in the middle of changing all my print statements to use debug, info functions. Forgot about that..

Fixed that.. not in the best state, but should work hopefully

ruby urchin
dreamy shell
thick karma
hearty dew
#
YourUtils.CommandModules.MyModule = YourUtils.CommandModules.MyModule or {}

YourUtils.CommandModules.MyModule.reloadAllClientOptions = function(args)
  YourUtils.sendRemoteCommand("MyModule", "reloadClientOptions")
end

YourUtils.CommandModules.MyModule.reloadClientOptions = function(args)
  -- Put client-side stuff here to actually reload the options
end

local old_SendCommandToServer = SendCommandToServer
function SendCommandToServer(command, ...)
  if command == "/reloadoptions" then -- Not certain this is the actual string. Double check that
    YourUtils.sendRemoteCommand("MyModule", "reloadAllClientOptions")
  end
  return old_SendCommandToServer(command, ...)
end
thick karma
#

❤️

#

I'm deciding whether to tackle my own menu first, or to try to find a way to force option updates to appear live in the menu...

hearty dew
thick karma
#

I'm thinkin maybe if I do my own menu first, I'll learn the answer to the other thing, or maybe even find a workaround. I dunno.

#

(just my own options tab)

#

Lookin at how Players on Map does it, their option tab looks pretty clean

hearty dew
thick karma
#

Mod Options is working but it has 2 limitations that I would like to overcome

#

1st, purely cosmetic, I'd love to move my options to my own tab

hearty dew
#

mcm does #1

thick karma
#

That's tempting to try to switch. However, before converting everything, I'd probably want to test an MCM mod to see if I can meet goal 2: when I set one of my mod's options in the debug console, I want that change to be reflected next time I go check my Options

#

That is not the case in Mod Options. If I just set the option, or call :set() on the data object, the value changes, but the appearance in the menu will suggest it hasn't

steep copper
astral dune
#

nice

lucid wagon
#

Hello, I just joined the server, I've been making a car mod following the steps and using other mods as a guide for mine, because there aren't any more tutorials than the ones in the forum. I just discovered that there's a Discord server, so here I am. My mod seems to be working ok. I'm just having this problem that the car is not showing any damage or blood. It stays visibly perfect until a window breaks completely, and you don't see the window texture anymore. What's happening here?

Also just seen I had to post in #mod_development and not in #mod_support

bronze yoke
#

you need to make damage and blood textures

opal rivet
#

Or do you have a texture even?

astral dune
#

Can you upload a mod to the workshop without owning the game? 🤔

blissful salmon
#

In the shared folder I have a lua file with an OnGameStart event...
I expected that the file is executed on client and on server side. But if I do the following print I can find it only in the console.txt but not in the coop-console.txt.

local function OnGameStart()
  ...

  print("OnGameStart Server: " .. tostring(isServer()))
  ...
end

Events.OnGameStart.Add(OnGameStart)

Output as expected in console.txt:
OnGameStart Server: false
But nothing in coop-sonsole.txt. Shouldn't shared code also be executed on serverside? Or is OnGameStart only a clientside event?

astral dune
#

I would expect Events.OnGameStart.Add() to throw an error if Events.OnGameStart doesn't exist. Are there no errors in the co-op console?

quasi geode
#

its a client side event

blissful salmon
#

So far I couldn't find anything in the coop-console.txt. For sure I can say no Error/Exception...

astral dune
#

I've definitely had errors because I tried to add to an event that hadn't been created yet, I'm surprised that works from the shared folder at all, unless that event is added by the vanilla shared code. Strange that it would be a client only event in that case

blissful salmon
blissful salmon
quasi geode
#

ya it doesnt trigger on the server side at all

blissful salmon
#

I moved the code to OnServerStarted so now it will be executed on server. What I am missing now is the solo game. What I do in the function is add some Events or replace functions based on my SandboxVars. So if something is enable I set for example :

ISReadABook.isValid = SoulMod.ISReadABook.isValid
-- or
Events.OnZombieUpdate.Add(SoulMod.ZombieUpdateModData)

What I realised now is that some of my stuff should only be executed on clientside but for the other stuff it should be executed on serverside or when it's a sologame. Is there an event which only is being executed on server and solo game? Or an event that is exectued for all (client, server, solo) so I can check what should be executed (isClient(),isServer()).
I just don't want to double code. The reason I put in the onGameStart event was that I can't access the SandboxVars when the scripts are initialized (at least I think I did it because of that).

#

I know that I can use both events and put the part in a shared function and execute it from both events. But I just wondering if there's a better solution for this.

astral dune
#

anyone use EmmyLua? And know how to alter/disable the autogenerated file headers?

hearty dew
blissful salmon
swift sequoia
#

What's the best way to floor a value?

#

Aside from my amazing breakdance skills.

quasi geode
#

math.floor(value)

swift sequoia
#

Oh! I thought math.* functions were blocked in kahlua.

quasi geode
#

just .random and related

#

*related meaning seed stuff

swift sequoia
#

Huh. Color me flabbergasted. And here I thought I had to twist myself into a pretzel to do basic things.

#

That was my lazy token for the day. Now all I need to do is remember how to store a value on the player object to give spent points persistence.

bronze yoke
#

player:getModData().yourvalue = whatever

swift sequoia
#

That must be relatively new. This is what I used to do:

#

`local player = getPlayer();
local steamID = getCurrentUserSteamID();
local dName = player:getDisplayName();
db[steamID] = db[steamID] or {};
dbref = db[steamID];

--dbref["descriptor"] = player:getDescriptor();
    
dbref["weight"] = player:getNutrition():getWeight(); --float
dbref["isFemale"] = player:getDescriptor():isFemale(); --boolean`
quasi geode
#

its not new XD

swift sequoia
#

Last time I did mods for PZ was a very long time ago.

bronze yoke
#

i've never seen anything like that 😨

quasi geode
#

its been valid for as long as i been modding pz (5 or 6 years now?)

swift sequoia
#

I was writing a bioprinter mod a while back but abandoned the project when I stopped playing PZ. The idea was when you die you 'respawn' at a bioprinter object that prints your body out of meat you stored inside it.

#

It might be that moddata existed and I just didn't kjnow about it so was trying to hammer out something more complicated than it needed to be.

astral dune
#

was added around 2013 or so I think

swift sequoia
#

Yeah, that was before I was last playing PZ. So I was just doing things the difficult way.

astral dune
#

what was that db table you were accessing? Did you have access to the player database?

swift sequoia
#

No, I think it was just a local var that I was storing data from.

quasi geode
#

the player database however, is new (build 41 stuff)

swift sequoia
#

Yep, that's all it was.

#

When I was doing the bioprinter stuff, it was definitely pre 41.

#

Its still a fun idea, making you print your own body from meat paste. The whole idea behind it was that you're a time traveler sent back in time to find patient 0. Once you find them, you sent them back to the future so a cure can be made. You, of course, are stuck in the past during the height of the infection.

#

Only enough power to return one person to the future, and that's not gonna be you.

nimble locust
#

hey guys, anyone know why Britaas weapon pack wouldnt work?

azure edge
#

any expert out that can suggest a mod to craft fridge and other stuff???? also i played at a server and to craft more things u used to get magazines that u read 1 time from zombies any mod like that maybe????

weak sierra
#

this came up in the rimworld community stupidly often

#

partially cuz there was a GOG release

astral dune
#

thats a shame. For privacy reasons I wouldn't want to release a mod from my main account, but also don't want to buy a second copy of the game either

weak sierra
#

privacy reasons? lol

#

i guess that makes sense

#

but first time ive heard of that approach