#mod_development
1 messages ยท Page 79 of 1
this just refreshes the ui, if the item isn't being synced it won't help
I think you still need to do the other things
just in addition, need to mark the UI as dirty
So, in debug mode there is the context menu to delete an item on right click. If I check that, I see:
item:getContainer():removeItemOnServer(item);
end
item:getContainer():DoRemoveItem(item);```
seems like you could just do the same thing? this is all on the client btw, seems to sync it to the server. Found in `lua/client/DebugUIs/ISRemoveItemTool.lua`
but we're trying to sync from the server, not to the server, right? that method won't even run on the server
hmm, can I just send the item to the client and remove it on both?
@humble oriole
have you seen what ISA does yet?
you don't remove items from inventories from the server side do you?
you can actually pass inventoryitems as arguments in server commands, so it might be as simple as telling every client to delete it...? not sure what exactly the interactions are there
sendObjectChange("containers")
refreshes the container on clients
I really thought that was for sprites
use that on isoObject
there's a lot of valid changes
somebody should document them...
I hope it does what you want
Well, it removes everything from the inventory
and when I put something in, the first time gets replaced by the item I left in there
oh, if I refresh it it fixes it
hmm
looks like if I combine it with that inventory dirty variable it fixes it
thanks guys

local theTable = {}
theTable[1] = "Lua"
print(theTable[1])
local function Save()
local fileWriterObj = getFileWriter("file_theTable.json", true, false);
local json = Json.Encode(theTable)
fileWriterObj:write(json)
fileWriterObj:close()
end
Trying to use the tutorial from here: https://github.com/MrBounty/PZ-Mod---Doc/blob/main/Save data.md
I don't think I fully understand it. The file gets saved "file_theTable.json", but nothing is inside it. I thought the "theTable" was a lua table hence I wrote it like one, am I wrong?
did you add the json library and require the file?
Greetings, a question about trees. I don't quite understand how to place them.
For trees consisting of a single element, such as e_americanholly_1, I made a function based on BrushTool. I'm fine with them. But there are some trees that consist of two sprites - tree trunk and leaves. In the game they have the property "ATTACHED", but if put through BrushTool they will be separate. How to combine them?
I've been trying to add traits but I can't figure out why it isn't working
maybe it doesn't like the numerical key...? it seems really unlikely, that library is pretty fleshed out, but that's the only difference i can think of with my own usage of it
gonna try with a letter, gonna report back in a few mins
do you not get any errors?
never used this before
anyoneknows a vanilla function that checks howmany people are near the player
Gimme a sec still working it out, I think if I fix it now I'mma have to present myself as a big dumbass here in chat
or do i have to make own function
How many people, as in zombies, other players (mp), or both?
just players
Well. It works now. The issue wasn't the table or the script or anything really, aside from my dumbass. The issue was that my mods folder was wrong, the setup actually. First I didn't even notice there's a zomboid folder in C:\Zomboid, and one in C:Users\Zomboid so I had to fiddle with that a bit. 2nd thing I had to adjust how I put the mods folder into the mods folder of the server. My mistake was that I put it like the modtemplate inside, aka with the Contents and workshop thing all together, when in reality I just had to put in the "modfoldername/media, mod poster in
Thank yall for the help, led me to figuring it out ๐ฆ
Not sure of a function that returns that. But you could iterate over the current MP players, and use: player:DistTo(otherPlayer) <= range as a condition if a player is near you.
Looks really good. I will definitely be adding this to my bow collection
function plCount()
local player = getPlayer()
local cell = getPlayer():getCell()
local x, y, z = player:getX(), player:getY(), player:getZ()
local xx, yy, zz
local rad = 6
local square = cell:getGridSquare(x + xx, y + yy, z)
local plCounter = 0
for xx = -rad, rad do
for yy = -rad, rad do
for i=0, square:getMovingObjects():size()-1 do
local chr = square:getMovingObjects():get(i)
if instanceof(chr, "IsoGameCharacter") and player ~= chr then
plCounter = plCounter + 1
end
end
end
end
return plCounter
end
function HermitTrait()
if not getPlayer():HasTrait("Hermit") then return end
if plCount() > 0 then
local plPanicVar = 0.1
local plPanicMultiplier = plPanicVar * (plCount+1)
local plPanic = getPlayer():getStats():getPanic()
getPlayer():getStats():setPanic(plPanic+plPanicMultiplier)
end
end
Events.OnPlayerUpdate.Add(HermitTrait)
getSeeNearbyCharacterDistance()
is on the pz website but its not on the lua
It's in IsoPlayer.lua on line 707?
damn i think i have a problem with my files
i should verify
i cant find that file
Should be in media/lua/shared/Library/IsoPlayer.lua
this is a fatigue check
can i still use it for my purpose
i just need to get howmany player are around the player
and also isCanSee() applicable for other players too right
yeah, if you want to know your *view distance based on fatigue
for i=0, square:getMovingObjects():size()-1 do
local chr = square:getMovingObjects():get(i)
if instanceof(chr, "IsoGameCharacter") and player ~= chr and chr:isCanSee() then
plCounter = plCounter + 1
end
end
ahh ok then ill just stick with what i have then
this part
chr:isCanSee()
am i using it right
cuz im thinking it might be.. tho i highly doubt
player:isCanSee(chr)
not sure, but didn't you want all players?
i just need the ones around
cuz it should increase a panic multiplier as more people is around the person
i was thinking about this but the plaeyrs are moving
im thinking it will create alot of error if i do that
if not playerSq:isBlockedTo(checkSq) then
...check obj...
end
this would not count people behind walls for example
ok cool thnx
if instanceof(chr, "IsoGameCharacter") and player ~= chr
and player:getCurrentSquare():isBlockedTo(chr:getSquare()) then
plCounter = plCounter + 1
end
you can check that earlier, before getting square objects
Another way would be:
for i=0, onlineUsers:size()-1 do
local buddy = onlineUsers:get(i)
if player ~= buddy then
if player:DistTo(buddy) <= 1.0 then
-- Do things
end
end
end```
Can `break` out after a certain player count succeeds if that matters, and still check if they are blocked by their squares. would just need to play with the "range" a bit
THANK YOU
ow boy this is not ram heavy at all
compare to mine
it's because square is out of the loops, if you are wondering (xx would be nil)
ye i fixed that but i prefer to use dherts checker instead cuz its totally lighter on the ram load
and less prone to error
function plCount()
local player = getPlayer()
local socialDistance = 6
local plCounter = 0
local onlineUsers = getOnlinePlayers()
for i=0, onlineUsers:size()-1 do
local chr = onlineUsers:get(i)
if player ~= chr then
if player:DistTo(chr) <= socialDistance then
plCounter = plCounter + 1
end
end
end
return plCounter
end
if SandboxVars.MFTEOTWC.blindMode then
Events.OnInitGlobalModData.Add(function()
for i=1,#itemList do
local item = ScriptManager.instance:getItem(itemList[i])
if item then
item:DoParam("Name = " .. Unlabelled Cassette)
end
end
end```
anyone have a clear idea as to why this code doesn't work?
looks like theres something wrong with my math or the way im doing it
define doesn't work
also you use sandboxvars too early?
what do you mean by using sandboxvars too early? also it doesn't work in that it doesn't change the names of the items as it's meant to
it doesn't produce an error or anything, just seems to silently fail
you don't save plCount anywhere
*you use luaclosure + number
you want to check sandbox value inside that function, because prior they are default values
oh huh i do have that event in completely the wrong spot don't i
glanced right over that
also you might be missing one end
oh no i just left that one out of the copy that's my bad
Your 2nd param here is also missing its quotes:
item:DoParam("Name = " .. Unlabelled Cassette)
Could just be: item:DoParam("Name = Unlabelled Cassette")
If that's a var name there shouldn't be a space
The field is DisplayName not Name
item UnusableMetal
{
DisplayCategory = Junk,
Weight = 1,
Type = Normal,
DisplayName = Unusable Metal,
Icon = UnsableMetal,
WorldStaticModel = UnusableMetal,
}
OHHHHHH
i was about to post asking further because i fixed all the previously mentioned bugbears but THAT'S probably why it's just abjectly refusing to work
thank you blair!
Always check the vanilla code + scripts ๐
if i can get this to work then only one feature eludes me... figuring out how to get the game to accept sideways vinyls
hmm
vexingly it is still broken
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
here's the full lua file
which mod is this in, I don't see it
it's currently contained within a separate test mod, this lua file and the sandbox settings for it are the only things in the mod
got cha fixed it i just merged the function
damn 1000 tracks
I added this yesterday, which is why I tried finding the file.
yeah i'm just staring at this and can't for the life of me figure out why it's broken still
very frustrating
theres no event to check for what food you just ate or about to eat
does somebody know if it's possible to add a functional flashlight to a weapon without any of the external library mods?
I think I know the problem with the DisplayName but now my item list viewer crashes trying to sort the items
this was throwing errors as well, 2 edits
local function onFillContainer(_roomName, _containerType, container)
if #itemList == 0 then return end -- <<<<
local dummies = container:getAllType("Tsarcraft.BlankCassette") -- dummy item type
if dummies:size() == 0 then return end
for i = 0, dummies:size()-1 do
container:Remove(dummies:get(i))
end
for i = 0, ZombRand(1 * SandboxVars.MFTEOTWC.maxCassettes) do
local itemChoice = ZombRand(#itemList) + 1 --<<<<<
local item = container:AddItem(itemList[itemChoice])
container:addItemOnServer(item)
end
end
0 is when you have core only, might as well not add / remove the function
ZombRand returns 0 to # -1, lua indexes start from 1 so we add 1 to itemChoice
@rancid tendon
god i need to change my nickname in here. anyway: thank you for the help!
i didn't really account for anyone having core only because like, why would you only have core active anyhow
but i suppose it's good practice to account for it anyway
Am I right in assuming that sendservercommand and sendclientcommand is the only reasonable way to get items from another player?
I am trying to use them but they are hella confusing ๐คฃ
Lots of arguments in the brackets so trying to work out how to use both ๐
I think if I right click a player, that's the way to obtain his ID, then send that ID via a client command to server, use a server function to get his items and send those items back to the client that right clicked him
Yep, I think this is will work
Real quick, what is the server's role in all this? What can it obtain that the player himself cannot? The ID, the inventory contents?
As far as I'm reading this code I'm learning from, the server receives a message with the Player Object and then gets the ID from that, sends the ID to the client which then uses that ID to get the inventory contents
Kinda seems off, like the server should get the inventory contents itself and then send those to the client instead of the ID
Code is working btw, just confused irl ๐คฃ
Anything in lua/server (in workshop mod folder or main install folder) is only running on the server, so anything like that is part of its role.
@drifting ore, e.g., you cannot send commands to other clients directly from a client afaik. Gotta tell the server to send the signal.
When things are saved in the Users/User/Zomboid/Lua folder on my PC, does that mean when I put the mod on a server it will be saved on each clients PC as well or in the server files?
In general you don't put anything in Zomboid/Lua, you put them in Zomboid/mods/modName/media/lua/client, server, or shared.
No I mean I'm using Json to save files, and it saves the file in the Lua folder of Zomboid
By default
Or you put them in Zomboid/Workshop/modName/Content/mods/modName(again)/media/lua etc.
Ahhhhhh, that stuff is local afaik
Do you create the save file using a client file or a server file or a shared file?
If you have a mod that makes save files, the saves are generally local afaik. I don't know if any mods that create serverside save files. A client-saved file won't autotransfer to server. Server won't have access to file data unless it reads the file itself somehow. Not sure whether server has its own save files
Depends on your goal. Are you trying to save server configuration data?
Trying to save player inventory information and values as his name, lastname etc to a json file
So anyone (in this case admins) can access that file to read it from within the game
But if it's stored locally that doesn't work ig
Mmmmmm
I figured the Lua folder was a local folder on my PC that represented a folder in the server configuration if the server was hosted elsewhere
Well servers may have something equivalent for their save files... I just don't know. I would try a similar process in a server file and see if you can read and write things using the server with some simple tests
Just try to write a single line and read it and print it from the server. If that works, server can do that stuff.
Might need to send the command to print to the client, idk if printing in a server file will print to debug console when you're hosting or not.
Just be aware that some events only happen clientside so if something doesn't seem to run, you may have triggered it from the wrong context.
I wonder if mod data is available server side... If saving files lets you down, mod data might work. Haven't tried it
Yeah was just thinking about that
I remember others talking that mod data saves that stuff directly on the server in its mod config
I'm gonna spend some time researching that as well so I don't waste my time with Json if it's not possible to pull this off
So are you using a JSON library to access your JSON or what?
Yeah
Haha dang
I spent hours learning how to configure it too lmfao
I dunno if that's worth packing into a mod or not. I mean probably not as big as some of these music mods but still
Seems like a lot of extra space and I'm not sure if it will deliver much function beyond what you can already do with a lua table
Intuitively, if modData does work, it seems like the more efficient path in terms of lines of code written
does anyone have a guide for getting items to appear in your character's hands, specifically backpacks? i have everything else down, but the model itself just won't appear.
i've been following this one (https://theindiestone.com/forums/index.php?/topic/37647-the-one-stop-shop-for-3d-modeling-from-blender-to-zomboid/), but no luck.
Hello and Welcome! Here you will find a concise and comprehensive guide and tutorial of making 3D models for Project Zomboid. Currently, this will mainly pertain to custom Clothing creation but may include weapon creation in the future. This will present how to create models from scratch with Ble...
does anyone remember (approximately) when PZ stopped loading localisation strings on the server side for mods?
@sour island I take it Expanded Heli events still has broken AEBS strings?
this is not true
clients also execute code in server
player inventory is client sided
servers also have that lua directory so if the code is executed by it it its saved there
if clients run it itll go to the directory you said
Ha, damn, gotta restore that code lmao, luckily didn't get too far ahead anyway
Thanks for the info!
So a server side player database in the form of a json is possible if executed from a server lua?
if you want to prevent clients from running code in /server then at the top of the file put
if not isServer() then return end
if you write the file on the server then yes
Thank you, do you think you could elaborate for me how server command and client command works? I can't find much docs online. Like, when I get an ID from a player (still not even sure how to precisely get one with right click) and send it to the server
Do I run the scripts I want in the server luas?
again keep in mind player inventory is client sided so you have to ask each client to send over the info
Or do I send the ID and info I get from server back to client to run the luas
Ooooh
That explains a lot!
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
bringing this one up again since its been a few hours
anyone know why this code just flatly doesn't work? doesn't change names as it should and i haven't seen any related errors
if you want to see client/server communication and how to do uis you can look at https://github.com/Browser8/PZ-Server-Points
Thanks, will give it a read. Gotta work out how to get a player by right clicking somehow ๐คฃ
This game is elusive but I'm not gonna give up
got your back on that too gimme a sec to find where it is
DoParam simply ignores you and sets something else.
You can use setDisplayName("no label"), but then sorting items crashes, like when you open the items list.
Events.OnFillWorldObjectContextMenu.Add(function(player, context, worldObjects, test)
if test then return true end
local playerObj = getSpecificPlayer(player)
local clickedPlayer
print("Number of Objects: " .. #worldObjects)
for i, v in ipairs(worldObjects) do
local movingObjects = v:getSquare():getMovingObjects()
for i = 0, movingObjects:size() - 1 do
local o = movingObjects:get(i)
if instanceof(o, "IsoPlayer") then
clickedPlayer = o
break
end
end
end
if clickedPlayer then
if clickedPlayer ~= playerObj then
local option = context:addOption("View Bio", clickedPlayer, onBioMenu, false)
else
local option = context:addOption("Edit Bio", clickedPlayer, onBioMenu, true)
end
end
end)
local o = movingObjects:get(i) just a var
Aha
oh wonderful
dang, i thought this would be a fun little feature but it seems zomboid is intent on preventing me from implementing it
if you slightly change the name every ~100 items it should be fine
that'd be a lot of effort to put in for this particular niche feature, i think
... plus, something just occurred to me
this feature is predicated on the player finding items and renaming them to identify them, but this code would still run and probably revert those items back to unlabeled items even if it did work each time the world loads, huh
nah, if a player names something, it sticks
what do I need to get a trait working?
I've examined the vanilla files and some other mods
but I can't scratch my head around it
they would just not know if a new item is same as something they found before, so every new item would be unlabelled
Btw when you update your mod, like, save the code etc. Do you have the restart the entire dedicated server or is there an option to reload the lua code? I've seen something online like a command that resets the lua but not sure if that's possible
as is now, I have to restart the server every change and log in with 2 versions of PZ nosteam to debug
open admin chat and do
/reloadlua MyFile.lua
works on same machine without much effort
Nevermind this
not a good idea to reload code with events
Just tried this and it keeps saying unknown lua file ๐คฃ
does anybody know what the second false means for traits?
profession free trait?
cant a player apply mod data to another player
player modData is also local
Ow damn
I thought client runs clientside, server runs serverside, and shared runs on both... do you mean that you run code in server when you call server code from client? Or do server files actually load on the client?* I recall various people suggesting files in client do not even load on the server... Is that not the case? Or do clients load server files, but not vice versa?
I seeeee
But does server load client?
code is loaded in order to ensure equal checksums
clients don't execute server code though
Okaaaay so it's only true in one direction, got it
So, just to be 100% clear, servers may execute client code but not vice versa, and both client and server load each other's code.
no, don't think of it that way
haha okay
if you have code that needs to be referenced on either side, put it in shared
I understand that much, but I am curious about the technical meaning of the folders
the fact that code from an opposing side might be loaded and active in the lua state should not be relied upon
So is it the case that clients may execute server code, but generally don't execute server code?
they never really execute server code, a server function might exist within the Lua state of a client, but executing it is probably semantically meaningless, because the client isn't a server
I am unclear regarding whether code in server can be called from a client.
you shouldn't care
for the purposes of structuring your mod, you should consider code on the opposing side inaccessible
the game may change in future where such a split is fully enforced
and your shit will then break because you were being stupid and relied upon code from the other side being in your state
Okay, but I am also interested in things like the actual truth in comparison to convention
Perhaps I should not be
But I am ๐
well, the answer there is to go make a mod, declare a function unique to each side and call it ๐
if you want to examine existing behaviour, go test it.
lol fair enough I was only asking here because I thought someone might know.
No worries
if you look through the game files, and some mods, you'll notice that there is occasional use of isClient() or isServer() to cause/prevent defining functions and data
Been trying to get this to work in game but it doesn't seem to be possible, I referenced it as well to make my own but for the life of me cannot ๐ฆ
where can i find the trait stuff for obese in the files
like the fall damage
or the fence climbing
function instaKillCheck(wielder, character, handWeapon, damage)
if getPlayer() == character then
if handWeapon:getModData()['instaKiller'] == true then
getPlayer():getBodyDamage():setOverallBodyHealth(0)
print('yep '.. damage)
end
else
print('nope '.. damage)
end
end
Events.OnWeaponHitCharacter.Add(instaKillCheck)
anyone know why this isnt working
"isn't working"
does that mean it killed your cat? made your computer explode?
the two most useless words in computer programming: "isn't working"
describe what you observe.
Your mod broke my save, uninstalled and will not be clarifying
My response? 'ok ๐'
lol
Did I get pinged? I got an alert
"Please let me know who to make out the cheque for $0.00 to, thanks"
yes, it was me, I was asking if AEBS was still broken for expanded heli events
however, in that time, I got to the root of the problem and punted this out: https://steamcommunity.com/sharedfiles/filedetails/?id=2915954029
Check what the character actually is maybe? Maybe its just the id and not IsoPlayer?
Ah, I thought I fixed it -- not sure why it's breaking in some peoples runs. I guess SOS is related
I spun up a server and the strings still didn't localise for me with the latest release
Hmm
it'd be nicer if the game added a hook-point for incoming strings so you could localise client side. kinda sucks for people who play on language X servers but play with the game in language Y
(the strings do localise with the mod I put out)
it's a very simple Translator.loadFiles() call in OnGameBoot
Is the fix for sp only? I wonder what it would choose for localisation on a server
the opposite, it's for server only
if you're playing SP, there is nothing to fix
but, if you read the mod description, you would know that ๐
Ok
@cunning canyon if you find yourself a spare 5-10 minutes, you can sort out the localisation issue now with https://steamcommunity.com/sharedfiles/filedetails/?id=2915954029
clients run client server and shared
servers run server and shared
they do in fact execute it
yes, I later clarified the isClient() check
Hmm so that's what was going on
It wasn't an impactful bug so I didn't look into it yet - but it's frustrating when you can't easily replicate it
I wish there was a way to send people settings and saves
Or something... Printout of non vanilla settings
yeah, something like a minidump() you can call on server and client that generates a zip
I had a bug way back when that was caused because the notation for numbers in Spanish use a ,
I think for decimals? I forget the details lol
@fast galleon what you need?
Yeah my solution was just to replace , with . for it lol
It was already a hacky string extraction to number so I didn't bother with doing it "correctly"
Not sure, it was pretty early into EHE
And vector2 is scuffed for exposure as it's overwritten with a Lua file
wait, what?
The vanilla files includes a vector2 that overwrites the exposed class
I use vector3 for the math stuff I need -- just ignore the Z
really, I can't find it in media/lua
But vector3 doesn't have as many getters - hence I pull the info off a toString
the exposed class is Vector2, vanilla doesn't appear to overwrite the table
They may have removed it by now - but there was a global named vector2
a grep indicates they did indeed
Ah nice, I am planning to sit down with EHE -- so I can't maybe remove that ugly stuff with vector3
although, vector2 wouldn't overwrite it, table keys are case-sensitive
It was the same name I'm not sure about capitalization
Had 3-4 functions related to math stuff but otherwise useless
Vector3 print also says vector2
So I think the util stuff is just super old and not really looked at lol
This guy looks like he knows about it: https://theindiestone.com/forums/index.php?/topic/34409-issues-found-with-vector2vector3/
I appears Vector2 is meant to be exposed but it can't be utilized because of this lua file: `ProjectZomboid\media\lua\shared\Util\Vector2.lua' The lua file in question defines Vector2 (={}) and includes two functions which can't really be used and are already within the Vector2.class. So it is pr...

yeah, that file is gone now
Awesome
Hello! Trying to find within the code of AuthenticAnimations how to stop some emotes to loop
For example the "Facepalm" emote loops itself
I have found that there are 2 files per emote one in a folder "actions" and "emote"
What are the purpose of each?
Found this line x_extends="looped.xml" but when I delete it the emote is not starting
<?xml version="1.0" encoding="utf-8"?>
<animNode x_extends="looped.xml">
<m_Name>Cough</m_Name>
<m_AnimName>Bob_EmoteCough</m_AnimName>
<m_BlendTime>0.30</m_BlendTime>
<m_Conditions>
<m_StringValue>Cough</m_StringValue>
</m_Conditions>
</animNode>
by deleting it, you are breaking the whole animNode
it needs to derive from one of the bases
if you just don't want it to loop, I think you can make it extend default.xml
<?xml version="1.0" encoding="utf-8"?>
<animNode x_extends="default.xml">
<m_Name>Cough</m_Name>
<m_AnimName>Bob_EmoteCough</m_AnimName>
<m_BlendTime>0.30</m_BlendTime>
<m_Conditions>
<m_StringValue>Cough</m_StringValue>
</m_Conditions>
</animNode>
Like that?
yes
no, the emote doesn't start
I can press escape to stop the emote even though nothing shows up
so the key hit is read
but no animation is performed
nope
put it back to looped.xml then
just to verify that you didn't break it by doing something completely unrelated
that was very quick
ok, so, when you derive, it's obviously just inheriting the properties of the file you name
so, remove the extend directive and instead copy in the properties from looped.xml
okay i think I got it
was able to slow down the emote for example
<animNode> <m_Name>looped</m_Name> <m_AnimName>Bob_EmoteSurrender</m_AnimName> <m_deferredBoneAxis>Y</m_deferredBoneAxis> <m_Looped>true</m_Looped> <m_SyncTrackingEnabled>false</m_SyncTrackingEnabled> <m_EarlyTransitionOut>true</m_EarlyTransitionOut> <m_SpeedScale>0.80</m_SpeedScale> <m_BlendTime>0.50</m_BlendTime> <m_Conditions> <m_Name>emote</m_Name> <m_Type>STRING</m_Type> <m_StringValue>default</m_StringValue> </m_Conditions> <m_Events> <m_EventName>EmoteLooped</m_EventName> <m_Time>End</m_Time> <m_ParameterValue></m_ParameterValue> </m_Events> </animNode>
However I shouldn't copy everything inside anim node right?
don't copy anything that you are already defining in your animnode
okay
assuming it works after doing that (it certainly should) - you can set m_Looped to false
if it doesn't you broke something unrelated
I see. Thanks for clarifying.
But what I don't get is that i have a blendtime in the xml file of the emote and also in the looped.xml
that's an override
<m_Looped>false</m_Looped>
didn't work
have you verified it works after copying in all the properties without modifying them
yes
so it just stops doing anything as soon as you change m_Looped to false?
no it still looped
uhhhh
this is making me distrustful of editing it live
restart the game and try again
ok
actually, I am generally distrustful of editing live; if something unexpected happens, I restart it to make sure nothing stupid like caching is happening
restarted and it still loops
even though loop is false
however I see that the break between two loops is smaller than before
so maybe it was about the "pause" between loops?
@thick karma thank you the code worked
No worries
Hey there I have an idea for a mod, but I am not yet familiar with the Lua or Java API of PZ.
Is it possible to create new Custom Window/Dialogue (with an Icon to open them or a Keybind) with just Lua?
yep
Great! Do you know any mod which has implemented something similar, so I have a reference? ๐
It is the Event EmoteLooped in the action file that is triggering the Loop. All looped emotes trigger this event (inherited from looped.xml), which tells the Emote action to restart. In comparison, emotes that do not loop trigger the EmoteFinishing event (from default.xml).
Thanks ! So how should I edit the emote code then ?
I need to replace emotelooped by emote finishing ?
Correct. The event that needs to be triggered is EmoteFinishing
For the record, of the Shared, Server and Client folders, the client loads all of them and the server only ignores the client. So yes, you can run code in the Server folder on the client, but the server and client are separate entities and will have separate copies of the Shared and Server folders
IIRC it loads the Shared code first, then the Client, then the Server code. Which I assume is why you can't require a file from the Server folder from code in the Shared folder, for example
It did work thank you a lot!
I also have a question about the meaning of Blend_Time?
It's the time to go from idle to animation?
Pretty sure this is the time to blend into/out of an animation. so you don't just "jump" into a new pose that is vastly different.
I see, however I see that there is one in "action" files and in "emote" files
trying to find the difference between both
"action" is for TimedActions. "emotes" is for Emotes.
but I have same files for both
it's two different folders
files are not exactly the same by the way
Right, they wouldn't be the same because one is to define a TimedAction, and the other is for Emotes. Those might be unused? I don't think that mod uses TimedActions, just emotes. But could be wrong.
I have changed the blend time in the "asleep" actions file it changed the time from idle to asleep
When i change the blend time in the "emotes" it stops the emote from looping strangely
i think i am wrong in this actions/emotes
it seems that "action" is not doing anything
Correct. This mod does not use TimedActions, only Emotes. I'm like 90% sure those action files don't need to be there
yeah you're right
maybe for actions like washing etc
but they are already here in vanilla
they could be overriding some vanilla animation that gets triggered, not sure. but, they are definitely not used for the emotes. don't use the mod, so not sure on its full scope of changes
strange thing with awake when I increase blend_time, after 1 loop the animation stops
even though it must loop
It's authentic animations by the way
but only using the part where he scrapped the emotes
Anyone know why game might be doing this?
I don't think i overwrite anything there 
TraitFactory.sortList();
local traitList = TraitFactory.getTraits()
for i = 1, traitList:size() do
local trait = traitList:get(i - 1)
BaseGameCharacterDetails.SetTraitDescription(trait)
end
this is my only interaction with base game trait factory
maybe it sets description twice? 
once in normal game creation methods
and 2nd one in mine?
probably it
yea ok that was the issue. I don't even remember why I had it
that for loop
Got a weird bug going on, managed to get the playerID from right clicking and getting his items and stuff.
But when I right click for example to get item count from the other player, nothing happens... UNTIL!
I switch to the other screen where the other player is
then it all happens at once, as many times as I clicked
I'm using the sendclientcommand and sendservercommand things so it must be something to do with that I just don't know what exactly could be causing such a weird "pause"
If you need some code lmk
Do you know where can I find the index with all the key numbers?
I need to set keybinds like "CTRL + ALT + xxx"
But the game doesn't let me in the settings
Just thought I'd share this with everyone. Comes in handy when working with the OnKeyPressed event:
Something like this? idk
yes!
YAY I helped once in this chat as well ๐คฃ
@kind fossil Also, if you like variables: https://zomboid-javadoc.com/41.65/org/lwjglx/input/Keyboard.html
Javadoc Project Zomboid Modding API declaration: package: org.lwjglx.input, class: Keyboard
thx
Keyboard.KEY_LCONTROL, e.g.
I need for example to have a keybind like that : CTRL + ALT + XXX
Alt is mysteriously absent, probably to discourage its use, idk
D:
Javadoc Project Zomboid Modding API declaration: package: org.lwjglx.input, class: Keyboard
But alt DOES work
You can reference it by its number
as in the screenshot on the forum post above
At least... right alt does. I use it in one of my mods.
So by following that
If I want an action to be toggled by CTRL ALT P
I should write "29 56 25" ?
what's the syntax?
(Emote) Clap=29 56 25
Like that?
Ummm where are you trying to do this, I have no idea where you would try a syntax like that
Mmmm I don't think that file allows binding multiple keys
crap
I think it's used purely to get key numbers from names
My objective is to bind all emotes to strange keybinds so i can toggle them from my streamdeck
instead of using the wheel
Word well if you want to do hold presses you may need Lua, but I don't know
damn it
Only way I know to do hold press activations is Lua, but then again I activate custom functions rather than vanilla emotes, so I've never really tried looking into this method of triggering things.
at least I can use the far right keys from the keyboard
using modifiers like shift, alt, ctrl would have been the best
In Lua, you could do something like if Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) and key == Keyboard.KEY_R then doStuff() end (for CTRL+R) during the OnKeyPressed event, but the catch is that you won't interrupt LCONTROL's default binding
You may be able to mod it in but yeah not in vanilla.
Or instead of doing I could directly connect the streamdeck keys to trigger emotes?
but I feel that it's wayyyy harder
cause it would need a plugin between streamdeck and PZ
Well key signals are generally just integers so if you can get Zomboid to receive signals at all from the deck, you should be able to print them and bind them
local OnKeyPressed = function(key)
print(key)
end
Events.OnKeyPressed.Add(OnKeyPressed)
``` @kind fossil
You can add this to any of your mods to just check what signals you get when you play
In the debug console
if you have any unusual keys that aren't named coming in from the deck, they should still have a number
But i think streamdeck uses an API to send information
they are not keys pressed like a keyboard
You are talking to burryaga the author of a joypad mod fyi
Does your streamdeck not have a way to simulate a keyboard key? i would think most do. If so, I would just bind it to some numpad keys or something (or just use the numpad on your keyboard to trigger the emote). those are unused by default
Yes that's what I'm planning to do if I can't find a solution
the thing is that I have less than 20 keys available with that method
I wanted to find a solution to use modifiers in keybinds (ctrl, alt, shift...) to increase the amount of emotes I can bind
Yea, like @thick karma mentioned you would need to check for this in your lua.
if isKeyDown(Keyboard.KEY_LSHIFT) then
Or whatever the key is you're checking for. You can use any key in that check too. things like KEY_RSHIFT, KEY_RCONTROL are all unused. Using that method again posted by Burryaga would give you the keycode for those keys
Hi guys, is there anyone who ever tried to change dynamic traits to make it fits his desire most? I'd like to remove one trait completely from this mod but i barely has any knowledge about mods
Or don't even remove, just make it never appears again cause it can be developed after killing 15k zombies
I can show./send LUA files in private message, thanks
This should do the trick:
-- normal numpad keys
[82] = "comehere", -- 0
-- numpad + rshift
[582] = "Burpees11", -- rshift + 0
-- numpad + rcontrol
[682] = "saluteformal" -- rctrl + 0
}
local doEmoteKey = function(key)
local index = key
if isKeyDown(Keyboard.KEY_RSHIFT) then
index = index + 500
elseif isKeyDown(Keyboard.KEY_RCONTROL) then
index = index + 600
end
if emoteKey[index] then
getSpecificPlayer(0):playEmote(emoteKey[index])
end
end
Events.OnGameStart.Add(function()
Events.OnKeyPressed.Add(doEmoteKey)
end)```
Just build the `emoteKey` array to fill in what keybind you want to do what emote. For a modifier key, you'll see i'm upping the index by an amount (500 for r-shift to avoid any overlap of keys, and so on). keybind "82" (0 on the numpad) does "comhere" emote when pressed, "Burpess11" when shift+0 is pressed, etc. You'll have to fill in the rest for the keybinds/animations you want.
damn!
so I just need to add all the keybinds in the emoteKey
and put the file in the lua folder?
No need to create a mod right?
It would need to be its own mod.
if its all client side then i guess it wouldn't matter. but an update to the base game or whatever mod you add this to will likely remove your change. also not recommended to be modifying vanilla lua
Or I need to write the lines in a specific file?
Iirc isKeyDown is in Keyboard, so unless it's duplicated in global, you need Keyboard.isKeyDown. I use it this way in a mod.
Needs to be in a file in lua/client somewhere.
okay thanks!
Yea, its a global too. ๐
I can add that in keys.ini for example? Or better to just create a separate file?
it needs to be a lua file
Oh dope I may adjust my mod in the future
so a file like : emoteKeys.lua in the "Lua" folder?
valid would be: lua/client/emoteKeys.lua
thanks
You would need to make a mod in the mods folder. I don't think dhert and you are thinking of the same meaning of "in the Lua folder."
You 'TECHNICALLY' can just dump it in the base game folder
I just don't want to bother with a uploading in the workshop etc
since i'm not a modder myself, it's for personal use only
Fair but not recommended haha for obvious reasons
The mods folder is specifically for non-workshop mods. @kind fossil
You can make a mod for personal use. it def is not recommended to dump files in the game folder/change vanilla files
In mods, you could make EmoteKeys/media/lua/client/emoteKeys.lua
oh cool so I can use client side mods from this folder on servers?
thanks for the info
By the way guys you don't do commissions ? We are looking for devs
If you're hosting for multiplayer you can give your mods to your friends and if they have the same mod in Zomboid/mods, you're good.
it's not a personal hosted server
Not usually, I prefer to focus on what I personally think the game needs most, and almost nobody wants to pay what I would want to take my time away from that in a committed way. I don't mind helping from time to time when I'm taking a break from stuff, but if I'm going to get involved in serious programming, I need to believe in it or be paid like it's a job. Too many people out here giving poor modders $50 for stuff that took 6 hours. Programming should pay better than that; it's taxing to code solutions to other people's problems, imo.
You're right ye
I work as a dev irl, so don't want to mix my hobby (modding this game) with being paid. otherwise that line of work/play gets burred too much. ๐
Totally understandable
We have been thinking of mod features that would help a lot our roleplay serie project, but we don't have the modding knowledge
For sure, I second that. Part of why I wouldn't take commissions that pay less hourly than my job is that I feel it would kill the fun of the hobby quickly for me to reflect on that while I'm grinding at a mod.
But I totally understand your point
I just feel that asking people to dev something for free is just unfair
Just talk to author man. U have posted alot of stuff about dynamic traits
Is it the dynamic traits world or just the dynamic traits
@dull moss dude
@kind fossil
https://pzwiki.net/wiki/Modding:Lua_Events https://theindiestone.com/forums/index.php?/topic/2530-mod-permissions/ https://github.com/FWolfe/Zomboid-Modding-Guide https://steamcommunity.com/id/Dislaik/myworkshopfiles/?section=guides https://projectzomboid.com/modding/index-files/index-1.html https://gist.github.com/Konijima/7e6bd1adb6f69444e7b620965a611b74 https://theindiestone.com/forums/index.php?/topic/15188-item-and-recipe-script-variables-brief-description/ https://www.lua.org/pil/contents.html
My personal approach if I wanted a mod I couldn't make would be to float the idea to other modders and hope someone who knows how decides that it would be a fun and worthwhile task for them to add that to the game. If the feature is very personal rather than for the good of the game, I probably wouldn't bother pursuing it, but I don't think there's anything wrong with saying in a room full of modders, "Wouldn't it be cool if..." and seeing if others agree.
And then I might donate what I can
Sure
However for me donation and payment feel different
That's why I have written a page with all our ideas so it can inspire people, since it's very roleplay related, it could benefit the community
Because payment says, "I paid you so you owe me," and implies a sort of business fairness to the exchange that imo is rarely present in this sitch
yeah i understand
Whereas donation says, "here's what I can give, I know it doesn't pay for what you put into this, but thanks."
It's a way to thank the dev
Just my personal perspective but I don't think there's anything fundamentally wrong with offering lower-than-programming wages to anyone who is legitimately happy to do the job.
I just don't because I feel bad lol
Who donates anyways
Only time i recieved a donation it was from. Fellow modder
Thnx sigma vulcan. Its not the $ that matters when u recieve a donation
I did a few times to be honest
Yeah honestly I wouldn't recommend modding as a way to make a ton of money. I do it when I already like a game and feel I know how to make the game better
I'm even subbed to a Modder's Patreon on Minecraft
since he has been developing a huge groundbreaking mod by himself for years
it's a way to say "mate, we are still here, keep up the good work!"
People already asked author how to disable bloodliust or if they can somehow remove it and she clearly said "no"
@dull moss ?
Ow ok then
and cause i've no knowledge about this kind of stuff i need to somehow remove it by myself or with help from someone else
Are you telling me that i can't change mod only for myself if i won't upload it?
Because i don't want to create mod patch
i just want to fix it for myself
are you playing SP?
Ah u can if its solo
what trait u dont want to see?
The bloodlust thing
bloodlust, usually Sp or with my buddy on private server
ah ye
well either do that
or alternatively you can use https://steamcommunity.com/sharedfiles/filedetails/?id=2914075159

The problem that i literally like every other thing in dynamic traits
besides this one annoying trait
so remove it
Just comment out on the lua file
lol yeah
comment out? You mean upload them here?
Just use
--[[ stuff u want removed ]]
No i ment comment out the code
Literally edit the lua files
yea, that's the problem, i open it and i've no idea what i should safely remove to make bloodlust never appear again without also crashing my game
Alternatively you can just add
return
Just before the function starts
ctrl+F -> type in bloodlust -> comment out code that adds the perk
You should hire a modder the
...hire?
lua is not that hard, it's very readable. just gotta read
read and learn
the only thing i ever did with "modding" was changing values of weapons for already made mods in payday 2 
yeah that would be a total waste of your money, it's a ten second change
well, i'm studying these files right now
if i had any real knowledge about making mods then it would be easier, that's why i came here for help
i think glytcher provided links above if you have specific questions, but otherwise the functions in the file are fairly self explanatory in most cases
although if they're being added dynamically it might cause issues, so I can see where that might be a problem
more or less just ctrl+F for anything you need to find
in your case, bloodlust
not really, the code for bloodlust is that it has random chance of being added after every kill or it's forced to be obtained after x kills
you can do a dirty edit if you just remove the trait though. you'll get a lua error, but it should be relatively harmless
What does bloodlust do
you're getting sad, bored, angry if you did not kill any zombie for x time
after more time you're starting to hear zombies sounds
lol
sounds like a shitty mod tbh
So an average PZ player
this mod was very good but then it has been added
Once you find the part where it sets it then just comment out that part
it has a very different options to be set cause it depends on trait that you've started with
function bloodlustTrait(player)
return
end
Ahhh this one
Comment out the event that calls the function
It would look something like
Events.stuffstuff.Add()
else
if not player:HasTrait("Bloodlust") and player:HasTrait("Desensitized") then
if DTrandomNumberForKills2(player, 15000) == 0 then
player:getTraits():add("Bloodlust");
that should stop ticking up counter
that's how it works in file
There just add
--
--player:getTraits():add("Bloodlust");
But poltergeists suggest a better way cuz it not use up much ram
But if you cant do that then this would be an alternative solution
Whats etw?
hm, there's also pure random chance to add it ๐ฆ
yea, there are two lua files related to getting this perk and there is also other one about how it works
ok thanks everyone, guess coming here with literally no knowledge was bad idea, especially if i had no idea what commands/functions are
But i'm grateful that you wanted to help me
hm, what I wrote would stop the counter, so even though if you have the trait, it would do nothing
yea but i had no idea where to add it and it's hard for someone else to explai nwhen he can't check lua file
I also thought about even other solution - i'll just change number in bloodlust from 24/72 hours to like 240000/720000 hours, this way i won't feel negative impact of this trait at all
so i won't remove it from game but negative effects won't ever appear
BLOODLUST TRAIT
function bloodlustTrait(player)
--print("DT Logger: running bloodlustTrait function");
if not player:isAsleep() then
player:getModData().DTtimesinceLastKill = player:getModData().DTtimesinceLastKill + 1;
end
--print("DT Logger: DTtimesinceLastKill value is " .. player:getModData().DTtimesinceLastKill);
end
function bloodlustTraitEffects(player)
--print("DT Logger: running bloodlustTraitEffects function");
-- CHECKS IF THE PLAYER READ ALL THE BOOKS TO LEARN HOW TO CONTROL THE EMOTIONS
if player:getModData().DTstressIntelligence == true and player:getModData().DTunhappynessIntelligence == true and
player:getModData().DTboredomIntelligence == true and player:getModData().DTangerIntelligence == true then
-- IF PLAYER HAVEN'T KILLED ZOMBIES FOR 72 HOURS, THEN THE MOOD WILL BE AFFECTED EVERY HOUR
if player:getModData().DTtimesinceLastKill > 72 then
--print("DT Logger: All the books were read");
-- STRESS
DTincreaseStress(player, ZombRand(5), 0.20);
-- BOREDOM
DTincreaseBoredom(player, ZombRand(5), 15);
-- UNHAPPYNESS
DTincreaseUnhappyness(player, ZombRand(5), 10);
-- ANGER
DTincreaseAnger(player, ZombRand(5), 0.30);
end
else
-- IF PLAYER HAVEN'T KILLED ZOMBIES FOR 24 HOURS, THEN THE MOOD WILL BE AFFECTED EVERY HOUR
if player:getModData().DTtimesinceLastKill > 24 then
--print("DT Logger: All the books were not read");
-- STRESS
DTincreaseStress(player, ZombRand(5), 0.20);
-- BOREDOM
DTincreaseBoredom(player, ZombRand(5), 15);
-- UNHAPPYNESS
DTincreaseUnhappyness(player, ZombRand(5), 10);
-- ANGER
DTincreaseAnger(player, ZombRand(5), 0.30);
end
end
end
Theres literally hundreds of ways u can disable it...
and yet i'm struggling to find any that i can execute
On the middle of first and second line
Add
return
Which is what poltergeist was telling u to do
It wont run the code
Below the return
Is return going to block only this command or whole lua file?
I have a patch file in lua/client named something like ~Patches.lua
if getActivatedMods():contains("DynamicTraits") then
require "DTstaticTraits"
function bloodlustTrait(player)
return
end
end
the script is for you
thanks!
if i don't have this patches.lua am i safe to create new one?
and just add script there?
make the name more unique
When you have more patches, you will probably make a separate mod to place your files separately
rather than edit the base mods
ok got it, i'm happy that notepad++ was enough to create .lua
you can do the same for some of the other functions too, like the second one you posted
tweaking the values is also something you could do if you feel like it
i've no idea what i can and what i can't do tbh
But i'm really grateful for your help
i think i already know but hope is always the last thing to go... does pz lua has anything to read json string into a dic or do i have to do the function myself and go mad with gsub or something like that?
nothing vanilla, just find a library online
https://github.com/MrBounty/PZ-Mod---Doc/blob/main/Save data.md
Can include the "json.lua" in your mod
i can load lua libs in the game? i thought that was... restricted due to security reasons
thanks @bronze yoke and @dark wedge
its just another lua file as far as the game is concerned.
oh that makes my life a lot easier then ๐
was even thinking about saving the json in another format easier to read from base lua...
for me it will be the 1st one to work without any hastle...
nice nice... app is done... working on the mod code...
and was thinking the json bit was gonna be a hastle...
since im exporting on twitch event a json string to a file that contains the data of what the mod has to do
{"title":"Presentinho","zombies":true,"zedquant":999,"gifts":3,"helicopter":3}
so with this... life is easier
I think the one from the MrBounty GH link is just for encoding/decoding json, and "just works" for that. while the other provides features like pretty printing and stuff too.
so ill use the mrbounty then, only need to decode json and store it into a dic
then use that dic to fill the values of the function that triggers the game event
Hi - I'm interested in intercepting all actions a player performs; to do so I'm currently planning to intercept calls to ISBaseTimedAction:perform() - but currently doing so is causing the game to report a "bugged action" when I do this... but it also runs my custom code whenever the player does an action, so I feel I'm on the right sort of track.
I wondered if anyone else had experience intercepting function calls from the vanilla LUA in a way that behaves as "politely" as possible to the base game. I feel like the context of "self" is part of what I'm messing up that's breaking the base functionality, but this is where my knowledge of the syntactic sugar of . vs : is getting to it's limits!
can you show your perform function?
Sure
This is my interceptor class. It only works on the first load (because afterwards it ends up swapping the base method for itself recursively I guess - but before solving that I just want to intercept calls in a way that plays nice with the base
I say class, that's probably the wrong way to describe it in LUA...
so the problem is using : passes the object before it as self: in this case, you're calling the original perform with PGMG.Client.Action as self
try PGMG.Client.Action.originalCall(self) instead of PGMG.Client.Action:originalCall()
Giving it a go, thanks - this part of LUA has always been a bit dicey for me!
My word, that's done the trick, no more bugged actions. Perfect. Now I just need to figure out how to not screw up the injection if the LUA is reloaded (i.e. end up in a loop back to myself) and the baseline should be there.
You shouldn't need to worry about that. When the Lua is reloaded, everything is reset and then your patch is just re-applied. as long as your override only does the override once per lua load, then it wouldn't loop back.
i think they meant when you reload a single file
Ah ... yes, I might be overthinking; the client will only ever reload all of the LUA, correct? (Short of using the debugger to ask it to reload just one?)
ya, you don't have to worry about someone reloading your file otherwise
Perfect
This works a dream, by the way. Thanks again.
I am still struggling with sendservercommand and sendclientcommand
Browsed multiple mods how they use it even the lua files in the game
I'm not sure how to send a request with it for an argument and then get it back
To be completely honest not even sure which one of those requests and which one sends
sendServerCommand sends from the server side, sendClientCommand sends from the client side
Yeah but for example theres isoplayer, module, command and args
For servercommand
Does this mean that isoplayer is the one youre sending it to
Amd args what you're sending him?
Yes on both - module and command are just strings used to detect if this is the call you're interested in. Player matters on the server side, on client side, I've always just used getPlayer() - other more experienced modders may be able to elaborate if that's entirely appropriate, but I know that works. Args is a LUA table with the arguments and as far as I can tell, it reaches the other side essentially intact.
Oh also my bad, servercommand is the client sending the server a command
so in "theory", its player - who is sending it
and args - what he's sending the server in the form of a command when that function is executed (when he does something to execute it)
no wait
got it wrong again
๐คฃ
args can take any LUA Table as far as I know.
I think I got it right the first time around but yeah in essence
I'm gonna try and think of it like that like you said, this dude sends this in a lua table and module command is just something to identify what is sent when
depends whats in the table, not everything will make it
Yeah I've only generally sent primitives in the table.
primitives are fine, but no userdata. From what I understand, inventoryitems are an exception and should send
I didn't know you could pass anything other than primitives to be fair
Are you allowed to leave some things in that function blank? I'm looking at a sendclientcommand in a function right now that just has module, command and args
Whereas on the project zomboid . com website it says it should take in player, module, command & then args
I don't think player should be blank. if you want to send to all, iterate from a player list i.e. getOnlinePlayers()?
there are two versions. One sends to a specific player, the other I think broadcasts
on the client side, the player parameter is the player 'sending' it
Oh yeah you're right @astral dune
I'm looking at one right now that takes module, command and table
I'll defer to @bronze yoke here as they seem to know the LUA of this game backwards XD
One was from Global Object and one from CGLobalObjectNetwork
Hi! So, i have a problem with a mod. I can Ask questions here, right?
if you're the one making it, sure, otherwise you probably want #mod_support
So, uh, first i wanna know what "mask" is in clothing settings
I didnt find any information about this
And i really cant understand what it is, and what is it doing.
ok, logic-related question. I might be
here but trying to figure if its possible to combine those 2 ifs somehow?
if A == true and B >= 10 then
if C == true and D >= 20 then
XYZ
elseif C == false then
XYZ
end
end```
Basically, I always want to check A and B condition to execute XYZ. But on top of that, IF condition C is enabled, it should have additional requirement D.
I mean I can do something like
if A == true and B >= 10 then
if C == true then
if D >= 20 then
end
else
end
end
if (A == true and B >= 10) and ((C == true and D >= 20) or C == false) then
think that should work?
I typed this out and i was like "wait a second"
if (C == false and A == true and B >= 10) then

So if I can get another players ID from a client side, by right clicking on that person
I can then also use this ID to get that players inventory since the inventory is client sided (someone said)
What is the use of the server in this instance? What can it provide that I cannot obtain via client-side code?
the inventory is on their client
Although even if they can be combined, there is almost no overhead in doing those checks so, do they make the code more readable?
we can't send commands directly to other clients, so you need to ping things off of the server
Advantage is that I don't have to have 2 instances of XYZ
repeating code is a bad idea
yep
So Albion, in this case, let me just break it down to see if I get it.
I get his ID from my client for example by right clicking
Send that ID to the server - should I then make a function within the server code to get for example an item count
And then send that item count back to my client?
If it reads easier, make it more readable, the overhead of an extra iteration or two in the state machine will mean little?
Via another send---command line
unfortunately, as the inventory is client side, you need to get their id from the client, send that to the server, then have the server ask that client for the information, have that client send the information to the server, and then finally have the server send the information to the original client
lmao that's cool, I'm gonna experiment with that now, thank you a bunch โค๏ธ
like player a -> server -> player b -> server -> player a
I have 2 92 lines function that are identical and only difference is that one variable is different
if SBvars.WeightSystem == true and SBvars.SleepSystem == true then Events.EveryTenMinutes.Add(weightSystemAdvanced) end
if SBvars.WeightSystem == true and SBvars.SleepSystem == false then Events.EveryTenMinutes.Add(weightSystemBasic) end
I usually opt out for readability, but fixing this shit was trash cuz I have to make adjustments in 2 same functions
So is this where the IsoPlayer argument comes in?
So I'd rather have more complex IF and 1 instance of function
Inside the sendclient/servercommand
Theres a pinned post
personally I'd do
if A and B >= 10 and (not C or D>=10) then but ya its less readable I guess
Basically deciding on who you choose, to who to send that command to?
yea this is perfect example where I'd use my variant cuz it's more readable
Thank you โค๏ธ
even though this one is shorter
Goodluck
if I'm reading this right the whole thing is just
if SBvars.weightSystem then
Events.EveryTenMinutes.Add(weightSystemAdvanced)
end
oh, I'm not reading it right

lua nonsense would be to do
if SBvars.weightSystem then
Events.EveryTenMinutes.Add(SBvars.SleepSystem and weightSystemAdvanced or weightSystemBasic)
end
that's evil
Readability is super critical if you want to scale something... if you don't, feel free to indulge ๐
did you even read what I said
I literally said that I'll opt out for more readable variant

Absolutely, yes, sorry, I was trying to support the comment
Ah
I think its perfectly readable ๐
I thought you thought I thought that less readable is better
(yes I tried to put as many thoughts as possible in that sentence)

The code was readable but this statement isnt
No, indeed, - although, as a good example of readability, even in plain English, I communicated it incorrectly.
Sometimes a picture paints a thousand words?
Lol
That made my day
Well, let us all rejoice in the joy that is programming machines
I think I just wrote the most scuffed ass lines of code ever to be written in Lua for zomboid. Jumping back and forth sending commands from server to client to server made me lose 10 IQ points easy
Hey, Step 1 is always "get it working," you can refactor it later. :P
That's pretty much how all of us feel writing LUA
lmao
I gotta say it's fun as hell tho when it finally works
Question: how can I NOT break ppl saves if I change sandbox variable type from boolean to dropdown menu (assuming there's a way to make a dropdown menu, think I saw in some mods, haven't researched it yet)
sometimes i write insane code on purpose hoping that someone one day will look through my source and go 'what the fuck'
Beyond evil
Yeah, this is definitely a thing ๐ค
You're going straight to jail

Readability is relative. ๐
I'm gonna start putting memes in ascii format in the code I write because if I ever get this working I might as well get some form of fun from it
finally a way to unalive 
But I second your notation, lol.
Yeah. Gotta eradicate all those "Too good at LUA folks"

I keep my code's chaos low by just including jokes in explanatory comments
Helpful ๐
albion is
, answered like a hundred of my questions
The enum sandbox variable type lets you make a dropdown menu. As for not breaking saves, i think the safest way is to use a different variable name, and cover it up in a translation file so it looks the same
albion has my tips all day long ๐
yea, hoped i could get away with using old variable name
what if
i do it in few releases

Like 1st update i make new var
2nd update i delete old
3rd i change new var to have same name as old var

1st and 2nd can be combined
ah fuck it, too much hustle, new var name it is
Christmas is over, time go go back to old pfp 
Well first you start with the cold virus...
Beat me to the smartass response

Do I get points on that one?
You get to help him make his virus
where do i find that?
i just started to mod
CommonCold:infect()
Dynamic Traits has a "Cold" Sickness
You mean this?
ya
oh
similar I guess, vanilla is so rare I forget about it
ok now what?
I just spent ten minutes writing out my problem to you guys to try and get help and then while writing it out I figured out what I'd been missing
CommonCold:propagate()
all right
Spread the illness
Soon everyone will have a slightly annoying illness that impedes perhaps 25-30% of motor functions. Aahhaaahahhaahhahhhaahaha!
My evil plan is complete
Soon the world will know my fury. Or about 25% of my fury.
But that's quite a lot of fury! Spread over a reasonably absorbent crowd.... but still!... Fury!
true
I don't think the game differentiates vehicles like this, but is there an easy way to tell if a vehicle is a van, truck, car, etc?
what are all the all cold stuff like affects
for example
if player:getBodyDamage():getColdStrength() >= 75 then
player:getBodyDamage():setPoisonLevel(player:getBodyDamage():getPoisonLevel() + 1);
-- player:getBodyDamage():setFoodSicknessLevel(99);
when initializing moddata for example we can do multiple or right?
like
modData.NewOutdoorsmanCounter = modData.OutdoorsmanCounter or modData.NewOutdoorsmanCounter or 0;
ah but then i have to make sure i set old counter to nil
so it doesnt overwrite again after 1st load
ok
you can get its name from its script, so yes
Hmmm, the problem is the name isn't guaranteed to say if it is one of those types. trying to make a solution that would work with modded vehicles too
Okay, here's a new one. Maybe someone can help me bring a little order to chaos myself.
Long story short, I'm trying to build some ZombieZoneDefinitions programmatically. IF sandbox option selected, THEN spawn X zombies in this zone, etc. For reference, here's what I want the declaration to look like:
ZombiesZoneDefinition.School = {
maleChance = 100,
Student = {
name="Student",
chance=70,
},
StudentSwimmer = {
name="StudentSwimmer",
chance=10,
},
StudentAthlete = {
name="StudentAthlete",
chance=20,
},
}
I'm building the ZZDs using table.insert, but while I've got the outfit definitions working fine I just can't seem to get male/femaleChance plugged in correctly.
ZombiesZoneDefinition.School = {}
-- This part doesn't work
if SandboxVars.ModName.GenderRatio == 1 then
table.insert(ZombiesZoneDefinition.School,{maleChance = 100})
etc.
end
-- This part does
if SandboxVars.ModName.StudentType == 1 then
table.insert(ZombiesZoneDefinition.School,{name = "Student", chance=70})
table.insert(ZombiesZoneDefinition.School,{name = "StudentSwimmer", chance=10})
table.insert(ZombiesZoneDefinition.School,{name = "StudentAthlete", chance=20})
etc.
end
It's probably because male/femaleChance isn't a table like Student, StudentSwimmer, etc. but I'm not sure how to plug it in properly in that case. Anyone know how to get this WAD?
ya, modded vehicles would be challenging, all vehicles are BaseVehicles and all you can really determine is their name
well, weight and size too, I supposed you could try to make up some rules
Yea, thanks for looking. I'm currently trying to see if i can get a property from a door that might say something. lol
lol, no I don't think you'll find anything interesting there. There are a few ways to tell if it takes heavy duty, normal or performance parts, that may help you figure it out, but its likely going to be a lot of guess work or mapping each vehicle individually with compatibility code
ugh, this is one of those "problems" that isn't actually even an issue. But i'm hyperfocused on it and can't stop. please someone hit me with a 2x4 to stop me. 
How do you make a virus with moodle framework
or with out
been saying 1 more debug run for the past 3 hours it's 2am here now
ffs
still stuck on the same thing, cannot figure out for the life of me how to operat sendclient/servercommand
it must be something hella obv because that's how it be
found mod with it,
{
type = enum,
numValues = 4,
default = 1,
page = AutoDrop,
translation = AutoDrop_LootMode,
valueTranslation = AutoDrop_LootMode,
}```
``` Sandbox_AutoDrop_LootMode = "Loot Mode",
Sandbox_AutoDrop_LootMode_tooltip = "Allows to override Mod Options client selection",
Sandbox_AutoDrop_LootMode_option1 = "Mod Options client selection (Default)",
Sandbox_AutoDrop_LootMode_option2 = "Auto Loot",
Sandbox_AutoDrop_LootMode_option3 = "Auto Drop",
Sandbox_AutoDrop_LootMode_option4 = "Instant Loot",```
can't find it being used in lua though,
I assume its something like `SandboxVars.AutoDrop.LootMode` and it returns value from 1 to 4?
by value i mean number, aka which option was used
In the case of the "maleChance" variable, etc. you can set this via:
ZombiesZoneDefinition.School.maleChance = 100
Since its not a table. Otherwise, seems fine?
How do you make a virus with moodle framework or with out
it might go 0-numValues? I'm not 100% on that. Lua/Java use different indexes and i can never keep them straight. lol
If it's something that player supposed to observe, then use moodle
if its sneaky virus then dont use moodle
If I make a sneaky virus where do I start making it?
Thanks for this, gonna test right now!
My friend, we're not going to be able to tell you how to make a full mod like that. Additionally, removing/re-adding your comment is not productive.
High-level overview:
- make a trait (can be added or removed on demand on a player) -OR-
track custom sickness values in your own scripts for a player (this would be "hidden) - Every x ticks or x minute events, do something if the player has that trait or something.
- After x amount of time, you die or get better.
If you want to use the Moodle Framework: https://steamcommunity.com/workshop/filedetails/discussion/2859296947/3380536561724844838/
I'd do in this order
- figure out a way how player can get it and code it
- figure out how it affects player and code it
3) add moodle support - test
oh u said sneaky
Ok
Worked perfectly, thanks again.
finally... done with the app for now... mod code at 80%...
https://youtu.be/KBRfGkmWp5g
A "small" tour of the finished alpha of the app, and it will be improved in the future, but now i will focus on the mod itself. Will be opening the app and mod for public use to help me find any bugs that remain. Any suggestions to add to the mod or app are more than welcome. Thank you for watching.
now time to take a break...
im trying to trigger a recipe using lua
RecipeManager.PerformMakeItem('Take Meat', Nuka.ZedMeat, getPlayer(),nil)
ISCraftAction:new(getPlayer(), Nuka.ZedMeat, 250, 'Take Meat', getPlayer():getInventory(),true )
any ideas how
heres the recipe
i want to make it available on the world context menu which is why im wondering if its posstibe to trigger the recipe
You need to actually do the TimedAction:
ISTimedActionQueue.add(ISCraftAction:new(getPlayer(), Nuka.ZedMeat, 250, 'Take Meat', getPlayer():getInventory(),true ))
Also, just to clarify the "item" parameter for the ISCraftAction is a reference to an actual item the player has/can grab, not just the internal name of an item.
Om my case its the corpse right?
Gold I love that because they have typos in their code I have to do shit like this
local function checkStartingTrait(startingTraits, player, trait)
if trait == "Claustophobic" then
if startingTraits.Claustrophobic == nil then
startingTraits.Claustrophobic = player:HasTrait(trait);
end
elseif startingTraits[trait] == nil then
startingTraits[trait] = player:HasTrait(trait);
end
end```
instead of just
local function checkStartingTrait(startingTraits, player, trait)
if startingTraits[trait] == nil then
startingTraits[trait] = player:HasTrait(trait);
end
end```
something like this but replace the function on the context menu with the craft trigger
local function NukaCannibalContext(player, context, worldobjects, test)
if isCannibal() == true then
local sq = nil
for i,v in ipairs(worldobjects) do
local square = v:getSquare();
if square and sq == nil then
sq = square
end
if instanceof(v,"IsoDeadBody") then
context:addOption("TakeZedMeat", v, TakeZedMeat)
end
end
end
end
Events.OnFillWorldObjectContextMenu.Add(NukaCannibalContext);
Would it be possible to create a zombie mod and have it be a singular unique zombie that spawns in the world (amidst other zombies, obviously) and only once, that has a unique outfit, plays music when it aggros onto the player (this would be heard in a short-ish radius, so it doesnt blast across the entire map) and can only walk slowly, attacks with a weapon (or looks like it does, like could i have it spawn with a weapon in its hand? would i have to make a special model for this?) and never loses aggro no matter how far the player goes, so eventually it would catch up? i want it to have really high health and not stagger unless it takes a lot of damage at once. for reference, im making a Michael Myers zombie mod that includes his lootable mask and knife and outfit when you kill him.
like are these things doable? i feel like they should be, given how moddable zomboid seems to be.
The one that killed me recently was: GridlePan ๐ก

ah yes let me add 2 special cases cuz someone cant type in english
if trait == "HeartyAppitite" then
if startingTraits.HeartyAppetite == nil then
startingTraits.HeartyAppetite = false;
end
elseif trait == "Thinskinned" then
if startingTraits.ThinSkinned == nil then
startingTraits.ThinSkinned = false;
end
elseif startingTraits[trait] == nil then
startingTraits[trait] = false;
end
idk how zombie spawn works but probably should be doable, if you can catch if zombie already spawned, not sure about infinite aggro though cuz i dont think PZ keeps track what zombies to in cells far away from you
that'd be gigantic waste of resources
and unneeded
you could forcibly teleport zombie to stay at least 300 range within player
I think
again, havent worked with zombies
casual 102 lines moddata.lua 
- How much moddata entries do you use?
- Yes
In stead of one singular zed make like the Minecraft cage that spawns mob
But on your case only spawns once and then delete itself
So itsorta a tile trap
And when a player is detected to be close enough it triggers
Just an idea
Not a bad concept too i think
Ye i like the Myers idea
but infinite aggro seems undoable without teleporting Z closer to player
cuz I'm like 99% sure PZ only does zombies within few cell range of you
Simply from logic perspective
Unless they found some smart way which I don't think they did cuz then we'd have NPC system by now
Oh cool: https://steamcommunity.com/sharedfiles/filedetails/?id=2553733512
This kinda already exists as the "Nemesis" zed from here
has anyone tried to make a manual transmission yet? I think I'm gonna put that on my to-do list if not, seems like it'd be fairly straightforward to implement, but I haven't looked into the code that handles gear shifts yet
iin lua u can do this, right?
local lowerCounterBoundary = -SBCounter ;
or do i have to
local lowerCounterBoundary = SBCounter * -1;
I usually ask chatGPT and it's down

oh nevermind its back up

yes
Yep coding is no more
hmm, i wonder how i'd do it then, to handle houses and stuff, so myers doesnt teleport into your house
neato, reverse engineering time
haha
It's a horrible future
The plan is to live a little and then die before humans become obsolete so we're fine
Think we got another 5-15 years
Unless you're younger than 20
then you're not fine

I wonder how i would handle aura-music. anyone have any ideas? ._.
@bronze yoke 
I was considering taking apart the true music mod to see how it handles boombox radius and then see if i could attach something like that to the zombie that spawns. im reverse engineering that nemesis mod to figure out the special/uniqu part, but yea
The IsoGameCharacter class (parent class of IsoZombie ) has the playSound() function which should do 3d sound. there are definitely "sound emitters" that you can hook into as well which do 3d sound.
so i could do something like playSound(directory to sound) and that should work, so long as its a wav?
my knowledge of coding is pretty shit, i took a python class last year(?, 2022 january i think) so its been a while.
i can still understand what it does when i look at it, for the most part tho
From my understanding, yes. Although, i've only ever needed to play vanilla sound-bits, so haven't pulled in my own audio. ha. looks like it is just wav tho
thoughts?
best usage of audio in any mod are these 2 mods, change my mind
https://steamcommunity.com/sharedfiles/filedetails/?id=2861801557&searchtext=last+of+us
https://steamcommunity.com/sharedfiles/filedetails/?id=2743379697&searchtext=surprise
By the way, does anyone know if zomboid hides the players arms/w/e when a hoodie is placed on?
I think I'm derping a little but how to reference https://projectzomboid.com/modding/zombie/core/TilePropertyAliasMap.TileProperty.html#possibleValues in lua? specifically that possibleValues function
declaration: package: zombie.core, class: TilePropertyAliasMap, class: TileProperty
like does the player body stop rendering when clothes are on
wondering cuz im trying to get clothes to fit perfectly over the base model for a mod, and i am having trouble with clipping due to the shoulders being weird, so i am wondering if that matters or not
would this work as a trait?
i put the cold code to try to change the cold when the trait is picked
oh yeah, do cloth physics exist in zomboid
according to mods, yes
oh wait maybe not
disregard my answer i have no fucking clue

no
Wdym
Dynamic raiiiiiiin.
alrighty, good to know! thank you very much.
oo you know what would be a cool mod, heat/cold resistant, like your character prefers heat/cold so gets cold/hot slower
chocolate raiiiiiiiiiiiiiiin.
maybe if resistant to cold, burns up faster, and vice versa
cool, gotcha.
Ok Iโll try it
So is it a trait?
if you make it, lmk, i'll sub to it!
mmmm
Backdrop shader pass with UI is a very sweet treat.
Time to make frosted blur UI backdrops..
How do I make a trait with the cold cold


