#mod_development

1 messages ยท Page 327 of 1

tired glen
#

I still put f on the end and it makes lua angy

bronze yoke
#

i'm just saying there's absolutely no difference whatsoever

bronze yoke
#

it still does nothing though

tired glen
#

interesting

#

Didnโ€™t figure it did

silent zealot
#

It won't actually matter - using 1 or 1.0 will become a "number" in lua and then then it converts when passed to java

silent zealot
#

"Put any data in here, IDGAF but don't you DARE tell me what sort of number you're using!"

bronze yoke
#

if you like type annotations you can use```lua
---@type integer
local int = 5

---@type number
local float = 5.0
-- (or just do nothing for numbers because it's the default anyway + specifying it doesn't change anything)

#

the language server treats integers as a subtype since it's generally convenient to do so

last zodiac
#

Honestly typechecking in the future similar to Luau would be nice

bronze yoke
#

yeah, i was talking about that just a couple messages ago ๐Ÿ˜… the language server treats them as separate types in any version because it is convenient

last zodiac
#
local mynum: number = 1000;
bronze yoke
#

there's no runtime difference but 'this function only takes integers'/'this table's keys should only be integers' etc are such common concepts and so easily checked that the language server might as well, especially if it supports the integer type for later versions anyway

last zodiac
#

what would be nice is straying away from kahlua in the future

#

maybe it can be an experiment in the future, trying out something else like jua (luajit4java) or some other alternative

bronze yoke
#

it doesn't really seem like TIS are interested in something like that but i think nearly everyone would appreciate it

bronze yoke
#

most of all kahlua just runs like shit LOL

last zodiac
#

i haven't really looked much into how Kahlua works

bronze yoke
#

by far the slowest lua implementation i've seen

last zodiac
tranquil reef
#

Anyone know where the code is for the temperature health gui

#

I'd like to replicate the UI a bit, if it's exposed

bright fog
#

Let me see if I can find it back

#

You could reverse engineer their mod to easily have a working example of modding it in

#

If that's the temperature GUI you meant

jolly grove
#

Hmm, does anybody know where the code for weapon sharpness is located? I'm interested in how dull a blade can become before it starts to affect damage and increases condition loss and by how much.

bright fog
silent zealot
#

InventoryItem.java

#

Max damage drops as soon as the wepaon isn't perfectly sharp, but will never drop below mindamage (This is why the katana with 8 min damage/8 max damage never needs sharpening.)

jolly grove
bright fog
#

So it's linear

#

I think a non-linear decrease would probably be better ...

#

Something like this sounds more fair

#

Tho at the same time it's not it's setting the damage to zero anyway, so it's not as hard as getting tired

jolly grove
#

I really dislike the sharpness mechanic. It's a brutal straight up nerf to all bladed weapons and it's especially devastating for short blade.

#

Think i'm just gonna add a set of combat knives that can be crafted or found that don't have sharpness and are slightly more durable to counter the fact, that weapons can no longer be repaired like in 41.

agile nacelle
#

@bright fog IsoGridSquare:getObjects() doesn't include walls, i can't figure out how to get all the walls other than north and west(?) wall using IsoGridSquare:getWall(), by any chance do you know how i can get the walls of every direction?

bronze yoke
#

those are the only walls on that square

#

the wall to the east belongs to the square to the east

#

same with south walls

agile nacelle
#

huh

#

so like... each tile has 2 walls?

bronze yoke
#

yeah

agile nacelle
#

i see

#

thanks

bronze yoke
#

the walls look like they're in-between squares, but really they're on the same grid as everything else

bright fog
grizzled fulcrum
solar lichen
#

Hello! I need help, I made a fashion for clothes and a recipe for crafting them out of money. Everything works fine in build 41, and there are crafting recipes. (I named the files with build numbers to show the differences.)

However, in build 42, the crafting script does not work and the game simply crashes with the error of not being able to load the crafts. If you remove the "craftRecipe" functions and everything in them, then the game works fine, however, logically, there will be no recipe for crafting clothes, but the clothes themselves will exist in the game and can be found using the Debug menu.

I believe something is incorrectly written in the "craftRecipe" functions, but I can't figure out what's wrong. Please help me!spiffo

bronze yoke
#

in outputs you shouldn't enclose the item name in []s

bright fog
#

Yea, what albion said

grizzled fulcrum
bright fog
#

lol

grizzled fulcrum
#

next TIS is gonna add Bite Protection VII or something

bright fog
#

That's kind of a thing already ?

grizzled fulcrum
#

ik I meant like enchantments or something, it was a joke tho lol

bright fog
#

Yea ik lol

agile nacelle
#

why do coroutines loops yields the main game thread brah

#

i thought coroutines are supposed to be like... behave like a different thread

#

whatever

bright fog
#

@ancient grail I see you've only linked your workshop files and not the mod itself. Those are private mods ?

#

No it's not

#

Please, link the mod itself or I will remove those links myself !

#

I see Tcherno did the same

#

Yea I think we need to apply some policy to this so the workshop items themselves are linked

#

I'll clean up that page a bit I think

manic forum
#

How would you guys do a timed event for a object. Like i got a Workstation, and a GUI for it, how would you make sure that workstation works in the background
i feel like hooking the timed events like 1min and so on seems suboptimal. Or is there like a timeout ?

queen oasis
#

if you can't tell, I spent way too much time debugging why self.currentItems was nil when it got to PickupItems()
I'm gonna change that to self:PickupItems() and then go cry in a corner for a bit.

manic forum
bright fog
#
  • Start progress: note current timestamp
  • Every minutes, diff between current and start timestamps
  • If diff > time of action: finish task
manic forum
#

hmm i will try thanks

bright fog
#

Check GameTime for timestamps I think it's in ?

bronze yoke
agile nacelle
#

am used to Luau.....

bronze yoke
#

basically the entire coroutine library is just to have functions you can pause and resume lol

agile nacelle
#

lua parallel execution is fake

bronze yoke
#

i don't find it useful even for the marginal cases where writing in that style would be helpful since it has awful overhead anyway

steady fable
#

anyone know a workaround for overriding your own craftrecipe in build42? im trying to build a compatibility patch right now

#
module Base
{
    local script =
    "{ inputs { item 1200 [Base.BlowTorch] flags[Prop2],} }"


    local recipe = getScriptManager():getCraftRecipe("PackBoxOfWeldingTorches")
    recipe:getInputs():clear()
    recipe:Load("PackBoxOfWeldingTorches", script)
}```
#

what ive got so far

#

i copied it from an indie stone forum post and modified it to try and make it work for my mod, ended up just making every recipe in the mod not work!

tranquil reef
bright fog
steady fable
# bright fog First off I'm shocked there's up to date forum posts regarding modding stuff ๐Ÿ˜ญ ...

well let me get the recipe set for you:


craftRecipe OpenBoxOfWeldingTorches
    {
        timedAction = OpenAmmoBox,
        Time = 15,
        Tags = InHandCraft;CanBeDoneInDark,
        inputs
        {
            item 1 [Base.BoxOfWeldingTorches] flags[Prop2],
        }
        outputs
        {
            item 12 Base.BlowTorch,
        }
    }

    craftRecipe PackBoxOfWeldingTorches
    {
        timedAction = PlaceAmmoInBox,
        Time = 15,
        Tags = InHandCraft;CanBeDoneInDark,
        OnCreate = Recipe.OnCreate.ToConditionInheriter,
        inputs
        {
            item 120 [Base.BlowTorch] mode:destroy flags[Prop2],
        }
        outputs
        {
            item 1 Base.BoxOfWeldingTorches,
        }
    }
#

im trying to override item 120 [Base.BlowTorch] mode:destroy flags[Prop2], with item 1200 [Base.BlowTorch] mode:destroy flags[Prop2],

steady fable
bright fog
#

Uh

#

Ok so two wrong things

bright fog
#

I didn't notice the module Base

#

Oh god

steady fable
bright fog
#

Secondly you're overwriting the original script file

#

You shouldn't do that

steady fable
bright fog
#

or lua/shared at the very least

steady fable
#

remove module base?

bright fog
#

Yea, remove that completely haha

#

The original post you found was most likely without any of the module Base thing ;)

solar lichen
# solar lichen Hello! I need help, I made a fashion for clothes and a recipe for crafting them ...

Thanks for the help! And one last point

Do I understand correctly that the folders Contents\mods\Mode_Name\41 and Contents\mods\Mode_Name\42 will be read by the game separately in the 41st and 42nd versions of the build? How do I make the mod work on both 41 and 42 builds?

I fixed the error above, but I would like the mod to work on both versions 41 and 42. However, the scripts are slightly different
Folders **41 **and **42 **contain the same mod.info and posters.
The **common **folder contains the working version for 42 builds

steady fable
#

let me see if it works now!

bright fog
#

B41 doesn't use this

steady fable
#

oh and while im at it should i keep any other lua files

bright fog
#

Refer to the wiki page regarding the mod structure

steady fable
#

i effectively just copied the mod over earlier to make the patch

#

its like this now

bright fog
#

Completely delete every files that are not yours at all

steady fable
#

oh no the mod is mine

#

i copied my own mod over

bright fog
#

I'm hella confused then

#

You said you copied the mod

steady fable
#

i did a copy paste and renamed it in the same folder

bright fog
#

Ooooooh

#

A secondary mod

#

ok ok

steady fable
#

yeah thats what im doing

bright fog
#

Uuuh depends ?

#

Do you want both to be enabled together ?

steady fable
#

yes

bright fog
#

If so yes remove the files from that secondary mod

#

Only keep the patch in it

steady fable
#

alright i'll test it now

#

get back to this chat momentarily i appreciate the help

steady fable
#

pzwiki my beloved

bright fog
#

:3

steady fable
#

oh and while we're at it theres also an issue where any liquids i pack into it get a duplicate empty bottle?

steady fable
bright fog
#

Hmm

steady fable
#

i'll get the code to you momentarily

bright fog
#

It uses crafts right ?

steady fable
#

yes

#
craftRecipe PackBoxOfAlcoholBottles
    {
        timedAction = PlaceAmmoInBox,
        Time = 15,
        Tags = InHandCraft;CanBeDoneInDark,
        inputs
        {
            item 11 [Base.Disinfectant] mode:destroy flags[Prop2],
            item 1 [*],
            -fluid 0.5 [Alcohol],
        }
        outputs
        {
            item 1 Base.BoxOfAlcoholBottles,
        }
    }```
#

this is what we got right now for it

bright fog
#

So this takes 11 bottles of disinfectant and packs them in a box ?

steady fable
#

its supposed to take 12 bottles of disinfectant and put them in a box

bright fog
#

Why 11 ?

steady fable
#

fluid is buggy in crafting right now

#

and the modder i commissioned to help me do this did that

#

that modder is unreachable right now too which is why im here

bright fog
#

What happens to the fluid ? It just disappears right ?

steady fable
#

its supposed to yes

bright fog
#

So you could just remove that fluid part right ?

#

And just keep the 12 bottles getting consumed ?

steady fable
#

but im pretty sure theres a reason for that fluid part

bright fog
#

Tho one issue would be duplications, so not sure how you should handle fluids for box recipes like that, I'm not familiar with those in the base game. Does the base game have such a recipe for items with fluids ?

bright fog
bronze yoke
#

yeah i don't really get what's intended by that part

steady fable
#

new code did this when packing

#
craftRecipe PackBoxOfAlcoholBottles
    {
        timedAction = PlaceAmmoInBox,
        Time = 15,
        Tags = InHandCraft;CanBeDoneInDark,
        inputs
        {
            item 12 [Base.Disinfectant] mode:destroy flags[Prop2],
        }
        outputs
        {
            item 1 Base.BoxOfAlcoholBottles,
        }
    }```
#

i did this and the alcohol bottle just appears when im done packing

steady fable
steady fable
#

well

#

it has some fluid recipes

#

for coffee and smelting

bright fog
steady fable
bright fog
steady fable
bright fog
#

Bcs it could be it doesn't take your changes into account

steady fable
bright fog
#

Make sure to unsub from the original mod, to only use your own local version

steady fable
#

i found that out last night trying to test out other boxes

bright fog
#

Depends, sometimes it does, sometimes it doesn't

#

Highly suggest you unsub from the original mod regardless

steady fable
#

i'll check

bright fog
#

This has caused more than a few brains to fry due to it

bronze yoke
#

it's known to cause a couple issues

steady fable
bright fog
#

Unsub

#

Keep it checked

#

You're using the same modID right ?

steady fable
#

yes

bright fog
#

Same mod so you didn't change any of that ?

#

Then yes unsub from the Workshop

steady fable
#

did that

bright fog
#

Bcs you got two mods locally and workshop that have the same ID

#

Both will mix together and that will cause issues

steady fable
#

the patch has a different mod ID

bright fog
#

After you done that, test again your new script recipe

steady fable
#

i'll check it

bright fog
steady fable
#

yes

#

it is from the main one

bright fog
#

Yea so that one would have issues

#

Due to another copy of it existing

steady fable
#

wow uh

#

its working

bright fog
#

The patch itself is new if I understood that right and so is not yet present on the workshop version, so it would work

steady fable
#

voila

bright fog
bright fog
#

What I think was happening:

  • the game picked one of the 12 bottles to empty with that fluid entry
  • sometimes it would use the same as the bottle not being destroyed, thus leaving an empty bottle
  • and other times it wouldn't and pick empty a bottle that gets destroyed anyway, leaving a full bottle
#

And since your own modification of the mod wasn't loaded, it used the one on the workshop, with that fluid recipe

steady fable
#

well the mod is fixed up now i believe but i have other issues with fluids

bright fog
#

That's why you unsub from your own mods when dev or use a closed environment from the Workshop

steady fable
#

when i opened it it just gave me half seltzer water half water

#

regardless of what i put in it

#

something to do with the [Water] fluid tag because i dont know how to indicate it

bronze yoke
#

yeah the issue there is that the game just randomly picks one when it spawns a water bottle

#

might need an oncreate to fix that

steady fable
#

fair enough

#

but it would be nicer to be able to have seperate boxes of seltzer and water bottles

steady fable
#

im not very experienced with modding but im aware of code structure and the basics of formatting

bright fog
#

Also

#

One issue: make sure that empty bottles that get packed don't unpack as full bottles

#

Bcs the fact it even gives you a fluid in the first place, means this is going to be an issue

steady fable
#

i'd like it so i can pack it like batteries for example, keeping the usedelta data

bright fog
#

Doesn't seem to be doing it's job properly then for bottles ๐Ÿ˜…

steady fable
#

doesnt seem to be doing its job properly at all!

#

well i'd have to check of course

bright fog
#

Didn't the original modder add that in ?

steady fable
bronze yoke
#

so you paid someone to make this mod and it doesn't even work properly...?

steady fable
#
require 'recipecode'

function Recipe.OnCreate.FromConditionInheriter(craftRecipeData, player)
    local items = craftRecipeData:getAllConsumedItems();
    local results = craftRecipeData:getAllCreatedItems()
    local box = items:get(0);

    for i = 0, results:size() - 1 do
        local resultItem = results:get(i);
        if box:getModData()["condition" .. i] then
            resultItem:setCondition(box:getModData()["condition" .. i])
        end
    end
end

function Recipe.OnCreate.ToConditionInheriter(craftRecipeData, player)
    local results = craftRecipeData:getAllCreatedItems()
    local items = craftRecipeData:getAllConsumedItems();

    local box = results:get(0);
    for i = 0, items:size() - 1 do
        local item = items:get(i);
        if item:getCondition() ~= item:getConditionMax() then
            box:getModData()["condition" .. i] = item:getCondition();
        end
    end
end```
steady fable
#

they just said "i dont want your scraps"

bronze yoke
#

christ

steady fable
#

never commission rainmaker ๐Ÿ™

#

no need for slander now though

steady fable
bright fog
#

wait

steady fable
#

and the code they gave me isnt published by them anywhere else

bright fog
#

that name doesn't ring a bell tbf

steady fable
bright fog
#

Damn this shit's a thing I forgot

steady fable
#

they were harassing someone earlier because they had a typo on the word "feelings"

#

so that says something

bright fog
#

Yikes lmao

#

Anyway

steady fable
#

its likely not linked or incorporated with the craftrecipes

#

oh

#

it does have an oncreate thing

#

for example

#

so it is linked

bronze yoke
bronze yoke
bright fog
#

True

steady fable
bright fog
#

You just need to make a new function for OnCreate

steady fable
bright fog
#

Yea

#

Finish my sentence for me lol

steady fable
#

i have the brain of an automechanic i cannot finish your sentence

willow estuary
steady fable
#

oh my god

#

does it work for flags[prop2] or is it exclusive to prop1

#

i'll test it out

willow estuary
#

Ignore props

steady fable
#

so on my end what would i have to do?

#

add the inherit condition to the inputs area?

bright fog
#

@ancient grail removed references to links to your mod page (as well for others that had done it) and replaced those with links to the mod itself, when I managed to find it. For the future, please link the mod itself or nothing at all. And for mods that may be hidden in private, add a note mentioning it like Private mod

bright fog
bronze yoke
#

i'm not really sure this is directly relevant, what they're trying to do is pack x items into a box item and then get items with the same condition/fluids/etc when unpacking

bright fog
#

Bcs your box should not inherit conditions

#

What albion explained more in detail

steady fable
#

some items dont have a condition so they're fine the way they were

#

(bandages et cetera)

#

but then theres crowbars and welder masks

#

and other similar items that have condition

#

or some sort of data that should be kept

bright fog
#

You need to use the same method as the battery one

#

But replace the condition check to something for the fluid

bronze yoke
#

so the condition stuff from the oncreates you showed isn't working?

bright fog
#

So it notes:

  • fluid type
  • quantity
willow estuary
#

I wouldn't have packing recipes for welding masks; some items have so much individual data that storing and re-instancing it is problematic both in the sense of potential bugs, and save sizes.

sonic needle
#

he lives

bright fog
#

Welding masks don't have unique properties tho

bright fog
#

Oh they do no ?

bronze yoke
bright fog
#

Yea no idea LMAO

bronze yoke
#

i remember a patch note about something to track ingredients used to craft an item but i've never looked at it so i have no idea how detailed that is, probably not very or save size would balloon

steady fable
#

ii'll test it out

willow estuary
#

Well, according to good game design, every item must be packable if packing exists, regardless of bugs or save size issues

steady fable
bright fog
#

But he's not packing welding masks anyway no lol ?

steady fable
bright fog
#

Tbf that's fine

#

You can still have for "decoration" in a way

willow estuary
steady fable
bright fog
willow estuary
#

It's intention was just "if we add some way to build something with nails OR screws how does the player get the right nails or screws when taking apart it"

bright fog
#

Aaah

#

That's an interesting challenge to handle

#

I know Vintage Story has that for some recipes I believe

#

No idea how they handle it however

steady fable
bronze yoke
#

if i were doing this i'd honestly just require them to be full ๐Ÿ˜…

steady fable
#

i agree but later on i am interested in adding firearms and ammo mags to the list of packable items

#

(because i also play with the smokes n guns mod, get plenty of those)

bright fog
steady fable
#

for the time being thats actually how it is i believe

#

i tried to put in used caffeine pills once

willow estuary
#

To be absolutely blunt and honest I consider going down the rabbit hole of "making everything packable" to be the equivalent of a Hellraiser puzzle box of endless workshop page bug reports.

bright fog
#

I really think that even for organizing stuff, you shouldn't pack things that aren't full (or empty)

steady fable
#

but theres a rule i learnt for coding when i studied c#:

never trust the user

bright fog
willow estuary
#

And also I can't imagine anything more useless than a box of packed 5% remaining/condition/whatever screwdrivers/light bulbs/wahtever

bright fog
#

Yea ๐Ÿ˜…

steady fable
willow estuary
#

"The garbage bins exist"

bright fog
#

At least for things you can merge

#

There's literally mods to merge items together

steady fable
#

or the thread

bright fog
#

So packing half empty pills sounds so stupid lol

steady fable
bright fog
#

I don't see how that applies here

willow estuary
#

Imagine going through a tripe-crate stack of packed lighbulbs and they're all in crap condition.

steady fable
#

alright i concede

bronze yoke
#

in b41 i had to write item serialisation for one of my mods to work and when b42 released i immediately vowed to never update that mod ever, even if i don't mess it up it's impossible to keep it up to date with the game and people are going to get very angry when i delete their items ๐Ÿ˜…

steady fable
#

we'll work with full condition

#

i think we stormed off track because what i wanted to see was how i could implement water bottle boxes

#

full water bottles and empty water bottles

#

both water and seltzer

#

god alot of the elements of this mod sound complicated

#

for now we'll stop here you've all told me enough

#

thank you

bright fog
#

Last info: there's tags for full and empty fluid containers

#

So it's very easy to do

steady fable
#

but its water, and the fluid [water] refers to both seltzer and regular

bright fog
#

However you need two box items for empty and full

steady fable
bright fog
#

๐Ÿ‘Œ

steady fable
#

i'll come back with my next problem sometime soon but in the meantime im gonna publish the mod and test it on a copy of my main world so I can implement what would be most useful right now

steady fable
#

my next move: pack empty plastic bottles into a box

#

because i have much more of those than filled ones

#

i'll have to find the right parameters on the wiki though

tranquil reef
#

any way to check if the player has been shot, or has gotten into a car crash

silent zealot
steady fable
#

better to pack them

silent zealot
#

throw them out

#

just fill up garbage bags of rubbish, walk outside and dump them in the rubbish pile.

steady fable
#

loot respawn is off in my world and so is zombie respawn

steady fable
silent zealot
#

hahahaha

steady fable
#

i am very stubborn and refuse to throw out anything that isnt renewable

silent zealot
#

just throw the empty bottles on teh ground then

steady fable
#

they're currently in a crate

silent zealot
#

Oh, a full on hoarder mod.

steady fable
ancient grail
steady fable
#

gonna wait for other mods to add renewable resources or for the game to do that for me

silent zealot
#

advanced 3D placement is the ultimate hoarder base decoration tool.

low bramble
silent zealot
#

(my boxes are all full of food, ammo, water, etc...)

#

back on track... do you need to track details of you empty plastic bottles, or are they all interchangable?

steady fable
#

somewhat

#

when packing it should only pack empty water bottles, and when unpacking it should only give me empty water bottles

silent zealot
#

Because if they are all generic, I think there is a generic "pack box of 12 things" recipe

#

(in B42)

steady fable
#

and it would cause conflicts with other mods i believe

silent zealot
steady fable
silent zealot
#

I'm pretty sure using lua you can add the extra input item and the extra entry to Item mapper

steady fable
#

i was told that earlier

steady fable
#

i have to use a lua function to work around it

#

and the lua function is very limited

silent zealot
#

Yes, because you don't want to override - you want to read the current recipe values then add one, then write back.

steady fable
#

currently my function would replace the entire thing

silent zealot
#

Definitely do not do that

#

I'm not sure that is still the correct object for B42 recipes, but you probably want to: 1) use recipemanager to get the item for the PackInBox recipe, 2) read the existing input and mapper fields, 3) update those fields with your extra values

#

Then repeat for the unpack recipe

#

you can extend the OnTest.GenericPacking and Recipe.OnCreate.PlaceInBox functions if needed

#

I'm not sure if this will appeal the same way but another option is to make container versions of the different sized boxes, then you can put anything into them using the standard inventory interface and place them around your base/in cupboards/etc.

silent zealot
#

Found the problem

#

local playerDirNorm = dirNormalize[pl:getDir()] or "W"

#

will always return "W" because dirNormalize[pl:getDir()] will never find a result

#

Because the output of getDir() is not a string, it's userdata which is basically Lua's way of saying "I don't have any idea what this is but I will pretend I do just enough to confuse the heck out of you"

#

So you can use it like a string for some things... but userdata containing "W" is not the same as a string containing "W" so you can't use it as a table index.

#

change it to local playerDirNorm = dirNormalize[tostring(pl:getDir())] or "W"

#

and the same here:

silent zealot
#

...and that was meant for a DM, oops!

#

@copper abyss

copper abyss
#

oop!

silent zealot
#

I'll leave it here in case one day it helps someone searching for "userdata" or "getDir"

copper abyss
#

I'll copy and paste this on a .info file rqqq-

bright fog
bright fog
#

Should be that one I think

bright fog
#

Bcs if you use print, it will do it automatically, so that's why if you view it with print you think it's a string

silent zealot
#

You can also use the == comparison with userdata, though I think it only works with other userdata that is exactly the same

#

But not >, or .., or a bunch of other stuff.

bright fog
bright fog
#

I can add it to the wiki page too

silent zealot
#

I'll make a github for it.

bright fog
#

Don't feel forced to

silent zealot
#

It's a good idea - the mod folder is already under git control, so addinga github is easy and makes sense if it's a mod I that other people will use.

ancient grail
bright fog
silent zealot
#

mod description has a link to github, I'll link github back to the mod later when I fix up the readme.md formatting a bit

bright fog
#

Yea I meant for Glytcher

#

Because he linked the Github instead of the mod, that's going to be problematic if people find that and end up making copies of your script

bright fog
#

Instead use modules since you already have modders require the script

silent zealot
#

That is correct, because I know how to do it that way lol.

bright fog
#

It's easy to do

#

Doesn't require much changes

silent zealot
#

Good idea, I'll update later tonight/tmorrow.

bright fog
#

๐Ÿ‘Œ

silent zealot
#

Instead of using this an excuse to avoid going shopping even longer ๐Ÿ˜›

bright fog
#

That's fair

silent zealot
#

wait, do I just add "return EasyDistro" to the end of the file? Since everything is already in a single table

bright fog
#

Told you it's easy as fuck ๐Ÿ˜‚

silent zealot
#

then modders can do "local funnyname = require("EasyDistro")" and call funnyname.AddItem.

#

lol

bright fog
#

There's a single line to change for you and for the modders that use it

silent zealot
#

I'll do it after shops anyway because making a change and wandering off without any testing feels like a bad idea.

#

And it won't invalidate anyone who starts using it as a global before I do that.

#

(unless I make EasyDistro local)

bright fog
#

๐Ÿ‘Œ

#

Yea you should make the original table local

bright fog
#

Didn't go in the detail of how to use it, wanted to but since you're probably going to change to use modules I figured I shouldn't add codes

#

Feel free to add to it

manic forum
#

Do ISO Objects needs to be 3d or can i use the mesh of like an oven and say Zomboid to retexture it?

silent zealot
#

with some depth map images

manic forum
#

oh that make things easier xD cuz my Photoshop skills are bad but my modeling skills are badยณ

silent zealot
#

Things like placed inventory items, cars, players are actual 3D models.

bright fog
#

Actually there's something regarding tiles that can ACTUALLY be 3D objects

#

Not just a depth map

silent zealot
#

Good news: Zomboid 3D models have very low standards, because they are tiny in-game and getting something vaguely OK with a few polygons and a 512x512 texture is better than a highly detailed model with a 2k texture.

bright fog
#

It was Ash that showed that, washing machines being actual 3D objects, but not appearing 3D, and it's the model getting a special render to become a tile

silent zealot
#

Similar to the way dead zombies/maniquins get rendered to an "atlas" of low-res still images?

bright fog
#

Perhaps

silent zealot
#

I looked into making mannequins higher resolution, but it looked like it would be a bit of a nightmare to code and a huge pain to keep updated as the java changed.

manic forum
#

i cant seem to find the images for iso objects

Get-ChildItem -Path "G:\SteamLibrary\steamapps\common\ProjectZomboid\media" -Recurse -File | Where-Object { $_.BaseName -eq "appliances_cooking_01_5" } | Select-Object -ExpandProperty FullName

i just used the sprite name of a random oven

silent zealot
#

A lot of vanilla iso images are in texture sheets

#

They are in the tile picker

#

I don't know how to access the image tilesheets, I think there is a tool for that

manic forum
#

Thanks, will look into it

silent zealot
#

Can a weapon use a different model when equipped vs. when attached to a hotbar? I'm going to make a folding survival rifle, but I don't want to go through the tedium of having a whole separate item for the folded version and swapping back and forth via recipe.

sly condor
#

if I set up a new stash, is it possible to force the triggering map to spawn as the annotated version? I can't find the file that dictates this... I can only force it through the stash debugging atm

quartz kestrel
#

Iโ€™m creating a mod where I need to export an fbx model for it. How can I convert the fbx to .txt? and how do I export its texture? can someone help me?

tranquil kindle
#

Game uses X or FBX, while FBX is encouraged by most modders

silent zealot
#

.x has text and binary formats... but avoid .x if you can.

quartz kestrel
#

thatโ€™s what they told me, that to import it into my mod, it needs to be in .txt

silent zealot
#

.fbx plays a lot nicer with blender, and you don't need to convert naything after exporting.

#

They might have meant you need to make an item in a .txt script file.

quartz kestrel
#

srry for the dumb questions, Iโ€™m new to modding and have no idea which folders I need to add to include the fbx

silent zealot
#

Back up a bit - what sort of mod are you making?

quartz kestrel
silent zealot
#

What is a "plush magazine" in game terms? And what if your model a model of?

quartz kestrel
#

Iโ€™m gonna make a magazine shaped like a duck

#

so that when players read it, it removes sadness

silent zealot
#

On one hand that makes no sense to me, on the other hand I know how to do it.

#

You're basically going to create a magazine, similar to vanilla magazines, but instead of the model for teh item looking like a magaizine it looks like a duck.

quartz kestrel
#

YES

#

I already made my model

silent zealot
#

Have a look in media\scipts\iitems\items_literature.txt

#

Unhappychange is how you remove sadness

quartz kestrel
#

module MyMagazines
{
imports
{
Base
}

item HappyMagazine
{
    DisplayName = Happy Magazine,
    DisplayCategory = Literature,
    Type = Literature,
    Icon = Item_MyMagazine,
    Weight = 0.2,
    WorldStaticModel = Magazine,
    UseDelta = 0.1,
    StressChange = -20,
    UnhappinessChange = -20,
    BoredomChange = -20,
    PanicChange = -20,
    Tags = Reading,
    Tooltip = Tooltip_HappyMagazine
}

}

#

dang

silent zealot
#

I don't think literature has a useDelta

#

But that coudl be a B42 thing

#

but if you copy the vailla item and change stuff, that will be fine

quartz kestrel
#

oh

#

I'm having more trouble exporting the texture in Blender, I think I can handle the folders

silent zealot
#

There will also be some model stuff in media\scripts\models_items.txt

#

I can't help with the texture export, for my blender work I've make a texture in Krita and then UV mapped the model onto it so the texture was already in png.

quartz kestrel
#

Iโ€™m not understanding anything in this wiki CAT

tranquil kindle
tranquil kindle
#

Thats one handsome duck. For my feeling it might be a bit big but we will see. From what i see you haven't made your model script yet?

quartz kestrel
#

idk how to put it in the folders, along with its texture

#

I wrote the scripts for the magazine, my mod is going to be a duck-shaped magazine

tranquil kindle
#

So in \steamapps\common\ProjectZomboid\media\scripts you have something called "models_items.txt" files, or other "models...txt" Those are called model scripts i belive
for example :

model FlashLight_Improvised
    {
        mesh = WorldItems/Flashlight_Improvised_Hand,
        texture = WorldItems/Lights_Improvised,
        scale = 1.0,

        attachment world
        {
            offset = 0.0000 0.0000 0.0000,
            rotate = -0.0000 0.0000 0.0000,
        }
    }

Mesh is where your Model (fbx file) would be, So in this case game looks in folder Model_X (always) then will go to WorldItems folder and there will look for "Flashlight_Improvised_Hand" file which has to be either X or FBX.
With texture its same case but it will instead look for "textures" folder instead of "model_X"

#

"attachment world" isnt currently our goal as its pretty much a way for you to edit how model is placed on ground, but you can do it later if there is need.

quartz kestrel
#

alright

#

I think I understand

tranquil kindle
#

I personally suggest to make new txt file in script folder, give it module Base (you already import it in your script so everything is alrgiht).
and lets say you exort your model to media>models_x>Duck.fbx (you don't need to insert it further, but you can)
and texture to media>textures>Duck.png

#

Then your model script would be "

module Base
{
model MyFirstDuck
    {
        mesh = Duck,
        texture = Duck,
    }
{
silent zealot
tranquil kindle
#

Then your item script would look somewhat like:

module MyMagazines
{
    imports
    {
        Base
    }

    item HappyMagazine
    {
        DisplayName = Happy Magazine,
        DisplayCategory = Literature,
        Type = Literature,
        Icon = Item_MyMagazine,
        Weight = 0.2,
        WorldStaticModel = MyFirstDuck,
        UseDelta = 0.1,
        StressChange = -20,
        UnhappinessChange = -20,
        BoredomChange = -20,
        PanicChange = -20,
        Tags = Reading,
        Tooltip = Tooltip_HappyMagazine
    }
}
quartz kestrel
#

Humm

#

gotcha

#

sounds simple, Iโ€™ll give it a try

quartz kestrel
tranquil kindle
#

Looks like your model did not load, the thing is you have static model which is for in hand display, you would need worldstaticmodel to show it on ground too.

#

No wait, my mistake you do have "WorldStaticModel", then it means that it should appear. It might be typo on your end or badly exported mesh, or maybe lack of texture?

quartz kestrel
#

I think it lacks texture

#

I put the icon and they never appear

tranquil kindle
#

Show me both you model and item scripts

quartz kestrel
#

I need to find someone to partner up with, lmfao. Iโ€™ll make the model and they handle the rest, because this is frying my brain

quartz kestrel
#

one sec

#

module MyMagazines
{
imports
{
Base
}

item HappyMagazine
{
    DisplayName = Happy Magazine,
    DisplayCategory = Literature,
    Type = Moveable,
    Icon = duck_plush,
    Model = MyFirstDuck,
    WorldStaticModel = MyFirstDuck,
    PlaceStaticModel = MyFirstDuck,
    Weight = 0.2,
    MoveSpeed = 1.0,
    PickupSound = PickupGeneric,
    UseDelta = 0.1,
    StressChange = -20,
    UnhappinessChange = -20,
    BoredomChange = -20,
    PanicChange = -20,
    Tags = Reading,
    Tooltip = Tooltip_HappyMagazine
}

}

#

require "Items/ItemUtil"

local function debugPrint(text)
print("[MyMagazines Mod] Loaded successfully!")
end

debugPrint("MyMagazines loaded successfully!")

#

that's it, I think

#

Iโ€™ll probably create another one, this one got too messy and confusing

tranquil kindle
#

You still don't have Model script anywhere, and there is no such thing as " PlaceStaticModel = MyFirstDuck,"
There are:
"StaticModel=" for display in hands, so in your case you need it for your model to show during reading,
"WorldStaticModel=" for displaying when item is on ground

bright fog
#

What ?

tranquil kindle
#

And you do not put lua thing in same file as script...

bright fog
#

Did you just chatGPT this shit ?

tranquil kindle
#

Doggy calm down

bright fog
#

Yea I'm calm, just got extremely confused about it

#

But in more seriousness, there's a plague currently of modders trying to use AI to make mods and they end up not learning anything because AI will never give them a proper good answer in the current state it is in

quartz kestrel
bright fog
quartz kestrel
#

Iโ€™m not used to making mods in lua, itโ€™s still confusing. I only know python

bronze yoke
#

you don't need a lua file in your mod at all, it doesn't do anything

bright fog
agile nacelle
bronze yoke
#

the site you linked is for 41.77, there's basically no api differences between those versions so i would assume so

bronze yoke
#

IsoDirections is an enum so you don't need to create it

#

just use IsoDirections.E for east etc

agile nacelle
#

oh

#

i see

bright fog
#

Decompile the java to check what that function does, a lot of these kind of stuff don't do anything

bronze yoke
agile nacelle
bright fog
#

And I can assure that for this kind of function, you better check there even is code behind it ๐Ÿ˜…

agile nacelle
#

good point

bronze yoke
#

looks implemented

bright fog
#

And tbf, if you continue doing modding for PZ, I'd suggest decompiling, that's kind of the next step

bronze yoke
#

i don't think it'll find stuff that isn't on that square though (so only N and W will actually work)

bright fog
#

One issue too

#

Actually nvm

#

Thought it wouldn't give you multiple possibilities, but it can't have multiple ones in the same direction

bronze yoke
#

i think there's some utils for finding stuff like walls independent of the actual square in starlit

#

no nevermind, there's some wall utils but they still only catch ones on the actual square

bright fog
#

Base game sort of has this kind of thing I believe

#

Wait no

#

It's also actual square too

bronze yoke
#

it kind of has it but it's really picky

bright fog
#

Thought you just meant in general catching walls etc

bronze yoke
#

in general working with walls is really annoying, i had to put a whole bunch of work into it for excavation

#

some of that code is supposed to move into starlit eventually but it's not general enough yet

bright fog
#

Yea

agile nacelle
#

are custom decompilers needed orrrrrr

bright fog
#

Yes

agile nacelle
#

idk i never actually tried decompiling

#

oh

bright fog
#

Way way better

agile nacelle
#

i see i see

bright fog
# agile nacelle i see i see
  • the most recent one by albion requires a single double click, compared to command lines for the majority of them
  • they take into account extra informations for a better decompiled code
#

So no it's not mandatory, but tbf if you want to decompile the game code, you're making your life way harder by picking generic decompilers

agile nacelle
#

noted

fallow mauve
#

How does map making work with B42

bright fog
fallow mauve
#

Where can I find the link to that discord

bright fog
#

I DMed it to you

fallow mauve
#

Alright thank you

agile nacelle
#

hmmmmm

#

i wonder which one to pick

#

real people would pick Notepad

bright fog
agile nacelle
#

but i dont want to give myself eyestrain just to read decompiled code

tranquil reef
#

has anyone made a gore mod yet

#

had one in development, weird that i'm still seemingly the only one that's tried. from what i've seen at least. not sure if i should keep going

ancient grail
#

@bright fog omg i just saw the tiledef and you actually linked it
THANK YOU SO MUCH

icy night
#

Does anyone know how to initiate puddles via Lua? I'm trying to mimic the climate settings I made in debug mode

#

Figured out how to get the rain, wind and fog. But puddles are tough

bright fog
#

But you weren't the only one in that case, it just turns out that you're the one with the most individual tile mods I guess lol

ancient grail
#

appreciate you man and yep ill keep the format

bright fog
#

Thx

ancient grail
#

lost the author name tho was sorta an advertising venue but still its worth it

grizzled fulcrum
bright fog
ancient grail
#

i understand
gave you your 4th profile award

bright fog
#

Lol thx

agile nacelle
#

it seems like getDoorOrWindowOrWindowFrame doesnt work

bright fog
#

Check if the vanilla game uses it

#

Both in the Lua and in the Java

#

(So decompile the game)

agile nacelle
#

:(

bright fog
#

That's also why you should decompile the game

agile nacelle
#

OH NO

#

MY INJELLIJ IDEA

#

ITS BROKEN

agile nacelle
bright fog
agile nacelle
#

seems like it does use it

bright fog
#

Check where it's used and how

bright fog
agile nacelle
#

its used in

#

getContextDoorOrWindowOrWindowFrame

bronze yoke
#

btw it's better to use code lens for this kind of thing

#

keyboard shortcuts may be different in vscode but in intellij it'd be ctrl-n to search classes, find the declaring class, then ctrl-click the method declaration's name to see all usages

agile nacelle
#

am using vscode rn

#

because intellij just uhh

#

blew up

#

i really need to fix it i had a mod project on it ๐Ÿ’”

#

i cant even find the intellij community install

bronze yoke
#

but basically doing it this way is a lot more resilient to weirdness, text search can report a lot of false positives

#

in this case it's a really awkward long method name so it's not going to come up with anything else lol but when it isn't it's a lot faster to do it this way

bright fog
#

You can access it by ctrl clicking the method right ?

bronze yoke
#

yeah

bright fog
#

Ok I see what it is then

bronze yoke
#

you can ctrl-click basically anything to see all references to it

bright fog
#

I'll try to document that on the wiki page I guess

agile nacelle
#

i... cant find intellij idea community edition download

#

OH

#

IT WAS JUST 1 SCROLL DOWN THE PAGE

bright fog
#

Yea they try to hide lol

agile nacelle
#

honestly i dont even think i need to reinstall it because really it broke because of lua plugin

bronze yoke
#

yeah don't use that garbage

agile nacelle
#

iiii cant find the folder for it

#

for the plugin

bronze yoke
#

if you've seen some older guides they recommend it but it's massively out of date and doesn't even work anymore

agile nacelle
#

fr...

#

i... cant find it

sly condor
mellow frigate
steady fable
#
craftRecipe OpenBoxOfDigitalWatches
    {
        timedAction = OpenAmmoBox,
        Time = 15,
        Tags = InHandCraft;CanBeDoneInDark,
        category = Packing,
        inputs
        {
            item 1 [Base.BoxOfDigitalWatches] flags[Prop2],
        }
        outputs
        {
            item 24 Base.WristWatch_Left_DigitalBlack,
        }
    }

    craftRecipe PackBoxOfDigitalWatches
    {
        timedAction = PlaceAmmoInBox,
        Time = 15,
        Tags = InHandCraft;CanBeDoneInDark,
        category = Packing,
        OnCreate = Recipe.OnCreate.ToConditionInheriter,
        inputs
        {
            item 24 [Base.WristWatch_Left_DigitalBlack;Base.WristWatch_Left_DigitalRed;Base.WristWatch_Left_DigitalDress] flags[Prop2],
        }
        outputs
        {
            item 1 Base.BoxOfDigitalWatches,
        }
    }```

any better way to accomplish packing different types of digital watches, or different types of items overall? i'd rather not have seperate boxes for black, red and dress watches
#

i do have a lua script to inherit condition but not types of items

agile nacelle
#

intellij idea is fixed โœจ

#

truly, the goat of folder navigation

bronze yoke
#

i use it for browsing java code since it's generally the best java ide, but it isn't good for actually writing lua mods in

steady fable
# steady fable ```lua craftRecipe OpenBoxOfDigitalWatches { timedAction = OpenAmmoB...
require 'recipecode'

function Recipe.OnCreate.FromTypeInheriter(craftRecipeData, player)
    local items = craftRecipeData:getAllConsumedItems();
    local results = craftRecipeData:getAllCreatedItems()
    local box = items:get(0);

    for i = 0, results:size() - 1 do
        local resultItem = results:get(i);
        if box:getModData()["itemID" .. i] then
            resultItem:setItemID(box:getModData()["itemID" .. i])
        end
    end
end

function Recipe.OnCreate.ToTypeInheriter(craftRecipeData, player)
    local results = craftRecipeData:getAllCreatedItems()
    local items = craftRecipeData:getAllConsumedItems();

    local box = results:get(0);
    for i = 0, items:size() - 1 do
        local item = items:get(i);
        if item:getItemID() ~= item:getItemID() then
            box:getModData()["itemID" .. i] = item:getItemID();
        end
    end
end```
i copied the condition inheritor and replaced some of the condition related bits with itemID, but i'd have to check if the parameters are correct
steady fable
#

found one but its in isoanimal not craftrecipe

#

and its integer this time

lunar robin
#

I suspect the player object isn't ready yet when OnNewGame is fired?

native lantern
#

Guys, how do I mod?

agile nacelle
#

or getSpecialObjects

pine patio
native lantern
pine patio
native lantern
finite scroll
#

i know how to add additional clothing by professions, but is there a way to remove some of the already available clothing for a specific profession?

agile nacelle
steady fable
# steady fable ```lua require 'recipecode' function Recipe.OnCreate.FromTypeInheriter(craftRec...

spent some time revising it after reviewing some of the javadocs

require 'recipecode'


function Recipe.OnCreate.FromTypeInheriter(craftRecipeData, player)
    local items = craftRecipeData:getAllConsumedItems()
    local results = craftRecipeData:getAllCreatedItems()
    
    local source = items:get(0)
    local sourceModData = source:getModData()

    for i = 0, results:size() - 1 do
        local result = results:get(i)
        local storedID = sourceModData["itemID" .. i]
        if storedID then
            result:setItemID(storedID)
        end
    end
end

function Recipe.OnCreate.ToTypeInheriter(craftRecipeData, player)
    local results = craftRecipeData:getAllCreatedItems()
    local items = craftRecipeData:getAllConsumedItems()

    local container = results:get(0)
    local containerModData = container:getModData()

    for i = 0, items:size() - 1 do
        local item = items:get(i)
        local itemID = item:getItemID()
        if itemID then
            containerModData["itemID" .. i] = itemID
        end
    end
end```
steady fable
bronze yoke
#

if you want to remove every item in a slot, it's probably safer to do ClothingSelectionDefinitions.fireofficer.Tshirt = nil or else it'll leave an empty table that might cause issues later on

bright fog
#

B41 or B42 ?

#

nvm B41 you mention server

steady fable
bright fog
#

Check what the error says, this is the next step to developping Lua mods and you basically can't work without reading them

steady fable
#

this is the most i had

#

even then ive already scrapped most of the typeinheriter code its just complex for me

finite scroll
bright fog
finite scroll
#

i need to remove base clothing from a specific profession

#

i probably should've been more clear about that

bright fog
#

getItemID doesn't exist

bronze yoke
#

oh, that won't be possible in any simple way

bright fog
finite scroll
#

the only way i could think to do it would create huge conflicts with any mod adding more professions

steady fable
bright fog
#

Ah

#

That's not how you'd do it

#

That's not the item ID at least

#

You will use item ID, but that's not the item ID

#

because those methods don't exist

steady fable
#

crud

bright fog
#

I'm expressing myself badly here lol

#

Give me a minute

#

getFullType is the way to get the item ID

#

Then your unboxing craft cannot output anything, and instead the output will be done from Lua

#

And you will create the items manually

steady fable
#

mkay

bright fog
agile nacelle
#

why is there no subclass for walls ๐Ÿฅ€

bronze yoke
#

what would this class do?

#

subclassing is the devil

bright fog
#

That's why you got IsoWindow and IsoDoor because those have technical aspects behind them

#

Walls however are nothing special and most needed is handled via tile properties

agile nacelle
#

i just wanted to like if instanceof but i mean i alr got a way around it

bright fog
#

In IsoObject

#

Walls are IsoObjects

#

Don't trust the isWallN and isWallW however ... do that with tile properties because corners are special ...

agile nacelle
#

ermmmmm

bright fog
#

That's not how you search

agile nacelle
#

outdated docs..,

bright fog
#

No it's not

agile nacelle
#

hm?

#

what am i missing

bright fog
#

Oh wait no it is, I mean I never used this method

#

But you're on B41 doc

#

Use the B42

#

You're on B42 right ?

agile nacelle
#

mmmmmm no

bright fog
#

Ah nvm then

#

Wait did you look at the mod we shared the other day that did exactly what you wanted to do ?

agile nacelle
#

yeah

#

but i wanted the vehicles to not come to a complete stop which in my testing they did not seem to achieve

#

which means am gonan have to... figure out also how to damage the vehicle because the vehicle doesnt actually collide

bright fog
#

They literally have images of the vehicle going through fences on the mod page no ?

agile nacelle
#

they did yeah

#

but when i tested out, while it did break the objects, the cars also lost all momuntem

bright fog
#

uh

#

You tested in B42 ?

agile nacelle
#

i could test again because honestly i dont really remember well if that was the case

#

oh

#

no

bright fog
#

I didn't even knew their mod was in B41

#

Also, the creator was around here, or in the modding Discord when developing it

#

You can probably contact him

agile nacelle
#

am good so far

bright fog
#

Don't hesitate to look at mod files too to see how things work, how they handle it

#

Of course do not copy pasta the code without authorization, but I think there's no shame to learning from others' work

agile nacelle
#

i looked at their code to see how they got the position of the grids

#

oh wait

#

that was from the other mod

#

super bulldozer

#

i looked at super bulldozer code to see how they got the position of the grid but thats all i did really

#

is this normal

#

theres clearly loops going on how come can't i use continue

bronze yoke
#

there is no continue keyword in lua

agile nacelle
#

oh

#

right

#

Luau... mb

bright fog
agile nacelle
#

win!!!

icy night
#

looks awesome

agile nacelle
#

yes

#

also takes car weight into account

finite scroll
bright fog
#

That's terrifying, but nice !

agile nacelle
#

๐Ÿ›ป

crimson spindle
#

Working in B41. There are some tile objects that seem to not be interactable at all... how do i go about changing it so that i can pick them up, use them, etc.? I'm in debug mode and I cant even get the option to pick this up using the pickup/place context.

I've managed to locate the item at least the sprite in location_community_medical_01 but not sure how to reference that specific sprite or whatever.

pearl prism
uncut pewter
#

hi is anyone here making mods for vehicles?

#

would like to pay for a modder to make a vehicle for me if its possible

#

?

pearl prism
uncut pewter
#

Can I private messege you?

pearl prism
#

For sure

wanton nest
#

hey so i dont know if theres already a mod for this but i want to put a simple compass rose/star on the map, how would i go about doing that?

queen oasis
#

comma's are, important. "why isn't this done yet?" - "because my brain is bad"

true nova
steady fable
#

hey quick question how many uses do.. chips have

silent zealot
#

One. If I open a packet of chips, I eat a packet of chips.

steady fable
#

its 15

#

the uses are 15

#

i am serious

#

i did the math on it

silent zealot
#

Not sure about Zomboid without checking, but I think they're just a food item so no "uses" but eat/eat half/eat 1/4

steady fable
#
craftRecipe PackBoxOfPlainChips
    {
        timedAction = PlaceAmmoInBox,
        Time = 15,
        Tags = InHandCraft;CanBeDoneInDark,
        category = Packing,
        OnCreate = Recipe.OnCreate.ToConditionInheriter,
        inputs
        {
            item 180 [Base.Crisps] flags[Prop2],
        }
        outputs
        {
            item 1 Base.BoxOfPlainChips,
        }
    }```
silent zealot
#

that's probably more accurate than me tryig to remember.

steady fable
#

food items usedelta is technically the same as like glue or alcohol wipes

#

its the amount of hunger they give i think

silent zealot
#

Are you coding individual chips as seperate items?

steady fable
#

thats their uses

steady fable
#

i have no better way of doing it

silent zealot
#

hides his rice

steady fable
#

oh yeah i should add like

#

those dried pea bags and such

silent zealot
silent zealot
#

I got asked at work if I knew LUA, and now I'm writing LUA scripts for HAProxy. Somehow HAProxy has worse documentation for their LUA PAI than Zomboid does.

#

They wrote the introduction and then just.. stopped.

stable mica
#

I want to mod a new town into pz but im clueless and never done this before, Any ideas where i start??

icy night
#

Where are zombie outfits defined for vehicle stories?

#

I cant find the right file

silent zealot
#

Java.

#

lots of classes starting wih RVS, one for each story.

#

This is the outfit for "rich Jerk", the crashed car & briefcase of gold:

silent zealot
#

Then come up with an idea, find a place to put it that doesn't conflict with any of the more popular map mods that already exist, and make it.

south bear
#

Is there a way to make altered zombie data persist through player deaths?

My game world has no sprinters allowed through the sandbox settings, but occasionally some zombies are spawned and set to be sprinters via a mod I created. When I die whilst fighting them and after I respawn, the sprinters are back to non-sprint mode.

I use this lua code:

zombie:setWalkType("sprint1")

Is there a way to make this setter persist?

(Edit: I should note that this even happens when I respawn in the same cell where I died and where the former sprinter is now suddenly a walker.)

silent zealot
#

From my understanding, the zombie objects get reused from a pool rather than being individually persistent

south bear
#

Is that something that could be potentially "solved" with moddata tables?

For example, by adding some sort of unique identifier to a zombie on spawn and then recalling that unique identifier on player respawn to re-set the parameters back to where I'd like them?

#

Thanks for the info BTW - I wasn't aware of the pooling thing!

silent zealot
#

Maybe, but I think anything you attach to a zombie will (at best) end up on a random other zombie

#

Have a look at the Bandits mod - that makes zombies into NPCs, and those are still NPCs after reloading, so it is doing something to keep state data for zombies.

silent zealot
#

If you figure it out post the answer here for reference!

south bear
#

Will do!

silent zealot
#

They might tie it to outfit, since every "faction" has a defined outfit and outfits persist since those presumably just a single saved guid. Assuming the mod also stops the outfits in question being used by normal zombies.

#

But check their code instead of my guesses. ๐Ÿ˜›

potent loom
#

persistenOutfitId is close to being a good id for a zombie. it changes once a zombie looses its hat so that need fact needs to be addressed. The generated id is a combined number of outfit id and a random number of 500 plus the info about the hat and a bit determining if that is a female. Bandits uses pregenerated 200 naked outfits but then puts the clothing according to configutation. All zombie data is lost on game reload. So it stores persistenOutfitId in global mod data together with the configuration that is used to restore the zombie(bandit) to the expected state

south bear
# silent zealot If you figure it out post the answer here for reference!

Seems the Bandits they are using getPersistentOutfitID() as a GUID, caching it and recalling it... every tick. ๐Ÿ”ฅ Thankfully, there is some code to help performance on that front included though (basically skipping the entire function a tick while the process is too slow). Pretty neat stuff!

south bear
#

realizes he is talking to the mod author

potent loom
#

yes, and there is extra caching method because bit conversion costs some performance, and the version of lua is old and do not allow bitwise operations

south bear
#

Thanks for this info Slayer - it is so crucial for me!

I see how you store the persistent outfit IDs as the GUID in the BanditUtils.GetZombieID, and how you cache that data from zombies on the tick in UpdateZombieCache, but how is the persistent info recalled/loaded onto existing zombies as the player approaches them/as the zombies are loaded in a cell?

potent loom
#

on each zombie update, the zombie is check if has a bandit flag (local erasable on game restart), if not, its id is checked if it exists in global mod data which serves as a persistent database of bandits, if yes then it means the zombie needs to be banditized (apply visual style, put the right clothes, give weapons etc), and then mark the zombie as a bandit so that the process does not repeat

south bear
potent loom
#

globalmoddata is like a soul of a bandit. Bandits work as long as they are paired. if and id of a zombie is not in global moddata the bandit immediately returns to zombie behavior

#
    if gmd.Queue then
        if gmd.Queue[id] then -- and id ~= 0
            if not zombie:getVariableBoolean("Bandit") then
                brain = gmd.Queue[id]
                Banditize(zombie, brain)
            end
        else
            if zombie:getVariableBoolean("Bandit") then
                Zombify(zombie)
            end
        end
    end
    ```
south bear
potent loom
#

yea just mirror everything you want for your zombies in global mod data.

#

remember to garbage collect data from global mod data once zombie is killed

south bear
#

Cheers! Thanks again!

potent loom
#

np

silent zealot
bright fog
#

I don't think I need to read everything Slayer, I kind of already see from a few mentions of what you should use

#

Zombie ID involves the use of the pID of zombies, and yeah that's the only way to store persistent zombie info

#

However I don't know if Slayer mentioned it but extremely important info: this ID is non unique

#

See the wiki page regarding that

#

All these should give you written info regarding how IsoZombie works and the pID page gives a code snipet of a pID method

agile nacelle
#

why does it need an arguement and how can i get a Vector3f for the arguement

silent zealot
#

If I understand correctly, Bandits defines 200 unique outfits that don't get used by normal zombie spawns, so the mod can spawn one of those and know that is the only zombie with that outfit and hence the persistentID will be unique

bronze yoke
#

it's often also acceptable to pass nil in situations like this

agile nacelle
#

i feel like passing nil just results in an error

#

but I'll try

bronze yoke
#

it takes an argument so it can reuse an existing vector3 instead of allocating a new one every time which may improve performance

#

i haven't checked this function but it is likely it'll just create one if you don't give it one

agile nacelle
#

i also looked at vector2 from getMovementLastFrame

#

and its properties were not capitalized

#

is this the same case for vector3

agile nacelle
small osprey
small osprey
# south bear Thank you! I will have a look!

Maybe also worth to check out https://github.com/SirDoggyJvla/Zomboid-Forge-B42 though it doesn't explicitly mention per-zombi-instance persistance. Not sure if thats what you are after either.

Though the Sir himself already replied you so if he didn't bring it up, don't let me guide you astray ๐Ÿ˜…

GitHub

Zomboid Forge is a Project Zomboid mod which allows modders to easily add their own custom zombies to the game. - SirDoggyJvla/Zomboid-Forge-B42

devout mantle
#

does britas weapon pack still work multiplayer

silent zealot
#

If you don't need direction you can use getSpeed2D() instead, which gives the ground speed (ignoring any vertical component to movement) and there's also getCurrentSpeedKmHour() (the code uses kph, then they write "mph" on the dashboard because 'MERICA!)

agile nacelle
#

i need the directions

#

i used getMovementLastFrame instead

silent zealot
#

if it works it works, and if you just need direction and not magnitude you don't have to worry about the affect of a varied frame rate.

agile nacelle
#

also i need a slight help

#

how can i highlight a grid

#

squaregrid

silent zealot
#

Check the show generator range mod

#

there's a method for it that highlights and lets you specify color (or at least, you can choose good or bad aka green or red)

#

I think it's a property of isoSquare, but that generator mod is teh quickest way to check I can think of.

agile nacelle
#

thx

silent zealot
#

How many Zomboid modders also mod Rimworld? It looks like it's gearing up for an expansion soon so there will be two games trying to consume all of my free time.

bright fog
red tiger
#

Is the API getModFileReader(mod, path, createIfNil) broken?

red tiger
bronze yoke
#

~3-6x faster depending on if you're annoying enough about performance to inline functions

bronze yoke
#

i didn't do it the same way at all

bright fog
#

But you get the same output ?

bronze yoke
#

if it didn't work why would i brag about it ๐Ÿ˜…

bright fog
#

idk just making sure everything's checks up

bronze yoke
#

i've tried it on a range of pids and it seems to work consistently

#

i can't say for sure it works in 100% of cases but the maths work out to me

bright fog
#

So what did you do ?

bronze yoke
#

the example would be zombieId = Bitwise.set(persistentId, 16, true)

bright fog
bronze yoke
#

yes

#

i tested against many zombies and compared performance to yours

bright fog
#

Could easily inline it yea

bronze yoke
#

this implementation is around 3x faster than yours, if you inline Bitwise.get in Bitwise.set it becomes around 6x faster instead but i don't want to do that

bright fog
#

You verify that the bit exists ?

bronze yoke
#

may look into some form of preprocessing to automatically inline performance critical functions like this but that's for another day

bright fog
#

Yea I see what you did

#

Yea inlining the get in set could make sure you don't recalculate local bit = 2^(pos - 1)

bronze yoke
#

that's not very expensive anyway

bright fog
#

yea

bronze yoke
#

the only real advantage to inlining is that it skips the overhead

bright fog
#

it's just some details

#

Yea

bronze yoke
#

which it seems is nearly the entire cost of this function lol

bright fog
#

ik

#

Yea that's fairly simple calculations

bronze yoke
#

i considered internal functions to reduce stuff like that but didn't seem worth the complexity

bright fog
#

what are internal functions ?

bronze yoke
#

here i mean separating implementation from API:```lua
local function get(int, bit)
...
end

Bitwise.get = function(int, pos)
return get(int, 2^(pos - 1)
end

Bitwise.set = function(int, pos, value)
local bit = 2^(pos - 1)
local hasBit = get(int, bit)
...
end

#

i'd avoid recalculating it if the function expected it to be already calculated, but that sucks for the API so i'd just have a separate function that the API delegates to

bright fog
#

Yea makes sense

#

Well tell me if you introduce a trueID function in Starlit, I'll reference it on the wiki page of pID

red tiger
#

@bright fog Need bitwise ops?

bright fog
#

No

red tiger
#

k

red tiger
#

Ok. Saw bitwise and had flashbacks.

bronze yoke
#

i'll probably just encourage people to use Bitwise.set(pId, 16, true) since another function on top of that just adds overhead

#

but internally i'm not doing that anyway so maybe not ๐Ÿ˜…

#
---@param zombie IsoZombie
---@return integer
local function getZombieID(zombie)
    return Bitwise.set(zombie:getPersistentOutfitID(), 16, true)
end
bronze yoke
#

you can cache if you want, i saw yours did that, it didn't seem that important to me

#

it's not really that expensive anyway

bright fog
#

It was extremely important actually

#

Kind of the core of the whole thing if you remove the bit swap operation. Because from what @sour island had said, caching was a major performance boost

bronze yoke
#

but it's also a memory leak ๐Ÿค”

bright fog
#

Technically yea,

#

Hmmm

bronze yoke
#

actually yeah if i make this public API i'll add caching

#

thinking about it most people do this shit on tick

bright fog
#

Exactly

bronze yoke
#

and it's going to be in the cache literally 99% of the time

bright fog
#

That's the reason caching it was needed, because this function had to be called by N zombies x every ticks

small osprey
#

Heya, so I have Project Zomboid Script Support installed and active in my vscode. Any Idea why I see colorized output for vanilla scripts but not for my modded scripts? I even tried to copy over vanilla content 1:1 but it doesn't seem to get recognized.

I tried editing the settings, which came coded towards a windows c:/ drive, to no avail.

bright fog
#

You can manually force the language usage by pressing ctrl + shift + P

#

then

#

Change Language Mode

#

@true plinth any idea why that happens ? My guess is an existent workspace won't take the changes

small osprey
#

That worked!

bright fog
bronze yoke
bright fog
#

Oh god I found them

#

Too many buttons syndrom

#

Yea idk for some reasons it wasn't set for me

#

Oh god I think I know what's going on

bronze yoke
#

the defaults might have changed since i started using idea, or i might have changed it years ago and forgot about it

bright fog
#

I think it imported my VSCode keybinds ?