#mod_development

1 messages · Page 359 of 1

terse mason
#

Very valid. Lotta new stuff and things to find

fathom forum
terse mason
#

Sure. Which parts? I'm not an expert so I can't promise I can answer fully but I will try

fathom forum
#

what is playerObj meant to be?

#

it looks like they are adding items and perk levels to some player

#

perhaps for debug

terse mason
#

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

fathom forum
#

thank you for the resource
it doesnt have any description of what it is tho

#

ya its probably for testing

terse mason
#

These 2 are good for searching for official functions

fathom forum
#

thank you

terse mason
#

Otherwise, I just load the entire Project Zomboid folder into VSCode and search lol

fathom forum
#

thats a good idea

terse mason
#

Helps to have an IDE search for you instead of suffering through it manually lmao

fathom forum
#

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

terse mason
#

tagged by spiffo

#

Like, have a radio and use it to transmit to chat, or just command based?

fathom forum
#

like i want my players to tune into a station
and i can make the radio say stuff

terse mason
#

Mmm I see I see plumpabug

fathom forum
#

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

terse mason
#

Fair

#

I don't think that would be too difficult, at least the command part. Not sure about Radio part

fathom forum
#

media\lua\server\radio\ISDynamicRadio.lua

#

may hold the answer

stable hearth
#

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)...

terse mason
# fathom forum may hold the answer

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
terse mason
stable hearth
#

I can show you the output in my excel sheet. XD

terse mason
#

Ofc lmao

terse mason
#

Oh wow, looks pretty

stable hearth
#

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.\

terse mason
#

Not sure if you know, but does Reloading the Lua pull in the Distribution List again if it's been changed?

stable hearth
#

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.

terse mason
# fathom forum may hold the answer

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)

stable hearth
#

(Note: This was all very much vibe-coded.. I cannot take credit for it outside of conception and end execution)

terse mason
#

but very interesting anyways

stable hearth
#

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.

terse mason
#

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

wet sandal
#

Dev tools are awesome! Do it!

stable hearth
#

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.

sonic needle
#

ClipSize = #,

isnt this that?

small topaz
#

Is there a way to convert a CharacterTrait object to the corresponding CharacterTraitDefinition object?

wet sandal
#

@small topaz

#

The highlighted one is a Map<CharacterTrait, CharacterTraitDefinition>
Assuming its exposed to lua that should do it

small topaz
#

What is the syntax for using such a java map in lua? Can I just use
local traitDef = characterTraitDefinitions[MyRegsitry.MyTrait]
?

wet sandal
#

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

small topaz
#

ok thanks! I'll try that.

flint beacon
#

My local mods on my mod folder are not working with this latest update do I need to restructure the folder?

wet sandal
#

Moving from 41?

#

If so yes

flint beacon
#

No from 42 to 42.13

#

They just won’t work anymore like custom clothing

wet sandal
#

Ah, no folder structure changes im aware of

flint beacon
#

Weird

wet sandal
#

Not sure if the resolution he posted helps you

small topaz
flint beacon
#

They show up on the mod menu but won’t appear on character, was just wondering if I needed to change anything

small topaz
flint beacon
#

That must be it then

#

Thanks much appreciated 🙂

dull moss
stable hearth
dull moss
#

Yeah I know, I pinned it for myself

tranquil reef
#

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

pastel whale
#

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

fathom forum
#

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?

cyan tusk
#

Is there a mod that can record some activities in a log, activities such as activating god mode, activating invisible, spawning items? for b41

bright fog
bright fog
low solstice
#

I love how OnPlayerUpdate and getStats for Boredom will just give you values don't match the actual changes Sigh

peak furnace
#

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

verbal yew
#

fellas, is there any reason to put your files in folders other than scripts/
like scripts/generated etc?

bright fog
verbal yew
#

Like, is that OK?

bright fog
#

It's a question of organizing your mod files

verbal yew
#

thanks, king

bronze yoke
#

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

low solstice
tepid skiff
#

Does anyone know why, if I export an animation in Blender (even with no edits), my weapon and backpack bug like this please?

nimble badger
cunning kestrel
#

Do we know how "player:getMoodles():getMoodleLevel(MoodleType.Endurance)" changed in 42.13 ?? it stopped funtioning.

nimble badger
grizzled fable
#

are recipeGroup usable at this stage? i tried to use it but maybe i'm missing something 🙁

cunning kestrel
nimble badger
quasi holly
#

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

brittle swift
#

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```
bright fog
nimble badger
shy mantle
#

Did they replace getEndurance with getLastEndurance ?

bright fog
#

Maybe ?

#

Check the Java docs

grizzled fable
# bright fog What the hell are recipe groups ?

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

brittle swift
#

Yeah, it seems to be essentially a flag used to merge multiple recipes into one from the user's perspective in game

shy mantle
#

It was changed, that explains why it's not working then lol

shy mantle
#

I just pushed it aside as a later problem

bronze yoke
#

so now we have meta recipes and recipe groups 😅

grizzled fable
brittle swift
#

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. 😖

bright fog
#

It needs to be in the Base module

brittle swift
#

Oh it does? I guess I misunderstood how the modules worked & thought all of our custom content had to be inside of custom modules.

bronze yoke
#

it is good practice to do so, but it is not working as of the latest patch

brittle swift
#

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

bronze yoke
#

it will probably be hotfixed soon

shy mantle
#

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

bright fog
#

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

brittle swift
bright fog
#

np

brittle swift
#

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.

tranquil reef
#

Do items with Hidden = true appear always in debug mode

bright fog
bright fog
#

Due to a bug

tranquil reef
#

Wasn't sure if that was an intentional thing or if I just didn't do it right

bright fog
#

I think it shouldn't appear at all in the player inventory ?

tranquil reef
#

I use "Hidden = true;" exactly. Does true need to be capitalized or something

#

ah, I'm a dumbass

#

";" lol

bright fog
#

Yea why tf do you have that lol

small topaz
#

So the vanilla ISBuildAction is still in the client folder? How is this supposed to work in multiplayer?

bright fog
#

Idk, there's some timed actions that are still client sided somehow

small topaz
#

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....

bright fog
#

The transfer items timed action too I believe ?

brittle swift
# bright fog Recipes need to be in the module Base

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.

small topaz
#

Yes, ISInventoryTransferAction is also in client which is weird since it manipulates player inventory...

bronze yoke
#

that action has always been super weird so i'm not questioning it

arctic kayak
#

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... 😅

heavy stone
arctic kayak
bright fog
#

But to answer your question, I haven't heard of them saying they'll remove it tho I haven't heard the inverse either

arctic kayak
bright fog
#

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 😅

arctic kayak
bright fog
arctic kayak
queen oasis
#

I do wish they'd open up caps on SP

arctic kayak
mellow frigate
#

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 ?

true nova
#

why not just make some more item containers to pair with the vehicle?

bright fog
#

You have a massive ass truck and it's split into a hundred containers ?

#

Plus good luck managing that shit lmao

true nova
#

make it look like one

#

wouldnt work for one very heavy item

bright fog
#

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 😭

queen oasis
#

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

true nova
#

or just dont put the item in the container and store it in a table and count all the weight yourself 🤔

queen oasis
arctic kayak
#

Never managed to make it work even with AI helping me

drifting ore
#

*especially with AI ‘helping’ you

#

They don’t know hardly anything about Zomboid and end up doing more harm than help

arctic kayak
#

Yeah. It s*** a little bit. But it saved me years for syntax

drifting ore
#

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

arctic kayak
bright fog
#

So at the end of the day, you still need to manage to put your item in the container

nimble badger
true nova
#

is a lot of moddata though

#

if it was all containers

bright fog
drifting ore
#

Yeah I was going to say that could easily turn dangerous

bright fog
#

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

true nova
#

yea the things i was doing that with are specific items and are all vanilla that have limited data

bright fog
#

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

arctic kayak
# drifting ore Yeah I was going to say that could easily turn dangerous

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)

true nova
#

so 50 containers as one is best solution 🤔

arctic kayak
true nova
#

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

arctic kayak
#

To be realistic, it would have to scalled dynamically with the size of the container...

true nova
#

obviously i was just curious at how fast i could break the game

arctic kayak
#

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

small topaz
#

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)

arctic kayak
small topaz
#

good point! not sure if you need it everywhere but using it is a good idea...

arctic kayak
winter bolt
#

the gamemodes are sandbox presets so any modded sandbox options that arent listed in them will just be default

sly gazelle
#

so how to register traits in this new version?

bronze yoke
sly gazelle
#

thanks

gloomy ember
#

anyone know where i could modify the starter kit?

hybrid tiger
#

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

gloomy ember
#

you can change it in function SpawnItems.OnNewGame

hybrid tiger
small topaz
#

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" ?

hybrid tiger
#

Found SimKDT's videos going to watch and that should hopefully answer my questions, will ask if I need help later

severe jay
severe jay
small topaz
#

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
bleak grotto
#

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.

small topaz
bleak grotto
#

Where can I learn this?

bleak grotto
#

I didn't understand. Which folder should I put the mod I want to develop into?

small topaz
#

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

bleak grotto
#

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.

bright fog
#

Go back reading the mod structure page

magic nexus
#

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?

bleak grotto
magic nexus
# bright fog You mean in the script ?

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.

bleak grotto
#

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?

bright fog
#

Your mod.info file was just in the wrong place in.what you showed us

heady shoal
#

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¿?

sonic needle
sonic needle
#

is that a misspell?

heady shoal
#

where?

sonic needle
#

a , usually ENDS, in most cases, so its weird there are , and then ; after it

rich reef
#

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

sonic needle
heady shoal
#

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

heady shoal
sonic needle
#

i would look around for evidence to check, im unsure myself

magic nexus
#

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?

heady shoal
#

it has to be there right? if i delete it from that line the whole map will deissapear?

heady shoal
sonic needle
#

any advice i give at this point is 100% likely to be wrong, as its not somethin
g ive done

heady shoal
#

no but thanks to you i found out they can work indeed, now i have to find how to do it propertly!! THANKs

rich reef
bright fog
sonic needle
#

that tripped me up Instantly xD

heady shoal
#

if i copy players db to the new save files, will all players from server keep levels and everything? ty

mellow frigate
verbal yew
#

FELLAS! Please teach me how to work with interfaces, I really want to create my own little window((

peak furnace
#

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

peak furnace
#

looks something like this

thin swan
peak furnace
#

oh, thank you

verbal yew
#

srysli... all function OnCreate for recipe a javaside now?!

peak furnace
#

well they are function calls

verbal yew
# peak furnace 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...

peak furnace
#

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

verbal yew
peak furnace
#

very good

peak furnace
#

which, uh, doesn't exist. in my files. for some reason
that's odd

thin swan
peak furnace
#

ohhh, that's probably my mistake, i'm decompiling .12

#

i'll backdate

thin swan
peak furnace
#

got it, cheers

haughty bridge
#

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

raven epoch
#

i mean

#

if u get bitten thats one way to heal no?

smoky vine
#

im unable to view these, can anyone share the migration guide pdf please?

sonic needle
#

ye

smoky vine
#

thank uuu

sonic needle
#

these are the exact originals.

smoky vine
#

legend 😄

frank elbow
sonic needle
#

it took 0.1s to do that

clear perch
#

Hey is there a mod where my character could lose weight faster?

winter bolt
#

new function for moving bodylocations

wet sandal
# winter bolt 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.

winter bolt
wet sandal
#

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.

smoky vine
#

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?

verbal yew
knotty saffron
#

anyone managed to bypass the serverside container size?

smoky vine
frank elbow
#

Korean moved to UTF-8 on 42.13.1, hell yeah

#

Wonder if that was the cause of the garbling in 42.13.0

bronze yoke
#

do we know if they're all utf-8 now? there was only a couple exceptions left

grizzled fable
#

hi, where to see the changes to fluid system? in this last update something is broke in my mod 🙁

frank elbow
grizzled fable
#

do you know how they change recipecodes rules? it dosen't work anymore 🙁

bronze yoke
#

what do you mean?

#

i am not aware of any changes to how recipecode works since 42.0

grizzled fable
# bronze yoke what do you mean?

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

bronze yoke
#

what is on line 16?

verbal yew
#

-- 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

grizzled fable
grizzled fable
verbal yew
frank elbow
#

So it's odd that that was working before, given that

#

Which update was it working in?

grizzled fable
#

i just remove Recipe.?

#

maybe this class is no more?

frank elbow
#

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

grizzled fable
frank elbow
#

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

verbal yew
# grizzled fable this is old i think, it's how is done now

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

bronze yoke
#

it may have just been left in until now for compatibility or something, i don't think it was used

grizzled fable
#

ok ty

verbal yew
#

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

grizzled fable
#

yep gotcha ty 😉

noble yoke
#

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.

bronze yoke
#

the vanilla oncreates were replaced with java implementations for type safety reasons, no other changes were made

noble yoke
# noble yoke > OnCreate = I think this part doesn't work anymore. document said most of the O...

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

earnest mulch
#

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?

mortal wraith
#

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?

verbal yew
#

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.

earnest mulch
verbal yew
mortal wraith
#

solved tho

open drum
#

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?

winter bolt
#

are you spawning the item in the client or server?

winter bolt
#

spawning it in client wont work anymore so everything related to that has to be done on the server

open drum
#

the code runs in client folder .lua

#

bit confused on that

winter bolt
#

what does your mod need to do?

open drum
#

i have this UI

#

that when clicked on the item icon

#

spawn item

winter bolt
#

oh yeah in that case you need to make a clientcommand

open drum
#

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```
open drum
bright fog
#

Send a call to the server to spawn the item server side, and sync that to the client with the proper commands

winter bolt
#

1 sec im gonna make an example script

open drum
#

i see i see

earnest mulch
winter bolt
#

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 })
open drum
#

right?

winter bolt
#

yeah

#

make a new folder inside server with your mod name or something and then name it something like ClientCommands.lua

open drum
#

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?

winter bolt
#

it goes in the CheckMoney function in the clientcommands script

open drum
#

hmm i see

winter bolt
#

in the client you do sendClientCommand(getPlayer(), "YOURMODIDHERE", "CheckMoney", { item = itemHere })

open drum
#
local candle = instanceItem("Base.Candle")
self.character:getInventory():AddItem(candle);
sendAddItemToContainer(self.character:getInventory(), candle);
winter bolt
#

to tell the server to run the item code on its own end

open drum
#

so for example

#

that code snip

winter bolt
#

yeah that code should be in server

open drum
#

i see i see

winter bolt
#

sendAddItemToContainer syncs the item to the client

open drum
#

gotcha

#

so i don't need to use the sync command separately like the pdf says

#
self.generator:setActivated(self.activate)
self.generator:sync()```
winter bolt
#

thats for world objects i think

winter bolt
open drum
#

this is only for the object (tiles) in the map

#

gotcha

#

ill try it

#

thank you spongie

#

that was great help. clearing things out

winter bolt
#

i think all of this would be moved to server and then replace it in the client code with sendclientcommand

open drum
#

yea looks like it

#

gotta do lots of rework in the code XD

winter bolt
#

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

open drum
#

hmm goodo idea

finite scroll
#

my professions, while they work perfectly in singleplayer, do not appear in multiplayer. is there a common known cause for this?

frosty cypress
#

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.

bronze yoke
#

that probably means your file isn't loading in the first place

small topaz
frosty cypress
small topaz
finite scroll
#

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

small topaz
finite scroll
wintry tree
#

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?

finite scroll
small topaz
finite scroll
#

it's possible i have other underlying issues because i've been struggling to get other mods that should work to run

half pelican
#

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.

wintry tree
#

I guess I could recreate the clothingselectiondefinitions file but that's a long work around.

small topaz
wintry tree
#

of course that would screw default clothing for every other modding profession...crap

finite scroll
#

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

small topaz
wintry tree
#

Are you guys adding them locally? Not from the workshop?

wintry tree
small topaz
# finite scroll what operating system are you using? i wouldn't expect it to make such a large d...

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.

small topaz
finite scroll
wintry tree
#

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.

small topaz
wintry tree
#

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?

small topaz
# wintry tree Sounds good. I will do that.

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 😉
wintry tree
#

Imma just test it real quick

#

Test Complete: ...No

finite scroll
#

i'll do more testing later

wintry tree
#

So, I'm not sure if I can remove a trait from my mod without screwing on going saves

silk sigil
#

Movespeed delta can't be touched by Lua anymore in 42????

small topaz
#

oh wait Iam confused XD

#

you tested removing clothing or traits now?

#

XD

wintry tree
#

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

small topaz
#

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)

wintry tree
#

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

small topaz
#

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...

rich reef
# mellow frigate Hello, I do not know drainables enough to give you answers, I do not even know i...

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.

wintry tree
#

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

small topaz
# wintry tree 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)
wintry tree
#

I'm going to try Events.OnCreatePlayer to see if that'll work

small topaz
#

anyone know what sendObjectModData(IsoObject o) from the GameServer does?

winter bolt
#

player:getSurvivedHours() == 0 didnt work when i tried that

small topaz
#

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

winter bolt
#

yeah thats the easiest way

#

i had to do that in my mod

wintry tree
#

I had it working in 42 previously but the code was given to me.

small topaz
#

Must say that I never tried but I just thought that this would work in theory...

wintry tree
#

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

small topaz
#

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!

wintry tree
#

Okay, thanks. I think I understand. Not really a coder lol, I'll try it

small topaz
# wintry tree 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

wintry tree
#

Thanks, I'll look at them.

small topaz
#

Is there a known limitation with the communication via sendClientCommand and similar commands on Linux or is this supposed to work?

bronze yoke
#

this is supposed to work

small topaz
#

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?
bronze yoke
#

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

small topaz
#

Ok many thanks! Good to know (and would have been impossible to find out by myself! XD). Then I'll try again!

lusty kindle
#

Anyone have good free sound effect websites?

slate umbra
bright fog
#

It's not very technical to achieve but it can be very annoying to do

slate umbra
#

is there a form or something i can go to?

haughty bridge
bright fog
#

Just a different system

#

And a better one overall

haughty bridge
haughty bridge
#

I guess you could register traits if mod is active?

open fossil
#

Whereabouts are the flags stored, specifically the hanging US flag and the 3-tile wide US flag?

#

I can't find them anywhere.

open fossil
#

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?

haughty bridge
#

I just love when translation and images do not work despite me following the exact guide unhappy

#

UIName = UI_trait_addictol:resitant,
UI_trait_resitant = "Resitant",

I call bull

willow tulip
#

Whats the new format for character:getBodyDamage():setWetness(...) ?

bright fog
haughty bridge
#

its just managing them is the issue

#

all I know is they completely scewed translation keys and Texture paths X-X

bright fog
#

Yea we'll have to see how that evolves but you can just access the registry in any lua file

bright fog
haughty bridge
#

I even tested different things

#

not one thing worked

bright fog
#

Uh I'd need more context I think

#

@bronze yoke had you managed to make icons and translation work for traits ?

haughty bridge
#

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

bright fog
#

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 ?

haughty bridge
#

unless I made a typo

#

...

#

istg

#

yeah no

haughty bridge
#

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

bronze yoke
#

the value given to UIName needs to match a key in UI_EN exactly

haughty bridge
#

as for icon idk still

haughty bridge
#

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

tacit plover
haughty bridge
haughty bridge
#

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

tacit plover
haughty bridge
#

I have a idea lemme test it

tacit plover
#

you made a registries.lua file as well right?

haughty bridge
#

its not like it isnt showing up

haughty bridge
#

unless I need it to be in 42.13's file instead of common

tacit plover
haughty bridge
#

nada

#

I mean its 64,64

#

a png

#

and its not like the case sensitive is weird

haughty bridge
#

I verified my file integrity and I am going to try with a different icon and see if that helps

tacit plover
#

it even works with a 64x64 icon (tho its a bit big)

haughty bridge
#
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

haughty bridge
#

maybe you may find something

#

cause I am frankly stumped

tacit plover
#

gonna take a look, cause it should be working

haughty bridge
#

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

civic galleon
#

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.

haughty bridge
#

I was testing getting players drunk killing zombies

#

and updating intoxication server side also replicated to client

civic galleon
#

ooooooh! That sounds fun!

#

but am I on the right track? Do we edit through sendClientCommand?

haughty bridge
#

it was hysterical, the worst negative trait I could cook up

haughty bridge
#

unless I am misunderstanding

haughty bridge
civic galleon
#

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

haughty bridge
#

wait how are you accessing math ProphetHeh

#

I a little newbie at zomboid modding not lua just zomboid

#

math wouldnt work for me

civic galleon
#

idk it just ahs always worked for me tbh

haughty bridge
#

do you have to require math?

civic galleon
#

no

haughty bridge
#

cause for me it throws a error when I try to use math.max

civic galleon
#

hmmmmm I am newer to lua, this is the only mod I have made for PZ as well

haughty bridge
#

I may of made a type considering honestly

civic galleon
#

used to JS/TS and Python so its all syntax at the end of the day

haughty bridge
#

LOL

#

I am diehard luau

civic galleon
#

no switch-case kills me ngl

haughty bridge
civic galleon
#

even bash has it

haughty bridge
#

make a aray with key value pairs, value being your function

civic galleon
#

but but but before I lose it. How are we updating player stats now on the server???

haughty bridge
#

then once done table.clear and nil the vallue

haughty bridge
#

@tacit plover you uncover anything btw?

civic galleon
#

but now I have to keep track of each player individually ugh

haughty bridge
civic galleon
#

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

haughty bridge
civic galleon
#

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 drunk

#

thank you very much for the info @haughty bridge

haughty bridge
#

I just need to solve this trait icon issue crying

tacit plover
#

its 1:1 to the ones i did, but it still doesnt show

haughty bridge
#

Cause if it’s just me, I don’t care

tacit plover
#

its not working, but now i wanna know the reason

#

ill keep tweaking it, if i find a fix ill ping ya

haughty bridge
#

I am out of ideas of what the hell could be wrong

frank elbow
#

Unrelated note that it currently says “resitant” instead of resistant, if that wasn't already noticed

frank elbow
#

Unfortunately no clue what the issue is at a quick glance though

frank elbow
haughty bridge
#

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

frank elbow
#

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)

haughty bridge
#

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

haughty bridge
#

That’s where I stored the addiction object

tacit plover
haughty bridge
haughty bridge
#

The very fact that I created it is breaking things

#

Somebody take away my keyboard now before my mods begin to delete the Internet

tacit plover
tacit plover
#

and its also very easy to break zomboid

haughty bridge
unkempt rapids
#

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?

frank elbow
#

Do you have a mod.info file? If so, in which folder is it located?

unkempt rapids
#

I do see mod.info file under contents

frank elbow
#

Ah, that template is out of date for b42 (I missed that you said sample, whoops)

haughty bridge
#

The wiki should be up to date on mod structure

unkempt rapids
#

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...

frank elbow
#

It's less to do with the containing folder and more to do with the internal structure, the organization of files into subfolders

#

You need the folders indicated under b42

unkempt rapids
#

let me give it a try. thx!

mellow frigate
haughty bridge
#

@frank elbow how many mod devs would I piss off I used halo text for debugging

unkempt rapids
haughty bridge
#

All errors appear over heads

frank elbow
#

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

frank elbow
#

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)

unkempt rapids
frank elbow
#

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)

unkempt rapids
#

so it should be like Workshop/Contents/mods/{MY_MOD} ?

frank elbow
#

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)

unkempt rapids
#

just making sure I get it properly, (also I feel being dumb lol, thx for the patience Orz)

frank elbow
#

No need to feel dumb, it's your first time trying out PZ modding. It's entirely understandable to not get things at first

unkempt rapids
frank elbow
#

You can thank albion for that, I haven't updated my stuff to b42 yet myself (mp-focused, so was waiting on mp)

haughty bridge
#

Nothing will get it to work

#

I broke it

#

Even though it’s perfect

frank elbow
#

Do I want to curse myself by also taking a look 😨

haughty bridge
#

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

unkempt rapids
#

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?

frank elbow
#

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

unkempt rapids
unkempt rapids
frank elbow
#

Are you certain that you copied the mod structure correctly?

unkempt rapids
#

yeah...otherwise it shouldn't load in the workshop right?

unkempt rapids
#

ahh I'm missing the common folder as the place holder...

bright fog
bright fog
bright fog
haughty bridge
#

It was the dumbest reason

bright fog
bright fog
bronze yoke
#

hmm yeah the game loads the texture and then completely ignores it 😅

haughty bridge
bronze yoke
#

the typo was definitely your fault and the first thing you should check 😅

haughty bridge
tight elm
#

Is this JavaScript guys? 🤓

tulip valve
#

anyone know if StatsDecrease from Sandbox also affects Endurance? Or is it just hunger, thirst and fatigue?

rich reef
raven epoch
#

what can i use for dialouge text?

young trellis
#

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

small topaz
#

What is currently the way to store something in player's mod data in multiplayer?

sacred matrix
#

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.

raven epoch
#

guys i need to set an boolean on an isoplayer

#

how do without another global table to store it

small topaz
# raven epoch 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.

raven epoch
#

oh that sounds useful

#

thanks

#

me when my mod doesnt work (it felt like breaking)

#

its not called Add?

#

am i losing me mind

tulip valve
#

Can this be pinned? It's very useful

raven epoch
#

ok i dont understand this error

#

it says i tried to call nil in NPCEncounter.UpdateEncounter

bronze yoke
#

tried to call nil means NPCEncounter exists and is a table but NPCEcounter.UpdateEncounter is nil

raven epoch
#

how tho

#

it works once

#

then stops??

#

keeps erroring afterwards

#

nvm doesnt work at all

#

it is defined tho

#

so still dont get it

bronze yoke
#

oh

#

getTime() does not exist

raven epoch
#

a

bronze yoke
#

your ide even points this out

raven epoch
#

but it existed in

#

mod optimization page

bronze yoke
#

oh, you don't have umbrella so it says that on everything 😅

raven epoch
#

ye dont have

raven epoch
#

print function bla bla

#

what does closure mean

bronze yoke
#

lua internal bullshit

#

technically only java functions are functions and lua functions are actually closures

raven epoch
#

huh

#

still weird that it prints out in console yet it errors in script tho

bronze yoke
#

the error is from getTime not UpdateEncounter

raven epoch
#

isnt getTime real?

#

what should i use instead

bronze yoke
raven epoch
#

oh

#

💀

#

goofy ahh mistake taking up 40 mins

#

turns out that function doesnt work in singleplayer anyway

#

so im cooked

bronze yoke
#

it definitely works in singleplayer, i wrote that snippet and only tested it in singleplayer

raven epoch
#

keeps printing 0 on me

#

i am on b41 might be that

bronze yoke
#

don't remember if i wrote it in b41 or not, it was a while ago

raven epoch
#

yep keeps printing 0

#

ahh

#

mb

#

mb

#

fixed it

#

ty

small topaz
#

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...

bronze yoke
#

no it's just all the traffic from the winter sale

#

doesn't work for anybody

winter bolt
wet sandal
#

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

bronze yoke
#

switch to emmylua

#

luals has no support for generics

wet sandal
#

Got a link for Umbrella setup on emmylua?

#

I dont see the addon manager in commands

bronze yoke
wet sandal
#

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.

bronze yoke
#

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"]
}

wet sandal
#

Thanks for the heads up

bronze yoke
#

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

small topaz
#

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?

wet sandal
#

Previously (most) moddata synced itself I thought.

small topaz
#

for me, that seems to be not the case in MP on 42.13...

wet sandal
#

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

bronze yoke
#

i didn't think player mod data ever synced but it's been coming up a lot lately so i guess it did...?

small topaz
#

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.

wet sandal
#

Sounds like I'll need to do this too

bronze yoke
#

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

shy mantle
#

Sooo how DO you sync player mod data to the server now

small topaz
bronze yoke
shy mantle
#

Wait what

bronze yoke
#

the server should be considered the authority on all data now

shy mantle
#

God damn it I keep forgetting

small topaz
bronze yoke
#

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

shy mantle
#

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

bronze yoke
#

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

shy mantle
#

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

small topaz
#

ofc, clients should be able to write too. but can also manually be done via sendCommands

bronze yoke
#

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

tame mulch
bronze yoke
#

i haven't tried it in b42, maybe some of the other people here have, but it did not work in b41

shy mantle
#

Ok, well now I'm definitely waiting

bronze yoke
#

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

winter bolt
#

wait i didnt even know that function existed wtf

bronze yoke
#

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

tame mulch
small topaz
tame mulch
tame mulch
# tame mulch **Usage:** Right Mouse Click on any world object (for example, floor) -> Option ...

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)
tame mulch
# tame mulch **Usage:** Right Mouse Click on any world object (for example, floor) -> Option ...

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)
tame mulch
upbeat turtle
#

ty aiteron! uwu_cat

small topaz
#

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....

small topaz
#

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

wet sandal
#

@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?

bronze yoke
#

no, i have no idea how you could've done that by accident 😅 i'm not aware of anything like that

wet sandal
#

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

bronze yoke
#

😭

frank elbow
#

Why on earth would EmmyLua allow that

foggy finch
#

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

haughty bridge
#

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?

wet sandal
#

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.

haughty bridge
#

Well yeah but I mean requiring a workshop mod for example

wet sandal
#

Oh

haughty bridge
#

So like say I make a lib that handles X task

#

How would other people be able to reference

wet sandal
#

2 layers to that

#

One you manually define on the workshop page

#
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

bronze yoke
#

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

haughty bridge
winter bolt
civic galleon
#

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.

bronze yoke
#

if the top level print isn't working that's something else, but usually moving the files is not enough

haughty bridge
civic galleon
bronze yoke
#

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

civic galleon
civic galleon
bronze yoke
#

yeah, and /client *does* only run on the client so god knows what's going on here 😅

sour island
#

In the past mods sending the entire table could hit a memory/data threshold

foggy finch
#

its fine if you dont know how to, but i was just wondering

#

since id want to do that

winter bolt
#

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

small topaz
#

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.

winter bolt
foggy finch
#

im gonna endup doing that

tame mulch
small topaz
sour island
winter bolt
#

you'll definitely want to test mp for your mod though by adding -nosteam to the launch options so you can open multiple clients

small topaz
#

and I don't want to XD XD XD

winter bolt
#

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

civic galleon
#

are we not able to modify player stats completely from the server, without any code running on the client?

small topaz
sour island
#

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)'

winter bolt
small topaz
#

therefore I asked. but I misunderstood your previous remark, then. my bad.

winter bolt
#

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

tame mulch
#

Hmmm, but need check edge cases

small topaz
#

When on server-side in MP, how do I get a list of all players currently in the game?

sour island
small topaz
#

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)

silk sigil
#

If I want AI help should I ask gpt or Gemini to get more Relevant and updated assistance

silent zealot
#

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?

bronze yoke
#

yes

bronze yoke
winter bolt
#

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