#mod_development
1 messages ยท Page 25 of 1
This is def one way, however it's.. not optimal.
Main reason being, well, it isn't compatible with other mods that override the same file.
Is it likely people will override it? Nah. Possible? Yes.
So what do I do?
I believe DoParam exists (?) which allows you to dynamically set stuff like that via code
it does
I've only seen it once or twice so I have 0 clue how to use it
have to use it before the item is instantiated tho
Prob on game boot yeah?
can't do it live once it's been instantiated
if u do it in shared lua
is usually fine
scripts can instantiate items
and some do
like loot scripts
sometimes
time decreases loot for example
or other mods that might tweak the item
local item = ScriptManager.instance:getItem("Base.PetrolCan")
if item then
item:DoParam("AttachmentType = Gas")
end
That's it. Just do it this way in the shared or server directory somewhere in a lua file.
yup
man im too stupid for this
xD
I was too
I feel like theres this modding menu you guys know about lol
Not really, it's all done via scripts and lua.
I just downloaded similar mods to what I was trying to create and followed their structure
That's really how most, if not all of us learn.
I do have a lil Java under my belt but it was pretty much following other people's mods
Don't feel too bad about being lost at the start by the way, it's normal.
at this stage, how can I have it effect happiness
Flote is that a txt file?
I spent 6 hrs the other day on a mod that should have took me 5 min to make but I missed a capital R and had an extra category in the recipe
yes.
Alright, hold on.
Should it not be?
I'm gonna guide you to where you need to be for that to work, mkay?
Is there something else I could use
I mean, technically notepad works, but I doubt you wanna put yourself through that agony.
That's prolly gonna be a lua
I dont
Not txt
^
I dont want to be in agony
One step at a time doh
Hehe understandable
I personally use a program called VSCode
(Visual Studio Code)
Notepad++ works for me but I'm sure vs is better
It helps to format everything all nice and tidy once you get the right extensions for it
and yoink im stealing that
i use scite mostly
Anywho, you'll need to create a new .lua file in order to actually run lua code.
crossplatform works with any language etc
okay 1s
And before that, we need to make sure that file is in the right place.
how do i make a lua lol
Your best bet for setting up a mod is by going to C:\Users\USERNAME\Zomboid\Workshop and copy pasting the ModTemplate file there.
Yeup basically
code and text are just plaintext files
okay ive got it open now what
I think you can just do "Save As" and put .lua at the end iirc
Alright, you copy pasted the template mod yeah?
yes
Alright.
There's some things in there we'll need to change before we can actually have a place to put it.
okay
The reason? It's a test map mod for the template.
last modding community i was in i wrote the template that ended up being given out :p
i dont envy u doin this over and over to help diff people
lol
like a reason im making this?
you have to put up the scaffolding
before u can build a building
this is the scaffolding ur working on
I just want popcorn to make you happy tbh
Alright so..
btw thanks for helping
Rename your new "mod" file to whatever you want for now
Object's name is "Thumpable" (sprite name "furniture_storage_01_46").
Np!!
Already did
๐
Okay perfect
You'll want to go down into "Contents" and edit your "mod" file really quick.
You're a smart cookie, so I have a feeling you'll be able to edit that with relative ease.
im in the contents
Just change the name in there for now so we can identify and enable the mod later in-game.
lol
i dont have maps only scripts
Oop?
That's alright then.
We might be interacting with different templates but it should work all the same iirc
okay
You can remove the "scripts" folder, we won't need it.
(If we were doing it the cheap route, we would, but we're doing it the snazzy way!)
okay
Alright, now we're going to make a new "lua" folder
got it
In there, we'll put another folder called "shared"
okay
Then, at long last, that's where you can plop down your newfound lua file.
a blank one or the one i already had
okay
im sure ull run into it eventually too lol
okay ive got the code
Perfect, if you have VSCode now, we can set that up with a single extension so it'll recognize parameters and the like.
Literally all you'll need is the "Lua" extension but sumneko
VSCode should make adding extensions a piece of cake, though if you need help I'm happy to assist.
where do i go
You'll see these buttons to the left, the bottom one is for extensions.
oka
Then you should just be able to type "Lua" in "Search Extensions in Marketplace"
first one?
Whichever is made by sumneko
okay got it
I believe it's the top one, but do check.
Perfect, alright.
Now go ahead and pop open your snazzy lua file in VSCode
Perfect!
Look at you go, mastering this in such a short timeframe when it took me days

Alright, now for the fun part, programming!
i mean I am being helped
Fair point.
okay im ready
Alright.. so now lemme read up a tad.
okay
Gotta figure out what the parameter is called that we'll be editing
im gonna quickly get some soda
Found it, it's called "UnhappyChange"
okay im back
You'll notice this is unhappy change, so giving it a positive value will do the opposite of what we want.
So we'll need to give it a negative value.
okay
In your script, edit the :DoParam() to make it into a "UnhappyChange = " setup
You can put your chosen value in after the =
(Remember to make it negative!)
including setup?
you have the word setup after the "
okay
Just do "UnhappyChange = -10" or something along those lines in the :DoParam()
So something like..
:DoParam("UnhappyChange = -10")
now im guessing I replace the petrol with popcorn
Mhm!
@weak sierra Question rq, does lua code run on it's own or do we need to hook up an event?
I'm pretty sure an event is needed but I wanna double check to make sure I'm not being dumb
(Sorry for ping aaa)
hey guys can someone send me the cursorwhite and cursor_normal files found in media/ui ?
I have changed a lot on files so cant verify, just need the two
I think udderly is busy, lets just play it safe and hook an event.
okay
(Also sorry Snow, I don't have a copy atm, I'm sure someone will get back to you tho!)
thanks, yeah no rush
I would verify if I didnt have a ton of mods and altered the files
Alright, now we're gonna do something interesting.
oh god
We're going to hook our little bit of code into an event.
okay
Don't worry! It ain't so bad.
good
First, we need to turn our bit of code into a function.
okay
I'm assuming your code looks something like this right now..
local item = ScriptManager.instance:getItem("Base.Popcorn")
if item then
item:DoParam("UnhappyChange = -10")
end
That's quite alright!
I might need to check something right quick to make sure we're modifying the correct item, so gimme a second
okay
(There's likely two versions of popcorn, if I'm not mistaken.)
I can't seem to find anything else, so lets stick with this for now.
okay
okay
This will, as you probably would expect, fire a function of our choosing on game boot.
okay
Put this below the rest of our code for now. Make sure you don't group this in with our future function.
Oh that's pretty easy to change I'm learning something new
under end?
mhm!
okay
spooky
Your software is going to freak out for a second, because we haven't given it something to end yet.
okay
So don't worry if things go red for a moment.
i did slightly panic for a sec
At the top, we're going to put in "function FunctionName()"
Without the "
Change FunctionName to something of your choosing, but keep it relevant!
it runs on its own
okay
It does?
mhm
That's news to me omg
got it
lmao
Tysm
how do u think it runs the part where it hooks up to an event
Is it bad to hook it to game boot or?
if it doesn't run on its own 
xD
it's way better to just have stuff run on its own when possible
stuff shud only run on events when necessary
Okay so flote I just got some intel from a very smart person!1
sweet
keeps load order sane and understandable in the environment
Forget that second end and completely ditch the event!1
What you have is apparently fine! Congratulations!1

so remove everything about end
Just remove the second "end", the function, and the event.
okay
okay so im ready?
(now I gotta go edit my mods smh, shame on you evelyn for being smart!)
Anywho, we gotta test it before assuming it's working, right?
yea
There's a couple ways we can do this, if you'd prefer the short and easy way since this may be your only mod for now, I can tell you how to do that.
If you think you'll be returning to the modding scene, I recommend a longer method.
i dont know if i will tbh
Okay, all you need to do is add "-debug" (without quotes) to the startup options to PZ
Then boot the game, you'll notice some things will be different.
Mhm!
okay
Then once it's saved, we're gonna head into pz and find your snazzy mod.
Alright, you probably see a couple new things right off the bat.
yep
Welcome to debug mode! The little pop-down menu is our scenarios.
We'll worry about that in a second.
okay
Looks like more traits
Just click the little play button up top
This happens in debug mode to, well, help debug.
the arrow going right
Mhm!
okay got it
If (fingers crossed), that was it, you should be in the clear.
Alright, now explore your mods folder for your mod.
Make sure to enable it, or your changes wont happen!
Under workshop iirc
oop my bad
It's quite alright, you can just reload your lua in the bottom right once it's moved
Handy!
1s
tbh i closed the game and moved it]
1s
nothing is showing up
should i have named the .lua to something
Hold on, lemme see
1s i think i might have fixed it
let me check
okay let me check if it worked
it didnt work
Im checking things on my end rq
I've got it here
It in the right place and everything?
Mkay!
thanks for helping
Yeye!
at least i get to eat popcorn bc i cooked it
wait theres an in game editor
With debug I believe so yes, but it won't save.
oh god adding magnet fishing is gonna be a compatibility nightmare
adding a lure is easy, getting it to work the way I want wont be
I am having issues where I cannot remove or update items on the loot tables. Even if I use RemoveItemFromDistribution and I confirm that it disappears out of the list with LootZed - those items still spawn at the original rates - but just don't show up in LootZed. I cannot find any way to actually get these adjustments to stick after the initial creation of the world or installation of the mod - even if the mod is removed and reintroduced with adjusted rates it still sticks to the original ones from the initial world start or mod install. - These were entered using the style "table.insert(SuburbsDistributions.all.inventoryfemale.items, "module.item") table.insert(SuburbsDistributions.all.inventoryfemale.items, (1)" - Is this a broken way to enter into the loot table for generic zombies? Is there any way to update or adjust this after the fact? Has anyone else ever experienced this issue? I am really stumped here. - My next steps are just forgetting the zomboid loot system all together and just shoving my items into inventory with my own scripts - but I would rather use the existing system - it just doesn't seem to want to be used.
debugging lua is pain in the ass tbh...
wish there's hot reload or something like most environment, such as nodejs
It sure is. It would nice to have a diagram of how some of this works. I am setting loot rates in sandbox and I think it does not work well. I think on the first time the game is loaded it gets those rates, but after that I think it when it gets those rates it does it too late maybe? If I comment out all my distribution entries completely then nothing spawns on a reload - if I count on it to look at a bool to make choice about which entries to do - it always goes to the initial one - not the new setting - even after running /reloadoptions - it has to be me misunderstanding the order of these things - or it is just buggy as hell and loot entries are not meant to me adjusted via sandbox by design.. maybe?
things may get overridden or something perhaps
i create a dummy local dedicated server that mimic the settings/loadorder in the main server, by then i can restart it all the times for doing a test before deployed to main serer
doing every test/edge cases in the test server, reload it, restart it, I notice even just a single missing "," in the scripts might cause indefinite black screen
without any further informaton
Yeah there is something with the orders for sure - I am trying to figure out the steps to get it to behave - I may be doing something out of order here too in my testing so I am looking at all of taht right now
really pain in the ass... also if the mod on the local isnt updated as in the workshop, you have to rely on steamlibrary workshop folder, not on your document/zomobid/workshop, so i have to copy between both, whenever restart, i copy to 2 folder (server/clientworkshp), then restart server, also reloading lua in F11
Cool thanks for the info!
unless if I already upload the new version, then server downloaded the new mod with new structure, i can just save my changes and F11 reload lua inside the game.
otherwise it will still be manual copy and paste. between 3 folder
for /Server folder you need server restart, whereas for client and shared can be done by reloading in the client.
or in server reloadlua
but server restart might do better.... as it freshly reloading it
Do you know if it is possible to run a local hosted server with a local mod and not with a workshop mod? For testing purposes that is
Good to know on that.
For that purpose, i just have to rely on current mod folder, usually at the end of the list, restructure it into separate mod later etc, never try with dedicated server, for host perhaps..
probably this way is working, find a mod workshop ID that are useless, put it in your server config, then just replace with your things there, to update the mod just copy over to your local dedicated server/workshop directory
K, I see. Thank you. Lots of tedious testing ahead.
I suspect the server always check the workshop upon restart or something, so yeah, a real workshop ID that can be found on the workshop might do the job, even it contains nothing in it, haven't try that yet.
C:\SteamLibrary\steamapps\common\Project Zomboid Dedicated Server\steamapps\workshop\content\108600\ [hereWorkshopID]
by that you dont have to upload to workshop everytime theres an update
Right now I run everything on another workshop entry and then I test using that and merge if I like it which seems to work okay
if there's multi autosave feature in your editor, make the files you are working also save to that folder as well, also the client\workshop folder
My problem seems to be that you cannot update loot table probabilities via changing sandbox settings. It will do it right the first time but will not successfully update after that. I even made a script that removes items from the loot table and restarted after that - right back to using original sandbox setttings - loot tables still report everything removed. So I am thinking it is not possible to set loot table stuff with sandbox variables except for the first time around that either the mod is installed or the world is started - after that it seems to ignore sandbox and go to whatever the initial setting was (not the default).
I can remove everything successfully from the loot table by removing the entries that are under the bool that was set the very first time.
In my actual script. So this gets saved somewhere and the game loots there - not back at sandbox - at least for loot tables. So I need to find a way around this and to see if I can ever see the adjusted sandbox settings via code or if they are not accessible.
so there are 3 dir i'm working
C:\Users\saver\Zomboid\Workshop\WORKEDMOD\Contents\mods\ --- [1] File im working
C:\SteamLibrary\steamapps\common\Project Zomboid Dedicated Server\steamapps\workshop\content\108600\SOMEID\mods\WORKEDMOD -- Server mod, i have copy [1] if test server need restart
C:\SteamLibrary\steamapps\workshop\content\108600\SOMEID\mods\WORKEDMOD--- [3] Client loaded files, if the server checksum are alot difference in the structure
So i'm editing [1], whenever changes made, i need to put [1] to folder [3] and reload via F11, if /server folder mod changes, i need to put [1] to [2] and restart/reloadlua on the server
if server restarted, i copy over [1] to [2] and [3]. then restart the game as well
gonna save for reference - thanks
yeah... try to check the load order, and Events subscription, there's onGameStart, onPlayerUpdate etc... to see which one is "refreshed" or reloaded during the runtime
also find a mod that does the settings in sandbox and could be reflected right in game during the runtime.
it might gives you clue...
I am actually finding a lot of mods with the same problem - doh! but hopefully I can find if one does it right - I thought more loot settings might do it - but it looks like that might have the same problem too.
Signing off for a bit but more testing later tonight - thank you for all your help here. something tells me... I'll be back ๐
hmm.. haven't tried to mess with distribution yet to notice the quirks, so far the architecture itself are relying on events and stack of object, lets say I wanted to change after plowing land also seeding it automatically, i've tried it can't be done because the isoObject are delayed to change until the timedaction function ends.. (calling another inside that action doesn't works except if its artificial function (like cheating it, emulate everything)), the closest thing is creating new cursor object with seed, where user need to do more click
right, hopefully you fix your probs soon...
Thanks! ๐
ISInventoryPane.onMouseUp fires when dragging items between the panes, but it doesn't when dragging off the panes onto the main game screen (to drop the item). How can I intercept an event when an item is dragged from a pain to the main game screen?
Also I'm looking for a way to intercept the TransferAll event
Anybody know of a mod off the top of their head that adds constructions I can reference?
overriding? set the destination to your choice and process the item in the loop?
there is hot reload
if u use debug mode
u can reload all, or reload by file
just unsub from the live copy of ur mod and use the one in workshop directory
it's uh.. simpler
@weak sierra hey sorry if the ping is annoying but just wanted to say thanks for the great mods
i know that, but that's not hot reloading, as you need to go into F11 and reload by files, what i meant was Hot reloading every CTRL+S or autosave, where's file is monitored for every changes.
ima web dev, its the same as F5(refreshing) in every file changes. meanwhile hot reloading should behave just like PM2/nodemon, or using webpack, https://webpack.js.org/concepts/hot-module-replacement/
probably in the future it can be done and applied/turn on/off on demand in debug mode, since it was the same as putting file monitoring in the coroutine to reflect/F11 for every file changes
Damn the building code is really based around the idea of using a hammer
?
There's a flag for ISBuildingObject called noHammerNeeded and it changes a lot of things based on if that's true or false
If it's true, it makes hammer noises. If it's false, the derived class ISWoodenWall (also used for metal walls) thinks you're making a log wall and forces the animation to be something else
I'm gonna derive from ISWoodenWall and replace the method that's giving me issues
I have very cool mod idea but poor modding skills
But this idea is too good so i search for someone that can make it
Someone who know how to make cars and perks
it gonna be enought
Type it out and if someone thinks it's good they may comment
Don't @ people though about it, just type it up
what item that has tooltips, wanted to check how it looks, then scrap the code
ok
So...
Imagine the negative perk that you were involved in in a car accident, as a result of the accident your two legs are limp for the rest of the game.
You start the game in a wheelchair that is treated as a vehicle, you can repair it, modify it and install some improvements, such as headlamps.
Moving without this cart would be possible, but the character would only be able to crawl.
Of course, all actions that would require the use of legs (e.g. driving a car) would be impossible to perform.
And it would be nice that such a friend in a wheelchair would have a hard time at the beginning of the game, but with the development of his wheelchair, he would be better and better.
Imagine if he could have a lot of things with him because he would have small containers welded to the wheelchair.
Tell me if you like the idea and if you could help make it appear in the game
.
Finally got the 3D model of the helicopter implemented and fully working! ( When the player spawns a heli will be spawned beside him too ). Note that the heli still require fine tuning/adjustments but that's the easy part... ๐
Off the top of my head scrap weapons uses tooltips
need the tooltip to show dynamic var/moddata
how do i add tooltip on hover without overriding it...
ISInventoryPane has alot of nice stuff for various tooltip stuff for showing variables
thanks
Which loop are you referring to? Is there not an event (when dragging an item to the main game window, or when clicking TransferAll) to overwrite (similar to ISInventoryPane.onMouseUp)?
Oh, there is ISInventoryPane.transferAll(). That looks like it does exactly what I'm looking for. I can modify that
there is loop even i haven't seen the code yet
the way it works, like transferAll, it might loop in to the destination
finding the bag, iterate tru multi dimensional table/array etc
also the items transfered need to be iterated as well.. in every general programming stuff, loop is kinda essential, coroutines, event loops etc
Ah, and ISInventoryPane.onMouseUpOutside() might be an event I can override when dragging an item to the main game window. I'll try those two out.
onmousemove?
what you want to achieve by the way
handle the event when the user drags an item from an inventory pane into the main game world to drop it
i see...
local dragging = ISInventoryPane.getActualItems(ISMouseDrag.dragging)
I'll try these out. Thanks
hi, what if I want to find nearby players (and this is easy) that are also potentially visible by my player (if I were to turn around by 360 degrees)? In other words given a player I want to find all players that he could potentially interact with, if another player is very close, but they are separated by a wall they shouldn't count (same if they are on a different floor)
I guess that there is no "is in line of sight" function that I could call
Wanted to ask simple question, does modData could store boolean values?
guys i have question how do i find this "Recipe.GetItemTypes." on the vanilla lua
The coords order in PZ is x,y,z or y,x,z?
nothing in the lua side that I know of, but the java side does some stuff. there is a lineClear function in LosUtil.java which to my understanding should be able to do this. although im not sure if you can actually used it as I haven't tried to do anything like this b4. you could also dig into the super survivors code. tmk there is some line of sight logic stuff there for aggressive npc that shoot at you. not sure if it is custom code, or if they utilize this function.
yes they can
Is there anyone who have made a repo with decompiled PZ? ๐ค
Thanks..... gonna try
doubt it. it sounds like something that would be TOS although idk. v good tutorial here though to do it for yourself
would be nice if an admin would just pin any of the messages for the decompile guide. so many times it needs to be shared, and I have to go find a link for it again every time
Thank you both, I did already followed the tutorials, but I was looking for a simpler solution like at the PD2 modding scene, where one person has the repo with everything decompiled (and fixed where needed)
with lots of PZ version, it would be tedious, having lots of branch.
much simpler if you do it yourself, it's automated as well with intellij.
@gilded hawk from the same guy, pretty nice boilerplate as well https://github.com/Konijima/PZ-BaseMod
Thank you, but I alreatyd have my own boilerplate https://www.npmjs.com/package/mx-create-mod
great, probably merge his base code into yours as well, other than just scaffolding the folder
it will be useful and much simpler
with your scaffold approach
Maybe, i'll probably merge it with PipeWrench tho
What's the benefit of having the Java side of the codebase? Can you actually do anything with that? I thought the only extendible part was the lua
it's handy to figure out hidden behaviours that are only visible in the Java files
eg: what traits really do
Or stuff like this: #pz_b42_chat message
thanks, I was also looking at IsoGridSquare::testVisionAdjancent but that only works, as the name implies, for adjacent squares. From there on you have to work your way for a full line of sight. LosUtils::lineClear seems much more promising, I'll also have a look at the mod + how the game actually works for aiming/sight
kahlua are just on top of the java, there are lots of things hid in there.. the one who emulate the Lua part
I understand the benefit of understanding how the underside works, I'm just curious if you can extend it
there are alot of things in java side that become relevant in just seeing how things work. For example the lua events are utilized alot, but almost all of them are actually called from the java side, so it is very useful to see how they are working.
you can extend java, you just can't share those mods on the workshop.
thats why most modding is still on just the lua side
has anyone tried this yet? https://github.com/pzstorm/storm
they wrap into nice API but it needs frequent update to follow up, so im not sure if its up to date to the current API.. probably there's lot of missing API
great... i've been looking into using pipewrench due to typescript typesafe.. would love to use it once you've done with the boilerplate
it's pain in the ass, going from TS/C# to lua, no typesafe, primitive debugging.. althou I just know it have breakpoints.
If you ask the guys at pipewrench, they might have already made a boilerplate generator like mine ๐
uh oh.. I didn't know that, i just know that it can be done with TypeScript, probably for my future mod project.
I strongly advice you give it a try, the guys at pipe wrench are lovely
Some caveats https://typescripttolua.github.io/docs/caveats/
Feature support
Thanks!!
is paw low in this server? ๐ค
How can you remove files from the game? I've tried by deleting completely the contnent of the file of interest and changing the file extention adding " -remove " ( Sample: map.info-remove ) but it doesn't work. ( Obviously simply emptying the file doesn't work )
Any other idea or suggestions about how to do it?
...maybe by creating a function os.remove(filepath) ?
( If feasible is there an event like " OnBoot " [ or similar ] to be used? )
Yep...OnGameBoot...
Is there a way to control in which direction an item spawns? I mean...Let's guess that I want an item spawning, pointing in a west direction...any way to obtain it?
hi, I just called a java method that returned an enum (LosUtil.TestResults), however the return type is actually a userdata according to the type function. Are enums not fully supported in kahlua?
everything java related is type = userdata because you aren't accessing it from java, you are accessing it from kahlua
I'm not really knowledgeable about the technical side of it, but to my understanding, you are never accessing the java object, you are only interacting with a kahlua interface which affects the java object, and so the interface is always type userdata
lua only has a few data types. string, table, number, boolean and userdata.. which is any data type provided by another language library (usually C/C++, in this case java)
but I can't invoke methods on the enum. Like name
that specific enum might not be exposed. (java classes need to specifically exposed to the lua)
yeah, that might explain it
Hey, so I was wondering does Singleplayer Mod Load Order matter?
Yes Sometimes
Is there a guide on where to put mods?
The first mod is that you enabled first.
It affects overlapping translation strings. Nothing critical as I know
***EDITED: Moved to " Modeling " channel
Is it possible that OnObjectAdded is only triggered in multiplayer?
does anyone knoe how to trigger an animation just by pressing a key
Search the workshop there are several mods doing exactly that, that you can use as reference ๐
How can I save data inside a tile a sync it with other clients? ๐ค
I want to increase the size of a wooden crate box and limit it to only a single type
sub on Events.OnCustomUIKey, or any pressed/trigger key events
is there a way to view the global ModData?
I think there was a way to view them in debug mode
Would anyone be able to help me out? I'm making the Ghostbusters firehouse, everything is going fine BUT I want to create a few custom ContainerTypes so that I can ensure certain loot will spawn in a custom tile I've made. My issue is I have no idea how to go about this. I have a distributions lua where I have set my distributions but I don't know how to add a custom distribution such as instead of having "counter =" "customthing =". How do I go about this? Any help would be great
put this in the #pz_b42_chat, is this a mod related bug and does anyone know how to prevent it from happening again or fixing it
I knew it would be a challenge. But there is no way back
The modern Internet is shit, to put it mildly. It's too hard to find simple photos of the front of the car and on the sides. Instead, they are trying to sell me new volkswagen models and show me how poorly teenagers tune this car.
regardless of how correct my request was. However, I will finish this retexture. The car is beautiful :]
im done with what i needed. @lusty nebula helped me alot . thanks tho
i have seen it
but i don't know what causes it
i would be inclined to assume map corruption
because the wood floor seems to be the "default" tile
possibly forced reboots could cause it
without saving
or while saving
Is there any way to write a server sided script that looks at some in-game variables and updates a file with them that can be stored on the server and referenced later - say after a reboot?
can someone help me out, i just wrote my first mod. it is only 30 lines of code. just modifying moddata. but i would like for someone to look it over and give me hints to what improve and how to upload it and test it.
you can just paste over here... for others to check
(1) i would like to know if this is correct. (2) and also how to tell the mod that this is the main file. i put it in C:\Users\NAME\Zomboid\Workshop\GPZModFixes\Contents\mods\GPZFixToxicZones\media\lua\server (3) how to upload the mod ?
you can upload through the workshop option in pz once you make sure it's working
u cant click subscribe?
Hello there. Is there any way to keep the formatting of the mod's workshop page description text from the workshop.txt or modinfo.txt file (I don't know which one steam uses to modify the mod's workshop page description)
Nope
Do we have to go through steam workshop again to modify the form and make it pleasant?
wow, that is bad.
if you don't want to reupload it again..
is it really imposible to disable the pvp stunlock?
Sorry I didn't understand. I just updated 4x my mod and every time I have to go through the steam workshop site to format the text with [b][/b] tags because I can't specify these tags in the description to be given in the workshop.txt file when submitting the mod to the workshop.
Hello everyone! I've just started getting into modding this game, I've made a few food items, but I wonder if its possible for me to make my own CDs? I haven't been able to find any information on this so I was hoping someone could point me in the right direction.
This is all I've really figured out on my own so far, not sure how I would replace the text lines for the lyrics.
Appreciate any help, thanks!
module NRC
{
imports
{
Base
}
item Track1 {
Weight = 0.01,
Type = Normal,
Icon = Disc,
DisplayName = CD: Bready or Not. Here I Crumb!,
WorldStaticModel = Disk,
MediaCategory = CDs,
}
item Track2 {
Weight = 0.01,
Type = Normal,
Icon = Disc,
DisplayName = CD: Like Butter. Iโm on a Roll,
WorldStaticModel = Disk,
MediaCategory = CDs,
}
}
}
Maybe look at existing mods such as https://steamcommunity.com/sharedfiles/filedetails/?id=2732656755
@pine fiber thanks for the response, but no luck there. I didnt see anything in those mods that handles setting the lyrics/text, those mods just appear to make it so you can play actual music files in game.
i thought this was a pretty simple ask but starting to think its impossible, as i havent seen it done yet.
i think i'll look into making custom vhs and radio stations, maybe that will help me understand how to do it
thanks, just a copy paste error
there's 44 tracks, i cut some out so it wasnt a massive wall of text lol
Is SoundRadius are based on tiles or the others?
Just makin test script but im really confuse about SoundRadius and SoundVolum Parameter
pretty sure sound vol is what you hear
Then what Radius for?
Thx mate, just figure out why MP gun mode get worse SoundRadius then SP
-- Some examples of radius and volume found in PZ code:
-- Fishing (20,1)
-- Remove Grass (10,5)
-- Remove Glass (20,1)
-- Destroy Stuff (20,10)
-- Remove Bush (20,10)
-- Move Sprite (10,5)
local soundRadius = 13
local volume = 6```
Seems like then SoundRadius are per tiles then
not 100% on it but i believe so
Theres a lot of help about it, thx mate
i think you can check it in debug mode as well, but i don't have an idea how to, you might just have to play with it
Yeah for sure... imma just turn on debug rn
Gonna tell you if i get sometin
performance
it's a deliberate change, and there's a mod that reverts it to the SP values if you want that
oooh
Is there a mod that skips the this is how you died message every time you log in?
you can copy paste the text from the steam description editor with all the formating tags visible into the description box when you upload the mod. You can also technically add it into the workshop.txt but you need to add the "description=" infront of every newline in the description. thats a pain in the ass so I always just insert it through the pz client as its easier
That is done because the game is loading...That is just something to " entertain " you ( Let's say so ) in the meanwhile, while the game is loading. You can edit the writings ( it's a simple text file ) but you'll get somehow a black screen while game loads
so for example here is the workshop.txt of a mod I have. notice that all the [h1], [list], etc tags are all inside as normal text. you just need to include those inside the text when you upload it to the workshop and they will be formatted correctly in the workshop page.
version=1
id=2778991696
title=HydroCraft b41 Continued
description=[h1]Latest Hydrocraft mod for b41 - for both MP & SP[/h1]
description=[h1]recent update highlights 11-Sep-2022[/h1]
description=[list]
description=[*] Added animations for when equipping dolly, toywagon, and wheel barrow thanks to trynaeat
description=[*] Added sugar crafting chain from beets thanks to trynaeat
description=[*] Added ability to smelt other ingots in 4 ingot mold
description=[*] fixed crops breaking on restart of a dedicated server
description=[*] fixed crop behavour when crops are unloaded. you can now leave your crops in greenhouses and go far away
description=[*] and much more in the change logs
description=[/list]
etc etc
Just curious...Where you get the widgets/banners instead? ( Look at the Expanded Helicopter Event Mod page for example )
SAMPLE:
by widgets do you mean the tags? i don't actually know what they are properly called. there used to be a link somewhere ez on steam but i don't know where it is anymore but this page lists all the stuff https://steamcommunity.com/comment/Guide/formattinghelp
you can just search steam formatting on google and it will give you the link
Got it, thanks mate...Nothing major I was just curious ๐
there are some missing stuff though, so maybe that page is outdated which is why the link to it is gone. but just googling it, you can find how to imbed imgs, https://steamcommunity.com/sharedfiles/filedetails/?id=1245720477
This guide shows you how to embed images and buttons in the description of artwork, screenshots, and workshops.
https://i.imgur.com/m9mCPUE.png
https:/...
...ATM I'm still struggling with the item shadow thing ( Not yet found a working solution ) so I'm busy with it....Widgets time later on LOOOL ๐
Thanks for the infos mate ๐
Have you asked permission of mod author to use his models in your own scripted way?
That's great! Thank you.
How can I check whether the player is currently performing a timed action (bar over head) (specifically if the player is performing the ISRemoveBrokenGlass action, if that is relevant)?
still no luck huh? what fo vehicles do abt shadows anyways?
his only playing single player so there shouldnt be any violation
not sure if there is a generic one for detecting any timed actions, but you can easily patch the perform function for that action, to also set some flag or call whatever function you need to do
I made that model, im not giving any permission. Singleplayer or not
Hello, I wanna get started on LUA modding but I'm not finding any documentation or basics thing, is there some place where can I get started? (I'm familiar with the LUA language)
Like how can I gather the player's injuries?
I made a mockup of what I'm planning to do, basically a minimalistic health panel (red: untreated, white: bandaged, orange: dirty bandage)
Thanks. That should work fine
Is something like that possible? Basically i wonder if there is a way to fetch a other mod into a boolean variable depending if its there or not.
Its just a tiny detail and i dont want to make a patch for it, would be nice to handle that in a elegant way
i mostly refer to the lua and scripts folders on the pz media folder
and other mods aswell to get an idea of it
guys i need help, i have this weird bug. first i build my custom furniture, then the real problem is when i walk too far away, and then come back the custom furniture i build visually disappear but the furniture is still in that location because i still see the containers in it.
use getActivatedMods():contains("modid") to get a boolean for the mod
Thank you, i will try that
Worked ๐
Thanks again!
displayin modData in the tooltips, any predefined function to do that?, seems like InventoryItem only has :setTooltip, which is not multiline..
also, anyone know the hook when we hover over the inventory item?
Hiho,
I've continued implementing Storm, a mod loader, but I can't add it in any way to the startup options of steam, which would make it more easy to start it off.
I was wondering, if there is any way to add startup options in steam?
Another route is to create a Steamworks account and register this starter as a mod, but I would have to pay 100$, which I currently don't have.
So either I start a gofund.me or find another way to achieve an easy installation + startup.
I think it might be the ISToolTipInv object, so take a look at where it is used
do you mean as an entirely separate executable that would start up zomboid? people can already add executables to steam by specifying it as a non-steam game, so you could just have people do that for your mod loader
Yes, that's another possibility. But it's a .bat or .sh file to start up the game and the external games adding allows only .exe extentions. I can browse and enter the .bat name, but then it doesn't appear in the list
my mods list isnt working for hosting servers can someone tell me which mod are not mp compatible like if you know any off the top of your head
make a few lines .exe with Golang or somethin to execute the bat or directly communicate with your OS api, in Delphi would be ShellExecute, in C# would be Process.Start
Golang are much simpler and easy to compile, just import os/exec then exec.Command, https://zetcode.com/golang/exec-command/
Go exec command tutorial shows how to
execute shell commands and programs in Golang. External commands can be
executed with the os/exec in Go.
compile into .exe
seems like the code are in java ObjectTooltip
can't found where the progress bar such as 'Remaining: [===--]
That's a good idea. Thanks man. I've never tried Golang, but it looks fun. I'll try it
you can also use steam browser protocol for that, C# example Process.Start("steam://run/108600/<args>/"), whereas args could be -debug, etc... https://developer.valvesoftware.com/wiki/Steam_browser_protocol
so its a one liner .exe
nice!
i suggest to go with golang, as C# would need you to use IlMerge or something to make it standalone, delphi could compile into standalone easily as well
so in golang would be exec.Command("steam://run/108600") to run zomboid, just add slash for adding args or somethin
your welcome
well, the mod loader is starting PZ by directly calling the main of it in Java. So this command isn't very useful for it. But the one to add a non-steam game could help users to add it
oh... then you can directly calling the modloader with that shell command.. wrapped in an exe
for now probably the best idea. Thank you ๐
yep, putting under one folder as well for ease
Is it possible to make players with a trait see a different name for an item ?
yeah by client-side adjusting it in the rendering.. but if your purpose is to do something like show whether something is tainted or poisoned then i'd advise just adding an extra ui bit for it, it'd be easier
if u actually changed the name then others would see it if you allowed it to work outside of the inventory
i am trying to get a list of all vehicle zones in a cell. this is what i am currently doing, and it yields 0 zones..
function UdderlyVehicleRespawn.GetZonesForCellAt(worldX, worldY)
local zones = metaGrid:getZonesIntersecting(worldX, worldY, 0, 300, 300)
local vehicleZones = {}
for i=0, zones:size()-1 do
local zone = zones:get(i)
if instanceof(zone, "VehicleZone") then
table.insert(vehicleZones, zone)
end
end
return vehicleZones
end
local zones = UdderlyVehicleRespawn.GetZonesForCellAt(cellx*300, celly*300)
i have had to do some guesswork and digging in the decompile to get this far
but unfortunately that method just is a stub in the lua side
it doesn't point to something i can find in the java side
so i have no idea how it works internally
whether it wants world coordinates or what
due to the context i presume it does
i am also making the assumption that it will return zones that intersect the bounds defined by X,Y through X+W,Y+H (at Z)
i am getting metaGrid like this..
local metaGrid = IsoWorld.instance:getMetaGrid()
i guess as a next troubleshooting step i'll print the original zone count it finds before filtering down to vehiclezones
but any input would be appreciated
i had tried passing worldX and worldY directly from the event i'm calling things from, OnPlayerUpdate, into this
but it said invalid argument, and when i looked it up it said INT so im assuming it gave me something fractional
and since i sought cell-wide anyway i computed the cell coordinates to world
print("[UdderlyVehicleRespawn] Found "..zones:size().." in the rectangle ("..worldX..", "..worldY..", "..(worldX+300)..", "..(worldY+300)..").")
so.. anyone got any info on this function? how it works? if it works?
searches the vanilla code for hints
function is not used in the vanilla lua..
i guess if i have to i can precompute a list of zones assigned to cells and store them in a table or smth
:|
realizes she should use IsoMetaCell
so searching in intellij does not find the functions by name
within the file
then i scroll around and try again and they show up, that's fun
i've heard that there's reflection available
where is the reflection
i imagine my life would be less painful if i knew ๐
It is a challenge having so little documentation haha
I have a few fixes for my loot problems all set up but it would be nice to know why my problem exists in teh first place so I could fix it rightt! noooo
Anyone familiar with loot tables and sandbox settings together? Is this a bad practice because of the reference to SandboxVars?
table.insert(SuburbsDistributions["all"]["inventorymale"].items, "ModModule.SomeItem")
table.insert(SuburbsDistributions["all"]["inventorymale"].items, SandboxVars.ModModule.CustomChance)
It seems like it only works as expected the first time the mod is loaded or the game is loaded and after that it never loads updated sandbox settings - just the first settings that were ever input.
I don't know how or why you don't think that works, but that is standard good practice that tons of people use, and it works ordinarily.
Also those are additions to the distribution tables, they don't really have anything to do with the sandbox settings.
Unless your are doing something weird with "updating sandbox settings" that is doing something weird to the distro tables.
- is there any way to get a list of vehicles in a cell besides just in the loaded-in bubble of the player?
- is there any way to get a list of vehicle zones in a cell, i can't seem to make anything work.
- Probably not, only vehicles that are within the 150 tile reality bubble around a player, "exist"
that's what i thought yeah, i really wish the vehicles.db had exposure
- I only know of polling zones by individual tiles.
there's tons of zone-getting functions for the whole world, for cells, for chunks.. but none of them seem to work?
metagrid, metacell, etc.
I... ...am the newest and stupidest member of the team and I don't know a fraction of the code?
there's a field "vehicleZones" on metacells and i can't access it because i don't understand when fields are exposed or not
you still know more than me, mate
xD
The behavior that has me questioning it is that if I use SandboxVars as a variable to set the chance and then I change this setting it does not seem to get reflected in the loot tables, even if I do /reloadoptions or if I restart the server. If I check the sandbox settings by having the player say what it is in game when I call a function - the updated sandbox settings are confirmed. So it seems like sandbox settings get updated fine, but loot tables do not reflect that. When I omit the SandboxVars reference in the loot table entry and replace it with a number - loot tables receive that number and get updated just fine on a restart.
If you're trying to do something that takes the cars in the world, in runtime, that does stuff like despawn cars to swap in new ones or something similar and "intrusive" to the world, I'd have a lot of expectations of it causing all sorts of issue if you got it to work.
yup
i already have it dynamically picking up cars in the reality bubble and tracking their last seen time, deleting them, picking a new car to spawn
just failing to get locations to spawn them
i plan to write code to teleport someone around the map triggering car load-in and building a heat-map as a one-time thing at world start
and use those values to guide the "goal" per cell
since i can't harvest the total count a more sane way
i don't wanna swap them out directly with the old car because then it could easily be exploited by players
and picking random spots would.. well, im sure u can imagine
- Ah, you know sandbox settings aren't meant to change in runtime; sure admins can do that in MP servers, but in many cases the server needs to be restarted when it takes effect.
- well then it sounds like the problem is the variable you're feeding to the tables," SandboxVars.ModModule.CustomChance", and not anything to do with loot distro/sandbox stuff being weird.
I wouldn't expect that work smoothly, and you may have all sorts of issues and headaches. And it may cause all sorts of more issues and headaches in MP.
Game wasn't designed for that stuff.
Not saying it's impossible, just my gut feeling.
Also teleportation in MP is very hard on server stability, and it can crash a server.
well regardless of whether it's a good idea or will work nicely, it should definitely be possible to get the zones and finish the prototype, lol.. and i am of course also throttling it per-cell-per-player and per-cell globally, configurable thresholds for that, all sorts of stuff to ease it
Cool, I definitely am restarting now haha, it wasn't always the case but now I am doing a full restart every time. - The only weird thing about that on #2 there is that it does work the first time. If I start a game with adjusted sandbox settings they work and reflect the sandbox settings - but not if I update those and restart. So I think you are right, that it is the variable causing problems, but what has me stumped is that it worked the first time and just not when they are updated.
Ah, just try having more console output as your code runs so you see the exact value of the variables as they're used?
print(tostring(SandboxVars.ModModule.CustomChance))
table.insert(SuburbsDistributions["all"]["inventorymale"].items, "ModModule.SomeItem")
table.insert(SuburbsDistributions["all"]["inventorymale"].items, SandboxVars.ModModule.CustomChance)
Like so?
Good call, I will do that now. I have been thinking maybe when the game world loads the first time more is going on and the sandbox variable gets loaded in before it gets called. But during an update maybe it isn't loaded in fast enough and table inserts happen first... or something. I should be able to see if this is the case now... Should we add to distribution tables in a script just like that or is it best to put them in a function and connect to a specific event?
Myself, I just have my distribution insert code in the lua file without any functions. Easier that way, less moving parts, less things to go wrong.
i usually use loops to avoid redundancy and make it easier to update, but no more complex than loop thru spawns + loop through items
i havent done configurable, but that has been a thing ive planned to do
i certainly hope i don't run into whatever you have, phil
lol
Okay that is how I was doing it before. - So I just ran a console test on that and I got back the original sandbox option - not the updated one.
It has been a doozy haha - but I am learning a lot too
any way to overlay something transparent over the player skin without things breaking?
unrelated question to earlier: is there a way to get a handle to another player's IsoPlayer from the client end?
i can write a mod to do what i need to do but it's a one-off..
How can I change the size of the police armoury containers?
The capacity of the armoury lockers, at the moment is 50, I was looking for a way to increase it to 150
In particular this one
it might be lumped in by container type
Javadoc Project Zomboid Modding API declaration: package: zombie.inventory, class: ItemContainer
this is the class that deals with containers
from IsoObject you can do getContainer()
mm
there was a mod that took those back when they weren't lootable and made them lootable
i bet that has something worth poking at
id poke at that and see if it tells u anything about replacing/modifying a particular container (and bonus points cuz it happens to already be the same one)
I was actually look at this too, I noticed that I need to use tileZed
I was hoping for a pure lua solution, I guess I'm stuck with it 
Regarding sandbox loot table issues - I put together some scripts that check the sandbox settings at different times via some events and output the results to console.
Here is the result:
NO EVENT - Entered straight into distribution script = Original Sandbox Setting is Shown
Events.OnPreDistributionMerge = Original Sandbox Setting is Shown
Events.OnDistributionMerge = Original Sandbox Setting is Shown
Events.OnPostDistributionMerge = Original Sandbox Setting is Shown
IN GAME CHECK = Updated Sandbox Setting is Shown
So I can see why it isn't working - and it looks like the sandbox doesn't get updated to new settings until after distribution is done. My next attempt is going to be to store the sandbox settings with getModData and see if I can access that on a restart. I don't have a lot of experience with getModData - I have only used it off of a player - is there getModData or something like that at the server level? Can I just do getModData without a prefix for some object?
there IS a way
but it's not "correct"
you can dynamically alter container capacity live when clients open the container conditionally
nothing actually enforces the container size beyond the lua on the client
Eggon's uses this to modify car trunks and such
u can hook the container stuff and go "if it's this one then capacity is actually X"
u probably have some experience hooking container code considering proximity inventory
if u happen to run into an issue where the updated size only applies after clicking the container icon and fix that, let me or eggon know lol
im hoping that's just a quirk in his code and not an issue with the approach
doesnt happen all the time or with all trunks
Sure, why not
At the moment I'm interested into looking at tile zed, and see if I can make a higher quality version of my idea.
Like, properly upgradable lockers. With X lvl in metal working you get X more capacity in that locker
I'm still a bit salty that I must go via tile zed tho
I am, but I'm not finding anything at the moment ๐ฆ
tho i assume it's diff containers that are built
depending on the carp level
they are visually different at two points
I'm looking into media\lua\server\BuildingObjects\ISWoodenContainer.lua but there is notthing that helps me ๐
Maybe it's something set via tileZed? ๐ค
ive not touched that program rly so idk
Is there a generic on observe function somewhere?
LoadGridsquare and ReuseGridsquare I assume?
Dunno about the ones you mentioned above but GetSquare is available
and yeah Events.LoadGridsquare exists.. not sure what "on observe" means here exactly
im guessing u mean "square starts to exist" in which case yeah probably
Just a warning, but OnLoadGridSquare can be very expensive run-time wise and affects performance, especially in areas with lots of multi story buildings.
I've used it extensively in the past for modding, and now I think that may have been a mistake on my part.
ahh okay thanks. I see
On observe as in updating an item only when it's observed, such as growing trees, but only when a player goes there, so I don't have to have a growing script running when there is no one able to observe the tree (Becasuse there are too many).
OnPlayerMove with throttling might be appropriate
if you want it to update them periodically when people enter an area, or enable a function that keeps running until player is away
and then disable
if that's your specific use case i'd use OnPlayerMove and have a throttled check for plants within radius of player, if found, adds their update functions to whatever event, track those plants whose functions are added and keep handles to those functions, and then when plant falls out of radius remove their functions from the event they are tied to and yeet em from the list
perhaps
it's very use-case dependent though and u have to weigh tradeoffs between all the logic to throttle/enable/disable vs. just running it all the time depending on how intensive and common the thing is
Yeah, thanks.
It's very specific for situation, I was hoping someone had a framework for something like this.
Anyone knows how to change the time to place a pipebomb/grab a pipebomb?
The timed version
depending on what you are trying to do, you could just use getsquare, since it won't return anything if the square is unloaded. you haven't really revealed what exactly you are trying to do so depending on what you are trying to do, it might be too performance heavy though
Gotcha, I'm just poking around seeing what I can do
Yeah loadsquare seems bad because I would have to check for my case position or existance of object, which would mean every square loaded it's pointlessly checking
Probably even if I only check positions, still bad
It's good to know getsquare is nil!
What's the fastest day to determine if something is on the lua side of the codebase or the java side
Could someone tell me if there is the possibility to create a working environment on Visual Studio Code with Intellisense for Project Zomboid modding projects as below (using IntelliJ IDEA) ?
if it is only certain objects on the map and not all, you can look into using the globalobjectsystem for handling it. that way you have then tracked, rather than constantly checking a square if or if not the object you care about is there. its how the game handles things like the rain barrels, traps and crops. again tho, without knowing what you are trying to do, this still might be overkill
any way to get hours elapsed, i get confused counting it, lets say i define a moddata today, and want to calculate it in the next month or years.
you can just write into the moddata a timestamp
I have a question, can I make a single object that when placed become a multy tile? for example the metal shelves when in the inventory it's devided in 2 pieces, when placed it occupy 2 tiles, can I do it with a single object?
like I have one object in the inventory and when I place it it become 4 tiles
Anyone can give a clue as to how to change a weather on the fly through lua?
or where to look for an answer
alr did use getGameTime:getWorldHour, the current codebase use getYear, getHour, getDay, to calculate, and i wont do lots of refactoring to it, so i just added tooltip and extra code to compare between legacy approach and current approach, seems using getworldhour are easier.
also i added hardcoded tooltip via setTooltip(args), my debug console now filled with missing translation, is that matters to the performance in general?, or it only appears in debug and client?
yeah I think the reason why some old code uses the whole getyear gethour getday schenanigans is due to an old bug in mp servers, which would cause issues with the getworldhour method. but I think that has been fixed already. atleast I use getworldhour for stuff and don't have issues
ah thanks, also sometimes client code which do addItemToServer/removeitemonserver produce errors,
check the debug code. debug mode has a UI where you can manage the weather. so you can just look at that code to see what they do in the lua to manipulate the weather
so its fine in 41.76 then?
tmk it is fine now
Anyone have a good resource to share for clothing icons?
thanks
also, is there anyway to add electricity to certain tiles, likes, i want to extend player safehouse electricity tiles
seems electricity only defined with shutmodifier, is it hardcoded in the java? :S
yes but its a bit of a hassle to do it, because it it won't persist when the square is unloaded, so it isn't perfect
let me try to find the code, it was really weirdly done and not great so i moved on, but if you want to put the effort, its possible
I think it was isosquare:setHaveElectricity()
you can also use virtual isogenerators if you want to give areas electricity
item RopeBelt
{
Weight = 0.1,
Type = Clothing,
DisplayCategory = Clothing - Accessory,
DisplayName = Rope Belt,
Icon = RopeBelt,
BodyLocation = Belt,
ClothingItem = Belt,
AttachmentsProvided = SmallBeltLeft,
}```
I specified the DisplayCategory as `Clothing - Accessory`, yet it shows up in game as `IGU_ItemCat_Clothing - Accessory`. Tried specifying as `Accessory`, but then it shows up as `Accessory` when I'm trying to simply use the existing `Clothing - Accessory` display category. Other mods that specify `Accessory` for clothing type items display as `Clothing - Accessory`, so I'm a bit confused why the behavior is different. Any ideas?
Oh, maybe it is the Better Sorting mod performing some shenanigans
Yea, it is Better Sorting. nm
Is there a best practice for using Better Sorting categories for items when the Better Sorting mod is loaded and falling back to normal categories otherwise?
question for modders
is it possible to make a functional bayonet attachment for rifles
but it would still push them when they get too close
depends. you could implement 2 items, one which was the gun, and another which was just a spear. and do something like have a hotkey switch between the two items. I don't think it is possible to make 1 item that does all three things, but you could fake it by having the 2 items, and you "swap modes" with a hotkey
what's the proper way to remove item from server in client's code, i saw legacy code use removeItemFromServer, but it doesn't appear in any vanilla lua side at the current version.
so question--
i have a mod that contains 3 packaged mods within it. if i wanted to make an additional optional mod that modifies one of those other mods, how exactly does that work?
i have a true music mod that i'd like to make an optional addon for that alters the loot distribution tables
put it last in the order of your "patch mods", you can just override with conditionals the function in your patch mods
so either way, it will load the unpatched mods then your altered list after
just find the function name, handle with getActivatedMods():contains("yourpatchmod"), under that scope, alter the function, keep it the original function in a local variable to recall the original, could be after or before your altered behaviour
hmm
perhaps this is a little above my paygrade as a distinct not-a-modder/coder
or, wait--i think i see what you mean, hmm
hmm, yeah i think this is a little too complicated for me maybe
what would the function name be here? table.insert?
Is simply changing the data in those tables not sufficient? You may not need to patch any functions
well
the patch is intended to be an optional modification to the baseline to make things more rare
i want the main mod to have these values normally, but allow folks to turn on an included patch to lower the spawnrates if they so choose
Might be simpler to do that via a sandbox configuration parameter, and use that sandbox parameter to set a different value e.g.
table.insert(ProceduralDist...blahblah, SandboxVars.mymod.rarerloot and 0.1 or 0.7)```
But if you want it in a separate mod, you would need to ensure the optional mod loads after the 1st. If you can do that, then simply overwriting those values in the ProceduralDistributions should be sufficient.
I think you might be able to ensure the lua file load order of the files by using `require("mainmodsfile")`, but I'm not positive if that works with how pz loads lua in mods. I'd need to test it (I happen to need to for something unrelated, so I'll have a better idea a bit later) or maybe someone more familiar could provide some insight.
loop thru the table and change it dynamically?, overring the those index
if i had to guess, using the require field would work to prevent the optional mod from loading without the main one, but would not ensure it would actually load second and simply wouldn't load at all if it were put first in the order
but that's a guess
also, one thing to note: anything that would require manual editing of individual lines is a definite no-go
the total amount of lines is like, 15000
mutating and looping thru it is your best bet then.
whaddya mean by that
as long as the patch load after the patched mod, it shall be fine, i did with greenfire, wrapped in getActivatedMods():contains if guard, and it loaded and patched.
Do you need to change the value of all/most of those lines? Or just a select few? Do you need to hand pick the new values (e.g. I need to change this 0.7 to 0.35 and then change this 0.8 to 0.7)? Or do you just want to scale down all down by some factor?
all of them, scaling them by the same factor
making a patch, overriding is your option, if you wont fork the original code and change it.
nah i don't want to fork it because i don't want to split the workshop metrics
noted
This ProceduralDistributions object is global and is used by vanilla lua code to distribute loot, so if you iterate over it to modify values, you need to do so in such a way as to not modify vanilla entries and entries from other mods
simply overriding the entire original file sounds easy enough there, my main concern is that i'm not even sure if it's possible to set mod load order outside of rearranging them in the ini file for that save?
you can do it with maps but i cannot recall if it's even possible with standard mods
Honestly, I think it'd be easiest to just have a script iterate over each line to insert a sandbox var to multiply the original values.
table.insert(ProceduralDistributionslis["Store"].item, 0.7);```
to
```lua
table.insert(ProceduralDistributionslis["Store"].item, 0.7 * SandboxVars.mymod.lootrarityfacor);```
Some text editors make that easier to do than others. If you'd want, I could do that real quick if you have trouble doing that to 15k lines.
hm
if it would be simply appending the exact same thing to the end of each line, it'd be pretty easy to do from my end
It's not every line. It's only the lines with the numbers there (the loot rarity)
loop thrugh ProceduralDistributions.list, get the type you want, or string find it, remove the record in the list then add that back up with your modified values.
once its done, this will be much cleaner way and better managed for further improvement/addition
Could do that too. Just have to compile which strings you need to look for bc like I said that object is global and other mods and vanilla insert entries into it
in every list, there are list of items..
the vanilla wont even get into the core part of your code if you handle the string properly..
tyrir, if i take your approach, what is lootrarityfactor?
like, item:getFullType() < check for prefix modulename. if its from true music then go on with that
It's a sandbox var. Like when you create a world, the user sets the zombie population to 1.0 or 0.8. It'd be like that, and users can adjust it how they prefer
only handle everything from Tsarcraft.
ah i'm familiar with sandbox vars, but i'm surprised at the idea that they're that easy to implement; would that be all i'd need to do to establish that svar?
for k, v in pairs(ProceduralDistributions.list) do
for i= 1, #v.items do
if string.find(v.items[i].item:getFullType(), 'Tsarcraft') then
--
table.remove(ProceduralDistributions.list[k].items, v.items[i].item:getFullType())
table.insert(ProceduralDistributions.list[k].items, 'yourvalue')
end
end
end
@rancid tendon probably something like that..
just a seudocode
You create them via adding a couple files, if you don't already have them.
Create media/sandbox-options.txt in your main mod. In it, put
VERSION = 1,
option mymod.lootrarityfactor
{
type = double,
min = 0.0,
max = 1.0,
default = 1.0,
page = mymod,
translation = mymod_lootrarityfactor,
}```
Then in `media/lua/shared/Translate/EN/Sandbox_EN.txt`, put:
```json
Sandbox_EN = {
Sandbox_mymod = "My Mod",
Sandbox_mymod_lootrarityfactor = "Loot Rarity Factor",
Sandbox_mymod_lootrarityfactor_tooltip = "This value does blah blah",
}```
pz's mod framework takes care of creating the lua var `SandboxVars.mymod.lootrarityfactor` from that (assuming I didn't make a typo).
ooh, thank you very much
this seems pretty easy to implement and it's a far more elegant solution than the one i started with
That code savaroo wrote works too, 1) assuming you can ensure it is loaded after the main mod and 2) no other mod uses Tsarcraft prefix in their item names (else there is a possibly of modifying their values)
i am almost certain that tsar has a ton of other very popular mods using the tsarcraft module
then add more check, like category "media - audio" and else
you can try debug it in console first by printing it, count the numbers etc..
that's the downside, you have to make sure about it, or if the list of items can be collected in your end easily, just put them in a list, to make a strict/explicit comparison to your "modded" list of items.
If I had to scrap through alot of list (more than 10k record), I usually make a snippet in other programming language such as Javascript/TS with Quokka(real time interpreter), and scaffold it into a lua table of item list, then begin writing the lua once I gather the table with the list collected and scaffolded
Are there any good tutorials/guides on how to make custom radio/tv stations?
Regarding the mod load order, I'm reading that specifying require=mymainmod in a sub mod's mod.info will cause mymainmod to load before the sub mod
And that the require() function in lua only works on lua files in the vanilla pz lua source code, not lua source from mods (although this is from like 6 years ago, so might be outdated)
the require statement will make sure that the second file is run after the first one. atleast practically. technically, what happens is that, if that file hasn't already been run before, it will be run on that line with the require statement before continuing the file.
i see all kinds of nonsense with the require function failing even for vanilla things that are definitely present among the many mods i run
doesn't seem to cause issues but it does concern me a little :P
require definitely works within the same mod
and i've seen it used between mods though i can't personally speak to whether it works or not
the require function works on any lua files. the lua can come from other mods, the same mod or vanilla. it just needs to be loaded by the game for that save
i suspect the random failure of require on my end has to do with being on linux
i think there's some nonsense in the path handling in PZ in some places
i've seen mod assets fail to load due to pathing
and i run it on wine to avoid that
what issues are you having? I don't get any issues with the require function unless I have specified the path incorrectly
random example
LOG : Lua , 1663625615565> Loading: Z:/home/evelyn/.local/share/Steam/steamapps/workshop/content/108600/2732834772/mods/CheatMenuRebirth/media/lua/client/CheatMenuRebirth/Lua/LuaInterpreter.lua
WARN : Lua , 1663625615566> LuaManager$GlobalObject.require> require("CheatMenuRebirth/Times/GenericInputWindow") failed
WARN : Lua , 1663625615566> LuaManager$GlobalObject.require> require("CheatMenuRebirth/Times/SkillInputWindow") failed
LOG : General , 1663625615566> [CHEAT MENU] ISUICheatMenu successfully loaded```
WARN : Lua , 1663625615578> LuaManager$GlobalObject.require> require("Recipecode") failed
WARN : Lua , 1663625615579> LuaManager$GlobalObject.require> require("XpSystem/XpUpdate") failed```
WARN : Lua , 1663625615556> LuaManager$GlobalObject.require> require("ISTimer") failed```
are there any current plans for a More Gloves type of mod? I feel like there is a very lacky amount of gloves
How do you specify the path when trying to require a file between two mods? Are the media/lua/client, media/lua/server, and media/lua/shared subdirectories within all mods within require's search path?
how i can turn off Zombie dragdown via mods\lua? i have CDDA zombies mod, which override base zombie settings, but looks like enable this dragdown option again. Can i just add ZombiesDragDown = false (this is how it looks in sandbox settings) in his functions somewhere or it doesn't works this way?
LOG : General , 1663625612225> [UdderlyGuns PPSh] Udderly Gun Reconditioning detected, adding reconditioning recipe.
LOG : Lua , 1663625612225> Loading: C:/users/steamuser/Zomboid/Workshop/UdderlyRP/Contents/mods/UdderlyRP/media/lua/shared/UdderlyRP_UdderlyAttachments.lua
Sep 19, 2022 6:13:32 PM zombie.Lua.LuaManager RunLuaInternal
SEVERE: Error found in LUA file: C:/users/steamuser/Zomboid/Workshop/UdderlyRP/Contents/mods/UdderlyRP/media/lua/shared/UdderlyRP_UdderlyAttachments.lua
ERROR: General , 1663625612233> ExceptionLogger.logException> Exception thrown se.krka.kahlua.vm.KahluaException: UdderlyRP_UdderlyAttachments.lua:4: unexpected symbol near `=` at LexState.lexerror line:278.
ERROR: General , 1663625612234> DebugLogStream.printException> Stack trace:
se.krka.kahlua.vm.KahluaException: UdderlyRP_UdderlyAttachments.lua:4: unexpected symbol near `=`
at org.luaj.kahluafork.compiler.LexState.lexerror(LexState.java:278)```
you'd think this is a straightforward thing to debug
print("[UdderlyRP Undead Survivor Patch] Looking for Udderly Gun Reconditioning..")
if UdderlyGunReconditioning and UdderlyGunReconditioning.RecipeAssignments then
print("[UdderlyRP Undead Survivor Patch] Udderly Gun Reconditioning detected, adding reconditioning recipe.")
table.insert(UdderlyGunReconditioning.RecipeAssignments[7], "ReconditionHeadhunterRifle")
table.insert(UdderlyGunReconditioning.RecipeAssignments[7], "ReconditionDeadlyHeadhunterRifle")
end```
but this is that entire file
print("[UdderlyGuns PPSh] Looking for Udderly Gun Reconditioning..")
if UdderlyGunReconditioning and UdderlyGunReconditioning.RecipeAssignments then
print("[UdderlyGuns PPSh] Udderly Gun Reconditioning detected, adding reconditioning recipe.")
table.insert(UdderlyGunReconditioning.RecipeAssignments[3], "ReconditionPPSh")
end```and here is a nearly identical file that you can see working just fine just before this one
:|
ik someone will ask so here's the tables it's inserting into
--Content of the below should be per-volume of the books, so:
--Pistols, Revolvers, SMGs, ARs, Shotguns, BARs, SARs, LMGs
UdderlyGunReconditioning.RecipeAssignments=
{
{--Pistols
"ReconditionTEC9",
"ReconditionM1911",
"ReconditionM9",
"ReconditionG17",
"ReconditionDE",
"ReconditionP228",
},
{--Revolvers
"ReconditionM105",
"ReconditionMagnum",
"ReconditionM625",
},
{--SMGs
"ReconditionMP5",
"ReconditionMP5SD",
},
{--ARs
"ReconditionAK47",
"ReconditionAK47F",
"ReconditionCAR15",
"ReconditionCAR15D",
"ReconditionM16",
},
{--Shotguns
"ReconditionM500",
"ReconditionM500Sawnoff",
"ReconditionM500SawnoffNoStock",
"ReconditionDoubleBarrelShotgun",
"ReconditionDoubleBarrelShotgunSawnoff",
"ReconditionSP12",
"ReconditionSP12F",
},
{--BARs
"ReconditionR700",
"ReconditionW1866",
},
{--SARs
"ReconditionR1022",
"ReconditionMR223",
"ReconditionMR223F",
"ReconditionM14",
"ReconditionSKS",
"ReconditionMSR788",
},
{--LMGs
}
}```
ran it on rextester and no errors
did i find a bug in the parser? :p
Has UdderlyGunReconditioning been defined as a table before this file? Otherwise, yes, it will be an unrecognized symbol. This would be one proper way to do it if so.
--Content of the below should be per-volume of the books, so:
--Pistols, Revolvers, SMGs, ARs, Shotguns, BARs, SARs, LMGs
UdderlyGunReconditioning = {}
UdderlyGunReconditioning.RecipeAssignments= ...
it has been yes
and the other script that works the same way executes with no error
print("[UdderlyGunReconditioning] Initializing Database..")
UdderlyGunReconditioning={}
UdderlyGunReconditioning.Magazines =
{
"Magazine_UdderlyGunReconditioning_1_Pistol",
"Magazine_UdderlyGunReconditioning_2_Revolver",
"Magazine_UdderlyGunReconditioning_3_SMG",
"Magazine_UdderlyGunReconditioning_4_AR",
"Magazine_UdderlyGunReconditioning_5_Shotgun",
"Magazine_UdderlyGunReconditioning_6_BAR",
"Magazine_UdderlyGunReconditioning_7_SAR",
"Magazine_UdderlyGunReconditioning_8_LMG",
}
UdderlyGunReconditioning.Books =
{
"MaintenanceVol1",
"MaintenanceVol2",
"MaintenanceVol3",
"MaintenanceVol4",
"MaintenanceVol5",
}
here is the bit of file preceding that
the bit after that does loops to assign recipes to magazines dynamically
all tested and working in a released mod
with one client mod inserting its recipe
(which still works right now, in the same run, that second example of code)
you can see its output in the error i posted just above the problems
yep. one thing to consider about mods is that they don't differentiate files from different mods. its a weird behavior on how they are loaded. so if in mod1 you have media/lua/client/file.lua, and in mod2, you have an identical filepath media/lua/client/file.lua but with different content, only one of those files will be loaded and read. I can't quite remember the exact ordering mechanism(been a while since it mattered to me), but if I remember correctly, for SP and hosted MP, they load in order of workshop id, last is the one that is kept, then in dedicated server, they load in the order of the workshop id's listed in the server.ini, again the last one is kept. this applies to all mod files, so xmls, .png, .txt, .lua, etc... As for the difference in client and server stuff, im actually not sure. I've never tried loading another client file from either server or shared or vice-versa, only from the same folders. I would guess that the require statement would see everything in SP, since they aren't separated, but then in MP, the server and client are properly separated so you wouldn't be able to require a client file from server file or vice versa
it's a good idea to prefix your mod files with the mod name
for that reason
when they are not sufficiently unique
its why you get issues with some older mods. there are alot of mods that used generic file names like "books.txt". They would conflict with each other because only one file would get loaded, as the last one would supercede the other "books.txt" files
or put them in a uniquely named folder if possible
that same behavior lets you prevent others' code from running and/or replacing it with yours though
which is important
let's try restarting PZ and testing it again
i know for a fact that junk remains in PZ that isn't unloaded when you reload lua
because sometimes things break on click to start with a getTexture() error loop
and a restart fixes it
so let's seeee
Oh, jeez. Can imagine all the headache that's caused. Perhaps they had the idea early on that mods would function by overwriting files e.g. overwriting books.txt entirely or merging in some way, and it's just been in that state since
they do function that way as well
it's a useful feature, but it'd be nice if it were somehow controllable
too late now without breaking things though
hehe
hey guys, im kinda hardstuck on a project of mine. it worked perfectly fine in singleplayer but in multiplayer it acts all wierd. so i wanna spawn a zombie via a recipe and like i said in SP no problem, but in MP it either doesnt spawn at all or spawn and i am the only one seeing it but i can kill it multiple times and so on. this is the spawn command im using in the lua, anyone has an idea? thanks in advance! ๐
well
i guess the default could be on an a new "don't do that" config-per-file-file could be introduced
without breaking new things
but so few people would end up using that
w/o default
that it's a pointless investment of their time
cuz it's admin only probably?
oh
i read the rest
it must be spawning it clientside and not with the server
u have to send a server command to the server probably
to make it actually "exist"
ahhh this is why it works SP and not MP?
the Oncreate is properly in the server folder right?
yeah it is
it is entirely possible that the createHordeFromTo doesn't work in MP. I can only see it being used in the challenge maps stuff which I think are all SP? I haven't actually played them much
well i had the very same problem with the addzombiesinoutfit command โน๏ธ
if you just want to create a horde, you should probably check what the admin menu in MP calls and use that function instead, as it isn't using createhordefromto there.
any idea how to find the java for functions that a search in teh decompile only gives results in the lua for?
u see any calls to it, then the stub that exposes it
and then nothing on the java side comes up 
createhordefromto is an example
so where do those stubs point? xD
global lua functions defined by java are in Lua\LuaManager.class
@LuaMethod(
name = "createHordeFromTo",
global = true
)
public static void createHordeFromTo(float var0, float var1, float var2, float var3, int var4) {
ZombiePopulationManager.instance.createHordeFromTo((int)var0, (int)var1, (int)var2, (int)var3, var4);
}
then.. why is intellij not telling me about them i guess is the real question
xD
hm searching that file doesnt show it either
change the search thing from directory to scope, then all places
will try that.
nope lol
this has led me to dead ends on a number of things in the past few weeks
trying to guess what args are supposed to be, etc
followed konijima's guide
oh shit
thjere's a file mask on
alright let's turn that thing off.
there we go.
i hate jetbrains products, their UIs are always so odd
things in weird spots, windows that disappear when u click on something or off of it
etc
solid under the hood, just the UI..
there shouldnt be any issue with require. it just gets used wrong. pointing to your second random example there:
LOG : Lua , 1663625615578> Loading: Z:/home/evelyn/.local/share/Steam/steamapps/workshop/content/108600/2335368829/mods/Authentic Z - Lite/media/lua/client/TimedActions/AuthenticZ_RecipeCode.lua
WARN : Lua , 1663625615578> LuaManager$GlobalObject.require> require("Recipecode") failed
WARN : Lua , 1663625615579> LuaManager$GlobalObject.require> require("XpSystem/XpUpdate") failed
this is a file in client trying to require 2 files in server (can only require in shared or same root ie: client)
i dont have cheatmenu so cant check the location of the failed requires on the other examples there
i don't know where those are off the top of my head, but im guessing u looked or know the locations already
that explains some things..
but i thought require stops the file from loading if it fails
so how come things just.. work anyway?
it doesnt
ah so parts of mods are just not running
and the makers don't realize
and work around it?
:P
that's.. sad
i don't use require, so that my code fails miserably if something isn't loaded 
no secrets there, hehe
its amazing how many people dont actually check the console for errors when they mod (or just ignore them i guess) ๐
It would be a mistake to assume that any modders, no matter how many thousands of subs they have, knows what they're doing.
I need a vomit bucket when I look at the old code in my own mods, for example.
Gotta say that a lot of your mods were like wiki's for me lol
Even when old ๐
Oh lordy, I'm sure there's a regular rogue's gallery of bad practices lurking in them 
I was able to disable Survivor Vehicles with a mod thanks to the Worse Vehicle code ๐ glad that option is added to vanilla now ๐ hope Worse Vehicle will eventually vanilla too ๐
so
apparently the file is loading just fine, because it actually inserts the things just fine
LOG : General , 1663628195197> [UdderlyGunReconditioning] Could not find recipe "ReconditionDeadlyHeadhunterRifle", skipping.```
this is it processing it later
so the error is meaningless from a practical perspective yet undesirable
:|
