#mod_development

1 messages · Page 66 of 1

bronze yoke
#

you can add vanilla lua as a library to reduce the errors, and the emmylua java documentation tool partially works with vsc to reduce them further

dull moss
#

Again, by clicking on that lightbulb

#

Or do that

#

My way is less effort, Albion way is more thorough

bronze yoke
#

my way gives you a bit of autocomplete, but to be honest it's more like a spellchecker than an actual helpful resource

quasi geode
#

thats pretty outdated. probably still works though

winter thunder
#

oh hello there

#

👋

bronze yoke
#

i think glytch3r still uses it, so it must work

winter thunder
#

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

sturdy salmon
#

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.

winter thunder
quasi geode
#

would have replaced the OnTick event in the previous post, but theres a OnEveryMinute event now which makes that snippit pointless

winter thunder
#

oh- Shit! Thanks haha, that helps <3

astral dune
#

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

ancient grail
#

@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

ruby urchin
bronze yoke
#

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

ancient grail
#

Yeah figured it a bit late

#

Took me a day to work it out
Even if i had all the codes lined up lol

dapper geode
#

Hey, just wondering, is it fine to create another folder inside lua/client or server, e.g. "lua/server/ModPatch"?

bronze yoke
#

yeah

dapper geode
#

trying to make my mod to be more organized ._.

bronze yoke
#

i actually would strongly encourage doing this if your mod has more than one file, otherwise you're just inviting conflicts

dapper geode
#

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.

astral dune
#

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

astral dune
#

just figured out that my collision detection doesn't work if one vehicle completely engulfs the other, but what are the odds of that? 😂

winter thunder
astral dune
#

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

winter thunder
#

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…

ruby urchin
#

SNIPPET: get all IsoMovingObject on player's instance

print(getCell():getObjectList()) -- Returns ArrayList<IsoMovingObject>
bronze yoke
#

having unique effects to specific things is always going to be cumbersome, that's sort of the nature of making things unique

thick karma
#

@winter thunder I'll hyu in DM

bronze yoke
#

you could have your relevant functions check for a drug-specific function and run that, sort of like vanilla's item script function parameters

bronze yoke
#

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

weak sierra
#

i miss it so much

bronze yoke
#

'JOE I NEED HELP' cracks me up every time

weak sierra
#

why is literally everyone making a drug mod right now

#

i know like 5 people, and i had started one too

#

that's wild

thick karma
#

lmao

astral dune
#

Dunno, must be demand. I don't really know what I'd do with a mod like that

bronze yoke
#

i have to admit i have never once thought 'damn this game needs drugs'

thick karma
#

Bahahaha @bronze yoke I think this constantly

#

Like even when I'm working and stuff

#

🤪

weak sierra
#

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

drifting stump
#

Same thing kinda happened back when i was doing the shop mod

bronze yoke
#

oh yeah there's a lot of those

thick karma
#

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

drifting stump
#

Well good effects arent really doable without shaders

weak sierra
#

there's some hallucination effects in the schizophrenia trait mod

thick karma
#

That's fair

#

I'm not trying to be all cynical

weak sierra
#

fake zeds and such

#

you can ABSOLUTELY do effects w/o shaders

thick karma
#

ARE there good effects in this game?

weak sierra
#

cuz u can draw on the screen raw

thick karma
#

I mean good in the context of this game.

bronze yoke
#

i was thinking the same thing, shaders would be a lot more fun

weak sierra
#

not sure if we can screw with shaders or not here

drifting stump
#

Sure can render images to make an animation but packing that many into a mod?

thick karma
weak sierra
#

the pipewrench tutorial, oddly enough, shows how to do that

thick karma
#

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

weak sierra
#

can procedurally move pixels in a 2d array and draw every frame or every few frames

thick karma
#

Etc

weak sierra
#

to create shader-like overlays

#

render partially transparent

thick karma
#

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.

weak sierra
#

you could make a hallucination that just shows random nonsense phrases on the screen at random

#

:P

thick karma
#

Absolutely

weak sierra
#

maybe on the upper end it could show them so much you can't really see well

thick karma
#

Auditory hallucinations could be funny

weak sierra
#

whereas on the edge it'd just be like a word here or there

#

yeah

thick karma
#

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

weak sierra
#

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

thick karma
#

haha yeah those would be fun

weak sierra
#

i recommend poking at the schizophrenia mod it has client-only fake zeds

thick karma
#

I might check that out that's pretty lit.

weak sierra
#

supposedly doesnt work as well in mp but does work

thick karma
#

Mmmm interesting I'll see what I can learn lookin at the code.

bronze yoke
#

i can't remember the specifics but they specified that you can't actually do it right now

weak sierra
#

aw

#

:/

bronze yoke
#

i do know of a lua mod that has a custom shader though, not sure how that works

viral karma
bronze yoke
#

core isn't exposed iirc

#

wait no of course it is lol

weak sierra
#

if anyone pokes at this and gets it working lmk

#

would be interesting tool to have in the toolbox

bronze yoke
#

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

weak sierra
#

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

bronze yoke
#

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

regal willow
#

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.

faint jewel
#

local obj = objects:get(index) how would i use this to detect if i found a vehicle?

finite radish
faint jewel
#

isVehicle would be awesome but does not exist.

bronze yoke
finite radish
bronze yoke
#

it was the blind trait

finite radish
#

(unless it was a java mod, which is another beast entirely)

faint jewel
#

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
bronze yoke
#

i assume the game loads anything in that folder

finite radish
bronze yoke
#

you have to restart the game after enabling the mod as it doesn't reload them with kua reload

faint jewel
#
            for index = 0, objects:size() - 1 do
              local obj = objects:get(index)
                return instanceof(obj, "BaseVehicle")
            end```
finite radish
#

you could even inline the obj definition if you want to make it even cleaner, up to you though

finite radish
#

you could load java classes in theory, as well as like... DLLs. not good

bronze yoke
#

well it's going to struggle to load java classes as a shader

bronze yoke
faint jewel
#

what do YOU think i think it does?

bronze yoke
#

it'll return whether the first object is a vehicle because you return no matter what

finite radish
#

that's what he's trying to do though, from the looks of it?

bronze yoke
#

if you're looping through the list you only want to return false if you didn't find one

finite radish
#

oh yeah I ignored the loop there

faint jewel
#
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
finite radish
#

i forgot that lua doesn't have continue PepeHand

#

does it have break? it's been a while

#

although nvm you wouldn't want to in that case

bronze yoke
#
for index=0, objects:size()-1
    local obj = objects:get(index)
    if instanceof(obj, "BaseVehicle") then return true end
end
return false
finite radish
#

ye that'd be good

bronze yoke
#

forgot the obj definition in there but that's not important to what i'm trying to show

#

writing this on mobile 💀

finite radish
#

does zomboid's flavor of lua support goto? i haven't looked into whatever implementation they're using via Kahlua or whatever

bronze yoke
#

i think burryaga was using that

faint jewel
#
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
finite radish
bronze yoke
#

you might want the return false further down, otherwise it'll only check one square

#

after the for xx loop ends

faint jewel
#

was there an update or something? code that USED to work, is now just loosing it's damned mind.

finite radish
#

most recent update was on the 12th

#

just hotfixes, but still

faint jewel
#

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.

finite radish
faint jewel
#

trailer is nil.

finite radish
#

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

faint jewel
#

OH FFS

finite radish
#

👍

faint jewel
#

it's spawnsquare that is nil.

finite radish
#

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

faint jewel
#
        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.

bronze yoke
#

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

faint jewel
#

it's christmas. I thought trees were acceptable.

wet sandal
#

You could probably replace that with some math instead.

local y = trailer:getAngleY()
y = math.round(y / 45) * 45
trailer:setAngles(180, y, 180)
faint jewel
#

(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!

ancient grail
#

Did you check ifor collide

#

Wrong term
Intersect is what i meny

#

Ment

faint jewel
#

that don't work anymore.

#

it's all busted

ancient grail
#

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

faint jewel
#

it could despawn someone elses car.

ancient grail
#

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?

agile vigil
ancient grail
#

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

agile vigil
#

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)

ancient grail
#

ow shit

ruby urchin
#

anyone know some way to get a ArrayList elem by value?

ancient grail
#

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

agile vigil
#

🤞

ancient grail
#

let me look for the snippets

#

u want to dertemine the key using the value correct?

ruby urchin
#

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

ancient grail
#

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?

ruby urchin
#

just avoid using a loop for ... do

ancient grail
#

@agile vigil

#

same shiz

agile vigil
#

Hm..

agile vigil
#
local mapAccess = {};
mapAccess[key] = value;

local thatThingINeed = mapAccess[requiredKey];

Do the mapAccess[key] = value; thing in your existing for loop to populate your table.

ruby urchin
#

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

ancient grail
#

ahh figured it out

#

i used wrong directory lol

agile vigil
#

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.

ruby urchin
#

yeah, that's right, but also I have that on a OnTick lol, so... unhappy

#

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
agile vigil
#

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?

ruby urchin
#

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
agile vigil
#

Do you control when objects are added/removed in the IsoMovingObjectList?

ruby urchin
agile vigil
#

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. scratch

ruby urchin
#

I like it, I will try that, thx man

agile vigil
#

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 😄

ruby urchin
#

lol

#

dont worry, I like that

ancient grail
#

damn it this is taking me a long time to setup

agile vigil
#

When you selected the Java version, you made sure it was on 17 and not 19 right, @ancient grail

ancient grail
#

it already did everything

#

but only decompiled the zomboid not the docs

agile vigil
#

I'm sorry I can't help more, then. I can't think of what's going wrong here.

ancient grail
#

instead of like that

#

only got his

#

is it possible if someone send it

#

?

dull moss
#

does character boredom level gets reset to 0 when they see zombie closeby?

#

cuz from testing it looks like it's the case

ancient grail
#

but i bet you know that

dull moss
#

actually idk how to open debugger without throwing error KekW

ancient grail
#

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

ancient grail
dull moss
#

i dont

ancient grail
#

are you testing with bunch of mods loaded?

dull moss
#

cheers

sour island
dull moss
#

or whatever setting would be called

faint jewel
#

anyone know why a trailer spawned with addvehicledebug, wont work as a trailer AND has no collision?

agile vigil
#

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.

sour island
#

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 👍

agile vigil
#

Time to find out 😄

waxen bay
waxen bay
#

cool thx

odd sable
#

where can i found modding docs ?

fast galleon
#

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

sour island
#

I think the entry box only works if it's in focus

#

I've used it to grab it's contents before though

thick karma
#

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

jagged ingot
#

Thanks for using this mod & Java patch. Did you figure out what you needed?

bronze yoke
agile vigil
bronze yoke
#

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

agile vigil
#

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

bronze yoke
#

i've been using this for a few months with no sign of problems

agile vigil
#

Could you describe what a "Bullet" is and why vehicle scripts have a toBullet() function, perhaps? It's a weird terminology.

bronze yoke
#

bullet is the physics engine zomboid uses

jagged ingot
#

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.

tough stag
jagged ingot
agile vigil
tough stag
jagged ingot
manic relic
#

anyone know if the bandana mask or what you call it is to big

tough stag
jagged ingot
#

Was before official support.

sour island
faint jewel
#

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??

jagged ingot
#

The player is already provided when firing this API call.

sour island
#

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

long ore
#

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

vast nacelle
#

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?

thick karma
agile vigil
#

I think I am missing something.

ancient grail
#

Jk

agile vigil
#

Funny thing is, it looks perfectly fine, until I enter aim mode for the first time in the session 😄

#

And randomly turns back.

#

scratch 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?

agile vigil
#

Ah, that is determined deep in Java code. Unfortunate.

drifting ore
#

Where is the clothing degradation defined - to what file .cfg refers to?

finite radish
# agile vigil Question is, how is rust level set on newly spawned wrecks?

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

balmy pike
#

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????

fast galleon
#

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

agile vigil
#

Fixed my texture errors googlemuscleL

balmy pike
#

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?

chrome rover
#

What is the bug?

abstract raptor
#

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

thick karma
#

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.

pine fiber
#

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?

astral dune
#

mostly generated garbage

fast galleon
#

@abstract raptor
I have never used this but I know core has things like isChallenge(), getChallengeID(), getGameMode(),

astral dune
#

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

tough stag
#

is there any workaround of <RGB> eating the spaces?

fast galleon
tough stag
fast galleon
#

if you notice, vanilla always has spaces together with the tags so it would be " RGB:1,1,1 "

vast nacelle
#

What about a .. " " .. after argb as well?

astral dune
#

msg = string.format("%s %s %s %s", argb, aname, msgrgb,msg)

#

give that a go

tough stag
astral dune
#

you could try adding extra spaces, maybe it only consumes one

tough stag
#

I hope this is enough msg = argb .. " " .. aname .. " " .. msgrgb .. " " .. msg lol

tough stag
astral dune
#

I'd probably just be lazy and use a - instead in between, like msg = string.format("%s %s %s-%s", argb, aname, msgrgb,msg)

tough stag
tough stag
astral dune
#

why, doesn't the dash or maybe a colon work? I doubt you want it to start a new line

drifting stump
#

use a special space character

#

a whitespace character with a different unicode to normal space

tough stag
astral dune
#

lua doesn't handle parsing unicode very well, but maybe just using some would be ok

tough stag
drifting stump
#
#

copy that

fast galleon
#

just out of curiousity, can you post the RGB.

drifting stump
#

dont know if discord replaces the character with normal space

#

if it does look it up yourself

tough stag
tough stag
#

<RGB:1,0,1> nanana <RGB:1,1,1> "Hello, this is a test"

fast galleon
tough stag
tough stag
drifting stump
#

yeah was discord

#

ive helped someone fix this before

#

game eats normal spaces you really have to do use a special whitespace

drifting ore
#

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?

zealous juniper
#

anyone know why scrap armor/weapons/guns mod doesnt work when i host a mp server

tough stag
zealous juniper
#

thanks

jagged ingot
#

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.

dull moss
#

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?

bronze yoke
#

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

dull moss
#

ok

#

but if there are 2 players

#

who does it grab? KekW

bronze yoke
#

none

#

or i mean

#

getPlayer() always returns player 0 on the client, and null on the server

dull moss
#

oh right im fucking pepeg

#

shit is ran client side

bronze yoke
#

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
dull moss
#

nah dont care about supporting splitscreen or whatever

#

ty

bronze yoke
#

all four splitscreen users are very disappointed to hear that

dull moss
jagged ingot
#

I thought that 6 years ago. xD

drifting ore
#

Weeeelll, it seems the erosion mechanic is kind of broken 😦

rustic grove
#

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?

dull moss
#

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?

bronze yoke
#

you'd need to do it OnCreatePlayer since there are no player objects that early

sour island
#

you can make a single function to 'get' a specific sub-table

#

in other words - put those 3 lines in a function

dull moss
#

ye but I want to run it only once

#

hm

sour island
#

onCreatePlayer would work as Albion says

dull moss
#

does oncreate player triggers on literal player creation or every time player loads into world too?

bronze yoke
#

every time player loads into the world

dull moss
#

nice

#

ty

#

Also successfully managed to catch % that player repairs vehicle part for HYPERS

sour island
#

Nice overwriting 👍

dull moss
#

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

sour island
#

perform clears some variables - like removes the action from queue

#

maybe there's something getting lost

dull moss
#

heh

sour island
#

if it works, I'd leave it

dull moss
#

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?

bronze yoke
#

local functions and variables run faster

dull moss
#

time to chanage every single thing to local hyperloaf

#

question though

#

local functions are limited to scope of lua file they are in?

#

Or mod?

bronze yoke
#

the lua file

dull moss
#

I see

bronze yoke
#

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'
dull moss
#

cool

sour island
#

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

dull moss
#

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?

sour island
#

yes

#

Events is global technically

#

If you're using events you almost always have no reason to make added functions global

dull moss
#

i see

#

man it's fun getting deeper and deeper into pz modding wowpepe

#

if i pass argument into local function, is it treated as local? aka faster

bronze yoke
#

arguments are always local

dull moss
#

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 pepega 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?

bronze yoke
#

yeah, no point

sour island
#

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

dull moss
#

NotLikeDis now everyone knows im dumdum

sour island
#

nah it's fine

#

also if you're using intelliJ + pzlibraries + emmylua you can define types for locals

dull moss
#

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?

bronze yoke
#

yeah

sour island
#

you can change player:getbodydamage() to bodydamage

dull moss
#

ye i call that part twice

#

microoptimizing galaxybrain

sour island
#

in the 2nd example

bronze yoke
#

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

sour island
#

you dont have it defined but refer to it

dull moss
#

ye my bad

#

fixed

sour island
#

you can ditch the unhappiness

#

I think you got it

dull moss
#

ye got the gist

#

cheers

bronze yoke
#

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

dull moss
#

ye

#

I can do something like this, right?

local modData = player:getModData();
modData.DynamicTraitsWorld = modData.DynamicTraitsWorld or {};

into

local modData = player:getModData().DynamicTraitsWorld or {};
bronze yoke
#

yeah

dull moss
#

coolio

#

its' getting prettier and prettier

#

I assume this is also fine?
local SBvars = SandboxVars.DynamicTraitsWorld;

sour island
#

yes

dull moss
#

so i can use all my settings without extra typing

#

nicela

astral dune
#

just make sure to only do that when you're sure you're going to get something back

dull moss
#

you mean sbvars?

astral dune
#

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

dull moss
#

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

sour island
#

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'

dull moss
#

classic

bronze yoke
#

oh, actually

sour island
#

you shouldn't do local modData = player:getModData().DynamicTraitsWorld or {};

bronze yoke
#

yeah chuck's onto it

dull moss
#

explain

bronze yoke
#

you're going 'the table at that location, or an empty table with no link to moddata'

sour island
#
player:getModData().DynamicTraitsWorld = player:getModData().DynamicTraitsWorld or {};
local modData = player:getModData().DynamicTraitsWorld
dull moss
#

ah I see

#

cheers

sour island
#

works

dull moss
sour island
#

new sandbox option for shops and traders - disable player wallets

#

you'll have to carry that cash

dull moss
#

where's that skyrim mod that adds weight to coins KekW

sour island
#

that's there

bronze yoke
#

oh that's such a smart way to handle money...

sour island
#

It's all Base.Money

astral dune
#

lol, reminds me of that meme picture of having to enter your phone number with a slider

bronze yoke
#

the money system i interact with sort of has this with wallets, but they've been a big pain

thick karma
sour island
#

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

bronze yoke
#

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

sour island
#

and items should have a 'very tiny' 'tiny' 'small' tag for size

sour island
#

while still staying within the design choices of TIS

bronze yoke
#

yeah, i'm maintaining a system written by someone before me, i don't think i would have done it this way

dull moss
#

Chuck bigbrain

sour island
#

I also forcibly overwrote item stacking for books with namedliterature cause I couldn't leave it like it was lol

bronze yoke
#

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

sour island
#

I was going to do the same for money in this mod but I didn't want more mod compat issues

sour island
#

it's how I'd want my experience to be

#

and unless its a commission I don't stray that far

sour island
#

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 unhappy

bronze yoke
#

i was commissioned to update the shop mod we currently use, it'd be a bad look for me if we switched mods 😅

sour island
#

Ah

#

well feel free to borrow the money behavior if you want

bronze yoke
#

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

sour island
#

alright lol

#

what do you mean by rewriting currency?

#

to act with change?

#

that sounds like too much 'realism' vs 'grounded'

bronze yoke
#

i have no idea, i genuinely don't know why they're rewriting it LOL

sour island
#

Like will you have 2 quarters and not be able to give someone 30 cents?

bronze yoke
#

i have no idea what the new system will be or if/how it will be better

sour island
#

🤷‍♂️

#

what was the base mod you updated?

bronze yoke
#

the mods i've been mentioning here are browser8's shop mod and aiteron's projectrp

astral dune
#

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

sour island
#

good question

#

any overloads for pixel offset?

#

maybe one for the texture?

dull moss
#

gone are the days of manual editing

sour island
#

are AI stealing our jobs?

dull moss
astral dune
#

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

bronze yoke
#

isoToScreenX() and isoToScreenY() seem relevant

astral dune
#

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);
bronze yoke
#

LOOL

astral dune
#

yes, those isoToScreen functions look really handy, maybe I should spend some time looking through this IsoUtils class

dull moss
#

what's the best way to go around making sandbox presets, if possible?

#

for mod sandbox settings that is

#

if it's even possbile PepeThink

bronze yoke
#

it's not

dull moss
#

sadge

bronze yoke
#

i was writing something like that but it was annoying and i don't really have the time anymore

dull moss
drifting ore
#

How to I make my saved preset settings available in a mod? Seems the usual way/folder path is not working

ruby urchin
#

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
drifting stump
bronze yoke
#

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

drifting stump
#

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

sour island
#

I don't see your shop mod on the workshop

drifting stump
#

Dont remember if i left it hidden

#

Since that version was really only meant as a test

sour island
#

I got asked to write one cause 1 was too old and the other was too strict

drifting stump
#

Specifically for the system to convert any container in the game into a shop

sour island
#

ah, if you know of any features I could add to mine, lmk

#

a buy/sell log seems like a good idea

drifting stump
#

There was also meant to be a room wide shop setting

bronze yoke
#

ooohh so that's what that was about

sour island
#

ah, like an old school MUD?

drifting stump
#

Where opening the ui would show stuff from all shops in the room

sour island
#

oh

drifting stump
#

Skizot also pitched the idea of map markers to show where shops exist

faint jewel
#

😄

#
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.

wicked cobalt
#

bro why is it when i setup my mods it just says fucking initializing

sour island
faint jewel
#

yup

sour island
#

Is transmit completed item to server a vanilla thing?

faint jewel
#

tis

wicked cobalt
#

anyone know a fix to setup mods it just stays on initializing forever i have everything i need for each mod to work

sour island
#

Check your log

#

Your mods might be stuck on pending download

wicked cobalt
#

how do i check log

sour island
#

user/name/Zomboid/console.txt

astral dune
#

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

wicked cobalt
#

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 😂

sour island
#

Your hard drive/user/NAME/Zomboid

#

Name being what your profile is

wicked cobalt
#

ahhhh

#

do i look for that like while i’m loading in

sour island
#

The file is console.txt

wicked cobalt
#

or just abort and look for the log

sour island
#

It resets each time you boot up the game

#

So it has to be opened after you get stuck

wicked cobalt
#

okay

sour island
#

Like vertically

wicked cobalt
#

so uhh

astral dune
#

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?

faint jewel
#

not logs

#

console.txt

#

one folder up

sour island
wicked cobalt
#

this shit is huge how tf do i know what i’m looking for

sour island
#

But something seems off - like it's mirrored

sour island
astral dune
#

if NW is 0,0, what would be south of it in game? 0,1?

wicked cobalt
#

cannot find “pending”

sour island
#

It sounds like your mods are triggering download checks and can't resolve it

#

Then post the log to pastebin and link it

wicked cobalt
#

the log is fucking huge i’m not doing that

#

literal novel

sour island
#

No wait 0,1 is south

#

I hate isometric lol

faint jewel
#

bottom left is south

astral dune
#

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

faint jewel
#

top right is north

sour island
astral dune
#

collision code is correct in the orientation, but the snapshot seems to be slightly earlier than the point of collision

sour island
#

The shadows are the collision boxes right?

astral dune
#

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

sour island
#

Oop issue?

#

Tick behind and all that

astral dune
#

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

sour island
#

Don't suppose you can find where they add the vector3 and just add it

astral dune
#

hmm, there is a lastLinearVelocity and jniLinearVelocity that the crash code compares

sour island
#

Good luck and good night

astral dune
#

my code fires at approx line 3058 in BaseVehicle, so I guess I'll look after that

#

night bud

sour island
#

👍

thick karma
#

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?

bronze yoke
#

what are you trying to do?

thick karma
#

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

bronze yoke
#

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()

thick karma
#

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?

bronze yoke
#

yeah

thick karma
#

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

bronze yoke
#

it shouldn't

thick karma
#

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

faint jewel
#

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.

rain iron
#

What is the code to set/get player speed? Looking to edit swing speed/walking speed via lua code

thick karma
#

@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

ancient grail
thick karma
#

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

bronze yoke
#

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

thick karma
#

😭

rain iron
#

What I wanted to do is to make a weapon similar to TF2 Eyelander where you heal + move faster the more you kill

wet sandal
#

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

finite rover
#

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?

wet sandal
#

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.

bronze yoke
#

you should check what the java is actually doing - it's not unlikely that you can just reimplement whatever that method calls

wet sandal
#

How do you check what the java is doing?

finite rover
#

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(

fast galleon
finite rover
agile vigil
#

I assume the chopTreeAction does WeaponHit after setting health to 1? That way only one swing will kill it, I imagine.

wet sandal
#

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

finite rover
fast galleon
#

yep, only thing in weapon hit is remove from square and some cache updates.

agile vigil
faint jewel
finite rover
#

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.

agile vigil
#

God I love big trucks in Zomboid.

#

I hope you figure it out, Birget, a Christmas tree would be heavenly.

faint jewel
#

i'm working on a whole ass rpg trucking mod. lol

finite rover
thick karma
# sour island I think because you're only supposed to have one anyway -- the new() some some U...

@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.

fast galleon
#

ISChat probably has been edited more than once over the years

ancient grail
#

Yes there are abunch of mods

finite rover
pearl flame
ancient grail
#

Just the snippet of how you delete

finite rover
ancient grail
#
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

finite rover
ancient grail
# finite rover 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

finite rover
# ancient grail ```lua if instanceof(object, "IsoTree") then if isClient() then sled...

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

ancient grail
#

Just phase thru the tree

#

The. Paste that on debug

#

In seeing alot of "if"
Make sure u have enough "end"

ancient grail
#

🫡@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)

agile vigil
#

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 😦

sour island
#

If there isn't a getter for it, usually no

agile vigil
#

bo?

#

Oh, aw..

#

Seems so devious to have this field binding we can't touch.

sour island
#

You can get around some field/class stuff but last I recall it can only read not write outside of debug mode

agile vigil
#

I only need to read.

sour island
#

Let me see if I can find my old code

agile vigil
#

Thank you 🙂

sour island
#
--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

agile vigil
#

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.

sour island
#

Sounds interesting, what's the intended effect?

agile vigil
#

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.

sour island
#

Ah nice

agile vigil
#

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.

sour island
#

Sounds like a solid improvement

#

The wrecks in-game always seemed off - I tend to use the "all wrecks are cars" type mods

agile vigil
#

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)

sour island
#

Credit to whoever showed me that in the first place -- and Tyrir who later clarified some stuff about it later.

agile vigil
#

Yeah that's some really useful stuff.

ancient grail
agile vigil
#

Now I really want to see industrial-sized logging equipment, specifically for making offroad paths that are shorter.

faint jewel
#

they exist.

#

there's a bulldozer that does that.

#

and my lawn mower does that but to grass.

ancient grail
untold mesa
#

are there any mods that disable the damage you take from carrying too much?

sour island
stone garden
#

hello anyone want hear my mod idea

#

i thinked into something unique

dusk saddle
#

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

stone garden
dull moss
dusk saddle
stone garden
sour island
#

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

sour island
#

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

faint jewel
#

why muldraugh... WHY

sour island
#

lol, there's some strong functions for flooring to certain places

#

I had to do it for money

faint jewel
#
-- 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.

astral dune
#

stuff that is put in the table you return is accessible, stuff that is local is hidden

bronze yoke
#

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

dull moss
#

how do I require file that's in parent folder?

astral dune
#

lua recursively searches, should find it regardless

dull moss
#

k, will try, thanks

jagged ingot
#

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.

dull moss
#

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()

quasi geode
# faint jewel why wont muldraugh?

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

astral dune
dull moss
#

do i need to bother with unique name for publicFunction? I guess no, since it's under This. right?

bronze yoke
#

no need

astral dune
#

as long as its unique in that table, you're in the clear

dull moss
#

ye, got it, ty

#

KekW can I have 2 files require each other? KekW

astral dune
#

I haven't tried, but I can only assume circular requires are bad news

dull moss
#

KekW thought so

bronze yoke
#

i think i tried it once, and it just refused to participate in my nonsense

dull moss
sour island
#

Yeah, the strong format is what is do for money -- works great

astral dune
#

I do math to truncate, which has worked fine so far, lol

fast galleon
#

hm, can I power my pc with require loop?

dull moss
#

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

jagged ingot
#

Heheheh.. I'd use something like math.floor(3.1415 * 100) / 100 for basic rounding.

#

That's just me.

drifting stump
jagged ingot
#

floats be floating.

astral dune
#

they do be floatin tho

jagged ingot
#

Also flopping.

#

"floating point operations per second"

finite radish
#

just use fixed point, ez binary clap

#

real gamers use Q notation

astral dune
#

trust the plan

jagged ingot
#

Coding while my fingertips break off from the artic blast here in the US.

astral dune
#

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

dull moss
#

any reasonable way to add code into some kinda of block so you can minimize it? 😄

#

if true then end KekW

astral dune
#

emmylua lets you set regions and stuff, if you use intellij

dull moss
#

vscode for now, but want to switch soon

astral dune
#

also there is a do .. end notation, but keep in mind that anything in the do block has its own local space

dull moss
astral dune
#

I don't know if vscode recognizes that or not, I've only ever used it for starbase's LOL code

bronze yoke
#

vsc recognised it

finite radish
astral dune
dull moss
#

funne, now do the same where locals will work outside function scope

finite radish
#

just pass them

#

ez

dull moss
finite radish
#

does Lua allow nested functions? i forget

#

that's a good solution if you don't like passing

astral dune
#

you mean just calling another function within a function?

finite radish
#

not calling, but declaring/creating/whatever

#

(and then calling, I suppose)

astral dune
#

oh ya, for sure, lua functions are first-class values, you can do whatever you like

finite radish
#

that's what i figured

#

so yeah, ez solution right there

jagged ingot
#

Just come to the dark side and code mods in Typescript. drunk

#

Nested functions are most useful for when I write I/O code.

#

That or recursive solutions.

astral dune
#

doesn't the typescript just have to get recompiled into lua at the end?

sour island
#

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

bronze yoke
#

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

jagged ingot
#

It also scales quite well. 🙂

astral dune
#

ya, still not clear on what you mean by "scales" in this context, lol

jagged ingot
dull moss
#

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
astral dune
#

sure

dull moss
#

cheers

astral dune
#

the only thing I'd change is the ~=nil, cuz its not necessary. Doesn't hurt to have it though

dull moss
#

👍 will leave for readability purposes

dark finch
#

Can anyone make a mod that simply convert specifically any gold jewelry to money?

#

Ill commission

finite radish
#

(not into lua specifically of course, but there's always an underlying layer until you get to ASM/binary)

astral dune
#

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

finite radish
#

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

astral dune
#

doesn't really address my point

finite radish
#

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

finite radish
drifting stump
#

lua is actually interpreted

drifting stump
#

but there is a jit compiler too

finite radish
#

mentioned that above

drifting stump
#

i half read that my bad

jagged ingot
#

Someone amazing set up an automatic updater for typings.

astral dune
#

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

drifting stump
finite radish
#

exactly lol

astral dune
#

ya ok, now you're just being rude. Thanks anyway

finite radish
#

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

jagged ingot
finite radish
#

if there's a demand for it to work, someone will update it - even if that someone eventually isn't Mango

drifting stump
#

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

jagged ingot
#

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.

drifting stump
#

having reusable shared code is major plus

astral dune
#

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

drifting stump
#

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

jagged ingot
#

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.

drifting stump
#

not really there already is the min version on the mod.info

#

wait no

#

i get it now

#

mod version

jagged ingot
#

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.

drifting stump
#

still think libstub would be better

jagged ingot
#

It's annoying to implement it yourself however version control would help a lot when it comes to things like dependencies.

drifting stump
#

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

jagged ingot
#

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

drifting stump
#

you dont have to

jagged ingot
#

I like to think you could do something like:

dependencies: {
  "this_mod_id": "2.0.4^"
}
drifting stump
jagged ingot
#

Oh that's a neat utility.

drifting stump
#

surprized you didnt know it

#

used in so many games with lua

jagged ingot
#

I'm not a Lua expert.

drifting stump
#

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

jagged ingot
#

A creative solution opportunity for PZ modding.

winter thunder
#

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

sour island
#

Mods have the capability to version lock in their modID but not many people use it

winter thunder
#

It’s goofy, but I thought it was an interesting concept

sour island
#

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

sour island
#

I wouldn't use - though

jagged ingot
#

I wish version control was built into the folder-tree for PZ.