#mod_development
1 messages · Page 183 of 1
I do not know what OnEnterVehicle is. also check that link https://www.wikihow.com/Format-Text-as-Code-in-Discord
Small question - Suppose mod 1 has a dependancy on mod 2. In PZ, when you enable mod 1, mod 2 is automatically enabled with it. Is that a result of having mod 2 as a depenendancy of mod 1 on the steam workshop mod settings, or do I have to do something in the code for that to happen?
in mod.info of mod1, you need to set require=mod2id replace mod2id by the id of mod2
much appreciated, thanks!
I've released a new version of my BB guns mod! Take a look: https://steamcommunity.com/sharedfiles/filedetails/?id=3007639881
Hello, is there any way to give my game a darker/eerie color filter, just like KI5 does in their screenshots
I've tried nvidia's color filters but it doesn't work
couldn't find a way to contact ki5 either
Hello, I was exploring the "clothing.xml" file and I have questions concerning how it works.
That’s smart
To my understanding "Probability" makes the main item spawns with a probability modifier and if it doesn't spawn it instead uses one of the SubItems(when it exists) and always uses one of them ?
Edit : It's wrong. If someones understand how this works, please ping me.
Edit2 : Solved
You can ask just do 2 of the back ticks to just do a section and not the full line
Is there no tool to somewhat automate "items spawning in the world" type files ?
Hi, for a few days now I've been thinking about an idea for a mod that would make me stick with Project Zomboid for longer. I like to keep items in specific clothing, belts, bags, etc. (the ones I wear). During exploration, I would like my character to automatically move items to a container that I have previously defined. For example, collected cigarettes would go to the belt bag, just like matches or a lighter.
For now, I'm browsing the wiki and trying to find suitable events or any hints in the files that would allow me to determine if it is even feasible to do.
Anyone know about changing/prioritizing item transfer?
i'd suggest looking for how game manages to transfer items in the first place, then dig deeper into items if they have certain tags, types or what makes them go into inventory/bag. It's just an idea to go further into.
I think there’s a mod on the Steam workshop called Dark World that does exactly that.
I swear if that’s what I’m looking for I’ll get on my knees and praise you
don't think thats it
Ayyyoooo
this is what im talking about
u can see how his game has a darker and a yellow filter to it
piss filter basically lol (kinda)
Not sure about that, it’s possible he edits the screenshots? I have no idea.
thank you for some info!
I don't have much experience either, hopefully someone with experience gives you some insights😄
Is there a way to spawn zombie using the debug menu ?
right click should give you an option called horde manager submenu of main
right click on what ?
anywhere should be fine
This might be a stupid question: How tf do I use the wiki XD How tf do I use zomboid-javadoc XD
In simpler worlds java docs gives you name of the functions that you can play with, A lot em are intutive naming wise. Like search for inventory if you wanna do something related to inventory, or say like im currently doing stuff with doors so i search for door related stuff. Ofca lot of experimentation goes to grab the right ones or you can also look at some of the mods and look at their code to see how tehy interact with a particular mechanic.
https://projectzomboid.com/modding/ this site is the same thing but better
You look here and only here: https://projectzomboid.com/modding/
And you definitely need to know what do you need, do you need player fullname? Then since player is a character go zombie.characters -> IsoPlayer and do ctrl-f and just try to guess that the method could be getFullName(), getSurname(), getForname()
package index
while interacting with player made double door, it's very inconsistent. Sometimes it would open the door and sometimes there's just thump noise i hear(the one you hear while opening doors). Is this a common problem or just some bug in my code?
seems to be happening with other doors as well
Seems like these do not work when added directly to translation keys for tooltips. Weirdly, it did seem to work when I did it for trait descriptions.
Thank you!
Late response but Oracle has free servers. I use one for my minecraft related testing.
They offer full VMs too, and the specs are pretty good.
Thats why i love modding in typescript, i can almost skip the part of searching through docs.
Interesting, im learning js these days. Might pick up TS i have heard great things about it.
getting hold of current player before the game loads throwing a lot fo errors i assume its because it's a null value, is there a way to make sure your files run after the player spawns?
we have this available for lua modding too
https://github.com/asledgehammer/PipeWrench-Template, Thats what im using now, works great.
Typescript is sometimes a huge pain, when im writing mods for pz almost all of the types are :any so it doesn't make lots of sense lol
haven't tried https://github.com/asledgehammer/Umbrella yet, maybe it has more types support
so you have the types and not at the same time👀
looking for ideas, i'd like to install something in doors. Is it possible if yes then where should i dig deeper? or just a limitation at game level ? How about adding doors of my own and modify recipe (not sure if that can be done)?
I should make a bomb vest that throws 10 pipe bombs around you and insta kills you. Good for multiplayer if you got bit and you want to still be useful.
Don't you
me

How do playerIndex parameters work? What do I fill that section with?
player:getPlayerNum()
the terms 'player index' and 'player num' are mostly interchangeable
How would my mod be able to know which specific player it wants to pick? Im still trying to do my russian roulette mod and I want the game to know that I am talking about the person interacting with the gun
is that from the context menu? the context menu events should pass the player index
Can someone give me a guide on how to make a mod for turning screws into nails?
Some really useful guides for scripts here
so all it would be would be like
recipe Open Box of Nails
{
ScrewsBox,
Result:Nails=20,
Sound:PutItemInBag,
Time:5.0,
}
I think so
I'm reading through this recipe script guide and I really dont understand it
as in the entire thing, like how on earth would I piece it together
I believe the extended stuff is more or less other ways to achieve the same thing.
But for a recipe that is just converting an item to another item, that should be enough.
Take what I say with a grain of salt tho, I'm big newb
recipe gives box of nails a sub menu Open Box of Nails, inside it the first couple of lines are the items you need to have in inventory. Result is basically what you get, here Nails=20 and time is how long it takes for this action and sound is what you hear.
what are recipe magazines called internally? For context: I'm trying to make the text "unread" the color red to make it pop some when looking at a ton of magazines.
I've tried looking up magazine and recipe using the program Search Everything from the Zomboid root folder and magazines only hits gun mags, and recipes is hitting logic for the actual recipes themselves.
recipe Change Box Of Screws to Box Of Nails
{
ScrewsBox,
Result:Nails=20,
Sound:PutItemInBag,
Time:2.0,
}
so this would give the option in crafting and when you right click to turn a box of screws into a box of nails?
i believe it should, havent dont anything like this myself. Try it out, put the file in correct folder and avoid using same file names as vanilla.
so how do I make it so I can do 1 to 1 for screws to nails individually as well
I am still quite confused on how this wou ld work
you can just tweak the no of nails for how many you want
yo'
you're telling game here's a script and here's what it gives as long as its valid, itll work.
actually i did try it out
here's my recipe for an item that i added to game while i was learning stuff a couple of days ago
you would also need to import Base module because you're using items that are already present in game
so it would be this instead
import {Base}
recipe Turn Screws Box Into Nails Box
{
ScrewsBox,
Result:NailsBox=1,
Sound:PutItemInBag,
Time:2.0,
}
recipe Turn Screw Into Nail
{
Screws,
Result:Nails=1,
Sound:PutItemInBag,
Time:2.0,
}
recipe Turn Nails Box Into Screws Box
{
NailsBox,
Result:ScrewsBox=1,
Sound:PutItemInBag,
Time:2.0,
}
recipe Turn Nail Into Screw
{
Nails,
Result:Screws=1,
Sound:PutItemInBag,
Time:2.0,
}
The crafting would allow
"Turn 1 Nail Box into 1 Screw Box"
"Turn 1 Nail into 1 Screw"
"Turn 1 Screw Box into 1 Nail Box"
"Turn 1 Screw into 1 Nail"
is that right?
make recipe names more descriptive, also it should be import {Base} instead of import Base
how can I make it more descriptive?
TNIS->Turn nail into screw
if you go with abbreviations and super short names you have a chance of conflicting with a mod that wouldn't naturally conflict
it's also just kind of bad for maintenance, you won't know what TNIS means at a glance in a year
ye much better
btw, is that your full file? there isn't a module declared in what you posted
also im not sure but i think you may need to wrap it around in your module name
whatever is your modID, name your module that
just add to the start
module MyModule { (call the module whatever you want)
and then an extra } at the end of the file
Keep it short and unique, so it doesnt match with other modIDs
yeah, it should preferably be something unique to your mod
when two mods name something the same way it causes a conflict
btw albion, something i wanted to ask. Is it recommended to always use your module name before item name, to get hold of item that exists in your module or when exactly do you need to do that?
(vice versa)
recipe Turn Nail Into Screw
{
Nails,
Result:Screws=1,
Sound:PutItemInBag,
Time:2.0,
also with this, how do I make it 1 nail only and not a stack of it?
MyModule was just a placeholder, you should use a unique name for it like i suggested use your modID instead. Also look at this for reference.
what about that
plus idk what modID is
in scripts, you can only access items in your module or modules you have imported unless you use the module name
modID is an ID for your mod, a way for to identify your mod from all the other mods. It shouldnt have space in between and should be unique.
so it's not necessary for your own module unless you have a possible name conflict with a module you've imported
if you're using the item name in lua then you should always use the module
ah oki thanks
where should I put modID and what number should I use?
https://steamcommunity.com/sharedfiles/filedetails/?id=3006109377, here read the folder structure bit and your recipe file should go into scripts folder
is there any other way you could show us your structure? bit skeptical of downloading files like that 🙂
module name shouldnt have any spaces in between, it's not description. Make it TSIN and change your id to TSIN as well for now, i dont exaclty know if its a must to name em both same. But it works and seems logical.
they don't have to be named the same, but it can be a good idea since mod ids literally have to be unique
mod.info shoudlnt have .txt as file format just keep it mod.info
in my example i used modName as placeholder name, you can name it whatever you want to call your mod maybe Nails to Screws or something would be fine.
where did I add modName, sorry
this one
one more thing, remember about folder structure. media should have folder scripts which will contain your script file.
is this right?
this?
Reason: Bad word usage
Reason: Bad word usage
How easy is it to do a animation/dance mod for PZ? Haven’t modded pz much I have made other mods before so I have a decent idea how it works but just wanna ask
well, what do you want to do? add your own door or add extra functionality to a game existing door?
id like to add an item of my own so i could work on a functionality with doors
I'm working on the last few days in a mod related to player made double doors, and I can say you can do a lot with doors
if that functionality already exists I think it's doable
I even made a wooden gate be a container 
so you want to make doors do something special when an item is attached?
basically the idea is to add scanner to door
declaration: package: zombie.iso.objects, class: IsoThumpable
maybe the door in the frames are actually https://projectzomboid.com/modding/zombie/iso/objects/IsoDoor.html
declaration: package: zombie.iso.objects, class: IsoDoor
an item that would allow so that it opens when a vehicle is about to enter
That is on my todo list for a feature in my mod 
i can't imagine an especially elegant way to do it but it should be possible
take a look on how the scanner explosives are done
and how you can get the door with it
maybe is a good way
i can place the module on the ground but i feel like it would look much better if i could add stuff to it so it feels more realistic
the way i'd do it is have the vehicle the player is currently driving look for the doors, instead of having the doors look for the vehicle
otherwise your doors will be scanning the world constantly
not the most elegant but i can't think of anything better
If you use a IsoThumpable, there is a method called setIsContainer(), which literally make the door be considered a crate
is the scanner visible? you could just make it a moddata boolean on the doors
then you can put items in it
Here's what i have so far i can open doors atm in all four directions, but i'd like to add three items to game. Scanner would basically stay connected to door, door tags would be in player inventory and im hoping later down teh line to add tiles that can be set nearby doors to act as pressure tiles to toggle doors. Im not sure what you mean by visible, what would moddate boolean on doors do?
oh wait so i can put my item inside it then ig
yes.
that's an interesting idea
I did it to place a car battery inside
when you attach a scanner it sets a boolean in that door's moddata, that's how you recognise which doors have scanners
i'm guessing the door only opens if the player is holding tags? so then if the player has one, scan nearby tiles for a door and if it has the moddata open it
by visible i just mean if it should have a sprite or not, i don't know how you would do that part
yes
ah visibility is not a priority atm
i can always improve on mod down the road for now i wanan set it up as soon as i can.
maybe setSprite() works? idk really, still didn't test it
I should prolly work with moddata then
should work yes, I use modData to store a "code" to a door, and save that to a controller, if the controller have the same code, it can be used to open the gate
also is there a way i can attach say my tag to scanner or even door, like maybe door ID or something a way for game to recognise teh tag belongs to this gate.
if the gate have no code, it is considered that my automatic motor is not even installed on the door
what peter's talking about would be the best solution to that
you can store the object position on the tag, so that it always search for the exact gate it is connected to
ooh, if you do it by position it actually saves a lot of performance
you don't have to scan for nearby doors, just check if the square is loaded, and if it is if it's in range
my mod is "almost" ready for release, I just want everything to be working beautifully before
yes for now iim searching every tile, i was hoping id just search for my scanner module and it would prevent all these unnecessary searches
If until there you still didn't manage to do it, could be a useful source 😉
peter, have you had any trouble with doors?
for instance doors don't always open it's very inconsistent and i just hear the "thumping" sound if that happens.
well, that didn't happened to me yet
the only problem I had was about when opening and closing a gate, the objects change position
so something my code got nil because there was no object in the middle
I got around it by ALWAYS saving the "corner" piece of the gate (left-most)
i think i experienced that as well
and if I needed to apply some change to it, I used a specific function to get all the 4 gate objects in a table, and change each one individually
Locking for eg. If you lock only one object of a full gate, if a player interacts with another position of the gate, it would open regardless of the lock on the other piece
ah
gates are complicated 😅
sounds like a nightmare
yeah, that's why I need a lot of utils functions to get around that many things 
but until now, it's working flawlessly. Just didn't test it on MP yet
I'm hoping that there aren't many things that needs to be changed for it to work
im slowly making my way there, once im done with the logic part then ill prolly optimize code and move to visuals and stuff.
and this is where IntelliJ is helping REALLY A LOT
Good luck! 😉
ty
I stored some variables in a dictionary and can access the value with a print statement
print(zombie_random_modifier[stat_name]["Seed4"]["seed_effect"])
>>> -99
However, when I assign the dictionary value to a variable and print it, I get "nil"
local seed_effect = zombie_random_modifier[stat_name]["Seed4"]["seed_effect"]
print(seed_effect)
>>> nil
Am I missing some lua gotcha?
how are you storing those variables?
Lua doesn't have dictionaries, but tables
as long as I know at least
i don't think this calls my function, am i using this correctly? i looked at dhert's previous texts on context menu to make this one
i do see the option on door menu tho
if the option is show yes it is
you just don't need to pass in the door two times
you already passed it as the target
oh oki i earlier passed as param but saw dhert mention target so i wasnt too sure, ty
where is the best place to commision a mod/ mod patch
not sure what's happening here, it does trigger the function tho. Seems to be throwing this particular error each time i would try to configure door.
in my code? there's only this file active atm and a script to add items which is working fine for now. This error triggers each time i click on cofigure door in context menu.
i think i might need to comment out the whole file just incase if it's still messing up with this one.
hmm, strange, usually the game files only output errors if the file that called it have something wrong
can you paste the whole function again?
door:setIsContainer()
end
local addOptionToDoor = function(player, context, worldobjects, test)
local door = nil
for key, value in pairs(worldobjects) do
if instanceof(value,"IsoThumpable") and value:isDoor() then
door = value
break
end
end
-- Add a context cption
local option = context:addOption(getText("Configure Door"),turnDoorsToContainers,door)
end
Events.OnFillWorldObjectContextMenu.Add(addOptionToDoor)```
local option = context:addOption(getText("Configure Door"),turnDoorsToContainers,door) here is the problem
target which in your case is door, is passed BEFORE the function, not after
what is passed after is the param1
oh so i must pass door before the function call
yes, that is considered the target
which is always the first param to be sent in the function you are referencing
yes, always
also forgot to pass in arg as true for setIsContainer 👀
ptsd trait
How can I work with modData on custom items?
ModData is essentially just a table that can hold almost anything
You can get moddata with item:getModData()
And then you can just add a value there
So smth like item:getModData().myValue = Value
Do items have this method? Can't find it in docs
inventoryitems should
any isoobject inheritor and some other things too
generally most things you could ever want moddata on have it
a cool shortcut for custom items is any property you add to an item script that isn't recognised by the game will be added as default moddata for that item
Interesting, then I can access that table and add more stuff to it ig.
I'll get on started on this one
@bronze yoke do you know the limitations for what can be saved in moddata?
well you can always store the information you need to recreate them if you have to
e.g. you can keep all the data of an object's state in the moddata and recreate the object from that state data
and for a function you can put its code as a string and loadstring it afterwards
is there a limitation to modData()?
I tried using it on zombies but it does not seem to save the data between game sessions (quit/restart)
zombies aren't usually persistent so neither is their moddata (usually)
the game tries to save as little information about zombies as possible
it does save on zombies flagged as dead players though, they're pretty much fully persistent
How does loadstring work?
thanks for the info
it literally just loads a string as code
it's the same as loadfile but for a string
sorry, another question, would keeping a global table of zombie IDs and their stats(speed, strength, etc.) slow the game down?
programming in lua explains it well
probably, there are a LOT of zombies
dostring/dofile are the same thing but they immediately execute it instead of storing it as a function
if there's no existing modData, will it get nil or just an empty table, im assuming empty table?
empty table
sweet, ty
internally, the moddata table doesn't exist until the first request for it is made, which is when it creates an empty table
ah oki, i just needed to know what case to handle. Altho just leared table[#table+1] is a neat way to append stuff
i wouldn't recommend using mod data as an ordered list, you have no idea what another mod is going to put in there
if the ordered list functionality is useful you can make it a table within the main moddata table
Figured out how to add 3D object into UI 👀
This pretty much explains my question when it comes to coding/fixing a mod, I don't exactly know how to have the items spawn in the bag that's in the inventory, like the starter kit that the game allows you to have
Almost the same way as the players inventory
So you would get the bag and then call :getInventory() on it
And then you can add items to it
Ah, alright, thank you
You have to store it in a local var though for easiness
Also works only on inventorycontainers so make sure you have one
how about preventing adding the items indefinitely?
What do you mean?
They mean to have it where the items aren't given forever I think
Like when you load the game again
oh wait yeah it can be the same as the starter kit
Well you can always set a boolean in players moddata to check for that
true.
Just remember to remove it once the player dies
I can always verify that what I'm pulling from it is an object of type I require and then do stuff with it, would that still be a problem?
Is there a specific way to get the damaged bodypart on a weapon hit?
I'm trying to figure out a way to negate damage (bleeding, bullet hit) under specific circumstances, and I imagined the best way would be to find the hurt part and remove said wounds?
Checkout bodyDamage and bodyPart in java docs
Anyone have any clue why the playerIndex for every player on my server is 0? I assumed it would be different for everyone, so I’ve been using getSpecificPlayer(playerIndex)
Player index refers to which local player they are. So in split screen, the second player would have a player index of 1 (and the first is 0, which is why everyone has that value)
i now was able to patch/fix the mods medic profession starting items
Reason: Bad word usage
this works fine as of now but teh problem is it shows the option just if i right click, i was hoping it would only show context menu for door object or IsoThumpable in my case to be exact
ah that makes sense, ty
also is there an efficient way to grab say a vehicle that player is currently in? or do i just search for objects and grab base vehicle type from there?
i think this might be it
Ah, okay, so I would need to use like getOnlineID() then for being able to click on other players in a server
Players modData is consistent when the player dies and a new one is created? that's weird
I thought it created a completly new Player object
trying to interact with vehicle, can't seem to trigger the event.
wait
its local
Where can I find the list of events?
I type it like that to avoid making mistakes
Yeah, thanks 😄
couldnt find it for some reason
about the print, does it show up in lua console?
Yes
that will make life much smoother👀
reloading the lua on F11 sometimes works too
except like when you have OnGameStart event, bec well its fired on the game start
i knew about the reloading lua stuff but always did something like add blood to player or anything in-game to tell if an event is fired or a condition is met, but printing in console is much better. I think i saw somewhere that you don't print variables in lua console ?
No idea, I always store a variable in some local and print that
hmm now it works, its either that i quit and started a new save or changed player var to global
You can kinda print variables to console with tostring()
debugger has been a great help tbh, to be able to capture objects and see their properties it all comes together
This one by albion is more consise and updated
https://github.com/demiurgeQuantified/PZEventDoc/blob/develop/docs/Events.md
ye youre right i think ill do
this is beautiful, thanks
does .. on both sides have any syntactical significance like instead of treating as plain string i assume?
ah
handy stuff and works with numbers
like a "+" but for strings
got it
But if you use it with a non-string variable, will probably return an error
try to use tostring() on things you are not 100% sure that are strings
ye toString() might be better equipped for this
Does anyone know where the inventory icons are located in the game files? I'm adding a couple different colored vanilla backpacks for more variety but can't find the icons anywhere to change them so I dont get the Blue question mark thing in the inventory.
Like:?
yes
Anyone know why debug console isn't showing ANY print commands?
wait actually
All the item icons are in the texture folder
Or similar to that
You dont need tilezed
btw just saw this, didnt know it existed. It's vanilla but in debug mode.
They all have Item_ prefix
Not the vanilla ones, you need to see the .pack files
are they hidden maybe or in a another folder in there that i might be missing?
only modded ones are in the texture folder
When creating an item, what is the function of the "Count" variable?
they are here
I got them all for one of my side projects 😄
This is definitely easier 😉
What am I looking at?
the door being open?
it isn't
I've seen some info about that in the past, can't remember why they exist but aren't in the game.
the moddata does pass to the corpse and then to the zombie, but the player's new character has fresh moddata
they aren't in the game because it would be weird to have two cars with animations and no others
they are the future
Oh yeah, that was it.
i think these are still WIP, like there's only 4 such vehicles and the sports car doesnt have trunk animation yet. Prolly will be released in future.
@worthy sparrow @cobalt fiber @neon bronze Thank you very much for the help. Would have never found that
No problem 🙂
aiteron mentioned a b42 vehicle rework in here a few months ago
So it is in the way I thought about
Someone said to delete the modData after the player died, maybe because it passes to the zombie then 
never heard anything else about it, but that's likely when we'd see this
it's best to think of the moddata as belonging to the character rather than the player
i see b42 as another game rework like b41 was, but maybe a bit smaller one
to me it's bigger
at least, the things they're changing feel more foundational and important to me
imagine... skills and traits that make any sense whatsoever
a reason to survive more than fifteen minutes
I mean the crafting tree, NPC, animals, thats just a whole new dimension added to the game, but the game quality jumped when b41 was released
I cant hardly wait for the crafting overhaul
It will also set the direction of where the game is being headed in future. Like all the stuff they talked about modern world stuff being irrelevent 5-10 years down teh line. So definitely a turning point.
The crafting system could be huge
Same mostly looking for animals and that crafting stuff, makes crafting much more interactive as a process. Plus it looks so cool.
oh don't get me wrong, i played b40, b41 was a huge step up
from what i heard game got more popularity and brought a new wave of crowd after B41
I think the 3d models came with b41 right?
Iwant to see how the game will look when npc are there, I had that thought since like we start the game and immediately there are zombies everywhere, what IF the game starts like a normal sims world and as the time passes you experience people changing, different military ops, the whole TV/Radio knoxevent, riots, crimes etc.
Yes
about the updates that mess up mods, how do you guys manage it? Is there a way to avoid it while you work on the fix? or do you just try to get the mod up as soon as possible?
I bet the second option.
What happens if you were to make a kill switch for your mod incase of say a version change? Would it affect the player saves?
that's a per-mod question
the kill switch or the former question?
the kill switch, it might break saves in some cases but usually probably not
there isn't really an ideal solution, just... fix the mod as fast as you can
ah you mean other mods being incompatible with yours
When the new machines come out I think I wanna make a kitchen mod. Like, making a stove a machine, having slots for pans, etc.
like pam's harvest craft for MC, kind of
With the new UI design system that will be easy to pull off
Haylo, here’s another dev-log sent down from the mothership. Few different things form different areas this time around, starting off with an example system update from one of the four main pillars of Build 42 – which are the crafting improvements, and the sorts of places they could take the game to. CRAFTY BUSINESS For […]
that's exactly my inspiration hahaha
I'm a sucker for cooking in games
very interested in seeing what the new thursdoid says!
Is player already a default global variable? Because I keep getting an error saying I'm calling a null variable in kahlua (or something along those lines)
nooo def not
grab your player with local player = getPlayer()
you need to get the player either from the functions you're already working with, or there's two options the grab your player
that's the easiest way lol
every time i explain the whole thing i get 'yeah i don't care about splitscreen' so i'm done doing that 
I was also thinking of getting the playernum since that's global, and using that to get the player
lmao that's what I was doing when I got the error, that's why I'm so confused XD
old as hell lol
wait--the other way gets messed up with splitscreen?
your code is probably running before the player exists then
gib code
if you want to support splitscreen you need to loop through getSpecificPlayer (or use the player object passed by events/functions)
prolly i just saw it today so shared it
ngl, I scrapped it because it was pissing me off.
most people just use getPlayer() so i imagine most mods don't work in splitscreen
oh wow! I had no idea haha
but nobody plays splitscreen so this isn't an issue for them
because one client is supporting two players, i imagine getplayer() only returns the first one
yeah exactly
i write all my mods for splitscreen, but i don't test them in splitscreen 
albion, why not write a compatibility patch? Is that possible?
you could hook into that method and return both players. with a comma so if they don't use the second value it won't break things. and other patches
sure but that wouldn't make their mods iterate through it
basically I was trying to add a custom context menu option when I right-click on another player on a server, so I WAS using player = getPlayer(playerIndex) but found out that wasn't working for a whole other reason. I had also done just player = getPlayer() and that's when I stated getting the new error lmaoo
Eye balled eulers
Anyone know a good guide for making animations ? I know dislaik had one but he deleted it
you can get it on the wayback machine
i don't know what this means but I think this is probably really cool?
hammertime
this is the proper way to get players for splitscreen```lua
for i = 0, getNumActivePlayers()-1 do
local player = getSpecificPlayer(i)
if player then -- there can be gaps so we have to nil check
end
end
lol yeahthey are what led me to poke people to try it lol
I was doing for playerIndex = 0, getNumActivePlayers() -1 do local player = getSpecificPlayer() but found out that was literally only for splitscreen lmao
it works in singleplayer
well, def not that far indented
In simple words how to rotate in XYZ using mouse X and Y, and using that im going to rotate any object around it's center, Im doing some extended weapon customization:
I was meaning it doesn't work for servers lol
it works in multiplayer too
as long as it's not running on the server, since the server has no 'local players'
ah okay, it just won't work for what I was trying to do ig lmao
I'm also still struggling with trying to figure out what arguments to put in my functions XD. Idk why but it's confusing as hell to me.
I can't even find getPlayer() on projectzomboid.com, only getPlayers()
OH, I was looking in IsoPlayer, thank you
Since we are in this topic, IsoGameCharacter to IsoPlayer?
this is mega poggies
Is IsoPlayer only for local? and everyone else is considered a GlobalObject?
the global object is just a bunch of functions for lua to call
I was trying to get a player from a item inside his inventory, maybe this works for SP/MP/SplitScreen?
local player = getSpecificPlayer(playerID)```
Event OnEquipPrimary has parameters of IsoGameCharacter and Item and how can I get the IsoGameCharacter to be IsoPlayer since I want to use some methods from IsoPlayer
an IsoPlayer is an IsoGameCharacter
IsoPlayer inherits from it
IsoGameCharacter is an abstract class, you'll never have an instance of it specifically, only something that inherits from it
hmmm, so this is maybe enough? local player = item:getContainer():getCharacter()
yeah, that's enough
Well that was my thought, but it just throws an error when i try to do simple getFullName, maybe It's nil when the event fires
i have to double check it
getSpecificPlayer doesn't use OnlineIDs, it uses the id from getPlayerNum()
which is essentially OnlineID % 4
cool! I tought that maybe IsoGameCharacter was not going to be a IsoPlayer
It was working yesterday, but I only tested it in SP 
maybe thats why, because the onlineID was 0
that seems weird, how can a nil character equip an item?
Im passing it to a different method, and in that method instead of using the passed down variable i used a local one which was nil, tested in in the event itself and its good.
local currentHealth = player:getHealth()
local healthToAdd = maxHealth * (healthPercentageToAdd / 100)
local newHealth = currentHealth + healthToAdd
if newHealth > maxHealth then
newHealth = maxHealth
end```
This looks correct, yes?
aside from the incorrect indent because discord hates me
isnt the max health a static value? so instead of doing that calculation you could find out whats the value of max health and just add the remaining
by static I mean everyone has that x max health
ah then nvm
generally health methods from the player object don't tend to work
usually you need to getBodyDamage and work from there
i think the ones from the character object are either deprecated or just used for zombies or something
ugh okay lmao
tbf, I've not even gotten far enough to test that because my custom context menu options weren't coming up XD
Is there a list of string params a javaObject:fromLua0/fromLua1/fromLua2 (...) method accepts?
if an item is inside a crate, can i call it to create context menu for that item?
I think you have to do OnFillInventoryObjectContextMenu, then look for that item and add the context menu option
but I guess best option is to find out yourself :p
alr ill give that one a try as well
but events.OnFillWorldObjectContextMenu should work for right-clicking on a player in mp, right?
It's in client side, and I think if you click on a player the playerindex parameters is set to that player
actually i can test this quickly
Essentially, I'm trying to make it so I can right-click on another player and have the option to either "Perform blood draw" or "Perform transfusion" based on what's in my inv
Or is this something that needs to be a timed action?
okay so, i tested this and I THINK you have to use the table worldobjects to find a player
Is removing the limit on the amount of smoke particles possible? Video contains example of slightly modified smoke with the SmokeRange = 10 instead of 5, but it seems there is a limit on the amount of smoke particles, wondering if that can be removed in some way? Been told in pz-techsupport it's java classes, was wondering if that's true
when im click on the ground its 0, on myself its 0
Sick, now gotta figure that out XD
Well thats how it is :p
Any clue where to find the tables just for me to reference
Unless I can hook it into newHealthPanel or whatever lmao. Idk, we will see
Never worked with table, I have no idea
I've got big aspirations for being brand new to modding XD
Javadoc Project Zomboid Modding API declaration: package: se.krka.kahlua.vm, interface: KahluaTable
I guess its just a table with IsoObject
your best way to testing is to iterate over that table and do like getName() or getObjectName() or whatever and just look for the stuff you need 😄
40.43 version??? 
damn didn't noticed lol
I got that from https://pzwiki.net/wiki/Lua_Events/OnFillWorldObjectContextMenu
https://zomboid-javadoc.com/41.78/se/krka/kahlua/vm/KahluaTable.html
LMAO here's the newest one
Javadoc Project Zomboid Modding API declaration: package: se.krka.kahlua.vm, interface: KahluaTable
everything is off in the docs
just making sure you don't have a weird bookmark
atleast they are the same thing lmao
lol, thank you! I'm actually looking in the actual game files now XD
wait
omg
Why don't you look at other mod how to do that stuff?
Thats just time saving af
LMAO I WAS GONNA DO THAT BUT I HAVE ADHD
The simplest answer that i haven't thought of
prefer https://projectzomboid.com/modding/ , it has named parameters
the playerindex is the player for whom the context menu is being filled, the worldobjects are the objects on the square
It lacks se package where kahluaTable is defined, or im just blind
ohh you're right
you can decompile the UI3DScene or see what is used in the Lua files. I don't think this is something that has been documented.
you can find it in the kahlua source code probably
Yeah, I've been using this one since you recommended it. Just struggling with the lack of descriptions on either website XD
I checked all of them and haven't got my answer, decompiling might be the way. Can you give me a hint on how to do that?
it only has the TIS classes
i think i've mixed up two different people's problems actually 
you may want to use Intellij version from 2022
Don't bother with jd-gui, it wouldn't open any files for me
Ugh installing whole IDE and everything just for that
Another question. So I'm able to get the texture in game spawning randomly with the others. I've added the new item icon texture to the texture folder and using item tweaker to try and add it to the list, but its not working for me. So how does the game know what icon to use with what texture if there are multiple options for the same item?
where would i find a decent guide about modding? mainly weapons and cars, i used to mod gmod and other source games so im not a complete noob in modding
Well for vehicles there is this.
https://theindiestone.com/forums/index.php?/topic/24408-how-to-create-new-vehicle-mods/
- The first thing you want to do, as with most mods is to create your mods folder structure, use the image below as a reference, replacing MOD_NAME with the name of your mod: Spoiler mods MOD_NAME mod.info MOD_NAME.png media lua client MOD_NAME.lua models Vehicles_MOD_NAME.txt scripts vehicles M...
thank you
I just found one of your comments on steam. I'm assuming it's you anyways. Just weird that I stumbled across it lmao
You could search for TeachedRecipes in the scripts folder.
Hello, looking into the game files in maps, I can see the .lotheader files only for Muldraugh, where could I find the files for the other locations?
muldraugh contains the entire map, the others just add spawn points
So, I'm looking at other mods that do similar stuff to what I'm trying to do, but I see this ```require 'TimedActions/ISBaseTimedAction'
DonateBloodAction = {}
DonateBloodAction = ISBaseTimedAction:derive('DonateBloodAction');```
But I don't understand what the "{}" is all about. This calls a table, correct?
it creates a table, yeah
in this case it's redundant
derive creates a table anyway
okay.
I'm assuming they probably copy/pasted one of the default timed actions and then customized it
probably
that may be what I end up doing because I am STRUGGLING to the point where I almost wanna give up XD
It would be different if there were tons of resources that give decent descriptions about what each func/var/param does XD
Thank you, I will look into it!
Here scanner is just a custom item, i converted the Double Door into a container. I wanted to grab GridSquare of scanner item, so that i can somehow iterate over its objects to get hold of IsoThumpable object is what double door fits into. But after so many edits and squeezing ifs in there door is still nil. Any ideas what could be wrong here? Im able to get the gridSquare where the door is btw.
https://github.com/FWolfe/Zomboid-Modding-Guide/blob/master/api/README.md#zomboids-lua-component
see how to loop an ArrayList
getObjects returns an ArrayList not a lua table
thanks
Also sometimes doors will be IsoObject, you can use f2, select square and check all objects on that square in debug.
ah got it, thanks i was able to grab the Gate object, it clearly says it's gonna return an ArrayList and idk for some reasons i thought lua is somehow acting as some sort of mediator but now i think i understand if i see a java object in there im free to call Java methods but keeping the lua syntax in mind
good lua implementations do that, but unfortunately we're using kahlua 
This still isn't super helpful, but I appreciate your contribution. I think I'm just gonna give up at this point, none of this makes sense which is weird to me because I'm normally pretty good at figuring shit out.
gotta work with what we got now
thank you, I will check that out.
my scanner item type is https://zomboid-javadoc.com/41.78/zombie/inventory/types/ComboItem.html accoding to debugger but it only has methods like getModData() or hasModData(), how can i set the ModData
Javadoc Project Zomboid Modding API declaration: package: zombie.inventory.types, class: ComboItem
it's a table, you use getModData to get the table and then change the values in the table
wow, ty. Without this channel i doubt my interest for making mods would survive past couple of days
Hey y'all, anyone got a guide or example repo for custom menus?
Additionally, can you add right click menus on any object / entity / etc..? If so, anyone got a reference for that?
you use the OnFillWorldObjectContextMenu event
it passes the list of objects on the square the player right clicked on, you loop through that list and if it has objects your mod is interested in you add your options to the context menu it passes
Does this include players and zombies?
not sure, honestly the object list it gives is really unreliable and you should probably just use it to get the square and then loop through its objects list
one of my mods had a bug because an object only appeared in the object list in debug mode, for no apparent reason
if you work from the square it can include anything you want
Ah nah, this wasn't what I was looking for. I was looking for where the tooltips are built for them. Literature contains the actual item
thank you again tho
Zombies on the square will show up, though?
Just out of curiosity, is there an event specifically for right clicking on players or zombies, rather than the square?
no
Hm
im a bit confused with regards to Tables, say my item has a field in script which is not definied in-game so it would result into converting it into modData so when i do something like item:getModData().fieldNameInScript=value am i replacing the table with this data? what if i wanted to append values should i use next or maybe #table?
when you do t.key = value you replace the value in the table t stored under that key with the new value
oki that makes sense, but here my table is supposed to be called doorTagconfig in script and if im doiing .doorTagconfig that would be something like doorTagconfig.doorTagconfig right?
you can't create tables from the script, only numbers and strings i think
oh so its essentially just creating a new table for my data and appending this info to a field called doorTagconfig
but to explain the script thing, if you added MyCustomValue = 5, to your script, you'd get 5 from print(item:getModData().MyCustomValue)
that would mean that it creates a table automatically then? jsut appends the value as a key to it
or i should rather say insert
QQ - Why won't my sandbox tooltips & renames show up? I see my options in there. They seem to be working properly FUNCTIONALLY but my Sandbox_EN.txt file does not seem to be taking. I've tried about 30 billions different ways to rename it. Plz help 🙂
Sandbox_EN = {
Sandbox_pointblankhf = "Point Blank",
Sandbox_pointblankhf_PointBlankEffectiveRange = "Point Blank Effective Range",
Sandbox_pointblankhf_PointBlankEffectiveRange_toolip = "Zombies shot upon below this range will be affected by point blank damage",
Sandbox_pointblankhf_PointBlankInstantKill = "Point Blank - Instant Kill",
Sandbox_pointblankhf_PointBlankInstantKill_toolip = "If true, when shooting a zombie within point blank range, they die instantly. \n If this is FALSE, the values below help determine bonus damage",
Sandbox_pointblankhf_PointBlankMinimumBonusDamage = "Point Blank Minimum Bonus Damage",
Sandbox_pointblankhf_PointBlankMinimumBonusDamage_toolip = "ONLY USED WHEN InstantKill is DISABLED. \n This is the minimum amount bonus damage that is applied. IE, if your damage is .0001, it would up the bonus damage to .2\n Bonus Damage Multiplier \n This does not affect base damage value, ONLY bonus damage. See equation below: \n\n TotalDamage = BaseDamage + PointBlankDamage\n PointBlankDamage = (Max(BaseDamage,PointBlankMinimumBonusDamage) * PointBlankBonusDamageMultiplier ) \n",
Sandbox_pointblankhf_PointBlankBonusDamageMultiplier = "Point Blank Bonus Damage Multiplier",
Sandbox_pointblankhf_PointBlankBonusDamageMultiplier_toolip = "ONLY USED WHEN InstantKill is DISABLED. \n Bonus Damage Multiplier \n This does not affect base damage value, ONLY bonus damage. See equation below: \n\n TotalDamage = BaseDamage + PointBlankDamage\n PointBlankDamage = (Max(BaseDamage,PointBlankMinimumBonusDamage) * PointBlankBonusDamageMultiplier ) \n"
}
also is there an efficient way to tell if its empty? i had to put in a key isEmpty specially to verify if its empty or not. nil doesnt really work i think since its not initialised
not == nil should work? ie:
if not variableNameHere == nil then
works with tables?
kahlua adds table.isempty(t)
no idea of the performance, table lib is usually pretty slow
that looks better, i thinkk ill use that instead.
the non-kahlua way you'd do it is if next(t) == nil but next isn't available in kahlua
i think i tried this one for whatever reason it didnt work for me, it does work in an online lua interpreter i tried but not in the code. Or maybe i had a bug somewhere but replacing it with just a key isEmpty made progress. Ill try out the one you mentioned.
The file needs to be at shared/Translate/EN/Sandbox_EN.txt
You have it at shared/EN/Sandbox_EN.txt
btw, you've also typo'd 'tooltip' as 'toolip' each time
yeah, zomboid uses kahlua, which happens to not have next
not really sure what the reasoning for that is
that's probably why it also adds isempty
OMG>>>>>> THANK YOU. jesus christ. i had to step away from it earlier because i was losing my mind. bout to try it.
Anyone know how this line works? IconsForTexture =
I'm trying add in some icons to go with the new textures I have added but it doesn't recognize the new one in game. I just get the blue ? in the inv.
IconsForTexture = BigHiking_Blue;BigHiking_Green;BigHiking_Red;Item_BigHikingBlack,
i think all icons file should have a prefix item_ no? and to be called without one
so remove the Item_ from Item_BigHikingBlack?
weeee. TY!
it's just what ik from when i added custom items to game, not really sure where this field IconsForTexture comes from, have you tried looking at vanilla files?
Thats from the vanilla files I added a texturechoice to the items .xml files that is working and showing up in game. But I cannot figure out how to get the icon to show up from the new texture
okay so you're using icons from vanilla files?
The first 3 are vanilla, the last is one I recolored to match the new bag color
item Bag_BigHikingBag
{
DisplayCategory = Bag,
WeightReduction = 80,
Weight = 1.5,
Type = Container,
Capacity = 22,
DisplayName = Big Hiking Bag,
IconsForTexture = BigHiking_Blue;BigHiking_Green;BigHiking_Red;Item_BigHikingBlack,
CanBeEquipped = Back,
OpenSound = OpenBag,
CloseSound = CloseBag,
PutInSound = PutItemInBag,
ClothingItem = Bag_BigHikingBag,
BloodLocation = Bag,
RunSpeedModifier = 0.95,
AttachmentReplacement = Bag,
ReplaceInSecondHand = Bag_BigHikingBag_LHand holdingbagleft,
ReplaceInPrimaryHand = Bag_BigHikingBag_RHand holdingbagright,
WorldStaticModel = BigHikingBag_Ground,
SoundParameter = EquippedBaggageContainer HikingBag,
}
}
@upper junco you update both places?
remove the Item_ from call
and if you saved the icon somewhere in your folders, rename it to item_NameGoesHere
if you include Item_ in the script, it's going to look for Item_Item_YourNameHere, since it adds that part automatically
ok will try that, thanks. Will let you know in afew min if it works
local zombie = zomtom.create('zombie', '1', '1', '1', 'NameBehaviortypehere'); zombie.manual = false; zombie:setHealth(100); zombie:setSpeed(0.8)
-- add zombie:set traits as needed :)
almost done with my library mod for making custom zombies
I am trying to make a way to easily add new zombies
this is a shortened variant of the code for people who just want to easily add a zombie
@crystal terrace @radiant flame Thank you very much, finally works. Now can add more colors for some variety
this is kind of frustrating
I'm using this function to determine if a player can knockdown another player and it's saying my inputs are invalid
elseif instanceof(collidee, "IsoPlayer")
then
if SwipeStatePlayer:checkPVP(collider, collidee) or collidee:isZombie()<-----------------------------------
then
collidee:setBumpType("stagger");
collidee:setVariable("BumpDone", true);
collidee:setVariable("BumpFall", true);
collidee:setVariable("BumpFallType", "pushedbehind");
--collidee:setBumpStaggered(true);
--collidee:setKnockedDown(true);
collider:getStats():setEndurance(collider:getStats():getEndurance() - knockdownEndCost);
collider:setBumpType("");
collider:setBumpStaggered(false);
collider:setBumpFall(false);
end
end
The arrowed line is the problem line
im making a mod for pz but i need textures anyone know how to make them?
both collider and collidee are players, and aren't null
which... should be able to be taken in as the respective IsoGameCharacter and IsoMovingObject, yeah? Cause the inheritance tree goes object -> movingObject -> GameCharacter -> Player
even if it didn't work that way, i have no idea how i'd access the parent versions of these
what you making textures for?
my mod
what sorta item ?
what about self?
it adds several diff freeze dried items in a can
must the folder under /mods/ always match the Mod ID?
like freeze dried frog meat and porkchop and steak and chicken
you're looking for SwipeStatePlayer.instance():checkPVP(collider, collidee)
by calling SwipeStatePlayer:checkPVP(collider, collidee), self is the lua table that holds the static SwipeStatePlayer functions, not a SwipeStatePlayer object
is there any in-game reference to look at like a category of item yours fit with? checkout their textures and try to keep the same size.You can use GIMP for making textures, there's also a pinned text in #modeling about sizes and stuff for textures refer to that as well
ik but im just bad at drawing and stuff
that's what tools are for in GIMP
oh, in fact, that is a static function, so it shouldn't be called with self at all
are you using umbrella? looks like an error in the method annotations
for staters try to copy the textures from something else maybe even in-game ones.
let me pull up an example of what i did
yeah i tried that but its to difficult for me
but yeah, just call with . instead of : and it should work
no umbrella, I have the game decompiled for this mod. I've been using umbrella for other projects though
agAIN?! let me see if this works
where'd you get the method annotations then?
lmao
the one you screenshotted
if it's capsid, yeah that's just one of the many things it gets wrong
i didnt understand too much about UV mapping but iknew i had to keep the sections as vanilla textures have so i just used the vanilla texture aas base and tweaked the color and logo. Plus once its in-game it's so small you could barely tell if its poorly designed.
yeah it's capsid. The file itself is searchable within the lua library I have added to my project
yeah, capsid's being so crappy are the main reason umbrella got made
although tbh i think capsid's lua annotations work better
the java ones are much better in umbrella but the lua ones always send me to the stubs when i try to jump to the source of a function
capsid annotating the game's actual lua instead of creating stubs worked better because of that
this is valid right? like im trying to make context menu options for two diff items
this worked
Thank you albion!!!
new problem. I have zero experience with sending events / packets, and I'm assuming that's the issue here
yes, but i'd recommend merging them into one function (even if it's a new one that just calls these two functions) as communication between java and lua (such as events) is very performance heavy
On my screen the other player gets knocked over, but the other person doesn't see anything. :S
hmm, sounds like you do need some communication then
i was thinking if i could that, also for some reasons if i were to right click on scanner item it triggers a function inside of doortag context stuff. Weird stuff.
and it doesnt happen the other way around, anyway ill try with one function maybe that's whats up
Do you know where I could research to figure out what exactly I need to do?
unfortunately i think the most well known guide on it was written by dislaik 💀
fuck
as a basic rundown, sendClientCommand(optional IsoPlayer player, string module, string command, table args) fires the OnClientCommand(player, module, command, args) event on the server (commands are named after the sender)
if the player isn't specified it assumes the local player 0, in most cases it doesn't need to be specified
then sendServerCommand(optional IsoPlayer player, string module, string command, table args) fires the OnServerCommand(module, command, args) event on the client (notice one less argument is provided to this one)
if the player isn't specified it sends it to all clients
the module and command strings are technically arbitrary and can be anything, it's up to your code to use them to identify commands, but typically module is the name of your mod and command is the actual identifier for which command is being sent
in your OnXCommand handlers you'd check the module and return if it isn't yours, then execute code based on what the command is
gotcha. So I could get away with doing a sendServerCommand(collidee, "AnthroTraits", "knockdown", {args here}) for both zombies and players that are knocked down. And I could look for an event in your documentation that does said command and check inside the event to make sure the module is "AnthroTraits" and the command is "knockdown".
here's an example```lua
-- on the client
sendClientCommand("MyMod", "Print", {text = foo})
-- on the server
local OnClientCommand = function(module, command, player, args)
if module ~= "MyMod" then return end
if command == "Print" then
print(args.text)
end
end
Events.OnClientCommand.Add(OnServerCommand)
(if you don't notice, edited to correct arguments being in the wrong order - because why would it make sense)
a common practice is to store command functions in a table, where the keys are the command string, and then just do commands[command](args) after the module check
I think you're missing a "," on the client 
But oh my, this is big
I'm definitely going to note this down
Will be very useful
Even though it wasn't me that asked for help, thanks for explaining it all 
Same. Thanks Albion
in a bit i'll look around the usual spots and if i can't see a good guide for this i'll write one up
elseif instanceof(collidee, "IsoPlayer")
then
if SwipeStatePlayer.checkPVP(collider, collidee) or collidee:isZombie()
then
collidee:setBumpType("stagger");
collidee:setVariable("BumpDone", true);
collidee:setVariable("BumpFall", true);
collidee:setVariable("BumpFallType", "pushedbehind");
if isServer()
then
sendServerCommand("AnthroTraits", "knockdown", {collidee})
end
--collidee:setBumpStaggered(true);
--collidee:setKnockedDown(true);
collider:setBumpType("");
collider:setBumpStaggered(false);
collider:setBumpFall(false);
end
...
AnthroTraitsMain.ATOnServerCommand = function(module, command, args)
if module == "AnthroTraits"
then
if command == "knockdown"
then
args.collidee:setBumpType("stagger");
args.collidee:setVariable("BumpDone", true);
args.collidee:setVariable("BumpFall", true);
args.collidee:setVariable("BumpFallType", "pushedbehind");
end
end
end
Am i picking up what you put down correctly or is there a grave misunderstanding here? Would I be sending a client command...?
@bronze yoke
unfortuantely your situation calls for client to client communication, which is annoying
you basically need to ping the command off the server
you have an OnClientCommand handler on the server that sends a server command to a client specified in the args
you can't pass an IsoPlayer directly so you'll need to send their onlineid as an arg and then retrieve the IsoPlayer from that
okay, lemme think on this
I'm guessing OnServerCommand would be appropriate for Zombies that are knocked over though?
or do I have to sync that between clients in the same way?
have you tested if that needs to be manually synchronised? my assumption is that it wouldn't need to be
since zombies aren't generally controlled by the server anyway
unfortunately yeah. I tried knocking a zombie down in front of the player in that one video and they didn't see it get knocked over, or affect at all. The zombie dysynced on my screen, sped up to the other player and bit him
was the zombie chasing them? pz's netcode gives ownership over a zombie to clients, usually the one they're chasing (so that ping is never a factor in you getting hurt)
maybe it'll synchronise if the knock down comes from the owner... or maybe not
they were chasing the other player, yeah
oigh. This is more complicated than I thought it was gonna be
im interacting with a diff item to open context menu but the debugger stops at this snippet of code from different context menu altho its not even targeted .
code for both the item's context menu are called by one function which is triggered by OnFillInventoryObjectContextMenu event
Pretty much every inv item triggers this error
I have found no reliable method of syncing a zombie's state across multiplayer. i.e., knocking them down and what not, and having it sync. You can't pass a zombie over a client command, and while zombies technically have an online ID there is no function to get a zombie by that ID so its worthless.
My current thought is to build a cache by the zombie's ID based on your current cell periodically, but it doesn't seem to catch all of the zombies when doing this.
You need to check if containerItems is nil. you initialized it to nil and only assign it a value in the next for loop. its stopping because you're trying to call the function :size() on a nil table
oh, i threw in a check before the arraylist traversal. Now it stops on declaration of containerItem. ill see if there's any other errors or maybe restart or something. Ty
Can you paste the code here? it's hard to see what is going on
you were right about this one, ty. Missed an end as well that ruined the if check.
just fixed it
Just working with one item behind the scenes takes a lot of time
ill prolly need to do a lot of optimization once it becomes functional as a whole concept
Thoughts on using
"reportEvent("wasHit")" or "wasBumped" instead of trying to sync states?
This seems to be what MoreTraits does with their similar trait, BatteringRam
thinking about this still
server commands can only be sent by the server, client commands can only be sent by the client
if you want a client to send commands to other clients, which is your case, you need to use a client command that makes the server send a server command
oh, yeah, sorry lol
I had updated that already after rereading what you sent and thinking on it more
i've gotta say I'm just... so burnt out right now.
this is a frustrating issue
i hope the report event thing works, as manually synchronising it like this is ugly
and as dhert pointed out you can't even easily communicate which zombie is being affected this way
yeah it's been like this for a couple weeks now lol
at least i'm reaching out much less here cause i know a lot more about research and what I'm doing
Come thursday if i'm still not done with this I might pay someone to try to help me out lmao
I've been trying target:reportEvent("wasHit") for a bit now, and it hasn't worked. 😦 where "target" is for sure an IsoZombie
there's also "wasBumped" and "wasHitPvp" and "wasHitPvpAgain" lmao
it might work for the "bumps", but its not working for me when i process a hit over MP. been scratching my head on this one for a while.... lol
each of those attacks definitely hit and caused the zombie to wince on the attacker's side no problem. but other players don't see that
A question about ItemContainer that we get from getInventory(), it has a bunch of method to verify if the container has a certain item which are expecting item name as string. Should i use item name as module.itemName?
No, just the item's type:
playerInv:containsTypeRecurse("Torch")
even if its your custom item?
I guess it checks for both the type and the full type in the java. so use whichever.
Can I pass a InventoryItem in the args of a sendClientCommand?
It works, but it doesn't guarantee you to get the same item obj. e.g. send to server and back to clients will be different object when you receive it.
If you need the object, it's best to find the ItemContainer and get the object there by using getItemWithID or getItemByID.
sending items should be used when you need the properties of the item but not the item itself
Okay, thanks for clarifying it! @bronze yoke @fast galleon
@turbid gale did you see the comment on the anims of your mod?
Been using this event for a while, a few hours later it won't trigger. Any ideas what might be wrong? I have reloaded saves a couple of times and files in teh correct location as well.
only one that's actually mine is the FAL charging, so I can't speak for the other ones.
most vehicles code need to be done on server and these events trigger on client only. Which is why I use them to send command to server for server trigger.
are you suggesting that i write this code in server and trigger an event from client which will trigger another event on server side?
Only if you want it to be MP compatible and it's something that needs to be done on server.
If the first print doesn't happen then you do something wrong, like maybe try to do this on server.
i think this is what you mean by that
OnXCommand handles, about this one not too sure how work with.
i was hoping not to complicate things right away, but you're right i should prolly keep it MP compatible.
speaking of print and server, when you host, the prints are found coop-console.txt
it's a snippet from vanilla client/ServerCommands, say if i were to trigger something on server side do i need this event or i just add my commands to my table Commmands. I have added event on server side OnClientCommand
Hello, is the full map size x,y (19500,15600) or (19800,15900)? I am looking at what's supposed to a be vanilla map with WorldEd and it has the later max sizes, but it would not make sense if a cell is 300x300
1 cell is 300x300
1 cell has 30x30 blocks
each block has 10x10 squares
and each square can have multiple tiles (textures)
how many cells teh whole map has?
65,52
Oh ok sorry, I was taking after worldEd
Oh yeah misunderstood lol
it's files should be 65_52.lotheader chunkdata_65_52.bin world_65_52.lotpack
/projectzomboid/media/maps/Muldraugh, KY
you can get a good idea how they are set up by opening projectzomboid/media/maps/challengemaps/Studio
that one only has 2 cells
these are it's bounds: 300 300 900 600
as you can see Studio only has these cell files:
chunkdata_1_1.bin chunkdata_2_1.bin
you can also see that it relates to it's bounds as a cell is 300 by 300
1_1 = 300,300
2_1 = 900,600 (if im not mixing them up)
Any idea which part/event of the vanilla code handles the player damage upon vehicle crash?
those are it's starting coordinates
thank you for the explanation, helpful 🙂
Depend on how you made the command handler
i just wanted to get a top level idea of what's going with these command exchanges b/w server and client
You can have a single function to handle all your commands
and the handler would grab the command table on either side and start executing those commands?
So you need two functions each side and then you can send functions in commands in your code.
it is better instead of making a lot of checks for x command in a function.
these two functions would be stored inside variables which will be sent along from server to client and vice-versa?
Nah, they are global functions and then you send your functions in variables to them.
would you call these global funtions handlers then? the one executing these commands on each side?
Yes
and id need an event to fire these handlers right?
Yes
so roughly that's all there is, thanks. Ill try out and experiment see what moves what.
I think there is a good reference in server/ClientCommands.lua
but idk, I don't remember
the mod isnt appearing in the game. I have added it to user > Zomboid > mods and it isnt appearing in the mod s area.
Also, it doesnt load in the game either as the screws / nails dont covert to each other (no option to do it)
can anyone help please? I dont know how to fix it
Maybe there's something wrong with the structure inside the folder
but it goes in that file location, right?
(spiderman is placeholder)
Yeah that's right, I mean inside your folder
I think there's something wrong in the folder order
wdym
Mods/TurnScrewsIntoNails Mod/mods/Nails to Screws
I think there's a "mods" folder in the middle there
nope
Nop, I'm wrong
Theres actually more folder than needed
All these files need to be in the "TurnsScrewsIntoNails Mod" folder
Not in the Nails To Screws
ok lemme retry again
does the scripts stay as .txt?
Yes
You have mod in amod
try taking all of the stuff inside turnscrewsintonails
and get rid of the second folder
thats good signs now
its appeared in the game
now ima test if the mod conversion works
Funnily enough
I just came on here with the same problem
Will see if I'm doing anything wrong too
so the mod structure in mods folder should always be
..mods\YourMod/media/stuff
for workshop it is
..Workshop\YourModCollection/Contents/mods/YourMods_CanHaveMultiple/media/stuff
usually if your mod is not loading/appearing in game, you messed something with that or mod.info file.
That's why when you install for example 10 years later MOD, you have 6 version of it, because it is collection of mods.
sometimes it also appears at the bottom of the mod list i think
What I and dome wrong, was that I put my mod 1st of all I to my downloads folder (I forgor) and then I to the actual zomboid folder rather than the user q
Should prolly pin these folders, makes life much easier
You actually got me an idea, gonna work on github for that.
with modlist text?
Nah I mean for mod structures to just make new people lifes better
I think i saw a mod template somewhere on github
ah i also have a guide up on steam
but you could add stuff to wiki if it doesnt exist, having everything centralised could be of great help
the more resources the better
There is an example mod in the game files, but yeah better to have one in open.
actually with github itll be much smoother just pull the repo and you're ready
You should totally do that
That was exactly the reason I started making website for pz modding and stuff, just to centralize everything and make small tutorials, examples to help people get started and for reference.
wait are we talking about pz wiki?
something like https://tarkov.dev/
Checkout all information for items, crafts, barters, maps, loot tiers, hideout profits, trader details, a free API, and more with tarkov.dev! A free, community made, and open source ecosystem of Escape from Tarkov tools and guides.
pz wiki is good for reference but its off in many topics
Someone have a good github on event descriptions acutally, but having everything* in one place would be good.
guys i got the mod working, but for some reason the gun model aint showing up in my hands
ye true a lot of work needs to be updated
Are you using vanilla model or of your own?
one of my own
from what ik ground models and static models are different(static being you use in your hands)
vanilla has seperate files for that, im not too sure how they handle that. Might wanna head to #modeling to learn more of that stuff.
also there is no explaination on fromLua method, no docs about it, nothing afaik.
Thanks!
I decompiled the java files and well, there is something but needs documentation and testing
Can someone what has gone wrong in my mod? I have it active but its not working at all.
Theres no GUI for turning it into nails
@warped condor sorry for ping, u seem to know what ur doing with mods
its because the mod keeps auto-disabling itself
is that why it wouldnt stay enabled?
Probably.
Follow this file structure
module MyMod {
imports {
Base
}
... your stuff
}
So it would look like this I guess
module MyMod {
imports {
Base
}
recipe Turn Screw Into Nail
{
Screws,
Result:Nails=1,
Sound:PutItemInBag,
Time:2.0,
}
}
I'm not good at script files, cuz they aint lua.
you miss s and yeah those brackets were fine I guess, so I misled you.
Lmk if it works now
wdym
like
normal resizing
because they are way too big
it aint 32x32 for icon and idk what poster.png size is
so poster size at max is 256x256
preview for workshop is the same
icno is 16x16
I guess
you can open paint and go to resize image
thx
it allows you to select pixels or %
To resize it use paint/photoshop/online sites.
aight lemme retry again
isnt it import ? or imports?
When I enable it, then press accept to save the changes, it doesnt do anything at all
it disables itself
wym?
what to
anything else
also you might wanna make sure its screws not screwbox or something else
Yup it was just example that he sent
prolly in items file in scripts folder of vanilla files
for ex here it says screws and screwbox are seperate
it's a BaseVehicle method
when i was playing around with vehicles there really wasn't any way to mess with it
i think it was literally just damagePlayers()
sorry i dont understand
what i mean is you should check your script and see what name you have used to item to interact with, is it screws or screwbox. Name should be matched.
so what would this do then
cause I want it to get a screwsbox and turn it into a nailsbox
they all use the correct name, i think anyway
It should work on ScrewsBox and turn it into 1 nail box i think(if the item names are right)
im assuming you're restarting your game each time? to load the scripts with the changes you made
yes
the mod keeps disabling itself again
wtf
why does it keep doing this
do u want me to send whole file in so u can test it or smth
cause it aint workin for me
yea
send console.log
wheres thatr
c users user zomboid console.log
im not sending it fully because it revails my name and location
also it doesnt appear in console.txt
i've just checkled
Need some help with doing a ForLoop in lua...
local function OnZombieDead(zombie)
local zedItems = zombie:getInventory():getItems()
for i = 0, zedItems:size() -1 do
print("item getCategory == " .. zedItems:get(i):getCategory())
-- This does NOT iterate the correct amount of times.
-- Just tested in game, a zed had 11 items, but this only iterated 9 times.
end
end
Events.OnZombieDead.Add(OnZombieDead)
Does anything look off, here?
that's because this runs before loot generates
if you look at the zombie's inventory i bet you'll see there's 9 clothing items
zombie loot isn't generated until the first time a player is in range to access the container
7 clothing, 1 "ammo", 3 "accessory"
anything that would be visible on the zombie should be there on this event, but nothing else
anything visible, that would be fine for my purposes. but military boots get skipped. maybe because the pants cover the top half of the model, or something. hmm,
can anyone help still, it appears in the mod list but wont let me enable it (it auto disables it)
In the recipe blocks I see use of things like this "[Recipe.GetItemTypes.Spoon]" - I am curious, when creating an item, how do I tell it that it is a spoon for use in this case?
maybe remove " (and-vice-versa)" from the name? do you have both workshop.txt and mod.info in the correct folders?
