#mod_development
1 messages · Page 359 of 1
can you help me understand some of the things in this function?
Sure. Which parts? I'm not an expert so I can't promise I can answer fully but I will try
what is playerObj meant to be?
it looks like they are adding items and perk levels to some player
perhaps for debug
It seems to be the Player Character that interacts with it, specifically the IsoPlayer object
https://projectzomboid.com/modding/zombie/characters/IsoPlayer.html
declaration: package: zombie.characters, class: IsoPlayer
I can't tell you why it's setting the Level to 7 though. My guess is Debug or a custom dev scenario that spawns in and uses all of these functions
Looking at the names of the other functions in the file
thank you for the resource
it doesnt have any description of what it is tho
ya its probably for testing
thank you
Otherwise, I just load the entire Project Zomboid folder into VSCode and search lol
thats a good idea
one of my goals is to have a radio broadcast that i can send text to through the normal text chat box
/radio hello
kinda thing
hi spiffo
tagged by spiffo
Like, have a radio and use it to transmit to chat, or just command based?
like i want my players to tune into a station
and i can make the radio say stuff
Mmm I see I see 
for example as admin i would type
/radio hello
and their radio would have hello text
hello again spiffo
later on i would like it to trigger based on their actions but one step at a time
Fair
I don't think that would be too difficult, at least the command part. Not sure about Radio part
Well that was a silly little project but it's done.
I've now got a mod that prints out every distribution list into a CSV file that can be imported into Sheets/Excel to aid in better balancing loot drop rates. Still gotta do the math and all that (which I have a Google Sheets for)...
ISWeatherChannel.lua
--Definition of bc pulled from WeatherChannel.FillBroadcast
local bc = RadioBroadCast.new("GEN-"..tostring(ZombRand(100000,999999)),-1,-1);
function WeatherChannel.AddFuzz(_c, _bc, _chance)
local rand = ZombRand(1,_chance or 12);
if rand==1 or rand==2 then
_bc:AddRadioLine( RadioLine.new("<bzzt>", _c.r, _c.g, _c.b) );
elseif rand==3 or rand==4 then
_bc:AddRadioLine( RadioLine.new("<fzzt>", _c.r, _c.g, _c.b) );
elseif rand==5 or rand==6 then
_bc:AddRadioLine( RadioLine.new("<wzzt>", _c.r, _c.g, _c.b) );
end
end
That's insane but cool. Screenshot?
I can show you the output in my excel sheet. XD
Ofc lmao
https://docs.google.com/spreadsheets/d/1En9xdCZScF4eff0Z6QU_GF3H5-udQmilPHM-LvRabCE/edit?usp=sharing
Oh wow, looks pretty
I wanted a tool to be able to logically balance all the outputs from all the damned mods... But there was no way to see the results AFTER the mods patched the distribution lists... So... I made one.\
Not sure if you know, but does Reloading the Lua pull in the Distribution List again if it's been changed?
Every time you restart the server, if you have enabled set to true on SandboxVars, it'll redo it.
So... Yesn't?
There's also an insane number of options for output
Enabled = true,
PurgeExistingLists = false,
Rules = "distlist.all",
-- Valid rule patterns (examples)
-- distlist.all
-- -> Writes 3 CSVs: procedural, distributions, suburbs
--
-- distlist.<group>
-- -> Writes 1 CSV for that group: procedural | distributions | suburbs
--
-- distlist.<group>.<prefixOrExact>
-- -> Writes 1 CSV for a subtree/prefix (e.g. procedural.Wardrobe)
-- or an exact list/path (e.g. procedural.Wardrobe.ClassyMan)
--
-- distlist.all.comprehensive
-- -> 3 group CSVs + top-level subtree CSVs (Wardrobe-level granularity)
--
-- distlist.all.totalcomprehensive
-- -> EVERYTHING: group CSVs + subtree CSVs + each exact list/path CSV (lots of files)
--
-- Multiple rules: separate with ';' or newlines
-- e.g. "distlist.all;distlist.procedural.Wardrobe"
}```
So purge just clears the folder it's outputting to.
Rules determine which distribution lists it outputs.
Probably going to see if I can do the same thing with the vehicle spawn lists as well.
Also, for this
RadioLine.new("<bzzt>", _c.r, _c.g, _c.b)
parameter1 = Message to Display
parameter2 = Red value (RGB)
parameter3 = Green value (RGB)
parameter4 = Blue value (RGB)
(Note: This was all very much vibe-coded.. I cannot take credit for it outside of conception and end execution)
Fair. Not exactly a mod concept that gets me jumpin out of bed
but very interesting anyways
I mean, critical if you want to ensure loot spawns are balanced.
Became obvious this was necessary after looking at how many mods just mad spam their loot.
My heart wants to make an tool for modifying this stuff more easily and to make it more accessible, so I'm very curious. My brain may not want to, but my heart
Dev tools are awesome! Do it!
Oh yeah, I feel you. Being able to edit that in a gui would be nice, but probably hell to accomplish and then output effectively.
ClipSize = #,
isnt this that?
Is there a way to convert a CharacterTrait object to the corresponding CharacterTraitDefinition object?
Mmm... Gui app...
@small topaz
The highlighted one is a Map<CharacterTrait, CharacterTraitDefinition>
Assuming its exposed to lua that should do it
What is the syntax for using such a java map in lua? Can I just use
local traitDef = characterTraitDefinitions[MyRegsitry.MyTrait]
?
I think it should be something like this
local traitDef = CharacterTraitDefinition.characterTraitDefinitions:get(MyRegsitry.MyTrait)
Because the map is a java object, you gotta use the get method
ok thanks! I'll try that.
My local mods on my mod folder are not working with this latest update do I need to restructure the folder?
Ah, no folder structure changes im aware of
Weird
@flint beacon
I think there was a similar issue with clothing mods above:
#mod_development message
Not sure if the resolution he posted helps you
aren't they showing up in your in-game mod menu?
They show up on the mod menu but won’t appear on character, was just wondering if I needed to change anything
Ty I’ll check this out
They changed a lot of things in their Lua-Java-API. For example, the whole bodyLocation system is different now and your clothing mod will pbbly not work anymore if you don't adjust. Also, they changed a small thing about how to define your item's script.txt file. So you might have a look at this as well.
#musicmaniacpins loot distribution dump with modded changes
Hmmm? Yeah, that's what that is.
Yeah I know, I pinned it for myself
Does Umbrella have an easy way to see what an old function has changed to
I have the 42.13 version installed but it doesn't give an error for outdated functions, just doesn't give an error when I put in the new 42.13 version
super random question is there a hotkey to hotswap to your inventory's respirator? if not there a mod for it? ..... and if double not, could be a sexy af mod that lets you hotkey swap headgear to respirator and back.... lmao i dunno shit about LUA but maybe id be curious
does feel like a kinda obvious vanilla hotkey though... i just slayed a nice batch of airborne infected zombies with riot gear so they couldnt scratch me, now that theyre nice and proper re-dead i would probably want to quickly whip out at least a N95 so their rotting corpse gasses dont infect me after i axed them all down
when i try to connect to my server with a non admin client it says the lua file does not match the one on the server
do i need to put my mod folder in the steam install folders workshop folder too?
Is there a mod that can record some activities in a log, activities such as activating god mode, activating invisible, spawning items? for b41
Read the MP notice guide in the pinned messages
No. @bronze yoke has copies of old decompiles if I'm not mistaken but not of the Lua
I love how OnPlayerUpdate and getStats for Boredom will just give you values don't match the actual changes 
so weird question, i figured i'd ask here
i'm thinking of "cleaning" my save a bit by deleting some files, but i'm not really sure how they're laid out. i assume there's some way to correlate this data to a grid
what i'd like to do is create a gui for this. might end up picking up python to create a little script that lays it out. but i also don't know how the cells are structured
fellas, is there any reason to put your files in folders other than scripts/
like scripts/generated etc?
The generated folder are simply generated scripts by TIS automatically
I just don't understand the difference, in my opinion, everyone just throws their script files into the script folder, without any subfolders...
Like, is that OK?
If you make subfolders, there won't be any clash with other files named the same way
It's a question of organizing your mod files
thanks, king
(in b41) the real boredom level is in BodyDamage
for some reason stats had an entirely separate boredom level that is tracked and increased/decreased by certain things but does absolutely nothing
in 42.13 the stat revamp moved all stats back to stats and cleared up all the weird stuff like that
well yes but the difference between each OnPlayerUpdate does not match the increases/decreases it is behaving fairly weird.
Does anyone know why, if I export an animation in Blender (even with no edits), my weapon and backpack bug like this please?
It seems the backpack and weapon prop bone got mixed up in your animation, if you enter debug mode and press 6 it should let you know what animnode the game is currently using, which might be the cause of this issue..
Do we know how "player:getMoodles():getMoodleLevel(MoodleType.Endurance)" changed in 42.13 ?? it stopped funtioning.
Pretty sure it was explained here https://github.com/SirDoggyJvla/Archive.Project-Zomboid-Modding/tree/main/TIS guides/B42 unstable MP
are recipeGroup usable at this stage? i tried to use it but maybe i'm missing something 🙁
ive seen the guide but not sure i understand it xD
Pretty sure they changed the name of many moodles... Not sure if player:getMoodles() still works tho
Hey can I just edit the main textures in the main folder for a custom skins and clothes
I did b4 42.13
Will it brake every thing if I don't make a mod..new to this. Just been editing mods with paint love it
the moodletype members have changed names https://demiurgequantified.github.io/ProjectZomboidJavaDocs/zombie/scripting/objects/MoodleType.html
So after getting my mod to properly load onto a dedicated server, this is what's coming up in the console logs on the server whenever trying to actually craft any of the custom recipes
java.lang.RuntimeException: attempted index: isCanWalk of non-table: null at KahluaThread.tableget(KahluaThread.java:1447).
Stack trace:
se.krka.kahlua.vm.KahluaThread.tableget(KahluaThread.java:1447)
se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:457)
se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:167)
se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1756)
se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1560)
se.krka.kahlua.integration.LuaCaller.pcall(LuaCaller.java:69)
se.krka.kahlua.integration.LuaCaller.protectedCall(LuaCaller.java:109)
zombie.core.NetTimedAction.parse(NetTimedAction.java:142)
zombie.network.packets.INetworkPacket.parseServer(INetworkPacket.java:55)
zombie.network.PacketTypes$PacketType.onServerPacket(PacketTypes.java:915)
zombie.network.GameServer.mainLoopDealWithNetData(GameServer.java:1593)
zombie.network.GameServer.main(GameServer.java:897)
ERROR: General f:116179, t:1765988902392, st:2,473,281,911> KahluaThread.flushErrorMessage > dumping Lua stack trace
-----------------------------------------
STACK TRACE
-----------------------------------------
function: new -- file: ISHandcraftAction.lua line # 354 | Vanilla```
Oh hey that's me 
What the hell are recipe groups ?
I think it was that weird thing they talked about... Being able to join multiple craftings into a same group eg: Craft long implement
Did they replace getEndurance with getLastEndurance ?
craftRecipe OpenBoxOfJars { timedAction = UnPackBox, time = 15, OnCreate = RecipeCodeOnCreate.unpackItemTypeFromBox, Tags = InHandCraft;Packing;CanBeDoneInDark, category = Packing, recipeGroup = OpenBox, inputs { item 1 [Base.BoxOfJars] flags[AllowFavorite;InheritFavorite], } outputs { item 6 Base.EmptyJar, item 6 Base.JarLid, } }
from C:\Program Files (x86)\Steam\steamapps\common\ProjectZomboid\media\scripts\generated\recipes
make a grouped expandable list of item with the same use
check in the crafting window ingame at packing you will see a group of OpenBox stuff
Yeah, it seems to be essentially a flag used to merge multiple recipes into one from the user's perspective in game
It was changed, that explains why it's not working then lol
That's mappers
I just pushed it aside as a later problem
so now we have meta recipes and recipe groups 😅
not that
Has anyone had any luck getting custom recipes to work on dedicated servers? I seem to be hitting a wall on what looks like a check for whether the recipe can be performed while walking (which it can't) but that's assuming I'm interpreting the console output correctly and I'm honestly out of my depth at this point. 😖
It needs to not be in a custom module
It needs to be in the Base module
Oh it does? I guess I misunderstood how the modules worked & thought all of our custom content had to be inside of custom modules.
it is good practice to do so, but it is not working as of the latest patch
Even the testmod they gave us in the sample documentation had their custom recipes in a custom module so I didn't think that had changed
it will probably be hotfixed soon
The difference between getEndurance and getLastEndurance is Last needs to be done on the server side for multiplayer now :P
I should have known because I need to set the endurance by removal on the server as well now lol
I don't like all this syncing stuff
Overall your mod should run server side now
Any stat changes should be done server side and a sync call should be sent, no need for commands, there should be functions to do that
That resolved it and my mod is working now. Thank you so much!
np
So.... it appears my mod works now but is also causing completely unintended consequences on dedicated servers. No errors are coming up in either the client or server console but other functions are definitely broken when the mod is in play, specifically the ability to turn on a generator. Any suggestions on trying to tackle that?
And for context, the mod is nothing more than a few custom items and some custom recipes. Nothing else.
Do items with Hidden = true appear always in debug mode
Appear where ?
Recipes need to be in the module Base
Due to a bug
In the inventory
Wasn't sure if that was an intentional thing or if I just didn't do it right
I think it shouldn't appear at all in the player inventory ?
I use "Hidden = true;" exactly. Does true need to be capitalized or something
ah, I'm a dumbass
";" lol
Yea why tf do you have that lol
So the vanilla ISBuildAction is still in the client folder? How is this supposed to work in multiplayer?
Idk, there's some timed actions that are still client sided somehow
Some TimedAction may not need any server side stuff. So they are fine in client folder. However, ISBuildAction is for actually building stuff like walls which you and other players are supposed to interact with in the game world. Therefore I wonder....
The transfer items timed action too I believe ?
Yeah, I moved all of them to the Base module which is what got them working. I just now have a weird bug that after performing any of the recipes I can't turn a generator back on until after I disconnect/reconnect it.
Yes, ISInventoryTransferAction is also in client which is weird since it manipulates player inventory...
that action has always been super weird so i'm not questioning it
Hello guys! Does someone know if TIS have planned to remove those very low limits to capacity for vehicle trunks? Nothing can go above 50 for backpacks and 130 for vehicles... That sounds absurd to me that a 40 tons semi-truck have the same capacity as a shopping cart... 😅
Too easy to live out of a car if you can carry an entire stockroom in a hatchback. Just get a mod.
Do you know something called "Kenworth W900 Semi-Truck"? It's like a giant truck. It's trailer is bigger than my house, but its carrying capacity is equal to my garbage bin in B42. AND it allready comes from a mod. I don't ask you to judge me, i ask if someone know if TIS will remove those stupid limits they implemented in B42 so that players can enjoy a realistic game like in 41.78.
There is a framework to go over this limit if you want
But to answer your question, I haven't heard of them saying they'll remove it tho I haven't heard the inverse either
Cool! Thank you!
I think the reason they did that was for security reasons
Anti-cheat reasons to be more specific ?
I mean that'd be a logical reason to do that at least 😅
But they made a game moddable... If they don't want people to make content, that make no sens to me. 😅
You're assuming they did it to hurt modders, but they didn't
I'd like to believe you, but I really don't understand those arbitrary limitations that came out of nowhere... For me it's like saying "you enjoyed those mods? Well we don't allow you to enjoy anymore, you have to suffer."
I do wish they'd open up caps on SP
Well, thank you anyway for the framwork, maybe i'll try to locally modify Ki5 vehicle mods if he/she doesn't implement it^^
in B42.13, I want to do something on a client once an item from its inventory was modified server side (its mod data is modified and syncItemModData is called). Is there already some callback I can attached my client on, to get it ?
why not just make some more item containers to pair with the vehicle?
Bcs that doesn't make any sense
You have a massive ass truck and it's split into a hundred containers ?
Plus good luck managing that shit lmao
It's not that easy
It also doesn't remove the limitation technically, you just now have 50 containers lmao
I wouldn't call that a solution at least 😭
looking at ItemContainer.getCapacity, that math.min is sus as hell. idk what the compiled is but I'm betting it's fixed in the next update
or just dont put the item in the container and store it in a table and count all the weight yourself 🤔
I thought about that for player inventory but then my head fell off
I had this idea when i tried to bypass the 50 cpacity for backpacks
Never managed to make it work even with AI helping me
*especially with AI ‘helping’ you
They don’t know hardly anything about Zomboid and end up doing more harm than help
Yeah. It s*** a little bit. But it saved me years for syntax
Helping with the basics is fine as long as you understand what your code is. I can’t imagine trying to maintain a mod that I don’t know what it does, and I’ve seen plenty of examples of people who will try AI code just because they don’t know how to write their own
Then they come into a support channel and paste some code that doesn’t make a lick of sense and everybody points and laughs
I learned a lot by trying it own my own and writing terrible code that everyone pointed and laughed at anyways, but you get the idea
Yeah, i get it. But in fact I mostly use AI to understand how code works. When i don't understand how a mod is functioning, i give function to it and i ask to explain me what the role of each line
Terrible idea 😅
Because for items to be saved by the game, they need to be in an ItemContainer
So at the end of the day, you still need to manage to put your item in the container
Pretty sure there were some issues when many individual items were inside a player bag or an inventory container...
oh yeah i have mods that i need things to save like that. i store its data in moddata and instance it again
is a lot of moddata though
if it was all containers
Take care with that, it can easily do suppositions of what the game does when something is named in a way, and yet it doesn't do what it thinks the code actually does
Yeah I was going to say that could easily turn dangerous
Same, that's also a terrible idea because how do you store uniques ? You store every single data ? Do you store the mod data of items in another mod data ?
There's too much limitations to rely on such a system, too many problems that can appear from this
This solution needs to be the LAST solution
But like I mean, the LAST OF THE LAST, actual LAST
You should absolutely not do that if there's a few dozen potential solutions that would be better
For example in the horse mod we needed to have a container that was accessible from the horse
yea the things i was doing that with are specific items and are all vanilla that have limited data
A solution could be the mod data thing, and there'd be likely other solutions, but we went with moving an invisible container at the feet of the horse instead, bcs the more we use the default game systems, the best it'll work
Yeah, Copilot made A TON of halucinations. I had to copy-paste the same prompt with the code every 10 min so it can remember what i was asking about... 😅
But as i said, it saved me years. I managed to fix some mods despite my only experience in coding was a bit of c++ and html like... 25 years ago... (edit: well 21, actually, i'm not as old as i imagined)
so 50 containers as one is best solution 🤔
It may cause problem since they implemented very unsecured right-click otpions when it comes to inventory containers when they implemented their "rename" option
actually. why not just change the weight of the items being placed in there?
then change them back when removed
what is the samllest weight an item can have? could do near infinite items if its really small
To be realistic, it would have to scalled dynamically with the size of the container...
obviously i was just curious at how fast i could break the game
I haver tried some things while i was trying to fix ProximityInventory
Like creating an invisible backpack that agregate all containers around the player and showing it all at once
But the thing is that the UI seems to dynamically "create" the type of the container when you right-click on it
Does the SandboxVars.MyMod.Something variable contains the correct sandbox setting even when playing a non-sandbox game (apocalypse,survivor,...)?
(which should then be just the default value for that game mode ofc)
I think you need a fallback in case there's no sandbox options, but i'm a big noob
good point! not sure if you need it everywhere but using it is a good idea...
With my poor logic, I would certainly test something like "if SandboxVars.MyMod.Something ~= nil then"
it uses the default value you set in the sandbox script file
the gamemodes are sandbox presets so any modded sandbox options that arent listed in them will just be default
Yea
I'm trying to update this old mod to 42.13 for personal use. Got a ton of errors when i just booted the game with it.
seems like they removed `TraitFactory´ table
so how to register traits in this new version?
thanks
anyone know where i could modify the starter kit?
I might be tweaking, but I was looking through, and cant seem to find the lua code file for
RecipeCodeOnCreate and RecipeCodeOnTest
I am trying look at some examples within the vanilla games and cant find that file anywhere.
I remember having it pulled up before, did they move it with the update?
Ah nvm I see what happened, I didnt do enough digging they got moved to Java it seems
nevermind i found it, its in ProjectZomboid/media/lua/shared/items/SpawnItems.lua
you can change it in function SpawnItems.OnNewGame
To continue off this, is there a link or something I can read more about this and still look at them / implementing?
In lua, when I have a CharacterTrait objec like CharacterTrait.ARTISAN or from my own registry, is it possible to print this very object name as a string? So that it outputs the string "CharacterTrait.ARTISAN" ?
Found SimKDT's videos going to watch and that should hopefully answer my questions, will ask if I need help later
BIG NEWS FOR DRUG MODS
just got in touch with another Modder who took it upon himself to code some visuals for https://steamcommunity.com/sharedfiles/filedetails/?id=3404956403
the next update will be TRIPY hint hint
DRUGS
In 42.13, some worn backpacks return nil when using item:getBodyLocation() on them?? Is this new?
just tested it via print-to-console:
LOG : Lua f:2, t:1766038599755> TEST OUTPUT location base:belt
LOG : Lua f:2, t:1766038599755> TEST OUTPUT item Base.Briefs_White
LOG : Lua f:2, t:1766038599756> TEST OUTPUT location base:underwearbottom
LOG : Lua f:2, t:1766038599756> TEST OUTPUT item Base.Vest_DefaultTEXTURE_TINT
LOG : Lua f:2, t:1766038599756> TEST OUTPUT location base:tanktop
LOG : Lua f:2, t:1766038599756> TEST OUTPUT item Base.Tshirt_WhiteLongSleeveTINT
LOG : Lua f:2, t:1766038599756> TEST OUTPUT location base:tshirt
LOG : Lua f:2, t:1766038599756> TEST OUTPUT item Base.Socks_Long
LOG : Lua f:2, t:1766038599756> TEST OUTPUT location base:socks
LOG : Lua f:2, t:1766038599756> TEST OUTPUT item Base.Shoes_TrainerTINT
LOG : Lua f:2, t:1766038599757> TEST OUTPUT location base:shoes
LOG : Lua f:2, t:1766038599757> TEST OUTPUT item Base.Trousers_DefaultTEXTURE_TINT
LOG : Lua f:2, t:1766038599757> TEST OUTPUT location base:pants_skinny
LOG : Lua f:2, t:1766038599757> TEST OUTPUT item Base.Bag_Schoolbag
LOG : Lua f:2, t:1766038599757> TEST OUTPUT location nil```
EDIT: So ok... When your clothing item is also a container, you can get its bodyLocation now only by `item:canBeEquipped()`, not anymore by `item:getBodyLocation()`... good.... 😐
EDIT2: ok... not always... some may stil work with getBodyLocaiton, some don't... pbbly somewhat buggy from the game's side here
In B42, should I put the mods I create into the Zomboid\mods folder? When I open the mods section in the game, the mods I put in the mods folder don't show up.
B42 requires a new folder structure for mods, different from the one in B41
Where can I learn this?
I didn't understand. Which folder should I put the mod I want to develop into?
you can still use the Zomboid/mods folder but you have to make a new folder structure within your mod as described on the wiki page I linked
Zomboid/mods/SimpleTestMod/
mod.info
poster.png
Contents/
mods/
SimpleTestMod/
common/
lua/
client/
server/
media/
I'm doing it this way and it's not working.
Mod info in wrong place
Go back reading the mod structure page
Hey everyone,
I’m doing some reverse-engineering on Project Zomboid vehicle mods and I noticed that most mod FBX files seem to be authored/exported at 0.010 scale in Blender.
Is there a specific reason for using 0.010 as the base scale?
You mean in the script ?
I noticed it and put the mod.info in the correct place. However, I still can't see it in the mods section of the game. Could you please provide the correct file structure?
No, I mean in Blender itself, not in the vehicle script.
The FBX files are already authored at 0.010 scale inside Blender, before any in-game script scaling is applied.
That’s what I’m trying to understand the reason for.
You need to follow the wiki
The mod appears when placed in the Workshop folder, but it doesn't appear when placed in the Zomboid\mods folder.
If I don't specifically create a file for version 42.13, it doesn't show up in the workshop. I understand correctly, right?
No it does anyway
Your mod.info file was just in the wrong place in.what you showed us
hey everyone, wanted to check if my map mod works on mp, but cant seem to make any map mod work on server (using gportal)? any known issues¿?
Mods=\MODIDEXAMPLE;\MODIDEXAMPLE2;\MODIDEXAMPLE3
this is my Broccoli B42.13 server
WorkshopItems=NUMBERIDHERE;NUMBERIDHERE
is that a misspell?
where?
a , usually ENDS, in most cases, so its weird there are , and then ; after it
Hello everyone,
I have been fiddling around with some drainable items and trying to use setUsedDelta() to adjust them, and it seems to work, but when I exit the area, or log out/log back in, the item does not seem to retain the change.
Or if it does retain the change, it is off slightly from what it should be. Say an item with 500 uses, with a useDelta of 0.002, should be at 500 when it is at max value, which is what it shows in game, but when I return its at 498 instead.
I've tried rounding and truncating the value from getUsedDelta() to have minimal decimal points and slop in the numbers, and then adding my increase to that with setUsedDelta(), but when I immediately grab the value again afterwards and print the result there is added decimal value completely irrelevant to what numbers I provided/calculated from, almost like a rounding error.
Sometimes when I come back to an area, teleporting to/from, the item with half usage is reset to full value, or another odd value that doesn't correspond to anything I had set.
Does anybody know why this happens, or a workaround? Been trying to figure it out, but it doesn't have much rhyme or reason behind what its doing.
This is my code, as of now, to try to test this. Basically just re-filling a Charcoal Bag with some handfuls of charcoal, a few at a time, and in-game it seems to work at face value, but does not hold it's value when I leave/return in various manners.
function OnCreate_AddHandfulOfCharcoal(sources, result, player, item)
for i = 0, sources:size()-1 do
local item = sources:get(i)
if item:getType() == "BagOfCharcoal" then
local currentUseDelta = item:getUsedDelta()
local adjUseDelta = math.floor(currentUseDelta * 10 + 0.5) / 10
local truncUseDelta = tonumber(string.format("%.3f", adjUseDelta))
item:setUsedDelta(truncUseDelta + 0.1)
end
end
end
Thank you for your assistance!
Details: B41MP Dedicated Server
Map=Muldraugh, <----
Muldraugh, KY is always already written in the config files, so i assumed it was right, in b41 u had to write it like that 100% idk if it changed in b42
should i try without KY?
i would look around for evidence to check, im unsure myself
When I try to open the vehicle editor, I only get a grey screen instead of the editor UI.
Has anyone run into this issue before?
it has to be there right? if i delete it from that line the whole map will deissapear?
YOOOO, okay now i deleted muldraugh, ky and all maps worked but the original map, that means it was overriding them, maybe i should put muldraugh ky the last one?
any advice i give at this point is 100% likely to be wrong, as its not somethin
g ive done
no but thanks to you i found out they can work indeed, now i have to find how to do it propertly!! THANKs
When loading maps onto a server, Muldraugh has to be last, otherwise modded maps won't load.
GODDAM okay hahah thanks
No I believe that is normal yea 😅
that tripped me up Instantly xD
if i copy players db to the new save files, will all players from server keep levels and everything? ty
Hello, I do not know drainables enough to give you answers, I do not even know if getUsedDelta represents the missing uses or the contained uses or whatever. At your place, I would print the evolution of getUsedDelta & getEntityNetID before and after any change to better understand what comes from logic / from math / from game save&load shenanigans.
FELLAS! Please teach me how to work with interfaces, I really want to create my own little window((
currently tinkering with propane refill from those little lantern bottles, but i'm not sure where i'd find RecipeCodeOnCreate.refillBlowTorch
aha. found it. but it's all garbage i can't read lol, uhhh. shit
can u send it?
looks something like this
Use this to decompile the java to be readable https://pzwiki.net/wiki/Zomboid_Decompiler
oh, thank you
well they are function calls
I used to often change what some of these things do after crafting, but now I’m not sure I'll be able to.
After all, this thing was used back in the day to predetermine the result.
It’s good if I can modify my own recipes using Lua, but how to intervene in the vanilla code now...
Looks like I’ll have to learn Java...
whatever you do, i wouldn't recommend using a chatbot to make your code
notoriously unreliable, will often cause more problems than just doing it yourself
but it can be useful in places. just make sure you fully understand the code it's implementing and don't just copypaste
That’s not something I do
reverse engineering at most.
very good
the utility appears to be having trouble finding ProjectZomboid.jar
which, uh, doesn't exist. in my files. for some reason
that's odd
Do you want to decompile for b42.12 or b42.13?
Ah yeah you need the version before the latest one
got it, cheers
coded like the worst mod trait ever
called it ultrakill costs 10 points, everytime you kill a zombie it will pick a random part of the players body and fully heal it
im unable to view these, can anyone share the migration guide pdf please?
ye
All three
thank uuu
these are the exact originals.
legend 😄
These are also available in #1448602571810803785 message, for future reference (to avoid the need to find the files to upload)
it took 0.1s to do that
Hey is there a mod where my character could lose weight faster?
new function for moving bodylocations
Should I be concerned with the bodyLocation list order for any reason?
I'm working on Equipment UI right now, but I haven't gotten to custom bodyLocations or anything yet.
Just been using the predefined constant bodyLocations so far.
no its just the order the clothing is rendered in
Oh. Oooooooooh.
That actually is of interest to me.
I define the preferred top item for combined slots based on the order I write my own lists in. This sounds like a much more reliable way to do that.
Well, maybe. Worth trying out at least.
hey sry if its obvious to you guys but where do i go to fix the names of my backpacks? It says it uses module.itemID for the name, so i thought it would be kuromi_backpack?
media\lua\shared\Translate\EN
ItemName_EN.txt
ItemName_EN = {
ItemName_kuromibackpack.kuromi_backpack = "SuperPuperDuperUltra backpack"
}
anyone managed to bypass the serverside container size?
working now, thanks a lot dude :))
Korean moved to UTF-8 on 42.13.1, hell yeah
Wonder if that was the cause of the garbling in 42.13.0
do we know if they're all utf-8 now? there was only a couple exceptions left
hi, where to see the changes to fluid system? in this last update something is broke in my mod 🙁
Argentinian Spanish, Catalan, & Czech still have unique encodings for now, but hopefully they'll follow suit soon
do you know how they change recipecodes rules? it dosen't work anymore 🙁
this
function: Herbalist_recipecodes.lua -- file: Herbalist_recipecodes.lua line # 16 | MOD: Herbalist LOG : General f:0, t:1766090002111> attempted index of non-table ERROR: General f:0, t:1766090005404> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index of non-table at KahluaUtil.fail(KahluaUtil.java:99). Stack trace: se.krka.kahlua.vm.KahluaUtil.fail(KahluaUtil.java:99) se.krka.kahlua.vm.KahluaUtil.luaAssert(KahluaUtil.java:89) se.krka.kahlua.vm.KahluaThread.tableSet(KahluaThread.java:1481) se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:434) se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:167) se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1756) se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1560) se.krka.kahlua.integration.LuaCaller.pcall(LuaCaller.java:69) se.krka.kahlua.integration.LuaCaller.protectedCall(LuaCaller.java:109) zombie.Lua.LuaManager.RunLuaInternal(LuaManager.java:1334) zombie.Lua.LuaManager.RunLua(LuaManager.java:1288) zombie.Lua.LuaManager.RunLua(LuaManager.java:1277) zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:1179) zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:1099) zombie.gameStates.GameLoadingState.enter(GameLoadingState.java:155) zombie.gameStates.GameStateMachine.update(GameStateMachine.java:95) zombie.GameWindow.logic(GameWindow.java:392) zombie.GameWindow.frameStep(GameWindow.java:825) zombie.GameWindow.mainThreadStep(GameWindow.java:597) zombie.MainThread.mainLoop(MainThread.java:68) java.base/java.lang.Thread.run(Unknown Source) ERROR: General f:0, t:1766090005404> KahluaThread.flushErrorMessage > dumping Lua stack trace
but i didn't touch any before this last update
what is on line 16?
-- Aggiunge 5 XP all'abilità Medico
:D
require "recipecode";
Recipe = Recipe or {};
Recipe.OnCreate = Recipe.OnCreate or {};
Recipe.OnCanPerform = Recipe.OnCanPerform or {};
-- Aggiunge una padella all'inventario del personaggio
function Recipe.OnCreate.GetSaucepan(craftRecipeData, character)
character:getInventory():AddItem("Base.Saucepan")
end
-- Aggiunge una pentola all'inventario del personaggio
function Recipe.OnCreate.GetPot(craftRecipeData, character)
character:getInventory():AddItem("Base.Pot")
end
-- Aggiunge 5 XP all'abilità Medico
function Recipe.OnGiveXP.Doctor5(craftRecipeData, character)
character:getXp():AddXP(Perks.Doctor, 5)
end
-- Aggiunge 6 barrette di granola all'inventario del personaggio
function Recipe.OnCreate.GetGranola(craftRecipeData, character)
character:getInventory():AddItems("Base.GranolaBar", 6)
end
-- Aggiunge una bottiglia vuota all'inventario del personaggio
function Recipe.OnCreate.GetBottle(craftRecipeData, character)
character:getInventory():AddItem("Base.WaterBottleEmpty")
end
-- Aggiunge tutti gli oggetti con i tag "SaltPacket" e "Salt" alla lista degli scriptItems
function Recipe.GetItemTypes.SaltPacket(scriptItems)
scriptItems:addAll(getScriptManager():getItemsTag("SaltPacket"))
scriptItems:addAll(getScriptManager():getItemsTag("Salt"))
end
function Recipe.OnGiveXP.Doctor5(craftRecipeData, character)
character:getXp():AddXP(Perks.Doctor, 5)
end
yes those are the recipecodes XD
love your mod, my fav into 41, btw :з
I haven't been paying much attention to the recipe side of things, so someone correct me if I'm wrong: pretty sure the move of those to Java means Recipe is no longer a defined table
So it's odd that that was working before, given that
Which update was it working in?
just before this one i suppose, anyway i just need OnCreate to work, how to use that now?
i just remove Recipe.?
maybe this class is no more?
Assuming the referencing works similarly to how it did in b41, which I imagine it does, it just has to be anything accessible in the global environment
So, your own global table with recipe callbacks, a global function, whatever
this is old i think, it's how is done now
Huh, it does still have Recipe. there 🤔 Could've sworn I saw people talking about how that was gone
It does say 42.5.1, but I figured it was an earlier change
i mean, its should be like:
craftRecipe MakeBiofuel
{
timedAction = MixingBucket,
time = 500,
tags = AnySurfaceCraft,Campfire,
skillRequired = Farming:1,
category = Herbalist,
OnCreate = Recipe.OnCreate.GetBottle,
inputs
{
item 1 [Base.Pot;Base.Bucket;Base.BucketForged;Base.PaintbucketEmpty] flags[IsEmpty] mode:keep,
item 1 [Base.Fertilizer;Base.CompostBag],
item 1 [Base.BakingSoda],
item 1 [Base.OilVegetable],
item 1 [Base.PetrolCan] flags[IsEmpty] mode:destroy,
item 1 tags[Fork;MixingUtensil;Spoon] mode:keep flags[MayDegradeLight],
}
outputs
{
item 1 Base.PetrolCan,
}
}
wheres OnCreate = Recipe.OnCreate.GetBottle,
just OnCreate = YourFuncGetBottle
and just simple function YourFuncGetBottle(craftRecipeData, character)
without Recipe. like tables etc
i'm pretty sure it was removed in 42.13 since that's the only time i've heard people complain about it
it may have just been left in until now for compatibility or something, i don't think it was used
ok ty
yep, method work
#mod_development message
in Recipe OnCreate = zReMyTestFunc,
In lua server side
(just this is code without notging more)
function zReMyTestFunc(CraftRecipeData, character)
print("My Test Func Work")
end
yep gotcha ty 😉
OnCreate =
I think this part doesn't work anymore. document said most of the OnCreate function was moved to java part. if you add OnCreate to your mod it might cause some error on server side.
I see, that makes sense
no, this is basic modding api, it works fine
the vanilla oncreates were replaced with java implementations for type safety reasons, no other changes were made
this is my previous attempt when I was using this mod on my server and got this log while crafting got adrupted by server. my guess is it's due to OnCreate stuff in that mod. once I remove it and its lua part it works fine.
https://steamcommunity.com/sharedfiles/filedetails/?id=3558162562
function: new -- file: ISHandcraftAction.lua line # 354 | Vanilla.
[19-12-25 01:05:40.177] ERROR: General f:36219, t:1766077540177, st:30,604,401,005> ExceptionLogger.logException> Exception thrown
java.lang.RuntimeException: attempted index: isCanWalk of non-table: null at KahluaThread.tableget(KahluaThread.java:1447).
Stack trace:
se.krka.kahlua.vm.KahluaThread.tableget(KahluaThread.java:1447)
se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:457)
se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:167)
se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1756)
se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1560)
se.krka.kahlua.integration.LuaCaller.pcall(LuaCaller.java:69)
se.krka.kahlua.integration.LuaCaller.protectedCall(LuaCaller.java:109)
zombie.core.NetTimedAction.parse(NetTimedAction.java:142)
zombie.network.packets.INetworkPacket.parseServer(INetworkPacket.java:55)
zombie.network.PacketTypes$PacketType.onServerPacket(PacketTypes.java:915)
zombie.network.GameServer.mainLoopDealWithNetData(GameServer.java:1593)
zombie.network.GameServer.main(GameServer.java:897).
[19-12-25 01:05:40.177] ERROR: General f:36219, t:1766077540177, st:30,604,401,005> KahluaThread.flushErrorMessage > dumping Lua stack trace
Hello,
I am a novice modder, and I am having trouble getting my mod to work in MP [42.13.X].
In short, my mod only adds items, recipes, and translations in Lua. The items work, but when I try to create the recipes, they only progress 1% and then stop without creating or using anything.
Do I have to do something specific to make them work in MP, like something in Lua or something like that?
Im trying to make more variants of the Kitty Keychain to add one that looks like my cat, and i got the icon textures and all that working, but the placed world item uses its giant 2d texture instead of the 3d one. Ive tried copying the KeyChain_Kitty.fbx world model but my added Keychain_Kitty5 does not use it. am I missing a script or something?
your recipe should be in Base module
but items shouldnt
if your mods items in Base module - your new recipes not working
If anything, it's just bypassing the error, according to the idea, everything should work without such dances (with its own modules or in base ones), just the problem is the latest version.
Thanks, I'll test that out. 
u should scripting your 3d model
So since i was just adding a variant of an existing model, in the added item's script I had "model KeyChain_kitty" and i thought it'd use the same model, but I had to use "model Keychain_Kitty5" and make a variant for it
solved tho
hi guys, has anyone already asked how to make spawning inventory items in MP changed in new update? build 42?
i've read the PDF file they uploaded
and used the "sendadditemtocontainer() " function
the item goes into inventory correctly
but they are not usable
nor can't be dropped onto the ground
do i have to use SendClientCommand() function or something?
are you spawning the item in the client or server?
client
spawning it in client wont work anymore so everything related to that has to be done on the server
what does your mod need to do?
oh yeah in that case you need to make a clientcommand
hold on let me show u the code
local function onConfirmPurchase(item)
-- Get the main window and the stored item
local item = what_item[1]
print("this is item 1 " ,item.item:getType())
if CheckInventory() >= item.price then
getPlayer():Say("your price was "..item.price)
if instanceItem("Base."..item.item:getType()) then
local itemadded = getPlayer():getInventory():AddItems("Base." .. item.item:getType(),1);
sendAddItemToContainer(getPlayer():getInventory(), instanceItem("Base."..item.item:getType()));
for i = 0, item.price-1 do
local credit = instanceItem(SandboxVars.Wuro.Credit)
local removeditem = getPlayer():getInventory():RemoveOneOf(SandboxVars.Wuro.Credit)
sendRemoveItemFromContainer(getPlayer():getInventory(), credit);
end
else
local itemadded = getPlayer():getInventory():AddItems("WURO_items." .. item.item:getType(),1);
sendAddItemToContainer(getPlayer():getInventory(), instanceItem("Base."..item.item:getType()));
for i = 0, item.price-1 do
local credit = instanceItem(SandboxVars.Wuro.Credit)
local removeditem = getPlayer():getInventory():RemoveOneOf(SandboxVars.Wuro.Credit)
sendRemoveItemFromContainer(getPlayer():getInventory(), credit);
end
end
else
getPlayer():Say("You have not enough credit(s)")
end
end```
so... use the Event.OnClientCommand.Add() ?
Send a call to the server to spawn the item server side, and sync that to the client with the proper commands
you need to make a lua file in the lua/server folder that will have a function that does all of that item inventory stuff so that you can call SendClientCommand to tell the server to execute the function
1 sec im gonna make an example script
i see i see
Thanks again, I was able to fix it. I had to change the modules of items and recipes to Base, and now it works perfectly in MP. 
the args in sendClientCommand is a table that you send to the function on the server but i dont know if items can be values
local Commands = {}
function Commands.CheckMoney(player, args)
-- do all the item creation and inventory management here
end
local function OnClientCommand(module, command, player, args)
if module == "YOURMODIDHERE" and Commands[command] then
print(command)
Commands[command](player, args)
end
end
Events.OnClientCommand.Add(OnClientCommand)
-- this is how you call CheckMoney
sendClientCommand(getPlayer(), "YOURMODIDHERE", "CheckMoney", { item = itemHere })
yeah
make a new folder inside server with your mod name or something and then name it something like ClientCommands.lua
then the code of
item creation go inside the server folder?
or can it be stayed in client ?
as long as the creation start in server?
it goes in the CheckMoney function in the clientcommands script
hmm i see
in the client you do sendClientCommand(getPlayer(), "YOURMODIDHERE", "CheckMoney", { item = itemHere })
local candle = instanceItem("Base.Candle")
self.character:getInventory():AddItem(candle);
sendAddItemToContainer(self.character:getInventory(), candle);
to tell the server to run the item code on its own end
yeah that code should be in server
i see i see
sendAddItemToContainer syncs the item to the client
gotcha
so i don't need to use the sync command separately like the pdf says
self.generator:setActivated(self.activate)
self.generator:sync()```
thats for world objects i think
this is all you need for items
this is only for the object (tiles) in the map
gotcha
ill try it
thank you spongie
that was great help. clearing things out
i think all of this would be moved to server and then replace it in the client code with sendclientcommand
and then anything you need to pass from the client to the server you can add to the table at the end of sendclientcommand
when its inline its kind of confusing but you can do it like this as well
and then the server function can just do args.item to access it
hmm goodo idea
my professions, while they work perfectly in singleplayer, do not appear in multiplayer. is there a common known cause for this?
I was working on a mod and i was trying to go into the lua debugger to find what went wrong and i couldn't find the script for the mod anywhere, and i was asking to see if anyone knew why. I knew someone had a similar issue but it was 2 years ago and the solution was never posted. this is using build 42.
that probably means your file isn't loading in the first place
I also have a profession mod which I updated for 42.13. Works fine in single player.
I just checked it in mp and have the same problem as you. Doesn't work for me in mp. New Professions are not shown in the UI.
thanks, i'll try to look into it on my own to see if i can find the issue before asking again.
Ah! I solved it! All I need to do is to add a server folder to my mod's lua folder! Maybe you should try it!
interesting, that’s strange
i’ll give it a shot
i do remember someone mentioned their mods unless they added the client folder, so i could see this happening
Maybe you need a server and possibly a client folder for the game to somehow recognize the mod for mp? Don't know. But just adding an empty server folder did it for me. Btw I also have a (non-empty) client folder. So better you give your mod a client folder too, even if it is empty.
i also do already have a non-empty client folder
I wonder what that folder does? I don't have server folders in mine but they show up in MP.
Is there someway to disallow clothing items added by default for a specific occupation?
unfortunately, mine still do not seem to appear
wait... I'll test again to be 100% sure...
it's possible i have other underlying issues because i've been struggling to get other mods that should work to run
Hello! I'm trying to get this code to work in B42MP (on a dedicated server).
Using debug messages, I see that swf.FatigueVar and swf.EnduranceVar are changing correctly, but after waking up, they return to their initial values.
Apparently, there's something I don't understand about player:getStats():set(CharacterStat.
Do I miss something? I would appreciate any help.
I guess I could recreate the clothingselectiondefinitions file but that's a long work around.
I just tested again. Works for me. I am on 42.13.1 and use the "host" button to test mp.
same here
of course that would screw default clothing for every other modding profession...crap
what operating system are you using? i wouldn't expect it to make such a large difference but i've experienced linux-specific issues in the past
so it's not out of the question
I also have a mod doing this and I used exactly this method: deleting them form the ClothingSelectionDefinitions. Not so much work though. You just have to iterate this nested table which can be a little hairy at the first but is really not much coding.
Are you guys adding them locally? Not from the workshop?
Oh, is it like a matter of doing table.remove or something?
I am on Linux too, Mint! Altogether, mutliplayer isn't great for me since my game sometimes crashs or "loose contact to server" when I try to host. But it still works sometimes which is enough for first tests and loading and starting mods works fine.
Are you sure you enabled the mod correctly? When in the MP mod menu, you select then mod, and then press "next" to go to the mp sandbox menu and then press "save"? It is necessary to it this way cause otherwise the mod is not enabled.
I test locally from my Zomboids/mod folder.
I think I did but I'll do some sanity checks
Oh, don't mind me then lol. Maybe that file is the key then. Mine were already on the workshop. I updated them for 42.13. Then downloaded them from the workshop to test in MP so the set up is different.
Is there anything useful for you here? https://pzwiki.net/wiki/Mod_structure#Common_and_versioning_folders
Yes, using table.remove appropriately. Iterating the table and doing it this way allows you to really only delete items you want and not overwriting the whole table. If you overwrite, any other mod modifying this table will be incompatible with yours.
Sounds good. I will do that.
Thanksk
I have another question. I suppose I could test this but if you know off the top of your head...How can I remove a trait from a mod without interfering with ongoing saved games. Would removing it's registry entry be sufficient?
when you search through the table, make sure to test whethe each field exists before you use the delete command. For example, when you would like to delete some specific pants item,
-- delete stuff from myTable["Female"]["default"]["Pants"]
end```
pseudo code but I guess you know what I mean 😉
yep i did exactly that, still doesn't work
i'll do more testing later
So, I'm not sure if I can remove a trait from my mod without screwing on going saves
Movespeed delta can't be touched by Lua anymore in 42????
Not sure if simply deleting the registry is safe for save game although I guess so cause otherwise, it would pbbly be impossible for player's to remove a trait mod from an existing game.
oh wait Iam confused XD
you tested removing clothing or traits now?
XD
I just tried and the game won't launch. Before 42.13 just commenting the trait out worked. It was still available in game but couldn't be selected in trait selects.
I tested remove traits
Oh wait. I think I might know
IsProfessionTrait = true, in the scripts file
removes from trait select but remains in saved game where it was selected
yeah. this makes the trait not selectable in the trait selection menu anymore. good trick!
to remove it from an existing game on a player, try player:getCharacterTraits():remove(yourTrait)
Oh, I don't want to remove it from the player. I think that would make people mad. I have a traits mod and I dont' really like it anymore. Some traits should be occupations but I didn't know how to do occupations at the time
So, I'm trying to give it a makeover without breaking peoples games
then using the IsProfessionTrait = true trick seems to be a good idea!
In multiplayer B42, can we still use the ModData.get("myUniqueKey") to permanently store data on the server?
Also in B42 multiplayer, is there some kind of unique player ID which is always assigend to the same player even when logging out and logging in again? (Guess there is such a thing but I am wondering how to access it...)
EDIT: ModData.get() doesn't seem to work for me. It has some functionality but data seem to get lost when server is shut down (i.e. leave game as host playing via "host" button). Not sure if my testing is though...
Thanks for the response,
I did debug prints with my original code, to verify the changes to the code.
The original getUsedDelta() is associated with the remaining value of the item. It would show something like 0.900000000346, for example.
I would then round/truncate a copy of that value to 0.900 before adding delta of 0.002 , to hopefully remove any decimal errors and keep it clean.
This was also verified with another print, showing 0.902, 0.904, etc, as I added additional value to the variable I used to then set the setUsedDelta() of the item.
But upon immediately retrieving the value from the item with getUsedDelta(), it would again show odd decimal issues, such as 0.904000000362, or similar.
This didn't seem to affect how it worked in game, as it would show the value in the item editor, and the remaining uses seemed to be correct as well.
But the weird issue, is upon leaving the area, either through running far, fast traveling, or teleporting, and then coming back into the area, the item would not maintain the set value of useDelta at all. It would either reset to the full amount, be an arbitrary amount far higher/lower than set before, or if the item was set to full amount before leaving the area, it would have a missing remained, for instance 498/500 instead of 500/500 as it should have been.
I am not sure what's causing that weird anomaly, or if I am missing some code that needs to be run to sync the changes with the server, or if it's an error in my code. As far as I can tell, things seem to be similar to others who have mods/items that adjust the useDelta of an item.
Any ideas? Been throwing things at the wall and not much is sticking on this one. I'm sure someone has had an issue like this spring up before.
Does anyone have an example of how to do trait swap in 42.13?
Something like - if player:HasTrait("Graceful2") then
player:getTraits():remove("Graceful2");
player:getTraits():add("Graceful");
But don't know how to do on character intialization
if player:hasTrait(traitPair.swap) then
playerTraits:remove(traitPair.swap)
playerTraits:add(traitPair.with)
end```
This works me for in single player 42.13 and 42.13.1. Put this code in the client folder and add it to the OnNewGame event. Won't work on multiplayer though.
Oh... and it may not work for all traits. For example, for me it does behave strange for the outofshape trait (but that was already an issue back in B41).
EDIT: corrected code! (forgot to say what "playerTraits" is)
I'm going to try Events.OnCreatePlayer to see if that'll work
anyone know what sendObjectModData(IsoObject o) from the GameServer does?
you can do it on the server with OnCreateLivingCharacter if you check to make sure the character is an IsoPlayer but ive not been able to figure out a way to check if the player is new since that event fires whenever you load a save as well
player:getSurvivedHours() == 0 didnt work when i tried that
couldn't you try to send a command from the client to server when client triggers OnNewGame event, catch the event on server and then do the trait swap on server? this would ensure that the player is indeed new
I had it working in 42 previously but the code was given to me.
Must say that I never tried but I just thought that this would work in theory...
It was something like this - NewProfession = {}
NewProfession.DoNewCharacterInitializations = function(playernum, character)
local player = getSpecificPlayer(playernum);
local inventory = player:getInventory();
if player:HasTrait("Brave2") then
player:getTraits():remove("Brave2");
player:getTraits():add("Brave");
end
end
Events.OnCreatePlayer.Add(NewProfession.DoNewCharacterInitializations);
Don't know if it'll work in 42.13 though
I think if you check whether the player has the trait, then this might also be safe cause when player loads the game, the trait is already gone and nothing wrong could happen
ah, in 42.13 you have to use player:getCharacterTraits(). and hasTrait() with lower case "h" now!
again, see here: #mod_development message
Okay, thanks. I think I understand. Not really a coder lol, I'll try it
ah... also: you have to use those new trait identifiers! just using strings like "Brave2" won't work anymore! read the migration guide here: https://theindiestone.com/forums/index.php?/topic/88499-modding-migration-guide-4213
A guide for mod authors on how to update your mods to the new identifier and registry system introduced in version 42.13. Migration Guide.pdf testmod_registries.zip Project Zomboid_ API for Inventory Items.pdf
Thanks, I'll look at them.
Is there a known limitation with the communication via sendClientCommand and similar commands on Linux or is this supposed to work?
this is supposed to work
Having issues with it and I am on Linux Mint. So here is a minimal example. Maybe some people here see what I am doing wrong:
my code in client folder:
sendClientCommand(player, "rasBodyMod", "myKey", {})
print("TEST_OUTPUT_CLIENT onNewGame ")
end
Events.OnNewGame.Add(mainInitFunction)```
my code in server folder:
```local function onTest(mod, command, player, args)
print("TEST_OUTPUT_SERVER1")
print("mod ", mod)
print("command ", command)
if mod == "rasBodyMod" and command == "myKey" then
print("TEST_OUTPUT_SERVER2")
end
end
Events.OnClientCommand.Add(onTest)```
In coop-console, the only output with the "TEST_OUTPUT" tag I get is this:
```LOG : Lua f:7, t:1766120969859, st:1,904,823> TEST_OUTPUT_SERVER1
LOG : Lua f:7, t:1766120969859, st:1,904,823> mod ISLogSystem
LOG : Lua f:7, t:1766120969859, st:1,904,823> command writeLog
LOG : Lua f:7, t:1766120969859, st:1,904,823> TEST_OUTPUT_SERVER1
LOG : Lua f:7, t:1766120969859, st:1,904,823> mod ISLogSystem
LOG : Lua f:7, t:1766120969859, st:1,904,823> command writeLog```
So my data seem to be not transmitted.
The client code seems to be completed fine though.
Is there a special folder structure I need in my server folder or something?
OnNewGame is too early to send a client command
due to what is likely a bug you cannot send client commands until the second game tick
Ok many thanks! Good to know (and would have been impossible to find out by myself! XD). Then I'll try again!
Anyone have good free sound effect websites?
https://pixabay.com/sound-effects/
heya, i've never made a mod before, but I want to change all the radio and TV texts to a custom message. is this an easy task?
Yes and no 😅
It's not very technical to achieve but it can be very annoying to do
is there a form or something i can go to?
A little annoying that they just removed it 
It's not a problem
Just a different system
And a better one overall
disagree, dynamically being able to control what loads was nice
https://pzwiki.net/wiki/Creating_dynamic_radio_channels
you can try looking here to start
I do like the script system do not get me wrong, but is kinda hard to change, like say if X mod is enabled do not allow trait
I guess you could register traits if mod is active?
Whereabouts are the flags stored, specifically the hanging US flag and the 3-tile wide US flag?
I can't find them anywhere.
the item? or the tile?
The item, I found the tile. Honestly sorta lost, I'm brand new to all this and I just wanted to make another.
Figured it'd be easy as copy-pasting a few things and directing it to a different texture?
I just love when translation and images do not work despite me following the exact guide 
UIName = UI_trait_addictol:resitant,
UI_trait_resitant = "Resitant",
I call bull
Whats the new format for character:getBodyDamage():setWetness(...) ?
I agree, idk yet if they added tools, just in general the registries systems seems good
oh yeah 100%, registries are way way better
its just managing them is the issue
all I know is they completely scewed translation keys and Texture paths X-X
Yea we'll have to see how that evolves but you can just access the registry in any lua file
Did you follow the guide on the wiki ?
I can not even get any translations or images to work 😭
yep to a T
I even tested different things
not one thing worked
Uh I'd need more context I think
@bronze yoke had you managed to make icons and translation work for traits ?
the translation thing is very much annoying me the most, I could care less about icons
cause sandbox translation works just fine
UI_EN = {
UI_trait_resitant = "Resitant",
UI_trait_resitantdesc = "Resitant test",
}
module addictol {
character_trait_definition addictol:resitant {
CharacterTrait = addictol:resitant,
UIName = UI_trait_addictol:resitant,
UIDescription = UI_addictol:resitantdesc,
Cost = 4,
IsProfessionTrait = false,
DisabledInMultiplayer = false,
Texture = media/ui/Traits/trait_addictol:trait_test.png,
}
}
as soon as I try translation here nothing
desc doesnt contain trait cause I wanted to see if one would translate over the other
Unless I am misunderstanding something
and this made following the wiki to
and i mean images are in the irght place
Addictol\42.13\media\ui\Traits\trait_test.png
I mean your mistake is a bit obvious I feel like
Your translation should have addictol: if I had to guess
As for the icon you named it trait_test.png but in the script it's trait_addictol:trait_test.png ?
tried that to
unless I made a typo
...
istg
yeah no
as for trait that is straight from the wiki
I tried a normal path
still nothin
module addictol {
character_trait_definition addictol:resitant {
CharacterTrait = addictol:resitant,
UIName = UI_trait_addictol:resitant,
UIDescription = UI_addictol:resitantdesc,
Cost = 4,
IsProfessionTrait = false,
DisabledInMultiplayer = false,
Texture = media/ui/Traits/trait_test.png,
}
}
like this doesnt work either
UI_EN = {
UI_trait_addictol_resitant = "Resitant",
UI_trait_addictol_resitantdesc = "Resitant test",
}
from my testing
it is treating UIName UIDescription as just a plane string, it doesnt seem to point to any translation
the value given to UIName needs to match a key in UI_EN exactly
I tried that
but as soon as you say it, it suddenly works >:(
as for icon idk still
wiki s not very much help X-X
I am gonna test with a diff image and see
yeah nope
they must of changed something
cause I never had this issue before
try only having "Texture = trait_test,"
lemme test that,
ON A UNRELATED NOTE, I was like "wait a minute that name is familiar"
also nope
doesnt work
I have been beating my head at this problem for like 5 hours
not matter what I try I can not seem to get icons to load
yeah, thats very odd - cause i made a quick custom trait, and it worked for me
hm
I have a idea lemme test it
you made a registries.lua file as well right?
ye
its not like it isnt showing up
Addictol\common\media\ui\Traits\trait_drinker.png
unless my path is incorrect (I changed the text to trait_drinker)
unless I need it to be in 42.13's file instead of common
hmm, its worth trying
maybe its a 43.13 bug?
I verified my file integrity and I am going to try with a different icon and see if that helps
im on 42.13.1 and its working for me, so this is very odd
it even works with a 64x64 icon (tho its a bit big)
module addictol {
character_trait_definition addictol:resitant {
CharacterTrait = addictol:resitant,
UIName = UI_trait_addictol_resitant,
UIDescription = UI_trait_addictol_resitantdesc,
Cost = 4,
IsProfessionTrait = false,
DisabledInMultiplayer = false,
Texture = media/ui/Traits/trait_resist.png,
}
}
Zomboid\mods\Addictol\common\media\ui\Traits\trait_resist.png
I tried the media thing again
not even doing Texture = trait_resist, seems to work
https://github.com/thekingofspace/Addictol
I rq made a git of it
Contribute to thekingofspace/Addictol development by creating an account on GitHub.
maybe you may find something
cause I am frankly stumped
gonna take a look, cause it should be working
Istg if its something stupid I overlooked I will lose my mind
I swear working with discords API was easier then zomboid 😭
and I had to reinvent several systems since the language I was using didnt have them
Being that damage is now being handled serverside, is it a fair assumption that things like player stats such as fatigue are as well? I'm reading up on sendClientCommand right now just in case.
I am asking because I am updating Sleep With Friends. Up until now, it was purely client-side. When I wake up, my Fatigue resets to where it would in vanilla.
I can confirm actually they are handled serverside!
I was testing getting players drunk killing zombies
and updating intoxication server side also replicated to client
ooooooh! That sounds fun!
but am I on the right track? Do we edit through sendClientCommand?
it was hysterical, the worst negative trait I could cook up
nah you can just set stat on server and it seems to replicate over
unless I am misunderstanding
And it was so funny, because the more zombies you killed the harder it would get to kill them
the functions I have written fire client-side, now calling player:getStats():set(CharacterStat.FATIGUE, math.max(0, modData.swfFatigue) ) so that it works with b42.13
but now that it works server-side (always should have lol) I need to learn how to change this
wait how are you accessing math 
I a little newbie at zomboid modding not lua just zomboid
math wouldnt work for me
idk it just ahs always worked for me tbh
do you have to require math?
no
cause for me it throws a error when I try to use math.max
hmmmmm I am newer to lua, this is the only mod I have made for PZ as well
I may of made a type considering honestly
used to JS/TS and Python so its all syntax at the end of the day
no switch-case kills me ngl
I mean there kinda are
even bash has it
make a aray with key value pairs, value being your function
but but but before I lose it. How are we updating player stats now on the server???
then once done table.clear and nil the vallue
just player:getStats():set(CharacterStat.FATIGUE, math.max(0, modData.swfFatigue) ) works
@tacit plover you uncover anything btw?
but now I have to keep track of each player individually ugh
You see I am decently well known roblox programmer so I am VERY used to having server have controlling over stats
it makes complete sense, but I am lazy and didnt think this mod would have needed to exist still
I thought the devs would have solved the lack of good fatigue handling in MP, but they never did
but I am not here to complain, only to solve the issue.
So perhaps what is my best move here? loop through all players and check if asleep, carry on as usual per player?
sleepticks are not evenly spaced btw, if anyone is wondering. You will get anywhere from 3-5 sleepticks per minutetick
Hmm unsure I’d have to run some tests but perhaps that is your best bet
ok im getting excited. I think i was just a bit frazzledd earlier because Im also trying to make my own server management tool purely in bash which i am very new at 
thank you very much for the info @haughty bridge
I just need to solve this trait icon issue 
yeah, im not sure why its not showing
its 1:1 to the ones i did, but it still doesnt show
Did work on your end?
Cause if it’s just me, I don’t care
its not working, but now i wanna know the reason
ill keep tweaking it, if i find a fix ill ping ya
Thanks I really hate riding on someone else fixing it 
I am out of ideas of what the hell could be wrong
Unrelated note that it currently says “resitant” instead of resistant, if that wasn't already noticed
….
Fuck
Unfortunately no clue what the issue is at a quick glance though
Idt that would cause it because it's consistently misspelled, just pointing that out
I am not known for my spelling LOL
Every single variable I have ever written probably has a typo
And also is some crude term that makes no sense
just ignore the amount of variables that are just 3 letters
For my discord bot wrapper the cached heartbeat value is labeled RST I don’t know why
I just did it that way
I have no way to confirm nor deny this, but I imagine that anyone who's done any amount of programming has had the thought “if it works, it works” much more than anyone who hasn't
(that said, clear variable names are a nice habit for future reading lol)
Obviously
For my open source libraries I use clear names
Anything where it’s just me working on it I just have a notepad of what every variable is
Which is bad, but it also helps because it means I can reference what exactly it is without having to find the original script
I can say for a certain, though my code has no memory leaks
That I can confirm
Readability? Who needs that
I highly highly doubt this is the case BUT
could it be because I have an constructor inside of my registries
That’s where I stored the addiction object
im not sure, cause the only issue is with the icon
That’s what I was thinking too, but it’s the only thing I did differently than other mods
I think it’s a little funny how my mod is one to one and manages to fuck up
The very fact that I created it is breaking things
Somebody take away my keyboard now before my mods begin to delete the Internet
thats part of modding 
and its also very easy to break zomboid
A game… made in Java… breaking…. No way really
Hi folks, very dumb question, I'm trying to get started on modling and on 42.12 legacy version via Workshop -> Create and update items -> then I tried to load the sample mod yet it says missing mod.info
is this expected?
Do you have a mod.info file? If so, in which folder is it located?
I do see mod.info file under contents
The wiki should be up to date on mod structure
yeah I was looking at this mod structure, but even copy it to C:\Users\Administrator\Zomboid\mods doesn't solve the mod info missing error...
It's less to do with the containing folder and more to do with the internal structure, the organization of files into subfolders
Read this section, https://pzwiki.net/wiki/Mod_structure#Mod_folder
You need the folders indicated under b42
let me give it a try. thx!
I hope someone answered you in the meantime. I do not know. if you are testing in MP 42.13.x, then item changes are supposed to occure server side. check the pinned message for InventoryItem interface changes (Project Zomboid_ API for Inventory Items.pdf), I'm pretty sure there is something about drainable and a specific interface to make them work.
@frank elbow how many mod devs would I piss off I used halo text for debugging
thx for the hint, yet it shows an different error as there is no contents folders ( which there clearly is...) I'm working on the legacy 42.12 version
All errors appear over heads
I imagine most modders test their mods in isolation, so probably not many unless you're also producing the halo text when not in debug mode
The contents folder doesn't go within the mod; that's used to determine what's uploaded to the steam workshop
i.e., Contents is the top level folder, which contains mods, which contains subfolders for each mod you want to include on your workshop item (most workshop items just include 1 mod)
okay...sorry I still don't quite get it. so looking at the current file structure, how should I alter it so the mods can get loaded. do you have any github repo recommendations I can peek into the correct file structure? thx!
I don't know any GitHub repos off the top of my head, but the wiki has a tree structure just like that you can reference
The example on the wiki should be interpreted as having an implied Workshop/ModName at the top (i.e., it describes the subfolder structure within that folder)
so it should be like Workshop/Contents/mods/{MY_MOD} ?
Workshop/YourMod/Contents/mods/YourMod
The first YourMod is the workshop item, the second one is the mod
(they don't have to be the same thing, but for a workshop item with one mod it makes sense)
https://github.com/demiurgeQuantified/StarlitLibrary here's a repo example
just making sure I get it properly, (also I feel being dumb lol, thx for the patience Orz)
No need to feel dumb, it's your first time trying out PZ modding. It's entirely understandable to not get things at first
bravo, this one is so much clearer. I cloned it to the C:\Users\Administrator\Zomboid\Workshop folder and it loads
You can thank albion for that, I haven't updated my stuff to b42 yet myself (mp-focused, so was waiting on mp)
Me and saph came to a conclusion my mod is cursed
Nothing will get it to work
I broke it
Even though it’s perfect
Do I want to curse myself by also taking a look 😨
The thing is, it is 1:1 with a working mod
And yet it ain’t
I AM INEVITABLE
maybe it’s a sign I shouldn’t be making a mod about getting addicted to drugs
okay I've more questions now.... after the mod is created and can be loaded, how to you test it? I can't see it in the mods list...
do I need to subscribe the mod I uploaded to steam to test it?
sounds a bit dumb... like I should be able to test it locally first?
I hope you didn't upload that mod 😅 If you did, you should take it down—republishing others' mods without permission isn't allowed
But yes, if you just have it in the folder you should be able to see it in the list & test it
oh I didn't not upload that one haha
yeah...weird thing is I don't see is after the game is loaded
Are you certain that you copied the mod structure correctly?
looks good?
ahh I'm missing the common folder as the place holder...
Are you on mac ?
Missing common folder
It's a very recent guide and the whole system is new so it's to be expected
Ah I confused you with the other guy anyway lmao
Oof
hmm yeah the game loads the texture and then completely ignores it 😅
It’s not my fault man the wiki was incorrect 
the typo was definitely your fault and the first thing you should check 😅
:(
you are banned from JavaScript themed birthday party
Is this JavaScript guys? 🤓
anyone know if StatsDecrease from Sandbox also affects Endurance? Or is it just hunger, thirst and fatigue?
Unfortunately I haven't gotten a reply for my issue, though I'm sure someone has seen the problem before.
I'm actually using B41 for this on my dedicated server, but will be transitioning my mods over to B42 once it's a bit more stable with MP.
Just hunger, thirst and fatigue
what can i use for dialouge text?
Where can I label my trait icons to have it reflected in game now, in the scripts .txt file wont show me my icons but I can change the name description etc
What is currently the way to store something in player's mod data in multiplayer?
I've created a basic Java mod loader. It's very young but allows for hooking methods, adding fields, and registring arbitrary Lua methods. If anyone's interested, let me know.
Additionally, https://theindiestone.com/forums/index.php?/topic/88499-modding-migration-guide-4213/ appears to be deleted. Where do you obtain it from now?
A guide for mod authors on how to update your mods to the new identifier and registry system introduced in version 42.13. Migration Guide.pdf testmod_registries.zip Project Zomboid_ API for Inventory Items.pdf
guys i need to set an boolean on an isoplayer
how do without another global table to store it
Global data are usually not required for such a thing (although I don't know your exact setup and there might be exceptions). You can just use lua's module-require commands to keep everything local.
If you want the boolean to be savegame persistent, you should use the player's modData. This works fine in single player without doing anything special. It is pbbly also supposed to work in MP but you need some additional things for using modData correctly which I was not yet able to find out.
oh that sounds useful
thanks
me when my mod doesnt work (it felt like breaking)
its not called Add?
am i losing me mind
Can this be pinned? It's very useful
ok i dont understand this error
it says i tried to call nil in NPCEncounter.UpdateEncounter
tried to call nil means NPCEncounter exists and is a table but NPCEcounter.UpdateEncounter is nil
how tho
it works once
then stops??
keeps erroring afterwards
nvm doesnt work at all
it is defined tho
so still dont get it
a
your ide even points this out
oh, you don't have umbrella so it says that on everything 😅
ye dont have
lua internal bullshit
technically only java functions are functions and lua functions are actually closures
the error is from getTime not UpdateEncounter
that page also shows it being defined a couple lines earlier
oh
💀
goofy ahh mistake taking up 40 mins
turns out that function doesnt work in singleplayer anyway
so im cooked
it definitely works in singleplayer, i wrote that snippet and only tested it in singleplayer
don't remember if i wrote it in b41 or not, it was a while ago
Has anyone else problems on the steam workshop with the "sorry too many requests" message recently? I am wondering if this is somehow caused by playtesting multiplayer and constantly loggin in and out via the host button...
i made a python script to make zombie outfit modding easier that converts the guids in clothing.xml into item names so you can make changes and then convert back
https://github.com/LazySpongie/OutfitXMLConverter
Contribute to LazySpongie/OutfitXMLConverter development by creating an account on GitHub.
Anyone know the cleanest way to avoid the yellow underline for things like this?
List<String>::get returns type E
So I force the type to string since that is wrong
Thanks!
Whoa, a lot more visual assistance going on in emmylua
Good. I need it.
My code sucks. My code from 3 years ago sucks harder.
oh yeah, i should tell you the unnecessary-if inspections are often wrong and you should probably just ignore them
you can disable them by adding```json
"diagnostics": {
"disable": ["unnecessary-if"]
}
Thanks for the heads up
those are mostly caused by nil checking the results of java methods but we just don't have a reasonable way to tell if a java method can return nil or not so it's usually not annotated correctly
Is there a simple command to sync player's mod data between server and client? Or is it necessary to do it manually right now?
Previously (most) moddata synced itself I thought.
for me, that seems to be not the case in MP on 42.13...
Not sure about now, but I never saw any simple builtin way to do it, I just ended up writing a tiny client/server script for the outliers
What object owns the mod data? @small topaz
Oh, I guess players, based on the question
i didn't think player mod data ever synced but it's been coming up a lot lately so i guess it did...?
For me, it wasn't necessary to sync modData in B41 so I didn't try. Problem is that in MP B42, the player's modData on client side are not stored in a savegame persistent fashion (i.e. they get lost when logging out). However, on server side, player's modData seem to be savegame persistent but not synced with client side modData (at least according to my testings so far). So my idea to make modData savegame persistent is to (also) write them on on server side to the player's modData. One way to realize all this and to update my mod accordingly would be syncing the modData between server and client.
Sounds like I'll need to do this too
ohh right now i remember, it was synced between clients but not to the server
sorry to the people i've misinformed about that lately but it's not like it's relevant to b42 anyway
Sooo how DO you sync player mod data to the server now
But I am not 100% about all this. It is just what my testing suggests to me so far. So don't take everything for granted rn.
you don't, the server sets mod data
Wait what
the server should be considered the authority on all data now
God damn it I keep forgetting
yeah... that's also a possible solution: don't sync anything and when accessing modData on client side, always use a sendServerCommand and request them directly from server
i do think it's bad that it's not sent to clients, that should be reported as a bug imo
the clients should be able to read it, just not write it
Now the question is, do I push this off for later if they fix that or do I just do the hack now and fix it again later
i wouldn't rely on it being 'fixed' as we don't know if it would actually be considered a bug
but i think they would probably agree that it's an oversight
Yeah, I just don't know how long it would take, or if ever, and reorganizing everything is just annoying
I don't want to, but I have to lol
ofc, clients should be able to write too. but can also manually be done via sendCommands
clients probably should not be able to write or else it invites a lot of potential for exploits with anything that uses that mod data
it could be prompted by the client in some cases but the actual writing should be kept to the server so that it can be sanity checked
player:transmitModData() not work for sync?
i haven't tried it in b42, maybe some of the other people here have, but it did not work in b41
Ok, well now I'm definitely waiting
i checked the code because i remembered the specific reason it didn't work and it's been completely rewritten and it probably does work now
so someone should try that
wait i didnt even know that function existed wtf
in b41 it didn't work for players because it tried to look them up in the wrong object list, it doesn't do that anymore so it probably works now
I will check it now. If it will works, I will send example here
I don't mean "should be able to write arbitrary stuff to modData". But if something specific happens on client side, it might be necessary to change smth about the player's mod data on server side. And from my pov, the natural and ppbly only way of doing this would be sending a command from client->server and then let the server adjust the modData accordingly. That's what I meant.
sync modData works! 
Usage:
Right Mouse Click on any world object (for example, floor) -> Option "SyncModData"
client code:
local function printClient(playerObj)
local data = playerObj:getModData()
print("Player ModData:")
for k, v in pairs(data) do
print(k, " = ", v)
end
end
local function printServer(playerObj)
local args = { id = playerObj:getOnlineID() }
sendClientCommand(playerObj, 'player', 'printPlayerModData', args)
print("You can check player ModData in server logs")
end
local function addData(playerObj)
local key = ZombRand(100000)
local value = ZombRand(100000)
playerObj:getModData()[tostring(key)] = value
print("Value added")
end
local function syncData(playerObj)
playerObj:transmitModData()
print("ModData sync done")
end
local function OnFillWorldObjectContextMenu(player, context, worldobjects, test)
local playerObj = getSpecificPlayer(player)
local subOption = context:addOption("SyncModData")
local syncMenu = ISContextMenu:getNew(context)
context:addSubMenu(subOption, syncMenu)
syncMenu:addOption("Show player ModData (Client)", playerObj, printClient)
syncMenu:addOption("Show player ModData (Server)", playerObj, printServer)
syncMenu:addOption("Add Random Data to ModData", playerObj, addData)
syncMenu:addOption("Sync ModData", playerObj, syncData)
end
Events.OnFillWorldObjectContextMenu.Add(OnFillWorldObjectContextMenu)
server code:
local ClientCommands = {}
local Commands = {}
Commands.player = {}
Commands.player.printPlayerModData = function(player, args)
local otherPlayer = getPlayerByOnlineID(args.id)
if otherPlayer then
local data = otherPlayer:getModData()
print("Player ModData:")
for k, v in pairs(data) do
print(k, " = ", v)
end
end
end
ClientCommands.OnClientCommand = function(module, command, player, args)
if Commands[module] and Commands[module][command] then
local argStr = ''
if args then
for k,v in pairs(args) do argStr = argStr..' '..k..'='..tostring(v) end
end
Commands[module][command](player, args)
end
end
Events.OnClientCommand.Add(ClientCommands.OnClientCommand)
playerObj:transmitModData() that called on server must work too
ty aiteron! 
if we can use transmitModData() on client side and thereby force the server to sync server modData with client modData, wouldn't this in theory also be a possible source of cheating and exploits? Other way around wouldn't matter ofc. But maybe I just misunderstand (and ofc, for us modders this provides an easy way of doing stuff).
But on the other side: A possible cheater could in theory always add some weird "send-to-server-commands" to their client code and manipulate the game thereby to a certain degree (depending on how the handler functions on the server are written). Only thing is that by having this option to sync all mod data at once by just a single command, they maybe even more felxible for cheating the game....
so it's basically the problem albion already suggested above if I get things right: by using transmitModData() on client-side, the client has basically unrestricted possibilities to write stuff to modData
@bronze yoke
Sorry to keep bugging you, just a weird question. No worries if you don't know.
I somehow deleted the definition of InventoryItem while using emmylua?
Any idea how that happened so I can avoid it happening again?
Umbrella is in ~/Zomboid/Umbrella
The mod i'm working on is in ~/Zomboid/mods/EquipmentUI/42.13/media/lua/ <-- This is where I have the VS Code project open
~/Zomboid/mods/EquipmentUI/42.13/media/lua/.emmyrc.json for config
I was working on stuff and at some point InventoryItem just became unrecognized.
I went to the Umbrella folder and git status was lit up for basically the entire thing.
git reset --hard got me fixed up, so no big deal. Just curious how I managed that.
Did I flub some weird key combo?
no, i have no idea how you could've done that by accident 😅 i'm not aware of anything like that
Lol, yea no clue what I did lol
Oh well
Figured out replication.
You can rename umbrella definitions.
Must've accidentally renamed the class while trying to rename a variable
😭
Why on earth would EmmyLua allow that
I have a quick question, how can i create like my own menu on the side bar, and have its own icon? So like the Health Menu when in game, but for my own? And is there something of style like a TextBox that exists where i can make it "read only" and just put anything into it whenever i want, more like whenever needed? Also, is there a possibilty of randomness, so like i want to list all the food items, randomly select one, and then give it to the player?
P.S. Its not really a quick question, i just wanted to do 2 birds 1 stone
This may be a little bit of a dumb question, are there any wiki articles on making library mods, like ones you can retrieve via require?
Any lua file can be loaded using require().
Generally all you need to do is declare a local obj, stuff all your functions inside it and return it at the end of the file.
i.e.
Well yeah but I mean requiring a workshop mod for example
Oh
So like say I make a lib that handles X task
How would other people be able to reference
2 layers to that
One you manually define on the workshop page
The other goes in mod.info
name=Inventory Tetris
id=INVENTORY_TETRIS
description=A full grid-based inventory overhaul for Project Zomboid.
require=\EQUIPMENT_UI
poster=poster.png
Tetris requires EQUIPMENT_UI
to make a lua file requirable you just need to return something at the end```lua
local myModule = {}
-- require("filename") will return this table
return myModule
all a mod requirement does is not let people enable the mod if that one isn't enabled, it doesn't do anything else
Well, I know all about requiring. I just didn’t know how to set it up so you can require a workshop mod for example.
from what i can find it looks like that sidebar ui is set up in lua/client/ISUI/ISEquippedItem.lua so it should definitely be possible to insert your own button in there
I am attempting to move a mod's logic server side. Does one just place the .lua files in media/lua/server instead of media/lua/client? Not even top-level print() seems to be coming up in the server-console.txt having done this.
if the top level print isn't working that's something else, but usually moving the files is not enough
I’m so used to psede that I keep trying to require stuff via @self or @psede
content of the mod aside (Im looping through the results of getOnlinePlayers()) I am struggling to figure out the missing piece. My declared functions fired no problem client-side. The functions are designed to run on EveryOneMinute. It is strange not even top level is hitting the log.
yeah that's really odd, everything you've mentioned should work on the server
it should be noted that files in the server folder do also run on the client, if you don't want this to happen you can start the file with a check like this:```lua
if isClient() then
return
end
how are you hosting the server?
in-game hosted servers log to coop-console.txt, not server console
steamcmd dedi
I will add this! I was unaware /server ran on both client and server. I assumed that's what /shared was for hahahaha
yeah, and /client *does* only run on the client so god knows what's going on here 😅
Can trasmit also include a key argument to transmit just that key/value? That way if a mod needs to sync its data it doesn't have to send the entire modData table?
In the past mods sending the entire table could hit a memory/data threshold
that helps part of the question, but i dont know for the food stuff.
its fine if you dont know how to, but i was just wondering
since id want to do that
the game ui is all lua code so you can definitely do all of that but the ui code takes a while to wrap your head around
for the food stuff you could probably loop through every item in the script manager and filter them by food items if you wanted to automatically grab every food item in the game or you can make your own list of items
Have a very specific question about visibility of clothing items worn by players in MP.
My setup: In client code, I equip a clothing item to the player. The item is not in player inventory and the player cannot interact with the clothing item, which is intentional since it only servers as some visual "sugar". This works fine for me when play-testing alone via the host button (also fine in single player).
Question: When other players are around, can they also see those "visual sugar" clothing items? Or is it necessary that I shift my code to the server to properly sync everything?
Just asking cause when play-testing alone, I cannot check how the system behaves if other players are around ofc.
other players arent able see it
Yeah figured that doing a loop was somewhat quicker
im gonna endup doing that
No, :transmitModData() send full copy of table. If need send only one key/value - better to use sendClientCommand, sendServerCommand
thanks for the info. (I guess you already know it from your character creation mod...?? 😉 )
Yes, Im asking if this can be changed 😄 - so sending just 1 key/value can be natively supported
yeah ive unfortunately had to spend the last week straight figuring out how all of the clothing syncing works lmao
you'll definitely want to test mp for your mod though by adding -nosteam to the launch options so you can open multiple clients
I'll now have to go through this topic too for my mod XD XD XD
and I don't want to XD XD XD
onclothingupdated only runs on each client so if you need to mess with any items in it you'll need to do a sendclientcommand in there
are we not able to modify player stats completely from the server, without any code running on the client?
even if it's triggered on server side?
I've made client/server commands to sync modData - but not everyone is comfortable using commands and I've seen multiple cases where a mod abuses transmit to the point of packets getting lost and the console spams 'cannot find X of null (isoPlayer)'
apparently when you trigger an event like that it only triggers it on the same side?
therefore I asked. but I misunderstood your previous remark, then. my bad.
singleplayer runs server code so it will trigger there but in mp the clients wont be affected by it from what i tested
in your case i think you'd have to just check if the item should be visible or hidden and then send the appropriate client command and it'll work fine
I think I won't change how JAVA transmitModData() works. But, maybe I will add some syntactic sugar for modders. Like:
playerObj:transmitModData() -- Java function call
playerObj:transmitModData("myCoolParam") -- sync ModData param by commands
Hmmm, but need check edge cases
When on server-side in MP, how do I get a list of all players currently in the game?
getOnlinePlayers()
This is exactly what I would suggest -- keep the original method, but allowing an optional specific 'check/replace for this key' would help newer modders out
Do the Events OnNewGame and OnGameStart have some server side equivalents? So, an event which is triggered on server when a player with a new character joins game or a player starts or loads/relogin to a game?
Or can I even use those commands in the "intentional" way directly on server? For example, OnNewGame is triggered on server when new player joins? (Wiki says "(client)" for this command but not sure if it is up to date)
If I want AI help should I ask gpt or Gemini to get more Relevant and updated assistance
Are comments on Steam mods broken for everyone, or am I being targetted for daring to open the comment sections of three mods at once?
yes
neither will give you relevant or updated assistance
OnCreateLivingCharacter but you need to check if the character is an isoplayer as well as not an isoanimal
it triggers on any player joining though even if they just came from character creation so i ended up just using the client functions and using sendclientcommand instead

