#mod_development
1 messages · Page 66 of 1
Again, by clicking on that lightbulb
Or do that
My way is less effort, Albion way is more thorough
my way gives you a bit of autocomplete, but to be honest it's more like a spellchecker than an actual helpful resource
thats pretty outdated. probably still works though
i think glytch3r still uses it, so it must work
the one he uses is a mod on the workshop that he incorperated into some of his mods, that one uses the os clock function to add IRL time delays
Hello, good evening. I don't know if this is the right game to ask, but I would like to make some videos, explaining some topics related to the creation of mods. However, I have several doubts, which are not about programming, but, rather, about how to search for certain information. The videos would be in Spanish, so if someone can guide me or recommend me some information, I would appreciate it.
Just for clairity, where does that last chunk of code go? This one-
Events.OnTick.Add(function()
local minute = getGameTime():getMinutes()
if minute ~= lastMinute then
Timers.check()
lastMinute = minute
end
end)```
would have replaced the OnTick event in the previous post, but theres a OnEveryMinute event now which makes that snippit pointless
oh- Shit! Thanks haha, that helps <3
My code has gotten adequately complex enough that I can't test it properly in PZ alone, but I really don't wanna try to figure out how to get lua 5.1 running in windows 😩
I had a link for something like that a little while ago, guess its time to look again
@sour island i didnt need the locking code lol
It turns out containers are both isoobject and thumpable at the same god damn time
I was about to give up then i said why not
I did a test print instanceof thump
And it worked jt printed
So the rest was easy
Ill just spawn them a combilock as they take ownership of the thing
Browser history?
you can take a look at the current guides on the pinned messages/project zomboid modding wiki and get the decompiled files from the game, read the code is the better way to understand what happens
almost everything is isoobject
like as far as i know literally everything that visibly exists in the game world?
you can see a class's inheritance tree on the javadoc
Yeah figured it a bit late
Took me a day to work it out
Even if i had all the codes lined up lol
Hey, just wondering, is it fine to create another folder inside lua/client or server, e.g. "lua/server/ModPatch"?
yeah
trying to make my mod to be more organized ._.
i actually would strongly encourage doing this if your mod has more than one file, otherwise you're just inviting conflicts
I think they also think the same as me, thinking that if you put the lua in another folder, it will make the lua not detected by the server.
And also one more question, do the client, server, and shared folders really separate their functions? because I see some scripts use the line to check "isClient?" in the script in the server folder.
The client folder isn't loaded in the server, and they are loaded in a particular order, but that's it
If you don't want a Lua file in the server folder to run on the client, you have to check
anyone know how to get the current, right now, up to date XYZ of a moving object in game? I'm having some trouble with collision detection and I have a theory that the coordinates you get from the object lag behind a bit
hitting things slowly works just fine, and determining if things are touching each other while standing still works fine, but slamming into something at 60km/h doesn't work
Thank you!
just figured out that my collision detection doesn't work if one vehicle completely engulfs the other, but what are the odds of that? 😂
By my luck? Or a normal person? 😂
lol
but for real, I'm pretty sure I need to get an offset of some kind from the world simulation to get an actual accurate position on a moving vehicle
maybe tomorrow I'll get my collision algo to print out where it thinks the vehicle is, so I can compare
You are probably right.
So- just to workshop current ideas, figure it is worth checking to see if this sounds like a good system or if anyone has ideas for how to tweak it. Regarding the drug mod I’m working on.
As it stands rn there is a module that houses a constructor for the drugs. There are various variables, importantly, I have categorized them. So- stimulants, narcotics, depressants, psychedelics, and steroids. There is also vars for potency, onset, and duration modifiers.
What I am thinking is that on consumption of the drug, it will check the category, then depending on potency will increase a corresponding variable to the category.
So, ALL stimulants will effect the same “consumed stimulants” variable. Which is how the primary effects will be derived. So- “minor stimulant buzz”, “major stimulant buzz”, and “stimulant high”. As an idea for the stages of consumption.
————
Issue is am having is that this means every single drug will need it’s own designation- so, even variants of the same drug will need a new block. Planned for this by having a variable that defines the “base” drug for the sake of addictions. But this system will make having unique effects on specific drugs very cumbersome, from what I am looking at now…
SNIPPET: get all IsoMovingObject on player's instance
print(getCell():getObjectList()) -- Returns ArrayList<IsoMovingObject>
having unique effects to specific things is always going to be cumbersome, that's sort of the nature of making things unique
@winter thunder I'll hyu in DM
you could have your relevant functions check for a drug-specific function and run that, sort of like vanilla's item script function parameters
RIP rigid towing system
but if you want each drug to be significantly different, it's likely that you will have to do a lot of unique code, that's just how it is
i miss it so much
'JOE I NEED HELP' cracks me up every time
why is literally everyone making a drug mod right now
i know like 5 people, and i had started one too
that's wild
lmao
Dunno, must be demand. I don't really know what I'd do with a mod like that
i have to admit i have never once thought 'damn this game needs drugs'
Bahahaha @bronze yoke I think this constantly
Like even when I'm working and stuff
🤪
RP value in my case
there's at least two weed mods, alcohol, but not much else
i think blair made a rudimentary cocaine mod
Same thing kinda happened back when i was doing the shop mod
oh yeah there's a lot of those
Haha definitely RP value is drastically improved by visual aids and tangible impacts
But for me what it comes down to is hallucination is fun and sometimes in some ways even moreso in games where there's no comedown and it's not quite so time-consuming
And I wanna see some good hallucination effects in this game
Haha
Well good effects arent really doable without shaders
there's some hallucination effects in the schizophrenia trait mod
ARE there good effects in this game?
cuz u can draw on the screen raw
I mean good in the context of this game.
i was thinking the same thing, shaders would be a lot more fun
not sure if we can screw with shaders or not here
Sure can render images to make an animation but packing that many into a mod?
This is exactly what I'm planning to help Brandon try
the pipewrench tutorial, oddly enough, shows how to do that
Try to have mandala style overlays that rotate opacities or something
So there can be a limited number of discrete pictures
But a complex effect
Also pulsing scale
can procedurally move pixels in a 2d array and draw every frame or every few frames
Etc
Yeah I'm not sure how I would code that but I can at least get something interesting to happen instead of nothing
Something interesting > nothing.
you could make a hallucination that just shows random nonsense phrases on the screen at random
:P
Absolutely
maybe on the upper end it could show them so much you can't really see well
Auditory hallucinations could be funny
I was thinking about ways to repack Trash Talker for people
That would be an easy one
In addition to auditory hallucinations I was thinking battlecries
The default game wheel has a small handful of shouts but for people who want to shout wildly all the time I could make a way
the most evil auditory hallucinations would just be like.. banging that isn't there, zombie noises
or maybe gunshots
stuff that has gameplay impact normally
haha yeah those would be fun
i recommend poking at the schizophrenia mod it has client-only fake zeds
I might check that out that's pretty lit.
supposedly doesnt work as well in mp but does work
Mmmm interesting I'll see what I can learn lookin at the code.
the author was talking about this in another server earlier, it was a java mod or something
i can't remember the specifics but they specified that you can't actually do it right now
i do know of a lua mod that has a custom shader though, not sure how that works
There is a shader class, and a RenderShader function in Core:
https://zomboid-javadoc.com/41.78/zombie/core/opengl/Shader.html
https://zomboid-javadoc.com/41.78/zombie/core/Core.html#RenderShader
Lots of fragments in zomboid/media/shaders too, might be useful
if getCore():getUseShaders() then
-- does this actually work?
end
if anyone pokes at this and gets it working lmk
would be interesting tool to have in the toolbox
i would be surprised if these were though, generally stuff on this level isn't
at least i don't expect the shader class itself to be
i would be unsurprised if there's partial exposure but no way to actually hook things up
i don't expect to just have neat and tidy lua access though
it tends to be that they only expose what they need for the official content
even though it would be trivial to expose more
which is a shame
at least that's how it seems to be from my observation
sometimes i find the issue is "how do i get an instance of X"
and sometimes the reflection necessary to pull a public field value just doesn't work mysteriously
lots of dead ends
i'm going to look into it tomorrow - i've seen custom shaders before, so maybe i was misunderstanding him and it was something specific about the shaders that wasn't possible in vanilla
Random stupid meme mod idea. PT belt that while you're wearing it you have god mode but if you take it off you die instantly.
local obj = objects:get(index) how would i use this to detect if i found a vehicle?
what mod? that'd be interesting to see. I can't imagine you can actually load any shader code but there may be some exposed functionality on the existing shader implementations that allow for tweaking/applying
isVehicle would be awesome but does not exist.
when i looked at it it was an actual opengl shader program included with the mod
instanceof(<object goes here>, "BaseVehicle")
it was the blind trait
that sounds wild. isn't lua restricted from accessing the filesystem? how would it even load it, other than maybe overwriting an existing shader? 🤔
(unless it was a java mod, which is another beast entirely)
sooo.. this would work then?
for index = 0, objects:size() - 1 do
local obj = objects:get(index)
if instanceof(obj, "BaseVehicle") then
return true;
else
return false;
end
end
i assume the game loads anything in that folder
should, yup. although you can just do return instanceof(obj, "BaseVehicle") instead of the true-false if statement
you have to restart the game after enabling the mod as it doesn't reload them with kua reload
for index = 0, objects:size() - 1 do
local obj = objects:get(index)
return instanceof(obj, "BaseVehicle")
end```
you could even inline the obj definition if you want to make it even cleaner, up to you though
nah, that'd be dangerous af
you could load java classes in theory, as well as like... DLLs. not good
well it's going to struggle to load java classes as a shader
this code probably doesn't so what you think it does
what do YOU think i think it does?
it'll return whether the first object is a vehicle because you return no matter what
that's what he's trying to do though, from the looks of it?
if you're looping through the list you only want to return false if you didn't find one
oh yeah I ignored the loop there
function canTrailerSpawn()
--detect the obj with sprite named wew
local player = getPlayer()
local cell = player:getCell()
local x, y, z = player:getX(), player:getY(), player:getZ()
local xx, yy, zz
for xx = -2, 2 do
for yy = -2, 2 do
local square = cell:getGridSquare(x + xx, y + yy, z)
if square then
local objects = square:getObjects()
for index = 0, objects:size() - 1 do
local obj = objects:get(index)
return instanceof(obj, "BaseVehicle")
end
end
end
end
end
i forgot that lua doesn't have continue 
does it have break? it's been a while
although nvm you wouldn't want to in that case
for index=0, objects:size()-1
local obj = objects:get(index)
if instanceof(obj, "BaseVehicle") then return true end
end
return false
ye that'd be good
forgot the obj definition in there but that's not important to what i'm trying to show
writing this on mobile 💀
does zomboid's flavor of lua support goto? i haven't looked into whatever implementation they're using via Kahlua or whatever
i think burryaga was using that
function canTrailerSpawn()
--detect the obj with sprite named wew
local player = getPlayer()
local cell = player:getCell()
local x, y, z = player:getX(), player:getY(), player:getZ()
local xx, yy, zz
for xx = -2, 2 do
for yy = -2, 2 do
local square = cell:getGridSquare(x + xx, y + yy, z)
if square then
local objects = square:getObjects()
for index=0, objects:size()-1
local obj = objects:get(index)
if instanceof(obj, "BaseVehicle") then
return true
end
end
return false
end
end
end
end
you have some weird tabs, but other than that it looks good to me
you might want the return false further down, otherwise it'll only check one square
after the for xx loop ends
was there an update or something? code that USED to work, is now just loosing it's damned mind.
local trailer = addVehicleDebug(SjobModel, sA, nil, spawnsquare)
is supposed to spawn a car but doesn't as
trailer:setAngles(180.0, FixAngle, 180.0)
says the table is nil!
when this was spawning trailers just a day or two ago.
and local isFull = spawnsquare:isVehicleIntersecting(); used to handle everything this dumb function is being made to fix.
hard to tell without more details, and which table is returning nil
trailer is nil.
make sure you aren't losing the trailer's scope, since you're defining it locally
if you want to use it elsewhere you'll either need to initialize it again in the new scope or pass it to the other function
OH FFS
👍
it's spawnsquare that is nil.
oh rip
same thing though, since i imagine that's a local variable you defined as well, but you'll have to check your assignment methods to make sure you're not having issues getting the square
local isFull = canTrailerSpawn();
if isFull then
spawned = false
else
local trailer = addVehicleDebug(SjobModel, sA, nil, spawnsquare)
--correct the angle. ugh
local FixAngle = 0
if sA == IsoDirections.N then
FixAngle = Nangle
end
if sA == IsoDirections.NE then
FixAngle = NEangle
end
if sA == IsoDirections.NW then
FixAngle = NWangle
end
if sA == IsoDirections.E then
FixAngle = Eangle
end
if sA == IsoDirections.W then
FixAngle = Wangle
end
if sA == IsoDirections.SE then
FixAngle = SEangle
end
if sA == IsoDirections.SW then
FixAngle = SWangle
end
if sA == IsoDirections.S then
FixAngle = Sangle
end
trailer:setAngles(180.0, FixAngle, 180.0)
spawned = true
break;
end
because spawning a car set to spawn NORTH mean you can add 22.5 degrees to the left or right.
which is sloppy ass parking.
you might want to consider replacing that if tree with a table
or at least using elseifs so they don't all get checked every time
it's christmas. I thought trees were acceptable.
You could probably replace that with some math instead.
local y = trailer:getAngleY()
y = math.round(y / 45) * 45
trailer:setAngles(180, y, 180)
(but i'll try it... jsut gotta get them to actually ya know... SPAWN)
wait... it fricking spawned a trailer.
yep. gonna lose my mind here.
and there was even a car!
Crap
🤔 thats got a be problem
Ah i know . Can u despawn whatver is there first if theres something there
Probably put a sign no parking . Restricted for company transport vehicle only or something
it could despawn someone elses car.
U can blame it on them being lazy to read the mod description
Ill do it that way atleast 😈
@jagged ingot
so im trying to setup intelij and the guide konijima posted said to install Java 17
but i cant find the specific java that he used.. can it be a more recent version?
Switch version number to 17 and use the Eclipse Temurin version, it worked fine for me 20 minutes ago 🙂
how do i switch
so thats why it returned error i used the wrong one
ah nvm i just found where i can delete the proj

That I do not know how to resolve. With a completely fresh IntelliJ install, it defaulted to Temurin 17 for me and worked out of the box, no need to do anything extra. (And I don't have pre-existing Java tools on this laptop, to my knowledge .. Probably)
ow shit
anyone know some way to get a ArrayList elem by value?
probably cuz i needed to configure it . its cuz i installed it on someother drive as my os drive is nearly full
i think it worked
🤞
yep hold on
let me look for the snippets
u want to dertemine the key using the value correct?
nop, just a way to avoid iterating, I already know what I need, but I already have a loop, I don't want to add another one as it will start to overload
I think I can't
already found it but ok
hmm so you want to make it find it using 1 line? cant you use alocal func?
or is it the same?
just avoid using a loop for ... do
Hm..
If you already have 1 loop and want to avoid another, you can save the list in a table. That way you'll sacrifice a bit of memory space, but get instant access to each individual item later on.
local mapAccess = {};
mapAccess[key] = value;
local thatThingINeed = mapAccess[requiredKey];
Do the mapAccess[key] = value; thing in your existing for loop to populate your table.
the problem is that is an ArrayList, not a table, that's why I think I can't, probably you can only use ArrayList<>:get(index) to get values
Yeah, you can't do it with an arraylist directly, hence why you'll need to save the values and keys to a table of some sort.
Note that if you only have like 7-ish objects at the most in your arraylist, it's probably about as fast as using a map/table anyway, so you really don't need to optimise it.
yeah, that's right, but also I have that on a OnTick lol, so... 
context:
---@deprecated
IsoDog.update = function(self) ---> OnTick
local x, y ,z = self:getCoords();
local square = getSquare(x, y, z);
local instanced = Utils.existIsoMovingObjectFromList(self:getEntity()); --> a loop
if square and not instanced then
self:setInstance(true);
end
end
Oof. Can you upload a snippet of the code? I'll gladly give a look and see if I can give you something that might make sense.
I don't see the arraylist above 😄
Ah, the Utils method.
Could you share the implementation of that as well?
Utils.existIsoMovingObjectFromList()
---Check if IsoMovingObject exists on player's instance.
---@param p1 IsoMovingObject
---@return boolean
self.existIsoMovingObjectFromList = function(p1)
local isoMovingObjectList = self.getIsoMovingObjectList();
for i = 0, isoMovingObjectList:size() - 1 do
if isoMovingObjectList:get(i) == p1 then
return true;
end
end
return false;
end
Do you control when objects are added/removed in the IsoMovingObjectList?
only added, they remove when IsoMovingObject moves away from the player
Okay, how about an amortised solution.
On adding to the IsoMovingObjectList, you also add to a table so you can quickly see if this particular object is near the player.
Then every X ticks, you clear the table and rebuild it from that tick's current IsoMovingObjectList, to avoid it growing infinitely large.
Does that make sense?
Or maybe that won't work. 
I like it, I will try that, thx man
You're welcome. Only problem I foresee with this is that you will have 'phantom' things for a little bit, like if something moves in range it is instantly added to the table, but it will wait until the Xth tick with being removed.
So as long as you can confirm whether or not it is in range during this 'phantom' period, it should all be gucci.
Unrelated: Sorry for picking the exact gift box you're using 😄
When you selected the Java version, you made sure it was on 17 and not 19 right, @ancient grail
yes eclipse like you said
it already did everything
but only decompiled the zomboid not the docs
I'm sorry I can't help more, then. I can't think of what's going wrong here.
does character boredom level gets reset to 0 when they see zombie closeby?
cuz from testing it looks like it's the case
you can try by opening general debugger
but i bet you know that
actually idk how to open debugger without throwing error 
anyways so finally with the help of @agile vigil i manage to setup the ide but my problem right now is that the color of the text are redish..... and in vs code it indicated warning on that file.. how do i change that
what kinds of error do you have
i dont
are you testing with bunch of mods loaded?
F11
cheers
If you're using intelliJ, there's settings for anything/everything
somewhere in code appearance
or whatever setting would be called
anyone know why a trailer spawned with addvehicledebug, wont work as a trailer AND has no collision?
I have a specific vehicle-related question. Is there any way to add a part to a vehicle that doesn't already have it defined, without needing to redefine the script?
Similar to how ItemTweaker lets us change item scripts.
Item tweaker is just doParam with more steps
I don't believe the scriptManager has anything like doParam for any of the other script types
But you can process a whole script block into the scriptManager as a string
Alternatively you should be able to grab the script object and make changes for any parameter that's exposed
This can be done on recipes to make a true obsolete -- and I use it to add tags
I don't know if vehicleScripts are more or less malleable than recipes though 👍
Time to find out 😄
https://steamcommunity.com/sharedfiles/filedetails/?id=2648115890 is this guide still cool for making a clothing mod?
Yep
cool thx
where can i found modding docs ?
self works fine, if you want the parent then do self.parent
*tested with a ISTextEntryBox
** the java actually calls the ISTextEntryBox.onCommandEntered with the table of that ISTextEntryBox. Someone can get confused by the declarations in that file, I guess.
function ISChat:onCommandEntered() is same as function ISChat.onCommandEntered(self) and the text box has the ISChat.onCommandEntered for it's onCommandEntered
I think the entry box only works if it's in focus
I've used it to grab it's contents before though
Oh shit so I could do self.parent:close() to close the panel of the text entry box in my onCommandEntered?
Whyyyyy does vanilla itself not do it that way?
In their own onCommandEntered for ISChat, they don't say self.parent:close, they use ISChat.instance. They hard reference the instance rather than getting the instance via self.
I will try using self.parent
Thanks for using this mod & Java patch. Did you figure out what you needed?
define the parts in your own script, and then add that script as a template to the original```lua
ScriptManager.instance:getVehicle('CarNormal'):Load('CarNormal', '{template=CarNormal_Upgrades,}')
If it is this simple, you are a Goddess. Bless! 🙏
you can also alter existing parts doing this, the only limitation i've run into is if a part is loaded from a template and isn't changed by the script you're adding to, you'll overwrite it instead of altering it
That makes sense.
I discovered the "copyParts" and (and copyAreas and copyWheels) methods on vehicle scripts, so I've been playing with those for now, but I've been consistently getting some errors
i've been using this for a few months with no sign of problems
Could you describe what a "Bullet" is and why vehicle scripts have a toBullet() function, perhaps? It's a weird terminology.
bullet is the physics engine zomboid uses
TIS are comprised of many native-English and non-native English speakers, so the API without context or documentation can be confusing. This is a common theme throughout PZ's codebase.
Yes yes, I have my command running in like 5 mins, very simple stuff, thank you for the work!
No problem. May I ask.. is this for Twitch streaming?
Thank you.
No, atm I'm trying to send the messages from discord using this, kinda janky stuff having a container running that sending a bunch of rcon for messages but hey, with my knowledge is a nice challenge
Ah ok. Didn't think someone would use this tool for this purpose. Nice. I ended up rewriting the chat protocol several years ago when I added support for Discord.
wait, what do you mean Discord support?
A long long time ago.
Was before official support.
I think because you're only supposed to have one anyway -- the new() some some UI close the old instance before opening a new one.
why does
sendClientCommand(char, "KYRPT", "spawnTrailer", {type = SjobModel, condition = 100, clear = true, x = sX, y = sY, z = sZ, dir = sA});
return
ISLogSystem
instead of KYRPT for the module??
sendClientCommand('module','command',{})
The player is already provided when firing this API call.
Anyone else getting reports of their mods download pending? Over and over until the game closes?
I can't replicate it but I get a few reports of the issue
Can someone suggest me some Winter mod? I wanna feel like it's actually some kind of atomic winter
Turning the temperature down to max in sandbox isn't really doing it for me
Is there any way to actually control the chances of knife jaw stabs?
Friend wants to disable jaw stabs for one of his weapons that uses the knife stab attack animations but removing "CloseKillMove = Jaw_Stab" didn't disable them.
Would setting crit chance to 0 do the trick?
I'll let you know if the parent thing works safely
Its missng a few things but other than that its all good
Jk
Funny thing is, it looks perfectly fine, until I enter aim mode for the first time in the session 😄
And randomly turns back.
The best solution, instead of adding textures and masks etc. I can think of would be to just set the rust level to 0 on my car wrecks, as that seems to solve the issue immediately.
Question is, how is rust level set on newly spawned wrecks?
Ah, that is determined deep in Java code. Unfortunate.
Where is the clothing degradation defined - to what file .cfg refers to?
it's randomized based on baseVehicleQuality, which is defined for those stories in VehicleZoneDistribution.lua
essentially every zone story has a chance to spawn a vehicle burnt, and that chance varies by zone. the highway pileups are 80% for example
and each zone also has their own baseVehicleQuality, and the burnt cars actually inherit that - so you're much more likely to have a high-rust burnt car in a trailerpark than you are to find one in a "good" zone
how do i add a custom sound to a recipe??? it would go Sound:"here", but if its custom then would i just say Sound:"mysound", regardless of the file path????
I seem to get some sort of reset on a moveable object after OnSave event, logs print reanimated zombies and globalobject save and then the object is reset (checking on EveryTenMinutes, the value missing is the AcceptItemFunction from container which doesn't save)
Why would it reset while being loaded?
*might be related to sendObjectChange, facepalm
Fixed my texture errors 
ok so when you are adding a sound to a recipe you just slap the name of the audio in and it doesnt matter where the sound is as long as its in a folder named "sound"
on another note what are the exact measurements of time? Time:50.0 = 5 seconds? 1 second?
What is the bug?
Hiya
is there a way to check if you've loaded on to a specific challenge map
I want a dust storm to happen only if you're on my new challenge map -- not when you're in vanilla
Are there any good automated translation programs for this game? I am considering offering translations for some of my mods, trying to figure out how much manual labor would be required to cover all of Zomboid's languages.
Hello modders! Have any of you already tested ChatGPT to generate full functions or help or documentation? And if so, what do you think about it?
mostly generated garbage
@abstract raptor
I have never used this but I know core has things like isChallenge(), getChallengeID(), getGameMode(),
I mean, chatGPT is neat. It'll write functioning code sometimes, and when its not you can point out bugs and it'll fix them. But I found it couldn't really work with lua very well due to not understanding the pass-by-reference pass-by-value distinction. Maybe with careful cajoling you can get it to write useful stuff but its not really worth my time when I can just write it myself
is there any workaround of <RGB> eating the spaces?
is this for tooltip / richtext? usually you need extra spaces around the <>
I think is the same using tooltip and addLineInChat, how these spaces would go?
if you notice, vanilla always has spaces together with the tags so it would be " RGB:1,1,1 "
nah, still the same
What about a .. " " .. after argb as well?
Gonna try, but since is the beginning there is no need for spaces
you could try adding extra spaces, maybe it only consumes one
I hope this is enough msg = argb .. " " .. aname .. " " .. msgrgb .. " " .. msg lol
Same result
I'd probably just be lazy and use a - instead in between, like msg = string.format("%s %s %s-%s", argb, aname, msgrgb,msg)
nah, eats every space in front it seems
I feel so defeated lol, I'm just going to use \n, damn
why, doesn't the dash or maybe a colon work? I doubt you want it to start a new line
use a special space character
a whitespace character with a different unicode to normal space
It hurts my eyes replacing spaces with other things
lua doesn't handle parsing unicode very well, but maybe just using some would be ok
don't know how
just out of curiousity, can you post the RGB.
dont know if discord replaces the character with normal space
if it does look it up yourself
okay
rgb is just a string, like saying "RGB:1,1,1
<RGB:1,0,1> nanana <RGB:1,1,1> "Hello, this is a test"
need more spaces
why tho, the spaces are added in the code, not in the command
the same, If I send that ch with the console then is replaced, gonna look for that unicode
yeah was discord
ive helped someone fix this before
game eats normal spaces you really have to do use a special whitespace
Do you guys know if this is supposed to be > I have 12 months later setting and after removing a all the grass from an area, it won't grow back?
Erosion days is set to 1 so it should grow back with one day but I think the mechanic just stops at some point?
anyone know why scrap armor/weapons/guns mod doesnt work when i host a mp server
That questions should go to #mod_support
thanks
I'm having way too much fun right now prototyping ideas for my TS React library..
/** @jsx PipeWrenchUI.createElement */
import { PipeWrenchUI, createUI } from '../../shared/pipewrench-ui/React';
createUI(
<element class="my-element" on-update={() => { print('Hello!'); }}></element>
);
It's going to be a bit of work to get selectors and calculating CSS stuff with a cache but IMO it's worth it if I can create UI elements for PZ instead of doing it all manually in Lua.
question about base pz events mechanics. So lets say i have event that is called OnZombieDead, right. It's run every time Z dies, for example. If I would put code related to player in there, aka player = getPlayer() and then do something there. How would it run on server? Does it run my function separately for each player? If yes, is this the case with all events?
it will not run for any player and the behaviour would not be different between events
getPlayer() is getPlayer(), it doesn't matter where you call it
none
or i mean
getPlayer() always returns player 0 on the client, and null on the server
if you want to do something for all local players, use
for i=0,3 do
local player = getSpecificPlayer(i)
if player then
-- etc
end
end
all four splitscreen users are very disappointed to hear that

I thought that the UdpConnection array stuff would disappear at some point.. or be migrated into an implemented server class specifically for CoOp.
I thought that 6 years ago. xD
Weeeelll, it seems the erosion mechanic is kind of broken 😦
newbie question: is there any sort of collision possible for a Blender item placed in the game? So if I just place a cube as a StaticModel can it be given collision?
Question: I am using moddata for my mod obviously and i was wondering if there's a nicer way to initialize everything than doing stuff like
local modData = player:getModData();
modData.DynamicTraitsWorld = modData.DynamicTraitsWorld or {};
modData.DynamicTraitsWorld.vehiclePartRepairs = modData.DynamicTraitsWorld.vehiclePartRepairs or 0;
in every function that is using moddata.
can I instead, for example, create event on game load where i would initialize all my mod data so i dont have to do nil checks everywhere else?
you'd need to do it OnCreatePlayer since there are no player objects that early
you can make a single function to 'get' a specific sub-table
in other words - put those 3 lines in a function
onCreatePlayer would work as Albion says
does oncreate player triggers on literal player creation or every time player loads into world too?
every time player loads into the world
Nice overwriting 👍
also for some reason
if you put restorationexpert before originalfixperform it would always repair to full condition instead of doign normal repairs and not increase repairs counter
idk why
but it was interesting interaction
perform clears some variables - like removes the action from queue
maybe there's something getting lost
heh
if it works, I'd leave it
maybe
yea not planning to change, was just saying
any benefit in making functions local? besides ensuring that they won't get overwritten. So far i've been leaving them global but making sure they have unique name by adding mod name prefix in front of them
How you guys do it?
local functions and variables run faster
time to chanage every single thing to local 
question though
local functions are limited to scope of lua file they are in?
Or mod?
the lua file
I see
if you want to share things between files, it's best to use this kind of design:
-- file1.lua
local foo = 'bar'
return foo
-- file2.lua
local foo = require 'file1'
cool
you can also add functions under foo (in file 1)
would make it harder to cause overwrites without making huge unique names
same reason you are naming stuff within something else in modData
probably dumb question but
so if i have a lua that i want to use for initializing mod data
local function createModData(playerIndex, player)
local modData = player:getModData();
modData.DynamicTraitsWorld = modData.DynamicTraitsWorld or {};
modData.DynamicTraitsWorld.vehiclePartRepairs = modData.DynamicTraitsWorld.vehiclePartRepairs or 0;
end
Events.OnCreatePlayer.Add(createModData)
it's fine if function is local cuz it still creates moddata which is globally available?
yes
Events is global technically
If you're using events you almost always have no reason to make added functions global
i see
man it's fun getting deeper and deeper into pz modding 
if i pass argument into local function, is it treated as local? aka faster
arguments are always local
smort
If I use variable only once there's no point in making a local version of it, right? Cuz it still would call it once, right? In 98% case that my question was
and not understandable, here's example:
if self.vehiclePart then
local part = self.vehiclePart;
vehiclePartCondition = part:getCondition();
end
no point in making local variable, right?
yeah, no point
self.vehiclePart is already local
I'd only redefine it for the sake of emmyLua knowing what it is
or need to recall it again
now everyone knows im dumdum
nah it's fine
also if you're using intelliJ + pzlibraries + emmylua you can define types for locals
using VSCode atm but wanna switch to inteliji over weekend, heard u can make good use of decompiled PZ stuff
so here, for example
local function DTWOnZombieKill(zombie)
local player = getPlayer();
if player:HasTrait("bloodlust") and player:DistTo(zombie) <= 4 then
local bodydamage = player:getBodyDamage();
local unhappiness = bodydamage:getUnhappynessLevel();
bodydamage:setUnhappynessLevel(unhappiness - 0.04);
end
end
i also have no use of locals, right, since i call to them literally once it's same if i would do
local function DTWOnZombieKill(zombie)
local player = getPlayer();
if player:HasTrait("bloodlust") and player:DistTo(zombie) <= 4 then
player:getBodyDamage():setUnhappynessLevel(player:getBodyDamage():getUnhappynessLevel() - 0.04);
end
end
right?
yeah
you can change player:getbodydamage() to bodydamage
in the 2nd example
if you only use it once, you still have to look it up once to pull it into the local space, it's no faster
you dont have it defined but refer to it
if you use it more than once, it will be faster, and even though the speed difference is pretty minimal for just two calls the resulting code will be a lot prettier
ye
I can do something like this, right?
local modData = player:getModData();
modData.DynamicTraitsWorld = modData.DynamicTraitsWorld or {};
into
local modData = player:getModData().DynamicTraitsWorld or {};
yeah
coolio
its' getting prettier and prettier

I assume this is also fine?
local SBvars = SandboxVars.DynamicTraitsWorld;
yes
just make sure to only do that when you're sure you're going to get something back
you mean sbvars?
if getModData had a chance to give you nil, then you'd get an error
it doesn't, so you're fine, just keep it in mind
it doesnt though, right?
yea
cheers
i got myself a DTWModData.lua where i'll be adding all my moddata stuff so that way I don't have to worry about it
local function createModData(playerIndex, player)
local modData = player:getModData().DynamicTraitsWorld or {};
modData.vehiclePartRepairs = modData.vehiclePartRepairs or 0;
end
Events.OnCreatePlayer.Add(createModData)
just started coding actual stuff though so only 1 entry so far but you get the idea
I've been trying to figure out why my wallets didn't dump money when disabled and its cause I didn't have a 'not'
classic
oh, actually
you shouldn't do local modData = player:getModData().DynamicTraitsWorld or {};
yeah chuck's onto it
you're going 'the table at that location, or an empty table with no link to moddata'
player:getModData().DynamicTraitsWorld = player:getModData().DynamicTraitsWorld or {};
local modData = player:getModData().DynamicTraitsWorld

new sandbox option for shops and traders - disable player wallets
you'll have to carry that cash
where's that skyrim mod that adds weight to coins 
oh that's such a smart way to handle money...
lol, reminds me of that meme picture of having to enter your phone number with a slider
the money system i interact with sort of has this with wallets, but they've been a big pain
Does that slider work with gamepad?
The wallet I refer to is a Ui element players can drag cash onto to deposit
withdrawing works like the split pop up
the slider extends the default slider
I considered using the wallet item but idk - seemed pointless lol
might look at it again - but I feel like it should operate like a container
our loose money items just suck to use, we don't merge them like this - we made the wallet items store money in moddata, you put money in with a context menu option, but that's annoying too
and items should have a 'very tiny' 'tiny' 'small' tag for size
I kind of hate context menus - I try to avoid them when I can
while still staying within the design choices of TIS
yeah, i'm maintaining a system written by someone before me, i don't think i would have done it this way
Chuck bigbrain
I also forcibly overwrote item stacking for books with namedliterature cause I couldn't leave it like it was lol
i try to make my mods fit as exactly with how i think TIS would have done it as possible, it's important to me that mods don't feel like mods
I was going to do the same for money in this mod but I didn't want more mod compat issues
same, most of my stuff is basically vanilla+
it's how I'd want my experience to be
and unless its a commission I don't stray that far
You could change to shops and traders :p
Working on a faction bank add-on
trying to deal with possible shenanigans faction leaders can do
then I have to work on the UI 
i was commissioned to update the shop mod we currently use, it'd be a bad look for me if we switched mods 😅
someone on the team is rewriting money from scratch for some reason so i'm just going to hope their version is nicer to work with
alright lol
what do you mean by rewriting currency?
to act with change?
that sounds like too much 'realism' vs 'grounded'
i have no idea, i genuinely don't know why they're rewriting it LOL
Like will you have 2 quarters and not be able to give someone 30 cents?
i have no idea what the new system will be or if/how it will be better
the mods i've been mentioning here are browser8's shop mod and aiteron's projectrp
either of you know a good way to place a marker on the ground at a precise location? WorldMarkers seem to only point to the center of squares
gone are the days of manual editing
are AI stealing our jobs?

no overloads that I'm aware of, and the helper method that does the actual rendering is private 😩
for world markers anyway, I don't know what other ways there are to draw something like an arrow on the ground, pretty sure UI elements are screenspace not in-world
I suppose I could recreate the direction arrow renderer in lua, as long as SpriteRenderer is exposed
isoToScreenX() and isoToScreenY() seem relevant
kinda hope spriterenderer isn't exposed, what the heck is this call? lmao
SpriteRenderer.instance.render(var1, var27, var29, var31, var33, var35, var37, var39, var41, var10, var11, var12, var13, var10, var11, var12, var13, var10, var11, var12, var13, var10, var11, var12, var13, (Consumer)null);
LOOL
yes, those isoToScreen functions look really handy, maybe I should spend some time looking through this IsoUtils class
what's the best way to go around making sandbox presets, if possible?
for mod sandbox settings that is
if it's even possbile 
it's not
sadge
i was writing something like that but it was annoying and i don't really have the time anymore

How to I make my saved preset settings available in a mod? Seems the usual way/folder path is not working
SNIPPET: get mapAPI
local mapAPI = ISWorldMap_instance.mapAPI;
print(mapAPI:getMaxXInSquares()) --> Returns 19799
print(mapAPI:getMaxYInSquares()) --> Returns 15899
--> enabled to use class methods zombie.worldMap.UIWorldMapV1.java
What would you have done differently?
regarding your shop mod? that one is fine actually
i was referring to the money system from project rp that it has to interact with
In my mind it isnt, wanted to rewrite the whole thing basically
Ui wouldve been pretty much the same but with tabs for buying selling and logs
I don't see your shop mod on the workshop
Dont remember if i left it hidden
Since that version was really only meant as a test
I got asked to write one cause 1 was too old and the other was too strict
Specifically for the system to convert any container in the game into a shop
ah, if you know of any features I could add to mine, lmk
a buy/sell log seems like a good idea
There was also meant to be a room wide shop setting
ooohh so that's what that was about
ah, like an old school MUD?
Where opening the ui would show stuff from all shops in the room
oh
Skizot also pitched the idea of map markers to show where shops exist
😄
function checkTileSpawns(sq)
local x, y, z = sq:getX(), sq:getY(), sq:getZ();
if #JobBoardTileSpawns.toSpawn > 0 then
for i = #JobBoardTileSpawns.toSpawn, 1, - 1 do
local tileSpawn = JobBoardTileSpawns.toSpawn[i];
if x == tileSpawn.x and y == tileSpawn.y and z == tileSpawn.z then
local sname = tileSpawn.Tile
local object = IsoObject.new(sq,sname)
sq:AddSpecialObject(object);
object:getSprite():setName(sname);
tileSpawn.spawned = true;
local signData = object:getModData();
signData.loc = tileSpawn.loc;
object:transmitCompleteItemToServer()
object:transmitModData()
--table.remove(JobBoardTileSpawns.toSpawn, i);
end
end
else
Events.LoadGridsquare.Remove(checkTileSpawns);
end
end``` what part of this would you put into the server, so the signs stay put?
that's all client side but the signs poof.
bro why is it when i setup my mods it just says fucking initializing
Poof as in relogging and they're gone?
yup
I tried adding map markers when they first came out - it didn't really pan out. I should add them to EHE too
Is transmit completed item to server a vanilla thing?
anyone know a fix to setup mods it just stays on initializing forever i have everything i need for each mod to work
how do i check log
user/name/Zomboid/console.txt
so this is a collision, and the modeled footprint of the same collision (with the left vehicle's footprint increased by 10%), and they still aren't quite "colliding". Also their orientation seems off, although I don't know if that's just the isometric projection messing with me.
Don't quite have this right
wtf
i’m not good at this pc shit nvm i’ll just play vanilla
tf is a user/name/zomboid where tf do you even find said thing like that 😂
The file is console.txt
or just abort and look for the log
okay
That looks to be flipped
Like vertically
does the coordinate system in game go in a strange direction? Like 0,0 in the nw corner and positive as it goes south or something?
0,0 is NW if you consider the left front of the white car NW
But something seems off - like it's mirrored
Use Ctrl+f for "pending"
if NW is 0,0, what would be south of it in game? 0,1?
cannot find “pending”
It sounds like your mods are triggering download checks and can't resolve it
Then post the log to pastebin and link it
But you should move this covo to #mod_support
I think 1,0 is south? Check the online map I guess
No wait 0,1 is south
I hate isometric lol
bottom left is south
iirc the game currently doesn't support negative coordinates, so if 0,0 is NW then East and south are the positive directions, which would explain why my little diagram is mirrored, since up and right are positive on a cartesian plane
top right is north
So the collision code is correct then, just the diagram being off?
collision code is correct in the orientation, but the snapshot seems to be slightly earlier than the point of collision
The shadows are the collision boxes right?
yes, although the one on the left is increased in size by 10% to prevent floating point errors giving a false negative, so even though in the diagram they look practically touching they'd actually be just a tiny bit more apart
so both BaseVehicle:getX() and BaseVehicle:getWorldPos() seem to be a little behind the actual simulation. Which is strange because getWorldPos literally accesses the simulation
could be, which means I would also have to simulate the motion, which is gonna be a pain
linear motion is fine, but doing backwards donuts? Now I have no idea where the vehicle is
Don't suppose you can find where they add the vector3 and just add it
hmm, there is a lastLinearVelocity and jniLinearVelocity that the crash code compares
Good luck and good night
my code fires at approx line 3058 in BaseVehicle, so I guess I'll look after that
night bud
👍
Anyone know the latest I can submit stuff to the ProceduralDistributions list and still have added items potentially appear in the player's spawn zone?
Would OnServerStarted work maybe?
what are you trying to do?
Sorry just saw this @bronze yoke I want to base the rates of procedural distribution of my books on 2 things: a sandbox option, and the game's selected frequency for LiteratureLoot
i.e. getSandboxOptions():getOptionByName("LiteratureLoot") and SandboxVars.Meditation.literatureFrequencyMultiplier
But historically if I try using SandboxVars immediately it doesn't work out so I am trying to delay adding the items slightly to make sure the proper variables exist
if you're looking for a time where sandbox options are loaded but distributions aren't, there is no such time
the closest you can do is add your distributions to the table on an event after sandbox options load (i like to use OnInitGlobalModData, but there are many that work) and then call ItemPickerJava.Parse()
Okay so you're saying I run these lines:
table.insert(ProceduralDistributions.list["ShelfGeneric"].items, "Meditation.MasteringYoga")
table.insert(ProceduralDistributions.list["ShelfGeneric"].items, rate)
table.insert(ProceduralDistributions.list["LivingRoomShelf"].items, "Meditation.MasteringYoga")
table.insert(ProceduralDistributions.list["LivingRoomShelf"].items, rate)
...
etc.
and then I run
ItemPickerJava.Parse()
and that presumably reapplies the distribution data?
yeah
Okay thanks, I'll try this.
This won't conflict with other mods to simply reload that data late, generally speaking?
I know reloading Mod Options late was a fucking disaster haha
it shouldn't
Alright workin with this
MasteringYoga.addBooks = function()
-- Base Rate
local rate = 2
if SandboxVars.Meditation.literatureFrequencyMultiplier then
rate = rate * SandboxVars.Meditation.literatureFrequencyMultiplier
end
-- if getSandboxOptions():getOptionByName("LiteratureLoot") then shitManIGotsTaGetPaid() end
table.insert(ProceduralDistributions.list["ShelfGeneric"].items, "Meditation.MasteringYoga")
table.insert(ProceduralDistributions.list["ShelfGeneric"].items, rate)
table.insert(ProceduralDistributions.list["LivingRoomShelf"].items, "Meditation.MasteringYoga")
table.insert(ProceduralDistributions.list["LivingRoomShelf"].items, rate)
. . .
ItemPickerJava.Parse()
end
Events.OnInitGlobalModData.Add(MasteringYoga.addBooks)
Ayyy seems to have worked thanks as always @bronze yoke
i need a help.
local adjDist = math.round((signDistance * distOffset) / 1320, 0.01) * distOffset;
local adjTime1 = math.floor(adjDist) * 60
local adjDelivery = os.time(os.date('*t')) + adjTime1;
it's ALWAYS like 5 hours. i just want to take the number froim adjDist (usually between 15-40) and multiply it by 60 (seconds) and add that to the CURRENT time. but yeah. it aint wanna work.
What is the code to set/get player speed? Looking to edit swing speed/walking speed via lua code
@rain iron :getMoveSpeed() and :setMoveSpeed(), unfortunately, in a dark twist ending Java will reset changes to setMoveSpeed() immediately
Also, setMoveSpeed OnTick will make the speed value report correctly (I just set mine to 15), but you still won't move faster
Sooooo good luck with that
P sure it's Java side trickery
Ye so 15 is the max?
No I arbitrarily set it from what it was, .05999999324893981, to different values actually
I kept increasing it all the way up to 15, and when nothing kept happening, gave up
unfortunately it goes java sets speed -> java uses speed -> lua sets speed -> lua reads speed -> java sets speed
it doesn't matter what you try to do to it because java will always set and use it before you can interfere
😭
Well that is some weird PZ jank
What I wanted to do is to make a weapon similar to TF2 Eyelander where you heal + move faster the more you kill
This is gonna sound a little wacky, but you can run the pathfinder multiple times in a single frame to make the character go faster
So maybe you could dynamically generate a vector based on the current WASD input with a length of about 0.5 tiles, and have the player move + pathfind towards that?
This would probably be very jank
But also hilarious if it worked well enough
Hello! Maybe I can find some help here? I have a mod that should delete a tree from the world and add it to players inventory, but in MP the tree doesn't disappear. I tried using "RemoveItemFromSquare" and "transmitRemoveItemFromSquare", but there's no effect until server reboot. Also tried "DestroyTile" with same results. Maybe some ideas how to make it work in MP?
I looked into the lua code for chopping down trees. The default method of getting rid of trees seems to be killing them.
the timed action for cutting trees simply
tree:WeaponHit(self.character, self.axe)
hits it with the player's axe
It doesn't actually do anything to remove it.
I'm thinking the java side might be handling the networking part automatically in response to the tree losing all its health.
you should check what the java is actually doing - it's not unlikely that you can just reimplement whatever that method calls
How do you check what the java is doing?
In chopTreeAction there's a line with in case of timed action instant "self.tree:setHealth(1)", but I dont't have knowledge how to use in my case, If I just add it to my action it bugs(
that is the tree object you want to remove from square.
yes. My mod is about digging out a tree in a forest and making it a Christmas tree at home. I don't know why in MP it doesn't delete the tree tile
I assume the chopTreeAction does WeaponHit after setting health to 1? That way only one swing will kill it, I imagine.
Ok I see the problem
Your timed actions don't have a reference to the tree itself
They seem to have a reference to the tile the tree is sitting on
checked, in admin it swings once. so not my story, i'm digging(
yep, only thing in weapon hit is remove from square and some cache updates.

In SP I don't delete tree through timed action. I do it with ClientCommands.lua, but in this particularly case I have to do smth different( With SP way the tree disappears after reboot to host.
God I love big trucks in Zomboid.
I hope you figure it out, Birget, a Christmas tree would be heavenly.
i'm working on a whole ass rpg trucking mod. lol
Thanks) Mod is already in workshop (Christmas Time) and all other features are working ok. Maybe I will leave it unfixed for now, it's not really big deal to chop this tree after getting potted version into inventory. Its my first modding experience, so i really can't do much
@fast galleon You were right, self.parent worked fine for referencing the panel of the textBox. I was able to simplify my code quite a bit. So weird looking the way this works in vanilla... they build a function to receive "self" inside of a class of which self is not an instance, but rather a child... that is not a normal way for code to read lol. But it does work in fewer lines so I'm still glad it works.
ISChat probably has been edited more than once over the years
Howexactly did u delete it. Can you share the code
Yes there are abunch of mods
@ancient grail
ty, ill post there!
Just the snippet of how you delete
object:getTextureName() and luautils.stringStarts(object:getTextureName(), "e_canadianhemlock_1_3") then
sq:RemoveTileObject(object);
local square = getPlayer():getSquare()
for i=0, square:getObjects():size()-1 do
local obj = square:getObjects():get(i)
if isClient() then
sledgeDestroy(obj)
obj:getSquare():transmitRemoveItemFromSquare(obj)
else
sq:RemoveTileObject(obj);
sq:getSpecialObjects():remove(obj);
sq:getObjects():remove(obj);
obj:getSquare():transmitRemoveItemFromSquare(obj)
end
end
this will delete stuff on the square the character is steppin on
you could use it to revise your code
i just use it for debug purpose
thanks! I'll try!
if instanceof(object, "IsoTree") then
if isClient() then
sledgeDestroy(obj)
object:getSquare():transmitRemoveItemFromSquare(object)
else
sq:RemoveTileObject(object);
sq:getSpecialObjects():remove(object);
sq:getObjects():remove(object);
object:getSquare():transmitRemoveItemFromSquare(object)
end
end
here you go
hope it works
i cant see the upper part of othe code, how you get the variables but if you manage to get that part already then this is just to check if its a tree then delete it
so use the second one i sent just wrote it based on your code...,. the first 1 is just for reference
Nope, no effect in MP, or I pasted it wrong. I don't know how to format my message like yours(
`if command == 'DigChristmasTreeAHCommand' then
local sq = getCell():getGridSquare(args.x, args.y, args.z)
if not sq then return end
for i=0,sq:getObjects():size()-1 do
local object = sq:getObjects():get(i);
if object then
if object:getTextureName() and luautils.stringStarts(object:getTextureName(), "e_americanholly_1_2") then
if instanceof(object, "IsoTree") then
if isClient() then
sledgeDestroy(obj)
object:getSquare():transmitRemoveItemFromSquare(object)
else
sq:RemoveTileObject(object);
sq:getSpecialObjects():remove(object);
sq:getObjects():remove(object);
object:getSquare():transmitRemoveItemFromSquare(object)
end
end`
many "end"s here
If you can noclip try this
Just phase thru the tree
The. Paste that on debug
In seeing alot of "if"
Make sure u have enough "end"
🫡@finite rover just tested it and it worked
now i improved the code
function despawnTrees(rad)
local pl = getPlayer()
local x, y, z = pl:getX(), pl:getY(), pl:getZ()
local xx, yy, zz
for xx = -rad, rad do
for yy = -rad, rad do
local square = pl:getCell():getGridSquare(x + xx, y + yy, z)
for i=0, square:getObjects():size()-1 do
local obj = square:getObjects():get(i)
if instanceof(obj, "IsoTree") then
sledgeDestroy(obj)
obj:getSquare():transmitRemoveItemFromSquare(obj)
end
end
end
end
end
usage:
despawnTrees(4)
Is there any way I can access Java fields in my Lua code?
I have a list of all Parts in a car, and I want to iterate over all the IDs they have, but when I do something like:
local partId = vehicle:getPart(index).id;
Then my partId is always nil 😦
It looks like I either don't get to this part of my code anymore, or my part is nil itself, so perhaps this question is answering itself 😄
Nope, the part is not nil 😦
If there isn't a getter for it, usually no
You can get around some field/class stuff but last I recall it can only read not write outside of debug mode
I only need to read.
Let me see if I can find my old code
Thank you 🙂
--TODO: Figure out how to get this to work outside of debug
for i = 0, getNumClassFields(zombie) - 1 do
---@type Field
local javaField = getClassField(zombie, i)
if javaField then
if luautils.stringEnds(tostring(javaField), '.' .. "speedType") then
print("-EHE:SWH: javaField: "..tostring(javaField))
if not javaField.setInt then
print("-EHE:SWH: setZombieSpeed: ERROR: javaField.setInt not found.")
return
else
javaField:setInt(zombie,speedVal)
end
end
end
end
```
So the class fields are exposed and you can parse through them
But the sets/writes don't seem to work outside of debug
This lets you read any field though
That's plenty for my use case.
My writing is done through a normal public method, but I need the part ids for perfect behaviour.
Essentially, I want to copy all parts of one vehicle to another except the wheels, as the wheels changes physical collision.
Sounds interesting, what's the intended effect?
When it works like it should, it adds lootable parts to burned wrecks.
But it does not let you get in and drive those burned wrecks.
Ah nice
My issue is that 4 cars in the vanilla game have different collision in their burnt form, compared to their non-burnt form. So they essentially started flying on their own when I threw on the wheels 😄
And since no burnt wreck model has tires, I consider it a small win to not have it in the mechanics menu.
Sounds like a solid improvement
The wrecks in-game always seemed off - I tend to use the "all wrecks are cars" type mods
Yeah, this is very much inspired by that sort of thing, except keeping them as burnt wrecks that cannot be repaired to a fully driveable state - and using code-based patching so it will work with mod-added wrecks.
Oh heck yeah. Thank you @sour island - not only did it work, but worked better than I could've expected it to.
I can even keep the tires, because the new way of copying (somehow) doesn't copy the wheel hitboxes. I think I can also remove a little rust-based hack I did at one point.
Edit: Nevermind, still gotta not copy the tyres, but hey, that's what I was trying to do with this method anyway!
(Rust as in rusty metal, not Rust as in the programming language)
Credit to whoever showed me that in the first place -- and Tyrir who later clarified some stuff about it later.
Yeah that's some really useful stuff.
https://imgur.com/tO9nXb7
never get lost again with auto trees despawner! hehe
Now I really want to see industrial-sized logging equipment, specifically for making offroad paths that are shorter.
they exist.
there's a bulldozer that does that.
and my lawn mower does that but to grass.
imagine your character sneezes and this happened ....
hahaaaaahahahaaachoooo
https://imgur.com/fLmFitw
are there any mods that disable the damage you take from carrying too much?
You got a snippet for that effect? Might need to revamp helicopter crashes lol.
What's your mod idea?
I also have a moddin' question here regarding creating sandbox settings for mods. I'm wanting to have my mod be customizable so you can enable/disable certain items (ie. Easter candies), though I don't really know where to begin for that
soo it would be cool if we had an mod that makes louisville an safezone until in day 8 like an meta event because of the project zomboid lore
I slightly don't get it.
Lets say theres function in file lua1 that i want to run in file lua2
do I do
-- lua1.lua
local function abc()
local a = 2 + 3;
print(a);
end
--- lua2.lua
local lua1 = require 'lua1'
local function xyz()
abc();
end
Sort of like how they eventually get through that military blockade, might be interesting
yeah because of the game lore
I believe you have to define a object/table to house all the functions -- and return it at the bottom of lua1
lua1.lua```lua
local enclosedSystem = {}
function enclosedSystem.Foo() end
return enclosedSystem
lua2.lua```lua
local callOverEnclosedSystem = require "lua1"
-- can use callOverEnclosedSystem.Foo() anywhere in this file
Man typing code on a phone sucks
sending it now
sent
Ty
I remember looking into shaking the trees with events but couldn't get it to work directionally
Having them break on impact might be good enough
why muldraugh... WHY
lol, there's some strong functions for flooring to certain places
I had to do it for money
-- Maffs Halp
function math.sign(v)
return (v >= 0 and 1) or -1
end
function math.round(v, bracket)
bracket = bracket or 1
return math.floor(v/bracket + math.sign(v) * 0.5) * bracket
end```
i borrowed a math.round.
lol
local adjDist = math.round((signDistance * distOffset) / 1320, 0.01) * distOffset;
all the restround to two.
why wont muldraugh?
and it's not cause of it's position.
I typically do something like this
--lua1.lua
local This = {}
This.publicVariable = true
local privateVariable = "something"
function This.publicFunction() end
local function privateFunction() end
return This
--lua2.lua
local stuff = require "lua1"
stuff.publicFunction()
stuff that is put in the table you return is accessible, stuff that is local is hidden
require is basically like calling your file as a function
it just gives you a variable containing whatever that file returns
so you need to return whatever you need to use from that file, and the easiest way to do that is to just put everything you want in a table
and then return that table
how do I require file that's in parent folder?
lua recursively searches, should find it regardless
k, will try, thanks
TIS Lua code is basically static-global references. Simply requiring their files loads classes and tables into the global space.
I would recommend using the module approach, which @astral dune mentions.
It's not wise to poison the global table.
if I have This.publicFunction() do i call in from within the file its in still by This.publicFunction() or can i just do publicFunction()
just use string.format
ie:
-- usage: round(123.4567, 2) returns 123.45
local round(number, digits)
return tonumber(string.format("%."..digits.."f", number))
end
-- alternately:
-- usage: round(123.4567, "%.2f")
local round(number, digits)
return tonumber(string.format(digits, number))
end
you can probably just skip the tonumber calls if your just going to display the results as a string anyways
like if you wanted to use This.publicFunction() in lua1.lua? you still need to use This.publicFunction(), there are ways around that if you really don't like having the module name (This) there, but that has its downsides too
yes, i see, thanks
do i need to bother with unique name for publicFunction? I guess no, since it's under This. right?
no need
as long as its unique in that table, you're in the clear
I haven't tried, but I can only assume circular requires are bad news
thought so
i think i tried it once, and it just refused to participate in my nonsense

Yeah, the strong format is what is do for money -- works great
I do math to truncate, which has worked fine so far, lol
hm, can I power my pc with require loop?
if I add recipes to playerRecipes and it's already there, is it fine or do i need to check if it's already known?
to player:getKnownRecipes() that is
Heheheh.. I'd use something like math.floor(3.1415 * 100) / 100 for basic rounding.
That's just me.
floating point precision has those things sometimes do what fenris said
floats be floating.
they do be floatin tho
trust the plan
Coding while my fingertips break off from the artic blast here in the US.
yes, its very cold here in [Redacted] as well. Also the heater is broke in the office, so there is half a dozen space heaters in here trying to save our lives. Its barely working
any reasonable way to add code into some kinda of block so you can minimize it? 😄
if true then end 
emmylua lets you set regions and stuff, if you use intellij
vscode for now, but want to switch soon
also there is a do .. end notation, but keep in mind that anything in the do block has its own local space

I don't know if vscode recognizes that or not, I've only ever used it for starbase's LOL code
vsc recognised it
this is just called a function

in terms of allowing you to collapse it?

does Lua allow nested functions? i forget
that's a good solution if you don't like passing
you mean just calling another function within a function?
oh ya, for sure, lua functions are first-class values, you can do whatever you like
Just come to the dark side and code mods in Typescript. 
Nested functions are most useful for when I write I/O code.
That or recursive solutions.
doesn't the typescript just have to get recompiled into lua at the end?
There's a few UI elements coded in the nested style - I kind of hate it lol
Idk if its just me I like everything with a line or two in-between
yeah i don't like the nested functions, i guess there's technically some advantage to it but i wouldn't even think to use them
Yes, however the Lua code generated from TSTL is far better when handling strongly-typed code.
It also scales quite well. 🙂
ya, still not clear on what you mean by "scales" in this context, lol
It's more about the design and removing human-error in the process.. Like using interfaces and abstract classes. Types also translates well to Lua so I can create data types that will all be consistent throughout the code.
something like this will work, right?
player:getModData().KillCount = player:getModData().KillCount or {};
player:getModData().KillCount.WeaponCategory = player:getModData().KillCount.WeaponCategory or {};
local killCountModData = player:getModData().KillCount.WeaponCategory;
if killCountModData["Spear"] ~= nil then
categoryKills = killCountModData["Spear"].count or 0;
end
sure
cheers
the only thing I'd change is the ~=nil, cuz its not necessary. Doesn't hurt to have it though
👍 will leave for readability purposes
Can anyone make a mod that simply convert specifically any gold jewelry to money?
Ill commission
every programming language works this way, btw
(not into lua specifically of course, but there's always an underlying layer until you get to ASM/binary)
sure sure, but not in a way you have to be exposed to. Lua is compiled JIT so for the programmer (us) its the final step. Imagine if the typescript tool stops being supported and now you have this heap of code you may not even be able to read that you have to make work again. Its a definite pitfall
lua isn't compiled JIT unless you're using LuaJIT, it's typically an interpreted language (with an interpreter)
in Zomboid's case it uses Kahlua, an ancient Lua emulator that actually creates a virtual machine with the underlying Java having exposure points that allow data access
so it's not really the "final step" any more than Java is the "final step" - it's just another layer of abstraction. all it comes down to is ease of access and usability, which is what a Typescript layer attempts to provide as well
doesn't really address my point
TS in particular is already a language designed upon Javascript and compiles directly to JS to function, Mango is just going to throw Lua into the mix as the target, since that's what Zomboid most easily allows access through modding
what's your point then? that Mango might stop updating the TS layer, so TS-based mods might stop working?
lua is actually interpreted
GitHub actions. =3
but there is a jit compiler too
i half read that my bad
Someone amazing set up an automatic updater for typings.
yes, support for TS could end at any moment. There is already a strong push to stop using other mods as a dependency, now imagine every line of your code relies on another project to function. Its something people should consider, its not a small thing
it still outputs lua code you can edit yourself if needed
exactly lol
that's a skill issue
ya ok, now you're just being rude. Thanks anyway

I'm not being rude, I'm serious
people already don't update their mods to new versions of the game as it is, there's several hundred outdated mods on workshop
I mean sure you could think like that however... I mean the damn thing works automatically without me needing to touch it since it simply hooks into the game's code without touching it and then spits out typings.
if there's a demand for it to work, someone will update it - even if that someone eventually isn't Mango
i really wouldnt support moving away from depending on other mods
issues with it currently are just the 1284981727981 uploads of the same mod with the same id and people having several installed
I wouldn't let a project like PipeWrench die. I was gone for nearly 100 days and it updated gracefully for 8 versions of the game.
having reusable shared code is major plus
its not really a plus for the reason you just mentioned. Its actually really hard for end users to figure out which version of some of these mods they're going to need
if anything the solution would be enforcing either unique ids on the workshop which does already exist with the workshopid but then rip non steam mods or on the mod loader simply prevent loading duplicate ids
or a thing called libstub
used on several other games
I love how no one in here mentions trying to make a form of version control as a solution to help in situations where mods are updated or don't.
A version-control feature for mods would fix so much of this.
I literally built one for a server last week so they can have both version control and security options for their exclusive mods.
not really there already is the min version on the mod.info
wait no
i get it now
mod version
Yeah. What if I define a file in the lua cache dir for the mod and the server decides which version to use? The mod could take that info and then load certain files and ignore / suppress the others.
still think libstub would be better
It's annoying to implement it yourself however version control would help a lot when it comes to things like dependencies.
would allow for several versions of the same mod to coexist
mods depending on it ask libstub for the version they were made with in mind
Could make something like package.json but for loading mods.
Great.. now that's another thing I'll need to add onto my list of things to make.
xD
you dont have to
I like to think you could do something like:
dependencies: {
"this_mod_id": "2.0.4^"
}
Oh that's a neat utility.
I'm not a Lua expert.
id change it a bit tho
it only keeps the most recent version
id have it store all major versions
though this library is commonly used when bundling libs with your mods is the norm
A creative solution opportunity for PZ modding.
Just as a goofy thing I found recently- because item tags are fully customizable, you can use them to store information for code. But, with something like
‘string.split(line, "-“)’
You could set up a defining variable, and additional modifiers, all in the item block.
So- in theory you could like have a food item you want to add a specific value to the mod data of the player and cause an effect with a certain strength. So, you could set some item tags like-
‘Tags = md-5, effect-10’
And then when you split the string it would tell you the variable to modify/function to trigger, and provide an input for how it works lol
Mods have the capability to version lock in their modID but not many people use it
It’s goofy, but I thought it was an interesting concept
At one point I set the version min to the newest branch cause people refused to update but still wanted my mod
And there was a new feature added in the backend so at first I actually had it check game version in order to implement it
Big headache before just locking the min
That's a good concept tbh - would make more sense to use tags than keep adding more variables like "hasMetal"
I wouldn't use - though
I wish version control was built into the folder-tree for PZ.




