#mod_development
1 messages ยท Page 511 of 1
Just a fun tangent here, but the earlier code I posted, that loads functions from a text file, was something I was interested in a means for servers to have server specific quest/puzzle/progression mechanics functions that would be unavailable for rascal players to solve via peeping the server mod files ๐
any1 willing to take a look at my collection and tell me which mod specifically isnt functioning?
Ah, didn't know pz uses kahlua. Thank you
This could definitely come in handy for my competitive server leaderboards system
#mod_support is the channel for that sort of help? This channel is where mod making nerds talk our mod making business, but that other channel is specifically for people getting help with issues using mods? ๐
no io.* or os.* or math.random...theres probably a few more i'm forgetting
@willow estuary ah gotcha, sorry bout that didnt see that one
Yeah, no sweat. It's a new channel anyways and all? ๐
Aha! I've figured it out!
The client and the server's radio frequency is different
it is being made, but the client's information isn't in sync
I looked into the server's logs and it listed a frequency so I tuned into that one and it was there
Now, does anyone know any functions to grab the server's specific info?
Yeah, the issue is the sandbox variable info and the server info aren't in sync..
MOD SUGGESTION: Cars have lighters in them 1993. Every single car came with a car lighter.
@sour island I know you were mentioning issues with servers and clients not having syncing variables for EHE, did you find a reliable method to grab stuff from the server to send to the clients?
In my case, the radio frequency is mismatched between the client and the server, and while if the client can find it they can tune in, but I can't grab it for checks
could always pass them through sendClientCommand/sendServerCommand. what orgm does for passing the server settings to the client (client connects, send the command to request the settings, server replies with the settings table)
Do you have an example/link?
I was just looking at that for EHE but couldn't quite understand how the module/command stuff work
uh not a clean one? its probably in like 7 different places scattered through the files. might beable to clean it up a bit though
will take a few minutes
That's all good, if you're willing to clean it up to show that would be awesome but I can keep poking around otherwise
@quasi geode Really what I need to know is a basic flow, so theoretically if I want to fetch the server's variable stored in gametime for example, I would do a OnClientCommand when the player connects, which is just the client asking the server to respond. I'd then do something like sendServerCommand which goes to a OnServerCommand function, where it gets gametime moddata (presumable only from the server?) and returns it via triggering another function or something?
well, its not exactly cleaned up, but i isolated the code at any rate:
-- Client side:
--[[- Triggered by the OnTick Event.
Requests the ORGM.Settings table from the server.
This is only triggered on the first tick, it seems sendClientCommand will not
properly trigger OnGameStart (GameClient.bIngame is false?).
Removes itself from the event queue after.
Credits to Dr_Cox1911 for the OnTick trick in his CoxisReloadSync mod.
]]
Callbacks.requestSettings = function(ticks)
if ticks and ticks > 0 then return end
if isClient() then
ORGM.log(ORGM.INFO, "Requesting Settings from server")
sendClientCommand(getPlayer(), 'orgm', 'requestSettings', ORGM.Settings)
end
Events.OnTick.Remove(Callbacks.requestSettings)
end
CommandHandler.updateSettings = function(args)
if not Client.PreviousSettings then
Client.PreviousSettings = {}
for key, value in pairs(ORGM.Settings) do Client.PreviousSettings[key] = value end
end
for key, value in pairs(args) do
ORGM.log(ORGM.DEBUG, "Server Setting "..tostring(key).."="..tostring(value))
ORGM.Settings[key] = value
end
Events.OnMainMenuEnter.Remove(Callbacks.restoreSettings) -- functions to restore original settings
Events.OnMainMenuEnter.Add(Callbacks.restoreSettings)
end
Events.OnServerCommand.Add(Callbacks.serverCommand)
Events.OnTick.Add(Callbacks.requestSettings)
------ server side
CommandHandler.requestSettings = function(player, args)
ORGM.log(ORGM.INFO, "Sending Settings to ".. (player and player:getUsername() or ""))
sendServerCommand('orgm', 'updateSettings', ORGM.Settings)
end
Callbacks.clientCommand = function(module, command, player, args)
if not isServer() then return end
if module ~= "orgm" then return end
ORGM.log(ORGM.INFO, "Server got ClientCommand "..tostring(command))
if CommandHandler[command] then CommandHandler[command](player, args) end
end
Events.OnClientCommand.Add(Callbacks.clientCommand)
How could I Check if a mod is loaded to add compatibility without requiring the mod in question to be loaded?
ofc theres tables and such in there that are defined elsewhere
Of course, okay, and i just found the documentation for sendServerCommand and sendClientCommand which helps clarify it a bit
getActivatedMods():contains("SomeModID")
Thanks a million! I knew there was a way, I just couldn't find it
This makes pretty decent sense, okay thank you @quasi geode , I'll mess around with this for a while I should be able to get it to work..
theres alot of extra fluff in that code snippit you'll probably want to remove (or not) stuff for restoring client settings on leaving the server etc
Yeah I see that with the onmainmenuenter etc
I do what Fenris posted.
You should be able to parse a table over as a single argument - if you needed that space.
Hmm, alright, makes sense. Seems im on the right track then
I actually have to rewrite EHE a bit, as I'm kind of leveraging off the players lol. My suggestion would be to run an event on server start - then use the commands to pull from the server.
Yeah that sounds like a good idea, alright I'll do that
Gotta keep some server security in there lol
If I understand what process will be the event and variable have to be in \server\
Then when players connect or if the frequency is changed you send a servercommand which hits all connected players.
Yeah and then that will sync up all the player's frequencies to match, and I can also do that with the mission index so all the players share the same progress in the missions
all that data is already stored in \server\ so thats no problem
you could make use of the globalmodData
But I think you'd have to make sure it's the server's I think
I am using global mod data for a bunch of stuff already, but there are issues such as verifying it's the servers
Now I'm pretty good at breaking things but this error is a new one
Error [Redacted] I guess lol
Lmao what on earth did you do
I tried to add to a table that doesnt exist
I'm trying to add my worldsprite tile to the list of tiles that work as beds in true actions... but I can't seem to figure out the right method
is there a mod that lets me destroy cars?
does anyone know how to be able to find out which workshop mod needs to be updated instead of me unsubscribing and resubscribing manually 1 by 1?
it will tell you the mod id of the mod normally then you can figure out its name from your mods folder.
can someone explain why i have to verify every time i want to host a server
i play and as soon as i stop hosting the server i have to verify my files because it says version number different from server
where is the PZ mod folder located and how do I delete all mods to start fresh?
You guys should check this out: https://github.com/ssjshields/pz-toolbox
Report logs to the github issue when it doesn't fix the issues - then he can cover those bases
Will delete installation folders afaik, redownload mods throwing errors, etc
Any idea why I get an error receiveObjectModData: index=-1 is invalid x,y,z=12069,7147,0. ?
For what I understand for now, it come from player:transmitModData()
I can't see anywhere else where this error can come from
index = -1 doesn't seem good
how are you getting the data you're transmitting?
I use it at different place so not sure where it come from exactly
But I'm surprised, I don't use a number as index for the table I'm using
hard to give a meaningful answer without more information ๐
I know, but I really have no idea where it could come from ๐
well add prints etc to your mod, to pinpoint the code responsible for this message
It's append every update
what are you adding to the player modData?
The problem is that I can't check, it only seems to append online
A table TOC with other Tables and variables in it
what kind of variables? Only pure lua types are allowed, you can't transmit java objects for instance
Oooooooooooooooooooooo
That it
A variable is the item equip
That's why it doesn't save it in solo when I quit the game and relaunch it.
in that case you can just substitute the item with a table, add the relevant fields you need, and when getting back the data you just instantiate a new item using the fields in your table
I do that in my spear traps mod if you want to check
Yeah that's exactly what I was thinking, thx. I should be able to do this, I just need a float
Anyway I was just thinking of changing this system because I use the item only to bring out its water resistance value so just save the value itself gonna be beter
hey quick question, do I sound like an ass for refusing my mods getting shipped into modpacks? See my last comment
https://steamcommunity.com/sharedfiles/filedetails/?id=2659216714
Hey folks, I want to get started making 3d models and clothing for project zomboid, I am having a hard time finding the right documentation for that. What would be the best place to start looking? My apologies if this question got asked already
Oh nvm, I found a pinned message that might help me.
Hi is Ritas weapon mod broken rn? It didnt work on my multiplayer server
Yep, check pinned message and the #modeling channel, it's for modeling cloth and items
i think thats fair
oh lmao that same person asked me that as well
Lol no, you totaly right. And it's not like you can't make a pack of different mods and then share it (steam collection)
Do you mean the steam collections? Or repackaged modpacks?
Never mind I just read the thing, I agree with you
If there is already time speedup in multiplayer via sleeping, isn't there a way to piggyback on that mechanic and allow speedup in general?
Do we have any vscode intellisense for PZB? 
maybe ask in #modeling ?
@winter bolt @drifting ore @gilded hawk thanks for your feedback ๐
the multiplayer sleeping is mostly a hack, artificially decreasing fatigue of the character, but not sure how you could speed up the game otherwise, how would you account for the shifted time between different players?
Sleeping in multiplayer with the "Sleep allowed" option enabled speeds up time if every single player is sleeping.
It's what we use to get through dark nights and rainy days.
oh that kind of sleeping
Sleep as a requirement however is still disabled as sleep need is a pain in the ass.
I was thinking if there was a mod to take advantage of that we could have speed-up possible in multiplayer.
well not having to sleep in MP is kind of game-breaking to me. That doesn't feel realistic at all, and totally change the way you play, in a very bad way IMHO
If it doesn't already exist, a great work around for MP sleep might be something like "resting" where you can lay down on the ground and replenish all the stuff like you get from sleeping normally just at a faster rate?
As a mod, obviously
Sleep as a need by default is not enabled in MP
We didn't know that going in
But it was nice
@drifting ore what about https://steamcommunity.com/sharedfiles/filedetails/?id=2686624983
Unsure how that mod works functionally
@drifting ore it's artificially removing fatigue every in-game minute or so, making your night much shorter but you still have to sleep now and then, so it's keeping the same game mechanic as single player mode
so instead of waiting 30 minutes real-time or so, it only takes 1/2 minutes depending on your settings
Sounds about what I had in my head
Makes sense that other people had similar ideas
I haven't really messed around with MP at all yet
But I imagine for now a lot of hotfixes for stuff that MP breaks is going to be creative mods like that
indeed
if you don't want people redistributing your mods then you should maybe change from GPLv3
@tacit ermine I think you're missing my point
I don't think I did but feel free to elaborate
hey all, i'm having an issue with a firearm i made
for some reason it lacks a lot of stats and can't be equipped, as seen on the pictures
on the first picture, the m4 is basically a generic item more than a weapon, it lacks a lot of options the firearms on the second picture have
you cannot see but if i right click on the m4, it doesn't say "equip both hands" or anything similar
have you read my comment?
yes
Also i can't place the m4 like a weapon i can only drop it and it shows the icon on the ground
How do I add a new line in localization files? 
UI_EN = {
UI_trait_BritishFoodFan = "British Food fan",
UI_trait_BritishFoodFan_desc = "On consumption of food -90% on all food happines/sadness effects",
UI_trait_ItalianFoodEnjoyer = "Italian Food Enjoyer",
UI_trait_ItalianFoodEnjoyer_desc = "On consumption of food +100% Increase happiness on food with positive happiness\n\nAnd +50% Increase sadness on food with negative happiness",
I tried the \n\n\ but does not work
try <br>
it works, thanks
Is there any support on making custom creatures in the world yet?
@quasi geode You might be interested in knowing of a bug I noticed with ProfessionFrameworkB41Patch
I have 2 traits set on exclude each other
ProfessionFramework.addTrait('BritishFoodFan', {
icon = "trait_BritishFoodFan",
name = "UI_trait_BritishFoodFan",
description = "UI_trait_BritishFoodFan_desc",
exclude = { "ItalianFoodEnjoyer" },
cost = 1,
})
ProfessionFramework.addTrait('ItalianFoodEnjoyer', {
icon = "trait_ItalianFoodEnjoyer",
name = "UI_trait_ItalianFoodEnjoyer",
description = "UI_trait_ItalianFoodEnjoyer_desc",
exclude = { "BritishFoodFan" },
cost = -2,
})
When I do this and I select a trait, by adding and removing them I can clone them in the Available Traits view
I solved this by setting the exclude on only a single trait
bri'ish innit
I even added the nice icons
bri ish food being a positive
it's a joke mod, but I had a long discussion about food with a girl im dating in the UK and god the difference of food mindset is insane compared to my italian mindset
Yes, cause you can eat dog food without issues
๐ฌ๐ง On consumption of food -90% on all food happines/sadness effects
๐ฎ๐น On consumption of food +100% Increase happiness on food with positive happiness<br>And +50% Increase sadness on food with negative happiness
i eat raw pasta like nobodies business
About pasta im so fucking confused why even after cooking it I get negative happines, like wtf O.o
oh okay understood
I didn't even knew I can add accompanyments
With the italian traits dog food makes you instantly depressed
I wanted to make the traits cost 0 since it's more of a personal taste then anything else
but the brit trait is pretty damn good
Is Britas weapon mod just broken rn or just me?
DId you copied the script of a vanilla weapon to begin with for your own?
It might missing some important tags if you created a weapon entry from scratch
For example just copy the whole M14 and adjust it so it fits to your own weapon:
i just replaced the entire script with the one from the vanilla m16 and nothing changes
maybe it's the model ?
i'll re-export it as fbx
still nothing... weirdly enough when I quit the game and relaunch it, the item disappears
like it's not in my inventory
DROPKICK MOD
question what happens when map mods update?
hey everyone i was looking for a way to add make up at game start
so maybe i can make my tattoos selectable at char creation
try #mod_support
What mods are these?
You will know that soon, very very soon! :p
I'm trying to add a custom profession, so I just call ProfessionFactory.addProfession from OnGameBoot event. It works fine when you create your character from main menu, but when your character die and you click "New Character" my custom profession is missing. Any clue how to fix that?
hmm but you not really gameboot the 2nd time
Search in media\lua\client\OptionScreens\CoopCharacterCreation
There is a function that resets proffesions CoopCharacterCreation:newPlayerMouse()
@rocky lynx found a better way than what you propose but still it feels like a bug
but that means all mods that add professions probably have the same bug
interesting, but that ProfessionFrameworkB41Patch is a unofficial, unauthorized and incorrectly done patch, so any issues occurring from its use arent really my problem. However if you have it mutually exclusive on 1 trait, it automatically applies it to both. It follows how vanilla does it, so its very likely thats a vanilla bug
dont call .addProfession from OnGameBoot?
Thank you, I have noticed how the ProfessionFrameworkB41Patch now is marked as not needed.
So, thank you for the answer
OnGameBoot is one of the points the PF starts to add them into the ProfessionFactory, so its likely your events are going to run out of order
@quasi geode when would you call it?
just call it normally when the file is parsed.
evidence?
@left plank my bad, it was a different nick: https://cdn.discordapp.com/attachments/925810444071997540/931908185315500072/Capture.png
sadly its still needed because every single mod made is linked to it and switching creates all sorts of issues. people using different mods that need both versions will have issues. that 'patch' is a disaster the way he did it (reuploading the whole mod, instead of just making a actual patch.)
I don't see the name similarities
how is Gourge and Glocktopus the same word
well it seems my mind is playing trick on me, sorry about that :/
just the G and the o I guess
in the future please take a bitmore precaution before defaming someone like that lmao
just a big claim is all
@left plank I will, again I'm sorry
Oh okay, I did a test run with both my mods https://steamcommunity.com/sharedfiles/filedetails/?id=2706575700 and https://steamcommunity.com/sharedfiles/filedetails/?id=2720124932
And it seems to work right now, events are fired correctly and the points are applied correctly
I hope this information helps
@left plank should I delete my message about it?
Sure
if both PF versions are running at the same time, one is going to override the other, and probably double up on the even calling...if one loads a mod adds profs and traits, then the second PF loads it will probably remove all the custom profs already added...if that unofficial patch takes precedence then new features such as clothing and spawn points wont work
probably for the best
done
Oh, damn that's really bad
Is there no such thing as a load order in zomboid? So that you can ensure the PF loads after PFb41p?
no it just loads everything and then execute the code
@quasi geode that doesn't address my issue ๐
its annoying i'm probably going to have to add extra code to handle this stupid unofficial patch. whole thing could have been avoided if instead of uploading the whole damn mod he just uploaded a single file with ProfessionFramework.Traits.Hypercondriac2 = nil
respawning a new character? in solo or mp?
eh i just tested in solo, died and clicked new character my profs and traits are there
hmmm is Lua reloaded when you die? ๐ค
because clicking NEW CHARACTER will call ProfessionFactory.Reset()
no, it doesnt need to. PF overrides the function vanilla uses to define the default professions
you must be doing something else
that's what I call doing something else ๐
so I guess I did the same, I just hooked BaseGameCharacterDetails.DoProfessions
i really should have named the mod better. apparently i misread this initial message since i was typing a reply to Mx about the profession framework issue and I'm still working on my morning coffee here
ProfessionFactory != ProfessionFramework
haha โค๏ธ
๐คฆโโ๏ธ
@quasi geode enjoy your coffee! ๐
Is there an id for each player? Which changes only on death and stays the same when the server restarts?
@quasi geode also in my case creating the job directly from global context would not work because my job has a custom trait that needs to be mutually exclusive with all other traits. But the traits list is empty when you do it from global context
do you need it to change on death?
No I would prefer not
I found getSteamID(), should work
But it only works on steam, it sucks
@drifting ore yeah I was going to suggest using getCurrentSteamID
@drifting ore what about using the player username?
But the username can change during the game no ? @weary matrix
so i have been looking a bit around some mods and the mod api. im not finding what i am looking for. how would someone go about to make a mod so that when you press a key it will make a sound ?
function onKeyPressed(key)
if key = KEY_0 then getPlayer():getEmitter():playSound("My_sound") end
end
Events.OnKeyPressed.Add(onKeyPressed)
Here's some code I have used for something similar Looks like you're good ๐
function KeyTest(keyPressed)
print("KEY PRESS" .. tostring(keyPressed))
end
Events.OnKeyPressed.Add(KeyTest)
Oh here's a an image with all the key codes as well
ah thanks
ill try again
hmm . is there some sort of debug tools ?
it says error 1 when i boot up the game
im pressing the right key but no sound is playing
hmm error 1 is not that descriptive
ok found the debug mod, the console does not show anything when i press the button so either the mod is not loading right or the key is not being read right
Did you add the mod to the save ?
jupp
@dreamy linden how you integrations with controller with your mod? ^^
what?
i edit the misstyped word
i still dont understand, sorry
you make some custome keys option into your mod right ?
im trying to use the F key to activate the sound yes
and how would people there playing the game with a controller be able to use the f key ? ^^
they have like a joystick ^^
well they would press it
oooh
ye. it does not even work with a keyboard soo
one step at the time
no controller support yet
fair ^^
@weary matrix also will work on the code now and send you the git link after..
can it?
I don't know but there is a setUsername() so I'm a bit worry
can anyone made a stone/concrete oven ? or let build an old oven
how does the game calculate which body parts are hit ?
@drifting ore isn't this different from the username you use when logging to the server?
@weary matrix What do you mean ?
The name you choose at the right with a password to connect ?
hmm. still not working
yes
not sure you can change that while in-game
Mmmm so what setUsername() do ?
well this is not helpful at all lol
Keyboard contains a bunch of constants
i just need the right number for the key tho :\
Javadoc Project Zomboid Modding API declaration: package: org.lwjglx.input, class: Keyboard
also love when you join a server where multiple mods use the same key :p
oooh the zombiod java docs... im an idiot
i.e.
if keyPressed == Keyboard.KEY_F1 then
...
end
not the onketpressed?
?
2 sec here is my code so far. ignore the sound name
if (key == KEY_F) then getPlayer():getEmitter():playSound("mods/fartMod/media/sound/poo3.mp3") end
end
Events.OnKeyPressed.Add(onKeyPressed);
just make that Keyboard.KEY_F
๐
It sounds to me like the issue isn't with the code itself, but that the file might now be loading?
is the code ever ran at all?
its an regular mp3 file
dont know
put print(key) in it
this is my first pz mod
Hey guys. Just questio. Is there any mod that allow you to crouch and lie down/crawl? I already have true actions on server and AuthenticAnimations are not suitable. Any help appreciated. Thx
or print("key is " .. key) so you can easily search for it
Your code is in a .lua file, right?
print("FART CODE LOADING!")
function onKeyPressed(key)
print("Key is pressed " .. tostring(key))
if (key == KEY_F) then getPlayer():getEmitter():playSound("mods/fartMod/media/sound/poo3.mp3") end
end
Events.OnKeyPressed.Add(onKeyPressed);
print("FART CODE LOADED!")
ye
But put some print statements like my example in the code, and then in console.txt it can help evaluate if the file is loading or the code is running etc?
will do
Good luck and thank you for your service.... ....farting mod guy.
lol
ok so in the consode it says its loading the mod but there is nothing being printed in the console.txt file from the print lines
strange
LOG : Mod , 1642270421055> loading fartMod
what's inside your mod folder?
It sounds like either your file isn't in the right location in the mod folder, or there's an error with it's formatting that is preventing the file from loading?
and what's the path to your script within that?
and you've went in-game with the mod enabled, not just on the main menu?
Need some help finding the lua for stuff like meds to base custom meds off, can't find where the code is, if it is even in the PZ directory
are custom passive skills fixed yet? last I checked if you marked a skill as passive with the system indiestone set up, it will still start at 0 like every other skill.
ok so it seems to be printing the print("Key is pressed " .. tostring(key)) in the ingame console with the key number but not the line above it.
Okay, not such a big deal, I think the messages will be higher up in the console.txt, but you know that your code is working to some degree? ๐
The next step is making a sound script for your sound.
This is a file in the vanilla media/scripts directory
does it need that if it should only play that one sound ?
Try changing your code to
if (key == KEY_F) then getPlayer():getEmitter():playSound("GainExperienceLevel") end
and see if that works for you?
I'm not sure if it's always necessary, but all things considered, it's for the best to set up scripts for any custom sounds you have in a mod?
changing the line to
if (key == 33) then getPlayer():getEmitter():playSound("mods/fartMod/media/sound/poo3.mp3") end
```made it print this
There you go ๐
now i just need to figure out why that path is wrong
Okay, also, even if the sound works without a script, it will still send a WARN: message to the console about adding new one?
Which would be no big deal, but people will contact you to report that as a bug?
A lot of these sort of "This part of the mod actually works but still generates a warn message" console messages pop up in tech and mod support, when they're unrelated to people's issues?
Not sure if mp3 works or not, but this is how I format my scripts for .ogg files?
sound Scissors
{
category = Player,
clip
{
file = media/sound/Scissors.ogg,
}
}
But this might work, if mp3s work with PZ?
sound poo3
{
category = Player,
clip
{
file = media/sound/poo3.mp3,
}
}
it still wants an fmod event for it
where do you save that?
in the scripts folder?
Yeah, and it needs to be formatted like the other sctipts .txt files
module Base
{
sound Scissors
{
category = Player,
clip
{
file = media/sound/Scissors.ogg,
}
}
}
an exemple of on of my mod
module base {
sound Cut_sound {
category = TOC,
loop = true,
is3D = true,
clip {
file = media/sound/Cut_sound.ogg,
distanceMax = 3,
volume = 1.0,
}
}
}
sound poo3
{
category = Player,
clip
{
file = media/sound/poo3.wav,
}
}
}```
and i saved that as sounds_player.txt in the scripts folder
Change the file name so it's not the same as a vanilla file name, it can be anything. within reason, but it's no good to have the same names as vanilla files.
ah
Hey guys. Just question. Is there any mod that allow you to crouch and lie down/crawl? I already have true actions on server and AuthenticAnimations are not suitable. Any help appreciated. Thx
hmm
And after the scipts are set up, try
if (key == KEY_F) then getPlayer():getEmitter():playSound("poo3") end
-- or if that doesn't work
if (key == KEY_F) then getPlayer():playSound("poo3") end
You're getting there, it's just the formatting now ๐
Right on!
ok now the next one would be to clean it up then to make it so that it shuffle between a set of random fart sounds
Okay, random sounds, gimme 1 second
This is the vanilla formatting for having one random sound, from a selection, play with a sound with a script is played.
sound FemaleZombieCombined
{
category = Zombie,
clip
{
event = Zombie/Voice/FemaleA,
}
clip
{
event = Zombie/Voice/FemaleB,
}
clip
{
event = Zombie/Voice/FemaleC,
}
}
ah so you just call the FemaleZombieCombined and it will pull one from the list `?
It should. So the same sort of formatting, but instead of event = Zombie/Voice/FemaleA you have file = media/sound/poo3.wav etc?
Yeah, no problem ๐
does this mod work in multiplayer btw?
or do you have to do other stuff for that to work ?
My mod get a lot of that error and I can't get why:
LOG : General , 1642272503421> 525โฏ797โฏ995> receiveObjectModData: index=-1 is invalid x,y,z=8535,11256,0
An idea ? All mu modData is float and bool
Hi there! I am currently trying to figure out how the "require" command in lua works and how to use it to overwrite specific functions from the vanilla code. More precisely, I have a code for a mod which should overwrite several functions from the vanilla file "CharacterCreationMain.lua" (located in the vanilla directory /media/lua/client/OptionScreens). If I just add the command 'require "CharacterCreationMain" ' to the top of my code, it doesn't work and produces an error. However, if I replace my mod lua-file and with a copy of the whole CharacterCreationMain.lua where I replaced the specific functions which I'd like to overwrite, everything works fine. Any ideas what I am doing wrong?
require "OptionScreens/CharacterCreationMain"
ok. thanks! is it in any way relevant where my mod lua file is located? i currently have it in Zomboid/mods/[MyNewMod]/media/lua/client/OptionScreens.
It shouldn't be? But I like doing it the same way, where I have stuff organized so my mod files are in the same directory as the vanilla files they references/overwrite/use/etc?
Or in a subdirectory of the vanilla directory.
hmm... ok.... so, require "OptionScreens/CharacterCreationMain" still doesn't work for me....
maybe it is a problem that there is another vanilla lua which refers to CharacterCreationMain.lua? in vanilla, the files CharacterCreationMain.lua and CharacterCreationHeader.lua are both in lua/client/OptionScreens and both luas contain references to each other? might this be causing problems?
I've never had any problems with multiple requires/references, but in theory if you set something up where two files required each other I could see that causing problems?
for the naming conventions in my modded lua file: how do i name the fucntions i want to overwrite? say i want to overwrite the function "CharacterCreationMain:create()" from the vanilla lua, do i have to declare the new function (in the new lua) as "function CharacterCreationMain:create()" or simply as "function create()"? currently using the first variant.
Just saw that the errors are probably due to the fact that I messed up some stuff in my code. With a simplified version, I was able to run everything without errors exactly in the way as Blair Algol suggested. Thanks for that!
how is it again to get the loot to spawn in crates again ?
for the stuff about overwriting vanilla functions and using "require"... again found out that all this seems not to work as easy as it should. it somehow seems to depend on the function. for example, I tried to "overwrite" the function CharacterCreationMain:createChestTypeBtn() by simply copying its vanilla code to a new lua file in my mod and still get an error although i did not change anything on the code.... could it be that there is some extra stuff you need take care of when overwriting vanilla functions and that simply putting a "require "[vanilla lua code]" in the header is not always sufficient?
code example ?
anyone managed to spawn bots? They'd help me debug stuff ^^
(like, honestly. not even pretinding.)
if that's not possible, whats the easiest way of spawning more than one process of the game to test mp mods?
give me a few minutes; i'll make one...
Any way to change 1 item property without copy-paste whole item? Like only MinDamage for weapon.
Maybe with lua?
require is mostly redundant in pz files. its use it lua is:
- to load a file that many not normally be loaded (pz is going to load all lua files anyways, so this reason is not needed)
- to ensure a file is loaded before the rest of the file doing the require (this is sometimes useful, but vanilla pz files will load before your mod one anyways, so also not needed)
- to catch a return value from the file being required (vanilla pz files dont generally return values. tables they create like
CharacterCreationMainget placed in the global namespace, no need to require to access them)
aslong you dont use dofile over require then im happy ^^
i dont use either when accessing vanilla files lol....i may use require on my mod files, as those are probably going to return a local table instead of global namespace pollution
that true. and also mod files you dont know which order they load into the game either
biker bois
they load in alphabetical order
load order of mod files is easy to predict without require
here is my code:
ohhh... might it be necessary to include local variables? the original file has two defined via "local FONT_HGT_SMALL = getTextManager():getFontHeight(UIFont.Small)" and "local FONT_HGT_MEDIUM = getTextManager():getFontHeight(UIFont.Medium)".
uh ya if your accessing those variable in your code
Ahhh!! this also seems to solve the issue!
yes, the code i copied used them
so, let's hope that all the local variables are defined in the head of the vanilla file. otherwise it will get messy since the CharacterCreationMain is quite long and i have to overwrite a lot of stuff from it...
you are also working on tattoos right now?
or is this already somehow part of vanilla right now? looks decent!
yep iam working on it
its already out there
not bad! i am currently working on a user interface which includes additional character customization. selecting tattoos is also planned.
oh i was gonna do that already XD
it detects the custom locations i made
we could work it together if you want
omg! we probably have similar ideas right now!
i did it in a way such that the tattoos are not displayed in the clothing section and i am currently polishing the code for that screen a bit. but it is already fully functionable.
although i don't have any good tattoo skins yet...
this is my mod already out there we can make it bigger
your tattoos look really good! depending on the body location, that's not so easy in my experience. you need to be very careful about that and have a good understanding of how the texture pngs are "wrapped around" the 3d character models.
bruh i think there a mess
i got a ref extracted from blender
besides the transparency adds some halo to them that make it look like they have white outline
makes me go crazy
also the mapping is a mess
tbh if i get to make a new model ill do it
with better mapping
using blender for it is probably much better instead of just using the texture pngs. but has probably a high workload
i do check textures on blender tho i use photoshop for editing got collage license
but i use maya for modeling cuz i have a problem extracting fbx
GIMP is also quite nice for the editing process...
i used it for cs 1.6 back at a time when i didn't own PS
but its good
but i am a linux user. so gimp is probably the only really good option i have... ๐
good ol days XD
as long its pngs who cares
๐
idk if it can use SVGs tho
vector graphics
would make it look much better
i read it XD
that's a nice idea! although the mod i am working on will not only include tattoos (and i am not sure i'll ever be able to finish it ๐ ). even in case we keep our mods separate, in case you like the customisation screen from my screenshot, feel free to use it for your mod. i am always happy to share the stuff i did. ๐
ya... i just reacted to your wrong message XD
wanted to react to your "we could work together..." and not the other line
besides competition is gonna be fun
๐
i am also welling to provide help in regards of your mod if you need

thank you!
ya.... i am not into competiion stuff... i'd just like to make mods out of a "good" idea which might add something nice to the game. ... and modding is a nice way to beat time during the pandemic. ๐
we should take this to Dms
Dms?
Question about the sandbox-options.txt
Mods can add this file to add configurable values they show up in the sandbox configuration for Solo and in the admin panel on a server setup.
But in a server if you want to configure this values befor the server starting for the first time where you add the values? in the SandboxBars? what is the format?
ModName {
prop = value,
}
thats for server cause SP is just
ModName.prop = value
which maybe does the same thing idk
any clue how to detect first time connection to server?
Maybe save the players username into a file to compare if that player ever connected before
otherwise seriously have no idea. I would have expected OnConnect etc to work but havent got any luck.
dont know if you can do it but you could see if the user exists in database ?
last one done
thought about that but how I would check the database from Lua?
can you watch it off with water?
Wouldn't you want to check if its a new character rather than on startup?
no
its perament
unless you peal it off with acid
No I really need to detect first time connection. On first connection I should not offer the possibility to choose the job my mod is adding
Ah I have no clue then
What job is it that you're adding?
a "Returned" job, so that when you die, if you select that job, it will respawn your character perk levels, boosts etc
if you don't select the job then you just start a new character as usual
very primitive way but works
Damn that sounds like a kinda cool concept
and it's persistent! It's attached to your steam ID on the server
That would be great for servers, especially considering the amount of time you have to spend reading books because you can't fast forward
this sounds interesting
but wouldn't that put the game out of balance ?
It's more of an alternate playstyle imo
It's not something you would use for every playthrough, but it would be a neat option for casual players or those who are learning the game still, it would also be on my modslist if I played mp
isnt that just like the mod there force you to write a journal ? ^^
guess it's similar except you don't need to write a journal ๐
the guy who wanted the mod tried many and none were good enough to him
well not really my problem. someone paid for this mod so...
This seems less clunky
Damn, that's pretty sweet
๐
gj man
thx
the "Skill Recovery Journal" ^^ kek
wow you get money for making mods damn
lololol
well it's not that much, but I don;t really need the money anyway, it's still fun to do
was someone ask for a mod and wanted to pay in steam card yester day it was a modeling person who didnt knew how to code so yea sometime people do buy/hire for an extra feature in your mod ^^ but rare after my knowlagde might be wrong
๐ค
howdy. This is not a request for help with modding as much as it is in understanding an already existing mod
I got fed up with the fucking zupeprcarts mod not having comments nor a discussion page explaining where we are supposed to find them. After several games without finding one, I decided to look into the files.
The image above seems to determine the rarity, as well as the loot tables where these items are supposed to appear.
First, I'd like to understand the numbers. I'd guess the numbers on every second row determine the rarity. I'd like to understand what does a value of one mean. What does that rarity stand for
second, would be understandig the locations. I always start in rosewood. According to the wiki, the supermarket there is part of the gigamart chain, but I can't find a single cart or trolley even with abundant survival gear loot setting (according to another file, this item is survival gear)
is there a flat map I can load to avoid loading times when testing mods ?
*not avoid, lower
if I'm not mistaken, 1 means 1/100 chance of spawning the item for any given container
Was just about to say I found a forum post that says the same
well, that sounds like bs. The zombie apocalypse has just started and everybody went there to get carts and trolleys AND I can't find a single cart left in the world among all the zombies I killed? Even my ass smells better than these odds
Most grateful. Guess I just need to change those settings then
try to set it to 50 or 100 for testing
and lootspawn to extreamly high aswell ^^
Sounds like good odds. If it works, I may just set it to 100/75. I mean, besides the supermarket at rosewood, which other locations indicated on that code do I have? There aren't any tool stores, I believe
btw, how do these chances work with loot rarity multiplier?
Rather than being for particular locations, I think those are loot tables which are used in various locations. I wouldn't know what they correspond to, though
well, according to the wiki, the gigamart one is quivalent to the big chain supermarket. It has the image of rosewood's one
The others, I got no idea. The janitor thing may be those shelves with cleaning materials, I suppose
yup, that's what I was afraid of ๐ boo, I'll try probing, maybe I can get it to output something useful, thank you very much!
alright, it's confirmed then
The issue with this mod is that the trolleys and carts are set to spawn at a rate of 0.5 to 1%
since the supermarket at rosewood doesn't seem to have a gigamart tools shelf, I'd be fucked. Would just have to keep checking all janitor shelvces in the hopes of getting a trolley, like the 1/200 chance that happened to me before
and since you can't find them spawned in the world nor inside zombies, that makes it all the worse
so, I either bumb everything to 100 and end up with way too many useless trolleys and carts unless I learn enough to make it compatible with a recycling mod (and also get 3 troleys inside each janitor's shelf) or soemhow learn how to add them as a spawnable item inside zombies
on my last playthrough with 0.4 population, I had to kill over 200 zombies before I was fucked by the respawn because I didn't know which were the bounds of a cell. 1/200 chance would be more than enough
I guess this is too much of a bother, but I suppose none here would be able to teach me how to add the troleys/carts to the loot tables of paw loot?
or if possible, give me a link for the game's loot tables and what they handle. These items having a chance of spawning at tool sheds and so would balance it a bit
Guys i'm trying to make Russian translation file with notepad++ but when i change the encoding to window-1257 it keep turning back to utf-8
am i missing something
go to prefs>new document and disable apply to open documents
had same problem when i made translations for my mod
@lapis stump so this checkbox unchecked
yep thats what I did i found the issue on a github page
hm yep same issue as you maybe my translation is still broken
When i open a RU file from the game encoding is ok, but when i make that file myself it just revert lol
ok so there is this setting here too
yo. so, it's late here and I'm gonna sleep soon, but I was just wondering: from what I udnerstand of coding, seems like you need to indicate an item from the game for a mod where you use it. I wonder, if I wanna use an item from another mod, what is the hange done to the path? May I request somebody to post the structure of such path, please?
btw, does itemzed still work for this game's version?
I set encoding to UTF-8 BOM saved then switched to window-949 encoding and saved it and its still windows 949 encoding nvm just set encoding and close notepad++ completely encoding is still there after opening
is there a way to modify a vanilla trait multiplier for a character that already has it?
Tweaking model sizes in-game one at a time almost makes you wish for a zombie apocalypse. ๐
any clue why this is not giving the player 50 XP for fishing, but rather like 12.5?
getPlayer():getXp():AddXP(PerkFactory.getPerkFromName("Fishing"), 50)```
guess I need a multiplier but not sure where to find it
do you mean perk multiplier?
I think so, I'm new to PZ. I'm a SW dev, but I'm trying to figure out how much work this is going to be :)
I guess you could add a multipler for the perl to the player directly?
so if I have an existing char on a MP server, and I want that trait's perk or penalty to be slightly more or less, I"m trying to figure that out
it uses the XP multiplier
you can use AddXPNoMultiplier(perk, xp) instead
thanks. I'm going to try to play around with this a bit. just getting started.
same thing, it only adds 12.5 instead of 50:
getPlayer():getXp():AddXPNoMultiplier(PerkFactory.getPerkFromName("Foraging"), 50.0)```
sandbox options XP multiplier?
apocalypse
hm
if ((Integer)var13.getValue() == 0 && !this.isSkillExcludedFromSpeedReduction((PerkFactory.Perk)var13.getKey())) {
var10 *= 0.25F;
}
is what causes it
var13 is an entry from the XP boost map
I don't really understand why that code's there
well if I add a x4 multiplier it gives the correct value but...
works for level1, 2 and 3 at least
if the XP boost has a multiplier of 0 and the skill isn't excluded from speed reduction, reduce the XP value to a 1/4th?
that seems quite arbitrary
it looks like it needs to have an XP boost entry with a value of 1 and then it'll use the full value
hmm
} else if ((Integer)var13.getValue() == 1) {
var10 = (float)((double)var10 * 1.0D);
}
unless of course it's sprinting, where 1 really means 1.25...
} else if ((Integer)var13.getValue() == 1 && var13.getKey() == PerkFactory.Perks.Sprinting) {
var10 = (float)((double)var10 * 1.25D);
}
hmm so should I try to set the multiplier in the hashmap returned by getMultiplierMap()?
those entries are from getXPBoostMap()
addXpMultiplierโ is for adding perk boost (like when you read books)
which is similar I suppose, but for professions
maybe that'll work, I don't really understand why this code is the way it is
I'm tempted to just add a x4 multiplier, would probably be ok in my case since I do it only for a fresh character
hmm in fact only problem is for the extra xp you have for current level
guess I should just drop it and problem solved
otherwise I can simply use setXPToLevel()
iv made a mod that makes some changes to base items not replaces just changes / new items was wondering if anyone good at making item mods could dm me and would take a look at it to make sure its all good and help with making a small fix to one part of it..
iv tested it in SP and i dont get any errors but would like a fresh pair of eyes to ๐
Does anyone know about a mod that makes look even rarer? I tried playing on extremely rare but I still keep coming across large amounts of items/food
Any mods that allow players to lock built doors? (other than the front and back doors of a home? Can't find one on the workshop). Thanks in advance
hi there! does anyone knows whether there is a command to color clothing items even "AllowRandomTint" option in their .xml file is set to false? if it is set to true, coloring can be done via item:getVisual():setTint(color) but if it is set to false, this command seems to have no effect.
I wonder how expensive it would be on cpu time to look at every tile in a loaded cell at a particular time of day and check if it has a type (gravel) and a tree, and if so remove the tree...
does anyone knows where this error can come from: attempted index: setTint of non-table: null. found this in the console.txt. seems to be related to some code: local myColor = ImmutableColor.new(1, 0, 0, 1)
if myColor then
item:getVisual():setTint(myColor)
end
at least the console says the error occurs at the line with the command item:getVisual():setTint(myColor).
what is really strange here is that the error occurs only sometimes. can run the game without any errors for 5 times and then, if try to enable the mod in question for the 6th times, it produces the error and breacks.
for context, i am currently trying to mod the interface in the character customisation screen. thereby working with the code from CharacterCreationMain.lua and CharacterCreationHeader.lua (both in lua/client/OptionScreens).
what really makes me crazy is that exactly the same code i made sometimes works and sometimes not. seems like random to me....
The error means that the result of item:getVisual() was null. Couldn't tell you why, but verifying that the result is a table should help avoid it
Which you can do using the type function
type(someVariable)
If it's a table, the result would be 'table', but zomboid may use the 'userdata' type, dunno. Either way, you could debug it by printing the value of item:getVisual() & type(item:getVisual()) and seeing what's happening
how can i print this?
print(...) where ... = one of those expressions, or both separated by a comma (presumably, at least. I'm not a modder, just assuming based on Lua knowledge that hopefully mostly applies)
Anyone know if there's a writing animation?
so, could i just put print(...) in the right place in my code and then it will be printed if i start project zomboid? and where will it be printed to?
You'll see it in console.txt
ok. i'll try. thanks!
To be clear, the ... was a placeholder which should be replaced by an expression
yes. understand that! ๐
Okeydoke, just making sure ๐ have fun
thx!
it doesnt use userdata. if i remember right type will return the name of the java class
So, the type function is overridden somewhere? And/or it's a table with a metatable (can't remember if there's a magic method for overriding that)? Interesting
ah well its not standard lua, its kahlua. the interpreter is written completely in java
so it does break some of the standard rules
Huh, I'll need to do some research to know what the heck is happening in kahlua
Thank you again, wise wolf ๐
you can do tostring() to safely print stuff that can't be concated.
you'd end up with tablex12335 etc but you'd know it's atleast a table
userdata simply mean it's a java object
cannot find any printed output in my consol.txt....
i'm sorry, apparently i was wrong. it is indeed returning userdata
print("type is " .. type(getScriptManager()))
LOG : General , 1642309466871> type is userdata
could have sworn it didnt, but its been years since i checked and i'm going senile in my old age lol
No worries, good to know either way. Although considering the above error was "null" rather than "nil", I wonder if the null type would also be userdata (i.e., is it java null rather than Lua nil)
But the errors are still there?
naw that one it will autoconvert java's null and lua's nil
That's a relief, seems like it'd be a headache otherwise
Look at how to kick a player, then check when that player connect, if it part of a custom ban list, kick it.
Server can save text file, you can load that file when server start. Make yourself some UI to add remove player from the list.
i just try to reproduce but takes a while. as i said before, the error occurs sometimes, sometimes not...
Did you add prints around any code that's guaranteed to execute? Idk why they wouldn't show up if so
But then again I only assumed prints would be added to console.txt along with other output; I could be totally off ๐
object try to call nil mean, you are trying to call a function that doesn't exist, maybe you have the wrong object or the method is not exposed or properly called.
the main error seems to be in line 1305 in myCharacterCreation.lua. that's where i've included the line "print(type(item:getVisual()))"
what is item ? how\where do you get that item
I assume the one after "HERE COMES OUTPUT" is the actual value? If so, that means item:getVisual() did return nil
Again, dunno why, but you could check for nil & handle that case
it didnt return nil, it threw an error (i think)
The call after it caused the error, I believe (see 1931 in the log)
HERE COMES OUTPUT was just some additional text i included so i can find easier. the relevant printed output is the stuff in the lines below
print("HERE COMES OUTPUT");
print(type(item:getVisual())) -- throws
yes!
again do you have a snippet to understand what item is
There's a nil on the line after that output, though
and before: print("HERE COMES OUTPUT");
print(item:getVisual())
oh
I think seeing a snippet would def be helpful like Konijima is saying
xD yeah
it looks like it fired twice once returning the nil...then a second time which threw
item is local variable and i defined it via
local item = InventoryItemFactory.CreateItem(itemType)
a few line before
whatever was in item that seccond time had no :getVisual() method
If the code is the same as it was way above, setTint is being called on the result of getVisual
item:getVisual():setTint(...)
here is the code which produces the error:
Ah, or getVisual is misspelled the second time
that would do it XD
if've used similar constructions over and over again in my code and it always worked flawlessly. just in this case
maybe also store the visual and check if its nil
local visual = item:getVisual();
if visual then
end
i'll try!
is there anyway to modify infection rate on mp server?
many thanks! did 10 tests so far and not a single error. hope that it will stay that way.
Did the visual change (or at least what you try to achieve works) ?
seems so. up to now, i didn't get an error. problem is that before, the error seemed to occur randomly. i enabled and loaded the mod 5 times and every thing worked fine and then, for the 6th time i got an error during the mod loading which crashed the game. and all that with exactly the same code! really do not understand how that could have happened...
Well i saw you use the ZombRand() and it would most likely be that. also if its a lua table it start from 1 not 0.
also had that suspicion but i did not really understand what exactly can go wrong in my case...
Is there a recipe line that excludes your favorited items?
so, what exatly is this "item:getVisual()". i think it should be sth like the color of a clothing item...?
ZombRand(0, #items)+1
if you have 5 item and ZombRand return 5 then you try to access 6 which doesn't exist.
But again you check under in a condition so that should really be that.
also ZombRand always confuse me with the last number being inclusive or exclusive
last number is excluded in zombrand
getVisual() return the ItemVisual instance of that object.
public final class ItemVisual extends BaseVisual {
yeah... but i think the code checks this by "if item then" ....
yeah its excluded then you are ok
but maybe that should be if its excluded
ZombRand(1, #items+1)
otherwise the last index would never get called
so if there is 5 items, giving 5 as last param would return max 4
hmmm.... so i copied that part from the vanilla code and it should therefore be fine as it is i guess....
ok nevermind im just mixed up
lol
thats not the problem anyway
so you ask what is getVisual() it returns the ItemVisual instance of the item.
which contains those properties.
if you have access to the java source code you can browse all its functions
btw, what this function does is the following: if you hit the random button in the character customisation screen, your character gets a random outfit and the above function (which i modified a bit) is exactly the function which is responsible for that
omg.... ๐
so, the case where my problems occurs is when the getVisual() is applied to new items i created. they are just clothing items but grouped under new "bodylocations" i created for them...
Oh crud has anyone gotten to me in regards to requests for mods?
but since they are clothing items with proper bodylocations, the should have Visual instances
Made a Quick guide to myself on How to Add custom XP and the Perks name and thought I'd share it here if anyone needs it
(I have no idea how it works tough
, I just know that THIS way worked for me)
does anyone know how to make the spawn points appear on a dedicated server keep spawning in single city
https://steamcommunity.com/sharedfiles/filedetails/?id=2721179072
Awesome new mod highly recommend to all server owners/admins !
Thanks @thin hornet !
Hi guys maybe you can help me with a problem I am trying to spawn an item on the player inventory
player:getInventory():AddItem(item);
seems it does not work. no error either
player is an IsoPlayer
what is item equal to
I think the problem is that I am doing so in the OnPlayerDeath event and it might be to late for spawning in the player invetory
string or InventoryItem
local item = InventoryItemFactory.CreateItem('Token.DeathToken');
ah
I want to spawn it the dead player inventory when he dies
but seems the game engine does not like that
any idea?
not sure but onDeath is called from the isoplayer so it should still be an IsoPlayer at that moment, but could be a corpse too.
if I replace the add item line with this it works
player:getSquare():AddWorldInventoryItem(item, 0,0,0);
how do I use an emitter
it spawns in the ground
so player:getSquare resolves fine
the weird thing is that the other one does not raise any error
so may be some short of race condition
@potent root
it's technically still a player at that moment but im probably wrong
trying to find the moment it become a corpse
sound emitter?
that is intereesting that means the AddItem call is somehow not working
I kinda wanna try making my first "mod" that would just change up the sound of the alarm on the digital alarm watch. Would anyone have any recommendations on where i could learn to do that?
@lunar abyss sorry I do n ot have any experience with emitters
well if the corpse is created first then what you add to isoplayer inventory doesnt matter as it will be removed anyway. Well Im just suposing.
that makes sense
Yes
but interestingly in the code you pastes it drops hand items right before calling the event
that makes me think the corpse may not be created yet
What kind of sound you need to play?
A sound in the world space or a sound emitting from a character or a UI sound or ...?
A sound emitting from a character
... for now
But I also intend on gettin playable instruments working again
I have a bunch of voice acting that a couple people did
It allowed the player to talk or make taunts with a voice
But now it's rather obsolete
local audio = 0; -- playSound will return a number so we store here to stop later
local character = getPlayer(); -- get the current player
-- Play the sound from the character
audio = character:getEmitter():playSound("MySoundName");
-- Stop the sound
if audio ~= 0 and character:getEmitter():isPlaying(audio) then
character:stopOrTriggerSound(audio);
end
in scripts/mysounds.txt
module Base {
sound MySoundName
{
category = Voice, loop = false, is3D = true,
clip { file = media/sound/MySoundName.ogg, distanceMax = 10, volume = 1.0, }
}
}
Anyone have an idea how exactly does an items "status" change it's use? (ex: an item is favorited so it can't be dropped, or a tshirt is equipped and wont be included in the Rip clothes). Is there a function for it as i haven't seen any in the vanilla scripts.
where can i find the code for the search mode/foraging item chance?
C:\Program Files (x86)\Steam\steamapps\common\ProjectZomboid\media\lua\shared\Foraging
thankies again
item:isFavorite()
item:isEquipped()
im assuming months is which month it will appear, bonus month is when there will be more, and malus month is less of it? in the foraging code
--[[--======== getMonthBonus ========--
@param _itemDef - itemDef
@param _month - (optional) month to check
Returns month bonus total for itemDef as percent
]]--```
huh
return a percentage
what does that mean?
it loop through the item definition and get the bonus value and the malus value based on the current month, then it add them together and divide it by 100 to return the bonus in a percentage format.
anothing place you can see the usage of getMonthBonus
when it populate the loot table
nah I tried three different versions of addItem and none seem to work I think the corpse may be there already
try just printing in in the OnPlayerDeath event and check in debug mode you should see a print about a BecomeCorpse
if it show before or after your own log
public void becomeCorpse() {
if (Core.bDebug) {
DebugLog.log(DebugType.Death, String.format("%s.BecomeCorpse id=%d", this.getClass().getSimpleName(), this.getOnlineID()));
}
this.Kill(this.getAttackedBy());
this.setOnDeathDone(true);
}
Repurpose them into a survivor NPC mod
So you just have NPCs screaming taunts at you as they shoot you
No I want it to be a vocalizer
months --months when the item can be found
bonusMonths --months when the item is more common (must be in months)
malusMonths --months when the item is less common (must be in months)
ah, thats what i thought too, but i wasnt that sure, now i know for sure
and months are like so { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }

xD
this is the stack
at zombie.characters.IsoPlayer.OnDeath(IsoPlayer.java:7753)
at zombie.characters.IsoGameCharacter.DoDeath(IsoGameCharacter.java:1501)
at zombie.characters.IsoGameCharacter.DoDeath(IsoGameCharacter.java:1495)
at zombie.characters.IsoPlayer.Kill(IsoPlayer.java:9630)
at zombie.characters.IsoGameCharacter.becomeCorpse(IsoGameCharacter.java:16435)
at zombie.characters.IsoPlayer.becomeCorpse(IsoPlayer.java:9647)
at zombie.ai.states.PlayerOnGroundState.becomeCorpse(PlayerOnGroundState.java:47)
at zombie.ai.states.PlayerOnGroundState.execute(PlayerOnGroundState.java:29)
so ti seems the becomeCorpse comes febore the onDeath
seems I either need to hook somewere else or I need to find a way to get the corpse
well im not even sure that the corpse is a different object
i never played with this yet im just browsing the source as we speak
if you find a dead player and press F2 in debug mode and select the square with the player corpse. what info does it give about the corspe on that square?
let me check
cause becomeCorpse only kill the character and complete the death process.
i dont see no transformation into a different object such as "corpse"
I think the key is going to be in one of this three
at zombie.characters.IsoGameCharacter.becomeCorpse(IsoGameCharacter.java:16435)
at zombie.characters.IsoPlayer.becomeCorpse(IsoPlayer.java:9647)
at zombie.ai.states.PlayerOnGroundState.becomeCorpse(PlayerOnGroundState.java:47)
I need to get the code decompiled ๐
any tutorial or guidance on it?
I'm fried right now. How might I calculate how many uses of water the player has available in their inventory?
@junior flame
For a single drainable item:
TotalUses = 1 / item:getUseDelta()
RemainingUses = item:getUsedDelta() / item:getUseDelta()
So loop inventory items
Increment a variable with the RemainingUses of each water item
use item:getRemainingUses()
local totalWaterUseAvailable = 0;
for i = 0, items:size() - 1 do
local item = items:get(i);
if instanceof(item, "DrainableComboItem") and item:canStoreWater() and item:isWaterSource() then
totalWaterUseAvailable = totalWaterUseAvailable + item:getRemainingUses();
end
end
@grizzled grove pin?
btw whats the difference between metalwelding and metalworking?
metalwelding is the correct perk
Cheers mate. I appreciate you. I was on the right track, just been staring at it for so long it turned to gibberish lol. Gonna take a break, but much love
Yeah rest well buddy
Fresh mind always work better
sure, someone can clean it out if need be
Sorry for pinging on a old topic, but does moddata save between server logins?
I'm using the worse searching mod that makes it so that player has to do an action before seeing what's in a container and it doesn't save between logging in and out
Is there a workaround or any way I can debug if this mod is broken or does moddata not save?
Server console? Like RCON?
Hey, recently i decided to make few mods for myself and my friends (mainly some tailoring changes, so it's easier to level up), i decided to take a look at game's code, found the right files, and started editing, uploaded item to workshop (Marked as private or friends only idk, because i don't want to just upload someone's else's work like that, plus that's just for myself), now, it works in singleplayer, but whenever i try to start a server, it automatically closes itself after few seconds, so my question is, how do i make it work in multiplayer? i read few guides, etc but i can't figure it out and my coding skills suck, i would be grateful for any kind of help
How do i make an item change its model when attached on the back weapon slot
(replying to djvirus)
Lua. :d
function Client.setUpShield(player,shield)
local player = getPlayer();
local playerModData = Client.getModData(player);
local weaponModData = Client.getModData(shield);
if player:getSecondaryHandItem() ~= shield then
Client.SetshieldModel(player, shield, 0);
end
end
function Client.SetshieldModel(player, item, number)
if Client.getModData(item).modelVariantNumber ~= number then
local itemFullType = item:getFullType();
if number == 0 then
item:setWeaponSprite("CarDoorShield1." .. item:getType());
elseif number == 1 then
item:setWeaponSprite("CarDoorShield1." .. item:getType() .. "Held");
end
player:resetEquippedHandsModels();
Client.getModData(item).modelVariantNumber = number;
end
end```
i edited someones code and this what i made and it dont work xD
<_<
Client.getModData looks like a function from somewhere in the code. because you are not using playerModData or weaponModData maybe you could remove it. Do you have a table called Client defined elsewhere?
well the original is 1280 lines of code but i can try to search
no idea what these do btw
You could do it like this
local Client = {}
function Client.setUpShield(player,shield)
local player = getPlayer();
if player:getSecondaryHandItem() ~= shield then
Client.SetshieldModel(player, shield, 0);
end
end
or like this
function djvirus_setUpShield(player,shield)
local player = getPlayer();
if player:getSecondaryHandItem() ~= shield then
djvirus_SetshieldModel(player, shield, 0);
end
end
or maybe
djvirus_shields = {}
function djvirus_shields.setUpShield(player,shield)
local player = getPlayer();
if player:getSecondaryHandItem() ~= shield then
djvirus_shields.SetshieldModel(player, shield, 0);
end
end
goal is to make the shield change its model when its equiped in the secondary slot
so the original model on the back slot can be changed to look fine
In Client.SetshieldModel it's using Client.getModData(item) which should be another function somewhere in the code so if it's missing that it's going to fail.
The functions are starting with Client. which only works if somewhere above that, it createsa Lua table called Client somewhere like Client = {} or local Client = {}. A name like Client might ideally be local because if two mods did Client = {} then one mod would overwrite the other and glitch it.
If you make it a local table with local Client = {} then it means another Lua file can't use it normally.
thats the original code
I know that it makes it so the model of an item changes when you have it in your hands.
djvirus_shields = {}
function djvirus_shields.getModData(thing)
if thing:getModData().djvirus_shields == nil then thing:getModData().djvirus_shields = {} end
return thing:getModData().djvirus_shields
end
function djvirus_shields.setUpShield(player,shield)
if player:getSecondaryHandItem() == shield then
djvirus_shields.SetshieldModel(player, shield, 1);
else
djvirus_shields.SetshieldModel(player, shield, 0);
end
end
function djvirus_shields.SetshieldModel(player, item, number)
if djvirus_shields.getModData(item).modelVariantNumber ~= number then
local itemFullType = item:getFullType();
if number == 0 then
item:setWeaponSprite("CarDoorShield1." .. item:getType());
elseif number == 1 then
item:setWeaponSprite("CarDoorShield1." .. item:getType() .. "Held");
end
player:resetEquippedHandsModels();
djvirus_shields.getModData(item).modelVariantNumber = number;
end
end
Maybe this will work.
You would also need some code to call djvirus_shields.setUpShield when the character puts it on his back or grasps it.
The file has a . before Held while the Lua does not.
Does moddata save when relogging from server
wait so what did i do wrong?
You have a . in the model name that should not be there, or you lack a . in the Lua file that should be there. Oh actually it looks for models in \scripts so this may not matter if the model name in \scripts does not have a ..
I was mistaken because I forgot about that the model names Lua uses are decided in a txt file. It may be fine.
This may work to get the function to run when your character grasps it with the left hand.
function djvirus_shields.OnEquipSecondary(player,item)
if item and item:getType() == "your_djvirus_shield" then
djvirus_shields.setUpShield(player, item)
end
end
Events.OnEquipSecondary.Add(djvirus_shields.OnEquipSecondary)
Are you wanting a special model for when the shield is held, or for when it is on the back?
well the original made it change when its held, but i would rather have it on back
wait so what do i need to use rn?
So letโs say I know how to edit some recipes for some items
And thatโs all I really want out of what Iโm making
I may not understand the question.
you sent me a bunch of code and idk where to put it
You could look at users\you\zomboid\workshop and copy examplemod
--***************************************************
--** Yeeeeeeaaaaaa boiiiii **
--***************************************************
djvirus_shields = {}
function djvirus_shields.getModData(thing)
if thing:getModData().djvirus_shields == nil then thing:getModData().djvirus_shields = {} end
return thing:getModData().djvirus_shields
end
function djvirus_shields.setUpShield(player,shield)
if player:getSecondaryHandItem() == shield then
djvirus_shields.SetshieldModel(player, shield, 1);
else
djvirus_shields.SetshieldModel(player, shield, 0);
end
end
function djvirus_shields.SetshieldModel(player, item, number)
if djvirus_shields.getModData(item).modelVariantNumber ~= number then
local itemFullType = item:getFullType();
if number == 0 then
item:setWeaponSprite("CarDoorShield1." .. item:getType());
elseif number == 1 then
item:setWeaponSprite("CarDoorShield1." .. item:getType() .. "Held");
end
player:resetEquippedHandsModels();
djvirus_shields.getModData(item).modelVariantNumber = number;
end
end
Client.RichTextPanel = ISRichTextPanel:new(0, 16, 375, 455);
Client.RichTextPanel:initialise();
Client.RichTextPanel.autosetheight = false;
Client.RichTextPanel:ignoreHeightChange();
Events.OnNewGame.Add(Client.onNewGame);
Events.OnFillInventoryObjectContextMenu.Add(Client.OnFillMenu);
Events.OnLoad.Add(Client.OnLoad);
Events.OnPlayerUpdate.Add(Client.onPlayerUpdate);
Events.OnEquipSecondary.Add(Client.OnEquipSecondary);
Events.OnEquipSecondary.Add(Client.OnEquipSecondary);
Events.OnGameBoot.Add(Client.OnGameBoot);```
Oh
this is what i got rn, some events might be too much idk
Does anyone know if you can find any of the things you need for electrical recipes through search mode?
Iโm 90 percent sure shit like the tv remote is just retardedly hard to find and it my own skill issue
It's not enough to make the model change when it is put on the back yet. This is just for a special held model. Functionally it will be similar.
both works
i just want it to have a different model when its either on back or held
--***************************************************
--** Yeeeeeeaaaaaa boiiiii **
--***************************************************
djvirus_shields = {}
djvirus_shields.Shields = {"CarDoorShield1"}
function djvirus_shields.getModData(thing)
if thing:getModData().djvirus_shields == nil then thing:getModData().djvirus_shields = {} end
return thing:getModData().djvirus_shields
end
function djvirus_shields.setUpShield(player,shield)
if player:getSecondaryHandItem() == shield then
djvirus_shields.SetshieldModel(player, shield, 1);
else
djvirus_shields.SetshieldModel(player, shield, 0);
end
end
function djvirus_shields.SetshieldModel(player, item, number)
if djvirus_shields.getModData(item).modelVariantNumber ~= number then
local itemFullType = item:getFullType();
if number == 0 then
item:setWeaponSprite("CarDoorShield1." .. item:getType());
elseif number == 1 then
item:setWeaponSprite("CarDoorShield1." .. item:getType() .. "Held");
end
player:resetEquippedHandsModels();
djvirus_shields.getModData(item).modelVariantNumber = number;
end
end
function djvirus_shields.OnEquipSecondary(player, item)
local inventory = player:getInventory();
local shields = {};
for i,shieldType in pairs(djvirus_shields.Shields) do
local items = inventory:getItemsFromFullType(shieldType);
if items ~= nil and (not items:isEmpty()) then
for j = 1, items:size() do
table.insert(shields, shield);
end
end
end
for i,shield in ipairs(shields) do
djvirus_shields.setUpShield(player, shield)
end
end
Events.OnEquipSecondary.Add(djvirus_shields.OnEquipSecondary)
Maybe this will work idk it might not
thx ill try it
Hi guys, i'm trying to replicate a video where a guy shows how to create my own pop soda, but i think the distributions.lua changed from the version he was showing on video. There was a lot more of non-procedural item distribution, how can i approach now with almost everything being procedural?
How come I can't see my workshop item in the game menu?
didnt work
What did happen instead?
well it still uses the same model
the one on the back and the one on the secondary slot have the same model
Maybe after copying examplemod in workshop you did not change the things properly.
You could add "print" things to different bits of the code like this
function djvirus_shields.SetshieldModel(player, item, number)
print("Running SetshieldModel ", item, number)
if djvirus_shields.getModData(item).modelVariantNumber ~= number then
local itemFullType = item:getFullType();
if number == 0 then
item:setWeaponSprite("CarDoorShield1." .. item:getType());
elseif number == 1 then
item:setWeaponSprite("CarDoorShield1." .. item:getType() .. "Held");
end
player:resetEquippedHandsModels();
djvirus_shields.getModData(item).modelVariantNumber = number;
end
end
And then check the console to see what it says
.-.
ill make a shield holster which gives you a slot on the back
You could use the default back slot, with a specific position for the shield?
yes thats what im doing
o
its a pain in the ass but it will eventualy work lol
Alright i figure out, i saw one project at github that used this method, i believe this will work without breaking any mods for anyone that want to create items and add to loot tables just do this
For the finding the exact tables that i want to add i just serched the type of material that already exist(pop in this case) in ProceduralDistribution.lua
Hope this help anyone that is doing the same thing
I have a weird issue with modded recipes, if i favorite a tool needed it disappears from the required items list like i don't have it. The vanilla recipes don't suffer from this issue, and it seems to occur only for the first item in the recipe.
anyone know how to make a groupBox sandbox setting ? and have and example on it ?
@mint sphinx https://github.com/hypnotoadtrance/MoreTraits/blob/master/Contents/mods/More Traits/media/sandbox-options.txt maybe this will help you
that just look like single tab option and not really a groupbox :/
i'm using https://java-decompiler.github.io/#jd-gui-download and I can't open any of the .class files do I need a diff app for that?
JD Java Decompiler
groupbox is like the zombie lore settings
oh, i see
i think few people use this one https://github.com/quarantin/beautiful-java
remeber to read the readme
My first mod lol(the model is a bit strange i don't know why)
This soda is the most delicious soda here in brazil, so i could not play the game without it, now i'm fine 
yo
Is there a wayยซ, with dfebug menu or some mod, to see a container's name?
I mean, the name as it is listed on the procedural distribution document
Yo! im trying to add britas and gunfighter arsenal to my mp server but cant seem to find arsenal ID folder 2297098490
any ideas?
C:\Program Files (x86)\Steam\steamapps\workshop\content\108600
@mighty solstice the di seems to be correct. Maybe you went to the wrong folder?
Just got this log from another user, modder who wrote this debug message, why?
In my experience the console logs arnt very useful lol
@sour island dobyiu know how to make a groupBox setting in the sandbox menu? I only know how to make a new tab and make setting for each of them not for a box setting
I don't know if that's an available feature tbh.
:/ damn i would just like to make it easier for people understand if they click this box on it would this box of thing into the game
feel free to do it
I think it's only old code stuff
Like, they also use woodwork in a few places and carpentry in others
sorry for repeating a question, but is there any way of, when accessing a container in the game, to see it's name as it appears in the procedural distribution file?
anyone knows how to kill the player?
local function skill_issue()
local stats = player:getStats()
stats:setOverallBodyHealth(-101)
end```
I tried setHealth(0), nothing
I tried setOverallBodyHealth(0), also nothing
and the -101 same result
I'm trying so hard to reduce the player's health but so far got nothing
try this maybe player:getBodyDamage():setOverallBodyHealth()
will try
I heard someone say to set thirst to -500 lol
why not trying the proper kill method?
but would much rather just relate to health
cause I dont know the proper kill method?
thats funny, the getBodyDamage makes the character count as Deceased for a tick before going back to normal
no death actually happens
does anyone know how the stripclub zone is referred to in the game files?
Can't find it to be mentioned anywhere so I don't even know how there's special zombies spawning there.
This seems to be wrong:
table.insert(ZombiesZoneDefinition.Stripclub,
its because the strip club zombies are spawned in by a special java story event iirc
sometimes you would get just the bunny girls, other times you get the cowboys
Strange this worked for me in the past.
I've wanted to set a health drain at first so I was looking for ways to actually damage the player that isn't adding an injury to a body part, but yeah, I'm not finding the right stuff for that
Any clue how to iterate a Java HashMap from Lua? Or getting the list of keys in the HashMap? Problem is the Set class is not exposed to Lua
is there a mod that allows you to carry two weapons on your back? like 1 axe and 1 crowbar
ah, nevermind I guess I can use transformIntoKahluaTable
yo
i wanna add the trolleys and shopping carts from the zupercarts mod so they can be smelted in the blacksmithing mod.
I asked the creator of the blacksmith mod and it told me that all I have to do is add a metal value to the items, so I opened the file for the carts and trolley's porperties and added the metal weight as it appears in the blacksmit mod.
Could somebody tell me if this would be correct?
You can set the bleeding of the neck to something like 3000 and he gonna die in 10s
can you make an example of what the code would look like?
This worked for me, but it was quite a whiles ago so I don't know if it works with the current build?
player:Kill()
Any way to change only one item property (or maybe a few in array) with lua?
I just found pretty good API, but i'm pretty sure there already should be something like that.
API:
https://steamcommunity.com/sharedfiles/filedetails/?id=566115016
local item = ScriptManager.instance:getItem("Base.PistolCase3")
if item then
item:DoParam("Capacity = 4")
end
Thank you so much! <3
np! ๐ค
Anyone know where the lua for stuff like painkillers, bandages etc is stored? i've only been able to find the animation code and not the actual 'apply meds' code if that makes sense
Is there a way to get a unique ID for every item?
yes
Free Online GUID/UUID Generator
Yeah, but is there one that I can get in-game?
Do items and thigns have it already set up?
i don't think so
and yes the do have it pre made
how do i check if the object/tile is water? like the water tiles
isn't this a mapping thing?
no no from a Lua file
to add something to the context menu when use on water
guessing you didnt read the most recent pin then? XD
The Modding Section of the PZ Wiki: https://pzwiki.net/wiki/Modding
This is where link to modding resources should be posted by the community.
Most of the pinned posts were migrated here; if a pinned post is missing, it's here now.
._.
hmm. maybe replacing the zombie footstep sounds with fart sounds was not the best idea
@winter bolt sry to bother but did you but since you did clothing before, do you know why i get errors when i hover over my item after doing using "setexclusive" in extrabodylocations?
group:setExclusive("ShieldSlot", "Back")```
i'm not sure, i've never really messed with that stuff in body locations
That will happen when container item are compared to clothing items with clothing tooltips in certain circumstances.
And set exclusive is one of the things that can cause that conflict.
hmm, its an item that gives an attachment slot tho
It's a clothing class item, right?
{
Type = Clothing,
DisplayName = Sword Sheath,
ClothingItem = SwordSheath,
BodyLocation = SwordSheath,
Icon = SwordSheath,
Weight = 0.1,
AttachmentsProvided = SwordSheath,
Tooltip = Tooltip_SwordSheath,
DisplayCategory = Accessory,
}
item ShieldBelt
{
Type = Clothing,
DisplayName = Shield Belt,
ClothingItem = ShieldBelt,
BodyLocation = ShieldSlot,
Icon = SwordSheath,
Weight = 0.1,
AttachmentsProvided = ShieldSlot,
Tooltip = Tooltip_ShieldBelt,
DisplayCategory = Accessory,
}```
should i remove the tooltips?
iv made the lap pillar you can craft be able to connect to the power grid.. but im having a slight issue with it
Nah, this is because the procedurally generated tool tips about armor value are being broken comparing clothing vs container?
This is custom lua I use to work around the issue; it doesn't work in all circumstances, but it might for you? Otherwise maybe try giving those custom items the Back BodyLocation instead, while also using this code, and see if that resolves the issue?
require "ISUI/ISToolTipInv"
local old_ISToolTipInv_render = ISToolTipInv.render
function ISToolTipInv:render()
local item = self.item
local player = getPlayer()
if item
and instanceof( item, "Clothing")
and item:getBodyLocation()
and player:getWornItem(item:getBodyLocation())
and instanceof( player:getWornItem(item:getBodyLocation()), "InventoryContainer")
then
return false
end
old_ISToolTipInv_render(self)
end
how can i find the sounds that the game uses ?
Check the sounds scripts in the script folder. There's likely more than that however.
ah thanks
cool thx, do i put it in server, client or shared?
client
dont need to edit it right?
Nah, should work out of the box, no problemo?
i bet that was blair
Oh! You have custom tooltip text for your item? Sorry, yeah, my solution would probably break that ๐
wait ill try again after removing it
My code also may be out of date?
ah still dont work ;-;
You're still getting errors? Try it with the body location changed to Back for that item + spawning in a new instance of that item?
i would rather have it work like that, since i actually got another mod with the same issue xD
Your toolbelt? If you change it's bodylocation to Belt + use my code, it shouldn't cause errors?
yeah that
still get an error :I
Iv made the lamp post you can craft connect to the power grid and not need a battery can use battery still Was wondering how to get it to show on generator and actually draw power from it so it increases fuel consumption i also have an issue where when the generator is turned off the light stays on for 15 / 20 seconds and has to be manually turned on when generator re-started.. anyone able to help?
Yeah, sorry, I use that code in concert with my suite of custom mod stuff, so it works in that context?
Here, maybe try this, then you can check the console output and see if the file with the code is loading and when it is, and is not, being triggered by searching the console.txt?
require "ISUI/ISToolTipInv"
print("Loading Custom ToolTip Override Code")
local old_ISToolTipInv_render = ISToolTipInv.render
function ISToolTipInv:render()
local item = self.item
local player = getPlayer()
if item and instanceof( item, "Clothing") and item:getBodyLocation() and player:getWornItem(item:getBodyLocation())
and instanceof( player:getWornItem(item:getBodyLocation()), "InventoryContainer") then
print("Overriding Vanilla ToolTip")
return false
end
print("Using Vanilla ToolTip")
old_ISToolTipInv_render(self)
end
ok somehow that fixed the toolbelt but not the shield or sword belt
Well that's good news at least ๐
Did you switch their body locations to Back?
"Using Vanilla ToolTip" showed up alot of times
Hm, any lua method to remove item completely from a game? ๐ค
Also, where you getting all this methods? Any lib? :)
"Loading Custom ToolTip Override Code" showed up once
"Overriding Vanilla ToolTip" didnt show up at all
Yeah, it will do that. You can comment out that part with -- if it gets annoying flooding the console.txt?
not yet, i also didnt change the toolbelt to Belt, but somehow it still worked?
You'll have to search the console.txt file for that part; it'll only appear in the console when that file is first loaded?
yeah thats where ive been looking*
Well, at least we got somewhere with this? ๐
i changed them to "Back" and now theres no error but there is also no description at all lol
Yeah, so that's the problemo with my tooltip over ride, it disables the tooltip entirely when there's circumstances where the clothing vs container comparisons would cause errors?
I do plan on trying making a better version at some point however.
It's a pretty primitive brute force solution TBH ๐
yeah its alot better than errors tho. and since its a late game item, it probably wont cause too much problem xd
Okay, great! I'll try and let you know if I update the code so you can take advantage of it? ๐
Blair Algol, can i get your attention just for a second please? :)
#mod_development message
Don't want to bore you with ping.
Yep, thanks for the help btw


