#mod_development

1 messages · Page 364 of 1

bright fog
#

What's in both versioning folders ?

merry grove
#

Mod for the version

bright fog
#

Show a screenshot please

#

And try launching your game with -nosteam as a launch argument

merry grove
#

Identical in the other

#

in 42.13 works

#

when I remove 42.0 it works aka doesn't display it

#

Only when 42.0 folder is in it dies

bright fog
#

Remove the .0

#

From the folder's name

#

I doubt it's the reason tho

merry grove
#

pretty sure I already did that

bright fog
#

Why are you using two different IDs ?

merry grove
#

Yeah nothing changed

merry grove
#

Before they were identical

bright fog
#

When 42.13 works, your mod is already loaded right ?

merry grove
#

It was loaded a new

#

I tried it

bright fog
#

If you swap to 42.12 then your game tries to load a mod that doesn't exist

merry grove
#

No, becuse I reload it

bright fog
#

And ?

#

I don't see what this has to do with it

merry grove
#

fuck it I remove 42.13

bright fog
merry grove
#

SAME ISSUE

#

Its not 42.13 falut

#

It doesn't work without it either

bright fog
#

In your mod.info file, remove everything and only keep an ID (the same for both versioning folders) and a name

#

Also can you tell me which file this is please ? I'm going to make a suggestion to the devs

#

Because this is a common issue that keeps appearing and it could EASILY be avoided with proper error handling

merry grove
#

And after removing everything but id from mod info it doesn't see the mod

merry grove
#

It detects it doesn't have a name

#

hm now it worked

#

I cahnged nothing

#

One second

#

When I added rest of the file in now it fails

#

And its this file

#

Oh god

#

It was complaing about this

bright fog
#

😅

merry grove
#

becuse version MIn was 42
Instead of 42.0

bright fog
#

Told you it was something shitty

merry grove
#

How in the fuck that makes the Mod ID fail

bright fog
#

Because they don't make proper checks for mod.info files

#

So if something is wrong, it keeps throwing errors on the mod selector file

#

And it literally doesn't tell you what is wrong, or if it does it throws it anywhere

#

Do you think you could send me your whole console file of the issue appearing please ?

merry grove
#

Ah already replaced it becuse I restarted the game

bright fog
#

Yea figured no worries

merry grove
#

BUt this was the whole thing

bright fog
#

I want to check the whole console file to see if they throw earliers errors actually

merry grove
#

It did

#

I couldn't find it tough

bright fog
#

So if they have some error checking for wrong mod.info files

bright fog
merry grove
#

Yeah, there was one, btu I just couldn't find it in the console

#

WAs thinking it was the issue, but I just couldn't find the error

#

Despite it throwing it me in the little box below

#

Anyway I need to test if the mod works now, it is easy to recreate it tough, just make the version whole number instead of a float

merry grove
#

42.0 works 42 doesn't

bright fog
#

So it needs to be a float

#

"float" (not really a float in reality)

merry grove
#

Yeah I said you need to amke a it a whole number to recreate the error

bright fog
#

Ah ok

merry grove
#

But god dammit, if it can't read version minimum a thing that is a optional value it should just ignore it instead of crashing

#

the mod selector

bright fog
#

Does hotfix patches work in the versionmin and max ?

#

Like 42.12.3

merry grove
#

I think so

bright fog
#

Bcs every single time you have something wrong with your mod.info file it'll throw an error there

violet obsidian
#

so how should I fix it? Should I use another function instead of this one?

merry grove
#

You could wait one frame

frank elbow
#

So you know for the future, that means it doesn't exist

#

This error, I mean

merry grove
frank elbow
#

“attempted index y of non-table: null” = you're trying to do x.y where x is nil

merry grove
#

Yeah, I get that, the issue was just completly unrelated

#

Or suspected it was with the game not reading it

bright fog
lethal shard
#

So I want to make a mod that changes the player behaviour similar to the panic mechanic. Which guides and tutorials should I consult?
I‘ve made a few java mods for Minecraft and know a decent amount of python, so I‘m no beginner to coding

bright fog
#

ups

bright fog
#

Based on what you're trying to do it might not require the same tools

#

As for guides and tutorials, I suggest starting with the modding wiki (check pinned messages)

lethal shard
#

Well our fried group was messing around with ideas that it would be really funny if non-smokers were affected if a smoker uses a cig around them
And they don’t know that I know my way with a bit of code

bright fog
#

In what way should they be affected ?

#

Like cough ?

lethal shard
#

So coughing, which may lead to slower movement, sprint/run interruption, item dropping etc

#

Aciidental shooting

bright fog
#

You should be able to do fairly easily actually

#

Yea those are easy to do

#

What I suggest you do if you haven't already, is take a peak at the following wiki pages:

  • Modding - links to a bunch of resources
  • Lua (API) - general Lua Java interface
  • Networking - explains how to network player interactions
  • JavaDocs - lists available functions
#

Also for your code environment for PZ, the following wiki pages:

  • Visual Studio Code
  • Umbrella (modding)
lethal shard
#

Thank you, will do

winter bolt
#

maybe check if item is nil as well?

frank elbow
#

Would've noted that earlier but I was making food 😄

bronze yoke
#

afaik it's not a general issue with mod.info, most errors are handled

#

it's persistently always versionmin causing this issue

#

and it's exactly this mistake every time

lethal shard
#

I know there’s the template thingy, but I don’t know what files to add and/or remove

bright fog
lethal shard
#

I thought I did

#

Brb

mellow frigate
#

Anyone got suggestions on vanilla base functions I could use to draw "zones?" (rectangle ones like vanilla allows to draw animal zones) ? Everything I found about keyword "Zone" relates to some model concept while I just want the display client side. "Overlay" seems not the right keyword either.

bronze yoke
#

do you need these areas marked for some purpose or just the visual?

#

the animal zones are built on top of a framework for adding new zone types but i don't know how moddable it actually is since obviously the game only actually has one type

mellow frigate
#

I think of a colored overlay to apply to a tile, with some alpha if possible, extendable to any tile.

verbal yew
#

If I create an event in the client folder with a local function that performs a check every hour—for example, adding a trait to the player over time—and once this player has gotten the trait, they no longer need this check event. Can I remove this event? Will it continue to run for other players? This is client-side, right? Or does it not work that way?!

mellow frigate
lethal shard
outer crypt
#

Is it possible to set an icon for a recipe that shows the "?" icon?

tropic cypress
#

Hi guys, stupid question.

I want use setCustomPages(HashMap<Integer, String>) of Literature item, but with this kind of map, java complains because is a kahluatableimpl object, not a HashMap:

local pages = {
    [1] = "Day 1: Some text",
    [2] = "Day 2: Some text",
    [3] = "Day 3: Some text"
}

How could I convert the lua table to HashMap?

I tried to configure the 3 pages of text with this alternative code:

        item:addPage(1, "Day 1: Some text")
        item:addPage(2, "Day 2: Some text")
        item:addPage(3, "Day 3: Some text")

But only the first page is shown, probably an error in my item definition?

    item Document
    {
        ItemType = Normal,
        DisplayCategory = Memento,
        DisplayName = Document,
        Icon = Notebook,
        Weight = 0.2,
        Pages = 5,
        CanBeWrite = true,
    }
lethal shard
#

So I want to start a function once a player uses an item, in my case a cig. how do I do that? there's a lot of events in the Lua docs, but I could't find one that triggers on item use

bright fog
#

Actions by players are handled with timed actions

exotic wren
#

Hello wastelanders catOwO
I want to ask when could i expect, in a rough ballpark, how much commissioning a modder would typically range? I have something that i have been wanting for a while, and i have recently started jotting down ideas.

bright fog
exotic wren
#

That makes sense. It would probably be just a bunch of items. No modals, or atleast they could all be the same tiny 3d modal.
Here is the first bit i have written down:

I have been wanting to commission a mod for a while. Implants and cybernetics.
some notes in no order:
-made with electronics skill
low tier cybernetics level ~5
can be found in military zeds and poi
High tier only craftable level ~9

Perhaps some pros and cons for each implant. Or only for the low tier ones.

outer crypt
#

banging my head on the skillbook update... The recipes work and the book loads but it does not show the recipes in the book nor can you learn from it. Do the recipes and the book need to be registered?

wraith fable
#

Oh yeah, I'll drop these here. Notes I made to help me get started modding.

#

By the way, the context is that I was researching how to make a mod that will allow me to turn all metal into an "iron" item, and then use that iron item to make all metal things. So I needed recipes to smelt (deconstruct) items and to smith (construct) items. I got the idea when I realized we had the Advanced Crafting Core mod, but it just adds the ability to use these tables for more modding, they themselves don't have a use.

That was really cool by that modder. https://steamcommunity.com/sharedfiles/filedetails/?id=2923979345&searchtext=advanced+crafting+core

tropic cypress
#

@wraith fable thx so much!! ❤️

wraith fable
#

You're welcome!

bright fog
#

Also if you don't know about it, check out the modding wiki and the Scripts page

#

If you want to contribute with some information, feel free to add those there

verbal yew
#

how can I get the first stage of the overweight (from items in inventory) moodle? (meaning a check for its presence)

tight elm
tropic cypress
#

sorry guys, what would be the folder to save a custom json file? common/media/name_of_folder?

outer crypt
wraith fable
lethal shard
icy night
#

Anyone know of any reason that I shouldn't "override" a vanilla occupation like this: character_profession_definition base:burgerflipper { CharacterProfession = base:burgerflipper, Cost = 0, UIName = UI_prof_cannibal, UIDescription = UI_profdesc_cannibal, IconPathName = prof_cannibal, }

#

It works, just wondering if anyone could think of any unintended consequences

bright fog
#

I think it should be fine ?

tropic cypress
# bright fog A json file ? What for ?

I'm working in a narrative quest mod, this an example of json what I need to config the scenario:

{
  "id": "campaign_0001",
  "title": "The Disappearance",
  "description": "Your sister has stopped answering.",
  "steps": [
    {
      "id": "step_1",
      "type": "note",
      "text": "The laboratory was evacuated last night."
    }
  ]
}

I want load it with getModFileReader("NarrativeCampaigns", "media/campaigns/campaign_0001.json", false) but the engine can not find it

bronze yoke
#

looks right to me, it might not like the leading /?

tropic cypress
#

sorry, my mistake, my code does not include it

bronze yoke
#

oh, build 42? your mod id needs to be prefixed with \\

tropic cypress
tropic cypress
#

thx @bronze yoke !! that fixed the error! 🙂

verbal yew
# bronze yoke oh, build 42? your mod id needs to be prefixed with `\\`

hi, do u know how in b42 i can do something like that:

craftRecipe ChmTakeBloodForNextWork {
        LabSyringe/LabSyringeReusable=1,
        AlcoholedCottonBalls,
        Result:CmpSyringeWithBlood=1,
        RemoveResultItem:true,
        Sound:zReVAC2_Mixing_D_2,
        Time:120.0,
        Category:Chemistry,
        CanBeDoneFromFloor:False,
        NeedToBeLearn:True,
        OnCreate:LabRecipes_ProcessBloodForAnalysis,
        OnGiveXP:LabRecipes_GiveXP_Doctor_1,
    }

like RemoveResultItem:true?
or now i can't predicate result item?

bronze yoke
#

just don't add a result

verbal yew
bronze yoke
#

outputs are optional in craft recipes, if you don't want a output just don't specify one

verbal yew
#

ah, don't need it

verbal yew
# bronze yoke outputs are optional in craft recipes, if you don't want a output just don't spe...

can u help me with this stuff:
craftRecipe FireHardenSpear
{
time = 100,
NeedToBeLearn = true,
OnCreate = RecipeCodeOnCreate.fireHardenSpear,
OnTest = RecipeCodeOnTest.openFire,
Tooltip = Tooltip_Recipe_OpenFire,
Tags = InHandCraft;Survivalist,
category = Weaponry,
timedAction = SharpenStakeWood,
AutoLearnAny = Spear:6,
xpAward = Carving:5,
inputs
{
item 1 [Base.SpearCrafted] flags[Prop2],
item 1 tags[base:sharpknife;base:meatcleaver] mode:keep flags[Prop1;IsNotDull;MayDegradeLight],
}
outputs
{
item 1 Base.SpearCraftedFireHardened,
}
}

i can't find RecipeCodeOnTest.openFire
can u send it from java?

marble marten
#

If I were making a mod and needing assistance, would this be the right channel or would #mod_support be more appropriate?

bronze yoke
#

this is the place but i don't know if i should be helping the cogs

dark vault
#

Hi guys, first time modder here!
I'm trying to make a Nailgun tool/weapon for B42.13.
So far i got it to shoot and i registered nails as a new AmmoType, but as soon as i shoot, i get an error, the game turns back and puts me at the main menu.

#

i tried looking at console.txt and other log files but i cant really find any errors

bronze yoke
#

try searching for STACK TRACE

dark vault
#

yea there is none this time

#

it seems...

#

before i was able to fix the issues by looking at the error...but this time im kinda stumped

bronze yoke
#

try 'exception'?

dark vault
#

''ERROR: General f:2344, t:1767585517351> ExceptionLogger.logException> Exception thrown
java.lang.NullPointerException: Cannot read field "projectileRed" because "isoBulletTracerEffectsConfigOption" is null at IsoBulletTracerEffects.createEffect(IsoBulletTracerEffects.java:204).''

bronze yoke
#

that'll be it, i remember someone talking about this before but i don't remember what the solution was

dark vault
#

ahhh

#

do you remember if it was in this channel?

bronze yoke
#

it was either here or the modding discord

dark vault
#

i'll have a look here

#

found someone mentioning this projectileRed field, but no solution

#

what files should i look through if i wanna find the source of the error?

broken fulcrum
#

no matter what i do....

#

i have even tried looking at other structures and still it wont work

broken fulcrum
#

is the new version [42] workshop uplaoder bugged?

thorn bane
#

@broken fulcrum I had a similar issue, I recall that I just moved the mod.info around until it worked lmao

#

Lemme check someth rq

broken fulcrum
thorn bane
#

@broken fulcrum Make sure you've got your mod.info in your Common and 42.12 file as well (or 42.13 if you're developing for MP as well)

#

So in short;

Zomboid/Workshop/Contents/mods/[MOD NAME HERE]

#

then you would have;

  • common/ (Your main folder, required)
  • all the other versions for B42
#

Make sure you have a mod.info in your common and alternative builds

bronze yoke
#

to be more specific, it needs to be in either common or all of your version folders, both is redundant and the one in common won't be used

thorn bane
#

hi albion HIII

#

ty for your work on the wiki, it's been very useful :D

broken fulcrum
#

omg it worked

#

lol

#

i feel so stupid

thorn bane
#

that's part of the job :P

#

oh sweet i finally got the axe

bronze yoke
thorn bane
#

is there a way to stop a player from dropping/transferring an item from inventory? trying to make a mod where an item needs to stay on the player

thorn bane
lethal shard
winter bolt
tropic cypress
#

Hi! 👋 what is the most effective way to reset lua scripts & items without exit to the main menu?

red wren
#

📖📖📖 Hi everyone -- I'm trying to mod in some custom literature -- I take it a lot of say magazines titles are made with ItemCodeOnCreate.onCreateSubjectMagazine -- unfortunately I can't find the details of this function -- Ideally I would like to make my own book subject -- and within that subject set a bunch of randomly defined titles/descriptions etc

tropic cypress
bright fog
# tropic cypress thx!

You can hot reload scripts but I'm not sure how good it is, and you can hot reload Lua but it involves writting your code by respecting some rules

red wren
frank elbow
main pasture
# red wren Do you mean decompiling the game code?
public static void onCreateSubjectMagazine(InventoryItem item) {
    Magazine magazine = item.getMagazineSubjects().isEmpty() ? (Magazine)Rand.Next(Registries.MAGAZINE.values()) : (Magazine)Rand.Next(Magazine.getMagazineBySubject(item));
    setMagazineName(item, magazine.translationKey(), Translator.getText(magazine.translationKey()), getDate(item, item.hasTag(ItemTag.NEW) ? 1993 : 1970));
}``` from scripting/logic/ItemCodeOnCreate.java
red wren
#

Ah ok -- I think the functionality I am after is bit too low level for my comfort -- I don't suppose its possible to patch an equivelant "e.g. onCreateSubjectFantasyNovel" at the higher lua level?

main pasture
#

I don't know about creating custom literature, but that seems to be the function triggered by OnCreate of the item, so you can just create similar function in lua and call it the same way. Have you checked if you actually need a new fuction for it, or can you just add them using the vanilla system?

summer osprey
# thorn bane <@1230020610697203812> Make sure you've got your mod.info in your Common and `42...

im having this same issue, no matter what i do the mod.info file isn't detected despite recognizing it when i first uploaded the mod to the workshop :(( originally i had to move the info file in and out of the common folder for it to work, however even doing that now it's still seen as being missing

is there something wrong with my branching? each and every version file has the same contents as the one shown in the third screenshot

sorry if im missing something obvious!!!!! <3 i'd appreciate any help

knotty stone
#

That 42.12 and other version folder is wrong, has to be like common in you folkpunkpz

summer osprey
#

im currently on 42.13.1, the 42.13 folder should work this version right?

knotty stone
#

Yes

thorn bane
#

leave it empty and restart

#

its 2:15 AM over here, i hope my idea works @summer osprey otherwise you are welcome to slay me in my sleep

summer osprey
hallow grotto
#

is there a list on how to write item and crafting definations?

bright fog
bright fog
summer osprey
bright fog
#

Your versioning folders are in the wrong folder, and also you're missing a common folder

#

It's mandatory

summer osprey
#

oh thanks! i didn't see that the versions folders were supposed to go in the mod folder, it works now :3

trim yacht
#

Is there a way to post a message from the system or server so that the discord bot will pick it up? Bonus points: even when a player isn't logged in? Use case is for posting about server restarts which may happen even if there isn't a user on

crystal terrace
#

Or a script that does the same thing on restarts. Create a webhook in one of the channels and trigger it from there.

trim yacht
crystal terrace
#

Ah mb

trim yacht
verbal yew
#

what's mean mode:mixture into craftRecipes?
-fluid 0.75 categories[Water] mode:mixture,

crystal terrace
hallow grotto
#

I uhh, have literally no idea what is going wrong here
I am trying to add some items into the game with a mod, but it is not working

#

I then open the item spawning, this menu pops up instead

tranquil kindle
#

Seems the mod is not updated to 42.13 and have its Type changed to Itemtype?

hallow grotto
#

oh that is probably why

#

I was following the wiki

tranquil kindle
#

Its your mod OR already existing mod

hallow grotto
#

existing, apparently it does not work for some reason, and it is fairly small

hallow grotto
broken fulcrum
#

HI! does anyone know anymods where you can set starting items or like kits? im trying to find one and really dont want to build one if theres already one out there

thorn bane
frank elbow
thorn bane
#

Wait, I’m thinking server options

#

My bad

#

ty for the correction omar groove

frank elbow
#

Ah right, SpawnItems—I thought something like that existed too but I couldn't remember

scenic glade
#

I am not sure if this is the right channel (or even discord) to ask, but is there a good place to ask someone to help/make a rather specific but easy mod for B41?

low vapor
#

Anyone know where I can find the projectzomboid.jar? I've been trying to compile one of my java scripts but I cannot for the life of me find it.

bright fog
low vapor
#

Bearing in mind, I'm on B41 so I'm not sure it's actually here?

bright fog
#

Ah

#

There's no .jar

low vapor
#

So I can't compile java scripts in B41?

bright fog
#

Of course you can

#

Tho unsure the exact steps

#

I think you need to make that .jar

low vapor
#

Does anyone here have that jar?

#

I'll even take a B42 one at this point, I just want to compile this java

bright fog
low vapor
bright fog
low vapor
#

It does?

bright fog
#

I think so yea

low vapor
#

mine didn't seem to do that when I ran it, just said it couldn't find the jar

low vapor
#

Yeah...

bright fog
#

The Zomboid Decompiler ?

frank elbow
#

You can use an older version of ZomboidDecompiler

#

Check the README on the GitHub page

low vapor
#

Yes, it says

#

ah

#

leme give that a go

frank elbow
#

If you're just trying to compile idt you necessarily need to decompile, although I'm curious as to what you're doing if you wrote Java without having decompiled first

low vapor
#

I'm hoping to be able to show it off very soon!

frank elbow
#

The game won't have a way to just load it unless you tell it to, which is its own thing unless you're using a loader

#

Alright, I'll trust you know what you're doing then lol

frank elbow
stuck tapir
#

What, if anything, needs to be included in a mod in order to add a crafting recipe other than a script for the recipe itself?

bright fog
#

Besides custom items if that's what you want to make

stuck tapir
#

Nope, just trying to add a new recipe to take apart a common item. Is it better to make a separate script file for the new recipe or just append it to the existing recipes.txt?

bright fog
#

You shouldn't do anything like that, you should always make your file

stuck tapir
#

Okay, I figured as much. Thanks!

marble marten
#

Hello everyone, I've only made one mod and it's just a zombie texture. Needing help on where to get started on making modded outfits.

I just need to make zombies, or a vast majority, spawn without clothes. It's for a 28 years later modpack I'm making.

tired glen
#

I decided to overwrite the challenge scenario for the last stand accumulator and just ignore the fact that vanilla saves won't be able to do anything with it
however now i am presented with the challenge of what weapons i want to make available for purchase, and what levels i should make the skills so it's more fun than killing 64 zombies with level 3 axe

winter bolt
#

im assuming it removes the outfit tables but ive not looked at the code

winter bolt
#

save this as a .lua file with a unique name in media/lua/shared in your mod

marble marten
winter bolt
#

with that exact name

marble marten
# winter bolt with that exact name

Okay, so this is what I added to my clothing.xml file, I'm just testing it with females zombies atm:

<m_FemaleOutfits>
<m_Name>28Years</m_Name>
<m_Guid>eb2209fa-81d3-4083-95f2-449ab185b682</m_Guid>
<m_Top>false</m_Top>
<m_Pants>false</m_Pants>
<m_AllowPantsHue>false</m_AllowPantsHue>
<m_AllowTopTint>false</m_AllowTopTint>
<m_AllowTShirtDecal>false</m_AllowTShirtDecal>
</m_FemaleOutfits>

Loaded into game and the females appear to still be clothed, is there a part of the code where I have to specify no clothing?

winter bolt
#

idk if the code actually works though

marble marten
#

I found the mistake, I didn't rename the .lua file to ZombiesZoneDefinition, I gave it a random name mistakingly.

Loaded back in, both the male and female zombies are spawning in missing a lot and sometimes all of their clothing, but a majority are still wearing random shirts, underwear, bras, etc

marble marten
#

As of now, this is how they're spawning

bright fog
marble marten
winter bolt
#

there's a separate script that spawns underwear but idk why there are clothes zombies in that screenshot

silent zealot
# marble marten No your code did work, it was my bad. I'm wondering if there is a special GUID f...
    <m_MaleOutfits>
        <m_Name>Naked</m_Name>
        <m_Guid>836531ac-7e02-4ede-8545-5ac987df51ba</m_Guid>
        <m_Top>false</m_Top>
        <m_Pants>false</m_Pants>
        <m_AllowPantsHue>false</m_AllowPantsHue>
        <m_AllowTopTint>false</m_AllowTopTint>
        <m_AllowTShirtDecal>false</m_AllowTShirtDecal>
    </m_MaleOutfits>
    <m_FemaleOutfits>
        <m_Name>Naked</m_Name>
        <m_Guid>836531ac-7e02-4ede-8545-5ac987df51ba</m_Guid>
        <m_Top>false</m_Top>
        <m_Pants>false</m_Pants>
        <m_AllowPantsHue>false</m_AllowPantsHue>
        <m_AllowTopTint>false</m_AllowTopTint>
        <m_AllowTShirtDecal>false</m_AllowTShirtDecal>
    </m_FemaleOutfits>
#

It's just a regular outfit with no clothes in it.

#

But! there is also this in Java...

#

Look into media/lua/shared/Definitions/UnderwearDefinitions.lua and decompiled java zombie/characters/UnderderwearDefinition.java to fiugure out what is going on and if you can modify the UnderwearDefinition lua table to get rid of underpants. Might be enough to just do

UnderwearDefinition.baseChance = 0
marble marten
silent zealot
#

no no no

marble marten
#

Oh

silent zealot
#

don't paste that into your clothing xml, it's already a vanilla outfit

#

If you want naked zombies, you can spawn those

#

But underwear gets added separately, so make a lua file in a shared with just

require "Definitions/UnderwearDefinitions"
UnderwearDefinition.baseChance = 0

and see if that stops underear items from being added. (it will throw an error if it loads before the vanilla definition file, butthe require line shoudl avoid that.)

marble marten
#

I got the underwear working thankfully

#

I do have a code I'm trying to use to make it only spawn naked zombies from vanilla like you said but it doesn't seem to be working

#

this is what I have

#

1 moment

#

for zoneName, zoneTable in ZombiesZoneDefinition do
ZombiesZoneDefinition[zoneName] = {{name = "naked", chance=100}}
end

#

This is in my ZombiesZoneDefinition.lua

silent zealot
#

So you want to remove everything in the vanilla table and just have naked zombies?

marble marten
#

Yes sir/ma'am

#

Sadly the above code did not appear to work. Having tested just now, about 60-70% of zombies were fully naked, but I still got a lot of shirts/pants/occasionally whole outfits on my zombies.

#

For reference. Progress has definitely been made though.

silent zealot
#

I think your lua is slightly wrong and is no replacing teh table entries properly, just a minute...

#

I can't test anything because my half-update broken mod is killing the entire game...

#

But I think you want to do for i,v in ipairs(table) to start...

#

This is actually one of the situations where Chat GPT is good. Tell it "I have a lua table like this (paste sample) and I want to iterate through and change teh content of every entry to this (paste example location with 100% naked)

#

It might not understand zomboid, but it's learned a lot of basic syntax for common languages. (And I assume any other LLM will do a simialr thing)

marble marten
#

Thank you! I will update on what GPT says.

#

I was trying to use Gemini earlier to make all zombies spawn with specific hair models but unfortunately that went nowhere.

tropic cypress
#

Hi guys! 👋 I'm trying use i18n, but it seems not work. I have a media/lua/shared/Translate/EN folder, with a Campaign0001_EN.txt file with this content:

Campaign0001_EN = {
    Campaign0001_Step001.Scene001.say = "Where is Emma?"
}

And try to use it with: player:Say(getText("Campaign0001_Step001.Scene001.say")), but translate not work and Campaign0001_Step001.Scene001 is said instead

Probably I'm using it in a wrong way :/

mellow frigate
tropic cypress
#

I'll try!

#

I tried with this key: Campaign0001_title = "The Disappearance" and this sentece: player:Say(getText("Campaign0001_title")) but it doesn't work 😕

tropic cypress
#

player is telling: "Campaign0001_title" on screen, insted "The Disappearance", seen something about translation 🧐

verbal yew
#

try change translation file Campaign0001_EN.txt => IG_UI_EN.txt
and contain
IGUI_EN = {
IGUI_Campaign0001_title = "The Disappearance"
}

#

@tropic cypress IGUI_Campaign0001_title = "The Disappearance"

tropic cypress
#

Damm it 😓

verbal yew
#

wata...

#

full game reload? or in debug mode LUA reload?

tropic cypress
#

That's my structure:

└───Contents
    └───mods
        └───NarrativeCampaigns
            ├───42
            │   └───media
            │       ├───campaigns
            │       ├───lua
            │       │   ├───client
            │       │   ├───server
            │       │   └───shared
            │       │       └───Translate  
            │       │           ├───EN     
            │       │           └───ES     
            │       └───scripts
            └───common
                └───media
                    └───campaigns

And IGUI_EN.txt:

IGUI_EN = {
    IGUI_Campaign0001_title = "The Disappearance"
}

and IGUI_ES.txt:

IGUI_ES = {
    IGUI_Campaign0001_title = "The Disappearance"
}

And the sentence: player:Say(getText("IGUI_Campaign0001_title"))

tropic cypress
#

i'm going to try with game reload

verbal yew
#

IG_UI_EN.txt
IG_UI_ES.txt

only contain IGUI_EN IGUI_ES

idk why but its working

verbal yew
tropic cypress
#

no! it doesn't work!! omg :/

verbal yew
#

vanilla files

tropic cypress
#

another try!

#

it works!!!!!

#

THANKS @verbal yew !

#

I would like use more than one translation file, one per campaign, but this is a fantastic point to study how, thanks! ❤️

merry osprey
#

Dear modders. Is it possible to make a mod where the player can control thier zombie self when they die? Or.. a way for an admin (or something) to become a playable zombie.

Not asking for someone take on this endeavor bug has anyone ever tried? Is this an impossibility?

verbal yew
winter bolt
#

wait im stupid i forgot about pairs

#

mb lmaoo

winter bolt
#

this should actually work

silent zealot
#

Something like that, but I'm in "stupid tired and should be in bed instead of stubbornly trying to fix this mod for multuiplayer" mode and lua array quirks annoy me when I'm well rested.

winter bolt
#

yeah i just did some python coding the last few weeks so i forgot how lua table loops work

winter bolt
silent zealot
#

My ChatGPT is full of stupidly easy questions like "how do I iterate through this thing in pythin" because I know there is an easy way to do it but damned if I can remember the syntax

merry osprey
silent zealot
#

I modded Zomboid so much that all it does now is plays Ping-Pong.

#

I feel like giving up on making this stupid thing work in multiplayer and just renaming it "multiplayer Ping-Pong roguelike"

merry osprey
#

Sounds like you need to address your mods addiction lol

merry osprey
verbal yew
silent zealot
#

This is mod_development, so the default assumption is people here are wanting to develop mods.

#

Which affects the way questions like "is X possible" get responded to

marble marten
#

@silent zealot I got it to work, thank you for all of your help!

silent zealot
#

Hooray! Naked people! Hundreds of them, all coming to hug me!

marble marten
#

Like 1 in 20 zombies will spawn with a shirt but honestly that's fine. I like to think those infected are "more fresh"

silent zealot
#

Or they had better quality shirts.

marble marten
#

Now I need to make a mod that modifies the zombies' sounds 😈

silent zealot
#

Make those shirts the currency on your multiplayer server.

marble marten
#

lol I might have to

mellow frigate
bright fog
#

It's the best method

#

It's the one I use in TLOU Infected and it works amazingly

verbal yew
#

Will this construct work?

function LabRecipes_LabResearchToVaccineTo2lvl(craftRecipeData, player)
    local result = craftRecipeData:getAllCreatedItems():get(0);
    remove(result)
end
#

I have three outputs
{
item 1 zReLabItems.bkNotebookVaccine2,
item 2 zReLabItems.LabFlaskDirty,
item 1 mapper:itemType,
}
and want to delete the first one and use the function to add another item, depending on the conditions

tidal shale
#

hello, i need help finding the current textures in project zomboid, where can i currently find all of them?

#

i found a few in media/textures, but not all of them

bright fog
bright fog
#

That returns an array list

#

So you need to use array list functions to remove an entry

bronze yoke
# mellow frigate <@119473430289448961> Since all that time, I follow blindly that thread's advice...

yes, these are mostly accurate: i would note however that some of these are very small performance saves are only worth using in very performance sensitive code as they reduce readability

the only one i think is wrong is the concatenation one due to flawed testing method, a .. b .. c .. d .. e .. f may be faster in performance tests, but it creates a new string for each .., which will all end up needing to be garbage collected, so it may actually make performance worse but since garbage collection happens at a random time later, the impact of this does not usually appear in performance tests. string.format and table.concat both avoid this: use string.format if the number of strings concatenated is the same every time, use table.concat if you would otherwise need to use a loop. use .. when you don't care or you're only concatenating one string

also since it doesn't mention this: while table.insert should not be used to add to the end of a table (even the lua manual recommends against this), when you need to insert into the middle of a table and shift elements up, it is the fastest way to do this

in particular, these are the ones i don't find worthwhile except when absolutely necessary to save performance:

  • caching class functions: this hurts readability, you call them very differently to usual, it is a very small performance save
  • caching globals: honestly there is no downside to doing this, but i don't bother because it's a very small performance save
    • both of these save around 20% of the cost of the call, but calls are very cheap, so it's 20% of a very small number. if you call the same function many many times (such as in a loop) then it may add up to a decent performance improvement, but generally it doesn't end up making any real impact
  • math.pow wastes performance for no reason and is straight up deprecated, but x ^ 2 vs x * x does not have a significant performance difference and the former usually conveys intent better

basically, do not waste your time micro-optimising code that does not need it, all you will be left with is harder to read code that doesn't actually behave differently. performance issues are usually caused by poor design and not small inefficiencies like these

verbal yew
bright fog
#

Yes

#

Wait

#

You're doing that during OnCreate ?

verbal yew
bright fog
#

You should not do that

bronze yoke
verbal yew
verbal yew
bright fog
verbal yew
bright fog
#

Well

#

No you'll remove it from the whole recipe

#

Not just the one being achieved

bronze yoke
#

i don't think that's true

bright fog
#

You think it makes a copy ?

#

That sounds weird

bronze yoke
#

CraftRecipeData represents data for that particular time crafting

#

you use it to identify the specific items that were spawned, how could it not be a copy

bright fog
#

Oh wait no yea

#

I think I confused for the class that holds the recipe data

verbal yew
#

it's mean all ok?

bright fog
#

yea mb

verbal yew
#

okay, thanks

tidal shale
#

can someone help me find the textures of the items?

verbal yew
#
function LabRecipes_LabResearchToVaccineTo2lvl(craftRecipeData, player)
    local result = craftRecipeData:getAllCreatedItems():get(0);
    result:getContainer():DoRemoveItem(result) 
end
drifting current
#

WIP peek at next week's new Coco's Domestics & Imports car.

umbral sonnet
#

good day all. I'm looking into building a mod that will create a local websocket server that can be accessed by another locally running service. Is this something that is possible without having to crack open the jar file?

grizzled fable
#

Is there an option in recipe script like the old Obsolete=true, on the 42?

umbral sonnet
flat root
#

how to get my mod to show in the select mods menu? I need to test it and make sure it looks good, it's just a clothing mod if that helps

quartz ibex
#

A quick Google shows pegasus and milua as rest apis to work with in lua. 🤷‍♂️

#

I guess the real question is, what kind of data are you looking to get or interact with?

#

To note, I'm new to modding PZ, and anything I say or suggest is speculation

umbral sonnet
#

I'm new to modding PZ as well and not familiar with Lau. I want to build an admin server to be able to interact remotely. Like Rcon on steroids

#

I looked at extending Rcon but it's closed off to Lua so I would need to patch the java class

quiet glacier
hallow grotto
#

am getting this error for my mod for when attempting to craft on a DS test server(it crafts fine on singleplayer) but cannot determine what is going on, everything seems to be fine

#

wait, does the recipe module has to be "Base" ?

#

That could be it

#

nope that did not wor

tidal shale
umbral sonnet
#

could it be in world items?

tidal shale
#

Oh the clothes? Man I must be dumb

#

That's all I needed to know, thanks

hallow grotto
willow tulip
#
function replaceRecipeOutput(recipeName,targetLine,newLine)
    local recipe = getScriptManager():getCraftRecipe(recipeName)
    if recipe == nil then
        DebugLog.log("Could not find recipe " .. recipeName);
        return
    end
    local outputs = recipe:getOutputs()
    local foundLine = false;
    for i=0, outputs:size()-1 do
        local output = outputs:get(i)
        if string.find(output:getOriginalLine(), targetLine) then
            outputs:remove(output)
            foundLine = true
            recipe:Load(recipe:getName(), "{ outputs { ".. newLine .. " } }")
            break
        end
    end
    if not foundLine then
        DebugLog.log("Could not find targetLine " .. targetLine);
    end
end
#

it was called like: replaceRecipeOutput("MakeImprovisedGasMask","Base.Hat_ImprovisedGasMask_nofilter","item 1 Base.Hat_ImprovisedGasMask,");

#

(you can delete the recipe:Load line to have it delete instead of replace)

verbal yew
willow tulip
#

RemoveResultItems is a tag?

#

Oh, so it shows a result in the recipe.

#

but thats not what you get, neat.

verbal yew
#

but it what i need

bronze yoke
#

RemoveResultItems simply is not a thing in b42, the new recipes are designed to avoid the usecases for it

#

or actually i see a recipe that uses it so i guess it is a thing

#

but this vanilla recipe that has a random result (most similar thing to what you're doing) just doesn't have an output at all:```
craftRecipe OpenUnlabeledCan
{
time = 80,
timedAction = OpenTinCan,
OnCreate = RecipeCodeOnCreate.openMysteryCan,
Tags = InHandCraft;Cooking;CanBeDoneInDark,
category = Cooking,
inputs
{
item 1 tags[base:canopener] mode:keep flags[MayDegradeLight],
item 1 [Base.MysteryCan] flags[Prop2;DontPutBack],
}
outputs
{
}
}

verbal yew
verbal yew
bronze yoke
#

yeah i found code for it, don't worry should work

verbal yew
silent zealot
#

You mean to add a new clothing slot?

verbal yew
silent zealot
#

that adds a new slot, then changes an existing item to use it. You could also add a new item using the new slot.

#

If display order matters, BodyLocationGroups:moveLocationToIndex() is the way to move a slot to a specific position.

#

(Assuming B42.13+)

verbal yew
silent zealot
#

For layered textures, that's the secret.

#

It was done differently pre-42.13.1 but now you can add a new slot for clothing and move it via an API command instead of getting an ArrayList and manipulating it directly.

silent zealot
#

Learn which - pre 42.13, 42.13 or 42.13+?

verbal yew
#

42.13+

silent zealot
#

Definitely better than old methods!

bronze yoke
#

there's no need to learn the 42.13.0 method anymore, you can't downgrade to that version easily

silent zealot
#

That's the java function (javadocs are not updated for 42.13.1)

silent zealot
bronze yoke
#

well 42.13.1 wiped saves too, but there's no steam beta for 42.13.0 to return to and 42.13.1 didn't break mods

verbal yew
#
if group:getOrCreateLocation(ItemBodyLocation.SHOULDERPAD_LEFT) then -- true
  --nothing
   else
  group:getOrCreateLocation(ItemBodyLocation.SHOULDERPAD_LEFT)
end
#

?

#

so as not to create duplicates or it doesn't matter?

silent zealot
#

no need, it gets OR creates.

#

So it won't make duplicates.

verbal yew
#

ah, yea

marble marten
#

I'm trying to make zombies spawn exclusively with a certain amount of hair/beard types but I don't appear to be having any luck, not sure if I put the code in correctly:

local zoneKeys = {}

-- Collect all zone names safely
for zoneName in pairs(ZombiesZoneDefinition) do
zoneKeys[#zoneKeys + 1] = zoneName
end

-- Replace spawn lists
for i = 1, #zoneKeys do
ZombiesZoneDefinition[zoneKeys[i]] = {
{ name = "naked", chance = 100, beardStyles="Long:20;Chops:10;Goatee:10;Moustache:10;Full:10;BeardOnly:10", maleHairStyles="Bald:10;BaldSpot:5;Donny:10;Fabian:10; Grungey:10; LongBraids:10; LongerBraids:15; MohawkFlat:10; Mullet:10" }
}
end

#

For the number values next to the styles, could I make all of them 100 to guarantee their spawns?

winter bolt
#

because im not sure if lua table iterators work like this for zoneName in pairs(ZombiesZoneDefinition) do

winter bolt
#

so i guess just make sure they all add up to 100

marble marten
winter bolt
#

oh i guess that does work then lol

#

i cant really find any info on it but i guess that format still works and just gives you the key then

marble marten
#

I made the values all equal 100 and they're still not spawning with the proper beards/hair

I'm honestly confused because I used another mod for reference and framed the code the same way they did.

#

But the naked part of the code appears to be working properly.

winter bolt
#

maybe the spaces after the ; in some of them is messing it up?

#

yeah i looked again and it seems like the space in the names would mess it up

#

maleHairStyles="Bald:10;BaldSpot:5;Donny:10;Fabian:10;Grungey:10;LongBraids:10;LongerBraids:15;MohawkFlat:10;Mullet:10"
should work i think?

#

tbh this hair and beard outfit stuff has always been mega scuffed to me so im not surprised its breaking but i dont see anything else that would cause it

#

@marble marten after looking more im fairly sure the spaces are the issue

#

the game will try to assign the hair name with the space at the start to the zombie, find that the name doesnt exist in the hairstyles list, and then use a random hairstyle instead

marble marten
#

Got rid of the spaces and still no luck it seems.

I'm wondering- do I need to delete the space between the " and the } at the end?

-- Replace spawn lists
for i = 1, #zoneKeys do
ZombiesZoneDefinition[zoneKeys[i]] = {
{ name = "naked", chance = 100, beardStyles="Long:30;Chops:10;Goatee:20;Moustache:10;Full:20;BeardOnly:10", maleHairStyles="Bald:10;BaldSpot:10;Donny:10;Fabian:15;Grungey:10;LongBraids:10;LongerBraids:15;MohawkFlat:10;Mullet:10" }
}
end

#

I'm wondering if replacing the ; with commas would fix it

winter bolt
#

and the space after " doesnt matter

#

im not sure why its breaking then

#

if you try it with just one hairstyle set to 100 does it still break?

marble marten
#

I can give it a shot

#

maleHairStyles="Bald:100;BaldSpot:0;Donny:0;Fabian:0;Grungey:0;LongBraids:0;LongerBraids:0;MohawkFlat:0;Mullet:0" }

Zombies still spawning with various hairstyles. So I'm wondering if I need to put this code somewhere else possibly?

#

I was trying to use ChapGPT to fix the issue last night and it made it worse- the code it gave me made my game crash but thankfully I made a backup of my original script.

verbal yew
#

How do armor elements work currently? Is it javacoded?
Or can this be checked somewhere in Lua?
I just don't see any "durability" characteristics in the protective clothing parameters...

bronze yoke
#

they break when a zombie pierces them, they don't have durability

#

they're either broken or not

#

it uses regular clothing holes, if it rolls a block, nothing happens, otherwise it gains a hole in that location and the next piece of clothing rolls

verbal yew
#

or not?!

verbal yew
bronze yoke
#

no, it depends on the protection value

#

if it's 100% it'll never break

#

if it's 95% it'll break 5% of the time (so it could break on the first bite, but on average will last a bunch)

verbal yew
#

In short, nothing has changed since build 41. The armor is still useless.

#

no adequate system of durability, protection class (relative to bites, scratches, hits from other players, shots from other players)

winter bolt
#

thats the right place to put the code i just dont understand why its not doing anything

#

so like do maleHairStyles="Fabian:100" instead

#

in a bit i'll test it myself and see if i can figure out anything

marble marten
#

Testing now, one moment

#

maleHairStyles="Fabian:100" }

#

Didn't appear to work either

verbal yew
#

dumping Lua stack trace Callframe at: getOrCreateLocation function: zReVAC2_BodyLocations.lua -- file: zReVAC2_BodyLocations.lua line # 12 | MOD: zRe Vaccine 3.0 ReMod by kERHUS

#

whats wrong here?

#

11 line load fine

#

java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at se.krka.kahlua.integration.expose.caller.MethodCaller.call(MethodCaller.java:58)
at se.krka.kahlua.integration.expose.LuaJavaInvoker.call(LuaJavaInvoker.java:194)
at se.krka.kahlua.integration.expose.LuaJavaInvoker.call(LuaJavaInvoker.java:184)
at se.krka.kahlua.vm.KahluaThread.callJava(KahluaThread.java:183)
at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:793)
at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:167)
at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1756)
at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1560)
at se.krka.kahlua.integration.LuaCaller.pcall(LuaCaller.java:69)
at se.krka.kahlua.integration.LuaCaller.protectedCall(LuaCaller.java:109)
at zombie.Lua.LuaManager.RunLuaInternal(LuaManager.java:1334)
at zombie.Lua.LuaManager.RunLua(LuaManager.java:1288)
at zombie.Lua.LuaManager.RunLua(LuaManager.java:1277)
at zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:1179)
at zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:1099)
at zombie.Lua.LuaManager.LoadDirBase(LuaManager.java:1215)
at zombie.GameWindow.init(GameWindow.java:1182)
at zombie.GameWindow.mainThreadInit(GameWindow.java:690)
at zombie.GameWindow.mainThreadStart(GameWindow.java:560)
at zombie.MainThread.mainLoop(MainThread.java:58)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Cannot invoke "Object.equals(Object)" because "this.id" is null
at zombie.characters.WornItems.BodyLocation.isId(BodyLocation.java:69)
at zombie.characters.WornItems.BodyLocationGroup.getLocation(BodyLocationGroup.java:32)
at zombie.characters.WornItems.BodyLocationGroup.setExclusive(BodyLocationGroup.java:71)
... 23 more
`

winter bolt
#

and then access them in the bodylocation script by doing zReVAC2.ItemBodyLocation.SHOULDER_LEFT

#

so

zReVAC2.ItemBodyLocation = {}
zReVAC2.ItemBodyLocation.SHOULDER_LEFT = ItemBodyLocation.register("zre:shoulderleft")
pliant cypress
#

Does anyone know how to fix build 42.13 mods

For example Guns maps and vehicles clothes

bright fog
rose hamlet
#

guys did someone make a mod what allows you to hug/kiss another player with his consent? and if not is it a good idea for the mod to create?

drifting current
#

Does anyone know how this number is changed/calculated for the UI? it seems to be changing when i change the power of the car in my script, but it's gone from 360 to 330 when i've changed the actual engine from 3600 to 1300.

cold skiff
# verbal yew `dumping Lua stack trace Callframe at: getOrCreateLocation function: zReVAC2_Bod...

try this.

zReVAC2BodyLocation = {}
zReVAC2BodyLocation.ItemBodyLocation = {}
zReVAC2BodyLocation.ItemBodyLocation.ZREVAC2SHOULDER_LEFT = ItemBodyLocation.register("zrevac2bodylocation:ZREVAC2SHOULDER_LEFT")
zReVAC2BodyLocation.ItemBodyLocation.ZREVAC2SHOULDER_RIGHT = ItemBodyLocation.register("zrevac2bodylocation:ZREVAC2SHOULDER_RIGHT")

--zReVAC2_BodyLocations.lua

require "BodyLocations"

local group = BodyLocations.getGroup("Human")
group:getOrCreateLocation(zReVAC2BodyLocation.ItemBodyLocation.ZREVAC2SHOULDER_LEFT)
group:getOrCreateLocation(zReVAC2BodyLocation.ItemBodyLocation.ZREVAC2SHOULDER_RIGHT)```
silent zealot
#

Someone will make a sex addon for it 5 minutes later. 😂

rose hamlet
#

ill try to make a mod like that someday, never tried modding on project zomboid :D

rose hamlet
silent zealot
#

Just do it from your main account, but make it a seperate steam workshop mod and leave hidden because they get really weird and the stupidest things

#

I had a mod removed because it added nipples as an option to spongies character creator, apparently that violates the "project Zombie Community Standards"

rose hamlet
#

i know its was a joke about being from alt account but ill keep it in mind :D

#

is there any way i can add custom anims to project zomboid?

willow tulip
silent zealot
#

Men's nipples are fine though.

rose hamlet
#

yo guys can anyone help me pls? i try to upload a mod to workshop via pz and it says it cant find an mod.info file

#

i used modtemplate to do everything as it should be but nothing really works

silent zealot
#

First: B41 or B42, And does the mod show up in your modlist and work for you?

rose hamlet
#

b42 and it doesnt show up on modlist, i put it in zomboid/mods and it doesnt show up

#

and i cant test this mod in sp cause its mp only

frank elbow
dull hornet
#

Hello, i'm Trying to fix my mod made for 42, It was working nice but visibly broke since 42.13 : I got a lot (in thousands) of
java.lang.NullPointerException: Cannot invoke "java.io.File.getAbsoluteFile()" because "file" is null at ZomboidFileSystem$PZFolder.set(ZomboidFileSystem.java:67).
I don't know if it refer to a missing "code source file" or if it triggered by one of my getTexture("media/textures/GUI/X.png")
my code didn't change since may
I tried an ugly copy pasta 42 > 42.13 directory, put my media/ inside common etc and i'm pretty lost 😅

Is there something specific who change during this update ?

drifting current
#

I got side tracked from developing my new car and ordered some Spiffo's instead.

mellow frigate
#

Hello there, anyone knows why IsoGridSquare.HasNoCharacters checks for barricades ? ```java
boolean HasNoCharacters() {
for (int n = 0; n < this.movingObjects.size(); n++) {
if (this.movingObjects.get(n) instanceof IsoGameCharacter) {
return false;
}
}

    for (int nx = 0; nx < this.specialObjects.size(); nx++) {
        if (this.specialObjects.get(nx) instanceof IsoBarricade) {
            return false;
        }
    }

    return true;
}
dark salmon
#

Hello, i would like to know how can i create the distribution script for my mod, i'm new to modding and i'm not sure to understande the pz wiki

true nova
true nova
marble folio
#

hey does anyone know if it's possible to have the corpses accessible through the recipes or is the only way to interact then through the context menu with lua?

I want to make a mod to harvest bones from the zombies but I can't get the Corpse Item to work, this is the recipe I'm trying:

module Base
{
craftRecipe Harvest Bones
{
time = 100,
Tags = InHandCraft;CanBeDoneFromFloor,
xpAward = Butchering:10,
category = Miscellaneous,
inputs
{
item 1 tags[base:sharpknife;base:meatcleaver] mode:keep flags[Prop1;IsNotDull;MayDegradeLight],
item 1 [Base.CorpseMale;Base.CorpseFemale],
}
outputs
{
item 1 Base.SmallAnimalBone,
item 1 Base.AnimalBone,
item 1 Base.LargeAnimalBone,
}
}
}

I can get the recipe working ingame but the Corpse Item just returns empty no matter if I have the corpse near me or if I'm carrying it

dark salmon
# true nova You want to add an item to the loot spawn?

Yes i want to add items to loot spawn i've done thing like that:

require 'Items/ProceduralDistributions'
require 'Items/Distributions'

-- On accède à la table existante sans l'effacer
ProceduralDistributions.list.ZazaSeeds = {
    rolls = 1,
    items = {
        "NLK.SativaSeed_Debug", 100,
    },
    junk = {
        rolls = 1,
        items = {
        }
    }
}

local locations = {
    { "kitchen",       "crate" },
    { "shed",          "shelves" },
    { "garagestorage", "crate" },
    { "farming",       "counter" },
}

for _, data in pairs(seedsLocations) do
        local roomName = data[1]
        local containerName = data[2]

        -- On récupère la définition de la pièce dans le jeu
        local roomDef = Distributions[roomName]

        -- Si la pièce existe ET que le conteneur existe dedans...
        if roomDef and roomDef[containerName] then
            -- ... Alors on insère !
            table.insert(roomDef[containerName].procList,
                { name = "ZazaSeeds", min = 0, max = 1, weightChance = 10 })
        end
    end
true nova
marble folio
true nova
stable mirage
#

Hey, quick B42 MP question:
what’s the correct server-side way to add an item to a player’s inventory so it appears immediately on the client?
Right now the item does exist server-side and shows up after a reconnect, but doesn’t appear live in the inventory UI.
Thanks

#

player:sendObjectChange("addItem", item)
player:sendObjectChange("updateItem", item)
inv:setDrawDirty(true)
What am i missing here?

dark salmon
true nova
dark salmon
true nova
#

Yea but it's not an exact thing, being weighted means more of a likelihood of spawning so 100 will not spawn 100% of the time it'll just spawn more often than items set less than 100

stable mirage
true nova
#

I would think setdrawdirty would need to be done by that client

bronze yoke
umbral sonnet
#

I'm trying to use lunajson in my mod but requiring the module is failing my mod layout is:

modId
- Main.lua
- lib
- lunajson.lua

should the import be require 'modId.lib.lunajson' ?

bronze yoke
#

require("lib/lunajson")

#

all mods share the same namespace for files so please use unique names, such as creating a modId directory modId/lib/lunajson

#

otherwise when you use generic names such as main.lua you're risking a hard conflict with any mod that also uses that name

umbral sonnet
#

thank you! another chatGPT fail LUL

unreal pewter
#

hey, does b42 file structure allow me to make a b41 version of a mod? like can i have a 41 folder, or should i rather put a b41 version in common and then a b42 version in a 42 folder? or do i gotta just make a separate mod

bronze yoke
#

41:
MyMod/mod.info
MyMod/media/...
42:
MyMod/42/mod.info
MyMod/42/media/...
MyMod/common/media/...

unreal pewter
#

alright, thank you

mellow frigate
# bronze yoke the animal zones are built on top of a framework for adding new zone types but i...

I checked and it is given by TIS as an independent tool and therefore very modable. Here is a simple rectangle selection exemple based on ```lua
addAreaHighlightForPlayer(self.playerNum, minX, minY, maxX+1, maxY+1, refZ, r, g, b, alpha)

Uploaded video speed is x3 so you do not waste your time.
https://steamcommunity.com/sharedfiles/filedetails/?id=3629755641

Create blueprints. Build from blueprints. Share blueprints.
You can create blueprints from original map buildings.
You can create blueprints from any map rectangle.
You can clear areas.

▶ Play video
bronze yoke
#

oh nice! that'll be really handy

candid sail
#

anyone know how I would be able to set off a firebomb on top of a player?

fresh lodge
#

Hello everyone, is there a way to add "component FluidContainer" to an item at lua level?

bright fog
#

You can do it for tiles at the very least

#

So surely you can do it for items

#

I'd suggest looking into the debug context menu of adding a fluid component to a tile

bronze yoke
#

do you want to add a fluid container to an instance of an item or a type of item?

bright fog
#

I guess that's important too yea

fresh lodge
#

tho the definition itself, like it's been edited in script . txt files

#

I attempted this:

local function editItem2(name, field)

    field =
    [[{
        component FluidContainer
        {
            ContainerName = WHATEVER,
            capacity = WHATEVER,
            InitialPercentMin = WHATEVER,
            InitialPercentMax = WHATEVER,
            CustomDrinkSound = WHATEVER,
            Fluids
            {
                fluid = WHATEVER:1.0,
            }
        }
    }]]

    local item = ScriptManager.instance:getItem(name)
    if item then
        item:Load(name, field)
    end
end

Like would do to recipes and apparently works

bright fog
#

component FluidContainer

#

But yea I was wondering iff that method would work for sub script blocks

#

That's good to know

bronze yoke
#

yeah this works

bright fog
#

Good to know

willow tulip
#

(field is passed into the function and redeclared inside as a local)

fresh lodge
#

Yeah i know, i just reused it for showing what was going on

fresh lodge
#

What about removing/hiding/deactivating a recipe? is that even possible to some degree?

neon hamlet
#

only behind a book i imagine

silent zealot
#

Try ScriptManager:getAllCraftRecipes() to get an ArrayList of CraftRecipes and then deleting an item. I'm not certain that will work, but it's worth a go.

mellow frigate
verbal yew
#

How to translate this?

drifting current
neat walrus
#

I need a wizard that can tell me why setting a clothing tint works in mp, but turns the clothing white in sp. I am losing hair.

    local color2 = ImmutableColor.new(self.r, self.g, self.b, 1)
    self.item:getVisual():setTint(color2)
    self.item:synchWithVisual()```
bright fog
#

Need more context here I feel like

neat walrus
#

it was a timed action and those three lines were all that are in the complete(), but I figured it out. synchWithVisual was unneeded. it was causing issues in sp, and possibly doing nothing in mp.

fresh lodge
#

i believe that the same is valid for "component Durability" and "component ContextMenuConfig"

oak swan
#

I have a mod suggestion for b42 if anyone is interested:

I love the climb mod and I love having night sprinters, but what I dislike is that climbing onto a roof is safe, but jumping off of it always leads to some sort of injury. I was wandering if anyone could make a mod that decreases injury rate/increases fall recovery from 1 floor drop with every fitness level.

bright fog
candid sail
#

im trying to make a little quest mod and as a reward for completing it i want to reset your negative moodles, i have no idea how to do that

umbral sonnet
#

I believe that would be the easiest piece to accomplish

candid sail
#

how would i go about doing that

umbral sonnet
#

for single player (i would start there first) look at:

local player = getPlayer()
player:getStats()
#

and CharacterStat

mellow frigate
#

when I play sounds from lua with with the 3 Sound Volume / Music Volume / Jump-scare sfx volume to minimum, the vanilla sound is not played but the modded sound is played at max volume. If I turn up the Sound Volume, I can hear both. ```lua
isoZombie:playSound('MSR788Shoot')--vanilla sound
isoZombiezSquare:playSound('mysterious_stranger'..ZombRand(1,3))--modded sound

winter bolt
mellow frigate
#

ain't no sound script stressed

mellow frigate
#

How do I ensure x/y is a float in lua when x = 1 and y = 1 ? it seems the java part does not find the "right" function to call because it thinks it is an integer.

bronze yoke
#

you can't

#

this is an issue i've experienced too, it's a hard limitation of kahlua's method invoker

#

it deduces type by value so if the value could be interpreted as two different types it's quite literally random* which one is picked

#

(*the same one is always picked until you restart the game)

#

i had this issue when passing nil as null is an acceptable value for literally every non-primitive java type

#

i can't remember the exact method but i wanted (IsoObject) null and was sometimes getting the (IsoGridSquare) null overload instead

thorn bane
#

I'm trying to create a custom item that uses the player name (Like an ID) but the translation name doesn't appear to be working. I suspect it's something to do with the name of the character name overwriting the translation file?

#

I suspect I gotta rewrite the OnCreate hook

thorn bane
#

Alright, I'm pretty lost on what I'm doing wrong 😭

I can't for the life of me use my own module and translation file instead of Base. Does anyone see what I'm doing wrong? B42.13.1
-# media/lua/shared/Translate/EN/PostMortem_EN.txt:

PostMortem_EN = {
    ItemName_Base.Alive_Player_Dogtag = "Cool Dog Tags!",
}

-# media/scripts/Items.txt:

module PostMortem
{

    item Player_Dogtag
    {
        DisplayCategory = Memento,
        ItemType = base:clothing,
        Weight = 0.0,
        Icon = Necklace_Dogtags,
        BodyLocation = base:necklace,
        ClothingItem = Necklace_DogTag,
        Cosmetic = true,
        WorldStaticModel = Necklace_Dogtags_Ground,
        Tags = base:hasmetal,
    }
}
bronze yoke
#

not how translation files work

#

you must match the exact filename of the matching vanilla file

thorn bane
bronze yoke
#

no, your translation file just isn't being read at all because the name is wrong

#

it wouldn't matter what module it's in

thorn bane
#

OHHHHH i get it now

#

aight, lemme try that fix inabit

thorn bane
#

Wait ignore

#

I'm stupid

bright fog
#

That's why this section is marked as needing to be moved

thorn bane
#

Finally got it working, thank you guys :D

dark salmon
thin swan
# mellow frigate when I play sounds from lua with with the 3 Sound Volume / Music Volume / Jump-s...

Yeah modded sounds are completely separated from the vanilla sound controls unfortunately... It's a real pain in the ass.
You can make your own volume control, but you have to use the emitter.
So you'd do something like:

local sound = emitter:playSound('mysterious_stranger')
emitter:setVolume(sound, float)

You can use getCore():getOptionSoundVolume() to get the sound volume used in the vanilla sound options, and then feed that into your setVolume call.
Just note that setVolume is from 0-1 and getOptionSoundVolume is 0-10, so just do * 0.1

thin swan
silent zealot
silent zealot
thorn bane
#

thankfully i fixed the issue, but i gotta figure out how to put the characters name on the item like an ID

#

ill figure that out later though, its way past my bedtime 😭😭

thin swan
thorn bane
#

otherwise, ill just rename on create or someth similar

silent zealot
#

Super simple

#

Literaly "that's just setName() with extra steps"

small topaz
#

I am currently trying to send player modData from server to client using


    if isServer() then -- if code is executed by server, sync player's modData from server to client
        local data = player:getModData()
        sendServerCommand(player, "myMod", "syncModData", data.MyModData)
    end
end```
However, the data are not properly send to the client (they are nil on client also they aren't nil on server). Is there something I am missing when putting the data to args of the sendServerCommand?
bronze yoke
#

why not player:transmitModData() ?

small topaz
#

If I get things right, this will transmit all modData from all mods which are active. I'd prefer to only send data coming from my mod (although your command would definitely be a quick and dirty solution...).

mellow frigate
small topaz
#

I'd still prefer sending only my modData 😉

#

point is that my mod has to sync modData quite often so I would like to have more control on what is send to not break other mods and keep performance cost low

bronze yoke
#

the args look right, what does the client portion look like?

small topaz
#

should add that my mod data are a table consisting of strings
data.MyModData.data1 = "a", data.MyModData.data2 = "b", ...
On client I have this


    if mod == "myMod" then 
        if command == "syncModData" then
            local player = getPlayer()
            local data = player:getModData()
    
            print("TEST OUTPUT ", args.data1) -- gives non-table: null error

            data.MyMod = args            
        end
    end
end

Events.OnServerCommand.Add(onServerCommand)```
bronze yoke
#

these are not the right parameters for OnServerCommand

#

nonPlayer is getting the args table

small topaz
#

so you mean onServerCommand(mod, command, args, nonPlayer) ??

#

it has different ordering from Events.OnClientCommand??

bronze yoke
#

there are only 3 arguments

#

i don't know what you're hoping for nonPlayer to catch

small topaz
#

XD ok... get it.

So, initially, I just expected without good reason that the argument structure of Events.OnClientCommand and Events.OnServerCommand are the same and so I though the latter also has a player argument (but I already noticed that it is not the same "player" as it is on server and so I just called it "nonPlayer"). 😅

thorn bane
#

does anyone know how to make multi-colored tooltips for items? i had a look online, and it seems its a modded feature, but unfortunately the only files i can see are B41 or older

#

nvm, got it! found the tooltip script and it seems easy enough to overwrite

small topaz
#

Did they again chaned smth on their print commands so that it now only prints the name of the variable? For me,
print("TEST OUTPUT ", args.data1)
now simply gives "TEST OUTPUT MyMod.data1" where MyMod is the name of the table in args... Not possible anymore to print the actual content (which is a string in my case)?

#

also tried this with DebugLog.log with the same result

EDIT: no problem at all. I was just confused.

bronze yoke
#

that doesn't sound possible

small topaz
#

ah no. ignore. I was just confused. everything right in my code and the output.

sorry here XD

graceful hamlet
#

hello everyone, working on mod, and struggling with some PZ quirks, when im using teleport Player:teleportTo(teleportX, teleportY, teleportZ)

game doesnt recognize player made structures (enclosed roofed building) as propper building
and does some weird things with roofs (floor tiles on z+1)

for example i have enclosed roofed area at place i want teleport to
after doing so, game decide that its better to render floor tiles from second flor instead of making it transparent

if i exit game, and load it, then it rendered propperly

first image what it is looks like after i teleport
second image, if i restart game (exit/load)

does anyone have ideas what i can do to fix this?

dark salmon
#

Where can I find the list of places to spawn my items? Is there a website for that?

molten kernel
#

Hello. Is there any way to "turn on" a newly installed street lamp? Without walking back and forth. I saw something about RecalcAllWithNeighbours(true)

silent zealot
graceful hamlet
true nova
graceful hamlet
#

only those structures that was been built by player, buildings that part of map - fine

silent zealot
#

RV Interiors manages to do it, check to see if they have a special trick.

#

Is the building at the destination pre-made (a map mod) or player made?

#

That may also be a big difference.

small topaz
#

When playtesting mods in MP via the host button, can I use the debug menu's item spawner to spawn items to the player inventory? Or will those items not work in MP due to the new server-side item handling system?

bright fog
winter bolt
small topaz
#

I am trying to get my timedActions to work in MP but they currently don't work. To test them, I use debug mode to spawn items needed for the action. So my first idea was that the problem are the items from the debug spawn menu. But possible that there is a different issue then.

Btw the Actions work fine in SP and in MP, they don't throw any error. I also tried to code them according to the new 42.13 timedAction system.

bronze yoke
#

cheated in items shouldn't cause issues

ionic tinsel
#

Hello, so where do I start to make custom trait in pz?

quartz ibex
#

Offhand question I haven't put much thought into; I know you can create sounds, but do we have options to do math on how that sound... travels? Like Can I do sound in a cone, or do some math make a sound come from the edge of say a circle inward, to draw zombies out to the edge of it?

bronze yoke
#

no

#

the attraction event is separate from the audible sound so you might be able to hack something together that does things like that, but i think it'd be really tricky to get it working properly

silent zealot
#

If the trait just adds skills when selected at character creation it's very easy to do, with B42.13+ having very different syntax to earlier versions

#

If the trait does something in game you have to work out how to hook in to that thing and add code, like hooking into the the function that eats food to add "If player has trait ShellfishAllergy and food contains one of {Lobster, mussels, Oysters} player:dies"

molten kernel
silent zealot
#

I don't follow... what commands or in-game actions are you using to do this? And what do you mean by "my" street lamp?

ionic tinsel
thorn bane
#

In my PZ Mod, I give an item to the player via the Events.OnCreatePlayer.Add() event, which works flawlessly in SP. However, in B42.13.1, the item does show in the inventory but cannot be dropped. As well, Admins cannot see the item when inspecting a players inventory.

Am I missing an event/check to send that data to the server, or do I need another event?

true nova
thorn bane
red bolt
#

Can anyone help me make an Instant item transfer edit/mod. I can't seem to find a way to edit the Dexterous trait which seems like it'd be the simplest solution. Just change the "50% inventory transferring time." to like 0% or 1%. The other 2 options I'm eyeing is by editing the ISInventoryTransferAction.lua directly or via a mod. I don't have a whole lot of knowledge so I'm looking at Neely's Player Changes mod that edits ISInventoryTransferAction. ATM I'm trying to loot at his edit and the base game file to see if I can just change a value or two and be done. Kinda doubt its that easy.

true nova
red bolt
#

I think I got it.

#

It really was as simple as changing 3 maxtime values to 1

true nova
red bolt
#

Gonna post here and in a few mod comments so ppl can make the simple edit if they want instant item transfers.

#

Step #1 - Navigate to ProjectZomboid\media\lua\client\TimedActions and open ISInventoryTransferAction.lua with Notepad
Step #2 - Search for ""TradeUI" and srcContainer:getType()" and in the line below it change "o.maxTime = 120" to "o.maxTime = 1"
Step #3 - Search for "self.item:setJobType("Putting in container")" and in the line below it change "o.maxTime = 50" to "o.maxTime = 1"
Step #4 - Search for "self.item:setJobType("Taking from container")" and in the line below it change "o.maxTime = 50" to "o.maxTime = 1"

#

The 3rd and 4th change seem super obvious, but i don't know if the 2nd step does anything in particular.

#

That seemed to make items transfer instantly. Only tested it in a new game and in the house i started in. Maybe the 2nd step is for when you do things via crafting?

thorn bane
#

God I hate how discord doesn't auto-hide the rest of the file grr

thorn bane
#

There we go :)

true nova
# thorn bane

looks mostly good. i dont think you need to transmit player moddata doesnt look like you do anything with it

#

id try changing the event you use

#

theres load orderd to them i cant remember

#

you might want to use OnNewGame because that fires when a new character is created so itll only add once and every time someone dies and makes a new character

molten kernel
# silent zealot I don't follow... what commands or in-game actions are you using to do this? An...
  1. By "my" streetlight, I mean a custom tile definition (same sprite, but with IsMoveable and without the streetlight flag).
    I use a context menu action to swap them via Lua. Here is the logic I use:

    1. Remove my custom object
      square:transmitRemoveItemFromSquare(customObj)
      square:RemoveTileObject (customObj)

    2. Create the vanilla object
      local vanillaLight = IsoLightSwitch.new(cell, square, vanillaSprite, -1)
      square:AddSpecialObject(vanillaLight)

  2. "My" streetlights (.pack, .tiles) are vanilla streetlights, but with the parameter (IsMoveable) and without (Streetlight).

rich reef
#

Hello everyone, I've got a question.

I have used AcceptItemFunction for items within scripts to allow certain items within certain containers, and it works great.

I am wondering if their is a way to hook into the same kind of functionality within Lua to check when an item is dragged/placed into a player's container, and then run code off of that?

I would like to run a script that consolidates stacks of items when someone drags it into a bag/container, and am not sure exactly where to look to find if this is possible.

B41MP is the use case for this.

Thanks in advance if anyone knows!

molten kernel
verbal yew
#

Guys, how do I get this script to work?
I'm calling it on the server, trying to send it to the client via sendServerCommand, but nothing happens, as if...

HaloTextHelper.addTextWithArrow(player, getText("UI_trait_zReAntibodies"), false, HaloTextHelper.getColorGreen())
getSoundManager():PlaySound("GainExperienceLevel", false, 0):setVolume(0.50)

silent zealot
silent zealot
verbal yew
#

right part working, left need try print

#

but nothing happens

thorn bane
verbal yew
#

HaloTextHelper and sound not work

silent zealot
#

Add a print statement to see if the code is being executed.

#

If not, you probably need to do something liek print everythingg teh cleint gets and try to find out if the server is not sending teh command OR teh client is not recieving it OR the client g ets it but for some reason it does not match the conditionals

rich reef
# verbal yew Guys, how do I get this script to work? I'm calling it on the server, trying to ...

I had a similar issue where I needed to send a sound to every player upon a big serverwide 'Event', and it required a ping pong from Player > Server > Player to get it to function correctly.

Like DrStalker said, I'd run a print and see if it's even being ran Server Side, and Client Side, and then go from there.

As far as I've tested, Sound Manager should run a sound if it's declared in a script file somewhere, as long as it's called correctly. It' should run just local to the player if I recall.

verbal yew
#

Jesus... just need disable invisible in debug mode...

rich reef
thorn bane
#

I've been looking at the new B42 API for creating items and giving them to the player. Unfortunately, I'm lost at what's supposed to go where. Does anyone have a mod example?

boreal pawn
#

are you just looking for a basic item like adding a ball ?

mellow frigate
#

in B42.13, ingame vanilla map is not updated with vanilla landscape changes, I used to hike and rest in Doe Valley Forest isolated pond. the pond is replaced by a sweet river. The ingame map still shows a pond. stressed

mellow frigate
#

Don't you worry no more, brothers and sisters, as the day is near where troubles will be no more: https://www.youtube.com/watch?v=osSUvcHID5s

Steam Is Saving Your Broken Mods

#steam #valve #gaming

Valve is fundamentally changing how the Steam Workshop handles game updates by introducing a revolutionary version control system that aims to end the era of broken mods. This video explores the new Workshop Item Versioning system, which allows mod authors to host multiple versions of the...

▶ Play video
red bolt
#

Nail on the head with that opening. Exactly what the situation I was in. Latest unstable patch broke everything, but auto-updated. Then mods started updating. Just a complete mess. Will be nice when steam doesn't auto-update literally everything.

verbal yew
#

whats problem can be:
sendClientCommand dont work from TimedAction (preform or complete), nothing send in log where i set print to module and command on serverside

mellow frigate
silent zealot
#

Which part of the timed action? There some weird "some parts are on the client, some parts are on the server"

winter bolt
#

its perform (client) -> complete (server) i think?

#

dont know about the rest but those are the two that run at the end

dark salmon
#

Is there a way to find tomato plant texture as png file in game ? or is there a resources web site for it ?

bright fog
dark salmon
#

Is it normal i can't extract images from pack files via TileZed ?

thorn bane
#

Just to be clear, not having an issue with putting the item inti the game, but i don’t know how to give said item to the player via the new api. The documentation doesn’t make too much sense to me rn

boreal pawn
#

in what capacity are you trying to give it to them , as an admin, via loot tables,

or maybe you want to create a crafting recipe to let them make it for themselves

can you link the api you talking about
@thorn bane

thorn bane
thorn bane
boreal pawn
#

i know in settings under INI - Players you can add item ids

thorn bane
#

Not what I’m after, it’s a custom mod item that requires its own function to run to do the things it needs to do

boreal pawn
#

i gotcha ill check it out

thorn bane
#

The key to making it work correctly is rewriting the functionality to give the player items, which seems to only come from this document

#

I can’t understand it though, I don’t think it’s clear enough in what needs to go where, and some context is missing in a few areas

#

I’ll peep it again tomorrow, eepy time for now

merry osprey
#

Anyone rocking a mod to fix the nutrition system? Shedding weight like a mad man and im stuffing my face full of venison.

tired glen
#

There isn’t enough cool items you can make with metal working
I wonder what cool items I can add with metal working

verbal yew
mellow frigate
#

I seriously guess it is server side though, you can probably take exemple on Project Zomboid_ API for Inventory Items.pdf "add item to inventory" process

verbal yew
# mellow frigate I do no know for body damage specificaly. If it is server side, yes. If it is no...

CLIENT LUA:

Events.EveryOneMinute.Add(function()
    local player = getPlayer()
    if not player then return end
    
    local clientResult = player:getBodyDamage():isInfected()
    print("[CLIENT] isInfected: " .. tostring(clientResult))
    print("[CLIENT] Infection progress: " .. player:getStats():get(CharacterStat.ZOMBIE_INFECTION))
    sendClientCommand(player, 'zReTest', 'zRecheck', {})
end)

SERVER LUA:

Events.EveryOneMinute.Add(function()
    local player = getPlayer()
    if not player then return end
    
    local serverResult = player:getBodyDamage():isInfected()
    print("[SERVER] isInfected: " .. tostring(serverResult))
    print("[SERVER] Infection progress: " .. player:getStats():get(CharacterStat.ZOMBIE_INFECTION))
end)

Events.OnClientCommand.Add(function(module, command, player, args)
    if module == 'zReTest' and command == 'zRecheck' then
        local bd = player:getBodyDamage()
        local callResult = bd:isInfected()
        print("[SERVER from client call] isInfected(): " .. tostring(callResult)) --- ТРУ
        print("[SERVER from client call] Infection progress: " .. player:getStats():get(CharacterStat.ZOMBIE_INFECTION)) -- ТУТ ВСЕ КАК НАДО
    end
end)
#

LOGS:

-- DEBUG LOG
[09-01-26 02:39:10.889] LOG  : Lua [CLIENT] isInfected: false.
[09-01-26 02:39:10.889] LOG  : Lua [CLIENT] Infection progress: 0.3549680709838867.
[09-01-26 02:39:10.890] LOG  : Lua [SERVER] isInfected: false.
[09-01-26 02:39:10.890] LOG  : Lua [SERVER] Infection progress: 0.3549680709838867.
-- SERVER LOG
[09-01-26 02:39:10.277] LOG  : Lua [SERVER from client call] isInfected(): true.
[09-01-26 02:39:10.277] LOG  : Lua [SERVER from client call] Infection progress: 0.3226982355117798.
#

real - player is infected

mellow frigate
mellow frigate
#

so in your complete action, after the action that induces isInfected = true server side, you need to propagate the effect to the clients

verbal yew
#

i mean, i should try to do it, just cut my func and put in :prefer()

#

without sendClientCommand

#

yep?

mellow frigate
verbal yew
#

okay, need to test it

mellow frigate
#

you can probably force the update of body damage server side with that trick player:getDamageFromHitByACar(0.);

#

maybe use this instead: sendDamage(player)

verbal yew
#
    if command == 'zRePojalustaRabotaySuka' then
        local serverPlayer = getPlayerByOnlineID(args.playerID)
print("[DEBUG] serverPlayer: " .. serverPlayer:getUsername())
        
        local body = serverPlayer:getBodyDamage()
        local health = body:getOverallBodyHealth()
print("[DEBUG] health: " .. health)
        
        local newHealth = health + 14
        if newHealth > 100 then newHealth = 100 end
        body:setOverallBodyHealth(newHealth)
print("[DEBUG] newHealth: " .. newHealth)
        
        local pMod = serverPlayer:getModData()
        local infected = body:isInfected()
        local albuminDoses = pMod.AlbuminDoses or 0
        
print("[DEBUG] infected=" .. tostring(infected) .. 
              ", AlbuminDoses=" .. albuminDoses .. 
              ", infectionRate=" .. (LabRecipes_InfectionRate(serverPlayer) or 0))
        
        if infected and albuminDoses > 0 then
print("[DEBUG] ok")
            local rate = zMathCeil((LabRecipes_InfectionRate(serverPlayer)*100-14)/7)
print("[DEBUG] rate=" .. rate .. ", albuminEff[rate]=" .. tostring(albuminEff and albuminEff[rate]))
            
            if albuminEff and albuminEff[rate] then
                body:setInfectionTime(body:getInfectionTime() + 
                    body:getInfectionMortalityDuration() * albuminEff[rate] / 100)
            end
            
            pMod.AlbuminDoses = albuminDoses - 1
print("[DEBUG] new AlbuminDoses: " .. pMod.AlbuminDoses)
            
            serverPlayer:transmitModData()
print("[DEBUG] ModData sync")
        else
print("[DEBUG] not ok: infected=" .. tostring(infected) .. 
                  ", doses=" .. albuminDoses)
        end
     elseif command == 'zReRecess' then
---- bla bla bla
verbal yew
# mellow frigate maybe use this instead: ```sendDamage(player)```

I need to get this part of the code working. I have three or four commands from a client, only the first one does not work.

In ":complete()" too. Couldn't work with BodyDamage. Even the character's ModData doesn't change...

For some reason, debugging information is not output to the log file...

#

putting this code in ":complete()" with a reference to self.character did nothing.

mellow frigate
#

call sendDamage after your last transmitModData

small topaz
#

Hi! I currently have some problems executing my TimedActions in MP properly. Here is a code snipped of one of my Actioned:

    if self.character:isTimedActionInstant() then
        return 1
    end
    return 300
end


function shaveStubbleAction:new(character, item)
    local o = ISBaseTimedAction.new(self, character)
    o.stopOnWalk = true
    o.stopOnRun = true
    o.item = item
    o.maxTime = o:getDuration()
    return o
end```
Is there anything obviously wrong with it which I am simply too dumb to see?
bronze yoke
#

i don't see an issue in this snippet

verbal yew
mellow frigate
hallow grotto
#

what the hell do you mean people are trying to vibe code mods
what do you mean it is bad enough to warrent its own section in the docs LMAO

flat bluff
#

Can someone tell me if my understanding is wrong?
The Indie Stone removed the use of property DisplayName in favor of using translation files based on the object base name. Right?

hallow grotto
#

yeah, to my understanding

flat bluff
#

Roger that, I'm trying to fix a mod I haven't worked in a while and noticed some changes from TIS.

#

Thanks @hallow grotto

flat bluff
hallow grotto
#

pray to the ommisah and light incense

verbal yew
#

BRUH

#

im just forgot [ ] for inputs in CraftRecipe

#

breaking the launch of the game in the debug with two parentheses in the script and getting a crash with an empty log is a favorite

bright fog
#

That parameter was always a very odd one that tough modders to do things wrongly

flat bluff
verbal yew
#

craftRecipe:isCanWalk() getting this from craftRecipe tags or isCanWalk = true?

#

like

    timedAction = Making,
    SkillRequired = Doctor:1,
xpAward = Doctor:10,
    Tags = AnySurfaceCraft;isCanWalk,

or
isCanWalk = true,

bright fog
#

Check the doc

small topaz
#

Still trying to make my TimedActions work in multiplayer. Problem seems to be that the server does not recognize my new() function. Here is the output from the coop-console.txt:
ERROR: General f:1246, t:1767990687532, st:39,246,502> LuaManager.getFunctionObject > no such function "shaveBodyHairAction.new"
Some relevant code of my TimedAction from the shared folder is here:

    if self.character:isTimedActionInstant() then
        return 1
    end
    return 300
end

function shaveBodyHairAction:new(character, choice, bodyLocation, item)
    local o = ISBaseTimedAction.new(self, character)
    o.stopOnWalk = true
    o.stopOnRun = true
    o.item = item
    o.choice = choice
    o.bodyLocation = bodyLocation
    o.maxTime = o:getDuration()
    return o
end

return shaveBodyHairAction```
This works fine in single player. Is there some special new procedure I need to use to make the server recognize the `new()` function? Or is it not possible to define this a local module only using
```local shaveBodyHairAction = ISBaseTimedAction:derive("shaveBodyHairAction")```
in my action code's header?
#

Also, in the client folder, I am putting my TimedAction in the TimedAction queque, as in pre 42.13 versions. Is this not possible anymore?

bronze yoke
#

i usually do this:```lua
local myAction = ISBaseTimedAction:derive("MyMod_MyAction")

...

_G[myAction.Type] = myAction

small topaz
#

_G[myAction.Type] = myAction what is this??

bronze yoke
#

when you start an action, the client sends the action's Type (by default, the string you passed to derive()) and the server looks for and calls _G[Type].new() to recreate the action on its side

#

by doing _G[myAction.Type] = myAction i can have a Type that is reasonably unique (as it will be a global) without having an ugly variable name in the rest of my code

#

of course, just removing the local keyword does work too

small topaz
#

Yeah... I only have 2 timedActions and there is only one place in my code where I call them. So I guess I go for the classical ugly and long unique name. 😅 It's ugly but easy.

queen oasis
small topaz
#

It possible to use the command
player:setWornItem(bodyLocation, clothingItem)
In single player, this will only equip the clothing item and display it in the game but it won't put it in the inventory.

When I would like to do a similar thing in MP (only equipping the item an making it visible but not putting it to the inventory), is it safe to do this on client -side or better on server-side?

bright fog
small topaz
#

So when I just do it client-side, I can see the item properly equipped when playtesting via the host button but I am wondering whether other player will see it too (which I don't know how to test)

#

My suspicion is that it would be safer to do it on server side. I am just afraid that for my mod, the server's workload might get to high if there are a lot of player are in the game.

Just testing it alone seems to be fine though...

bronze yoke
#

i would assume that other players would not see anything done client side

small topaz
#

ya... I am afraid too 🙁

#

I think modder spongie mentioned somehow that this trick won't work on client-side but I am not 100% if I understood correctly...

bright dawn
#

Good day everyone, what are your tips on reducing the size of your mod that is heavily using pngs? my photos are mainly portraits so its 512x512, I prefer not downscale its resolution to preserve more quality, my mod even reach 110mb and that's why reluctantly downscale it to 256x256 and now its not crisp anymore. This is ny WIP mod looks like to give a scale about the photo size https://youtu.be/FudyfaW9hrM?si=YpDB78kfnBQyVg3X&t=29

mellow frigate
bright dawn
#

Thank you sir

#

Wow, tremendous help sir ty

mellow frigate
fresh lodge
#

I have noticed a very weird fact in MP, i tried to add a recipe like this in media/scripts/recipes/file.txt:

module Base
{
    craftRecipe RefillLighterFluidTin
    {
        timedAction = Making,
        time = 30,
        OnCreate = RecipeCodeOnCreate.refillLighterFluidTin,
        Tags = InHandCraft,
        inputs
        {
            item 1 [Base.LighterFluid] mode:destroy flags[ItemCount],
            item 1 [*],
            -fluid 0.04 [Petrol;Alcohol;Cologne;Perfume],
        }
        outputs
        {
            item 1 Base.LighterFluid
        }
    }
}

In MP always fails to work, fluid is consumed but the new LighterFluid is not added to the inventory, tried even with mode:keep and no set output like this:

module Base
{
    craftRecipe RefillLighterFluidTin
    {
        timedAction = Making,
        time = 30,
        OnCreate = RecipeCodeOnCreate.refillLighterFluidTin,
        Tags = InHandCraft,
        inputs
        {
            item 1 [Base.LighterFluid] mode:keepflags[ItemCount],
            item 1 [*],
            -fluid 0.04 [Petrol;Alcohol;Cologne;Perfume],
        }
        outputs
        {
        }
    }
}

and then both with and without setCurrentFloat(1)in media/lua/server/file.lua within RecipeCodeOnCreate.refillLighterFluidTin
I really am at a loss here

bronze yoke
#

in the second example, missing space after mode:keep likely borks both the mode and the flag

fresh lodge
#

that's a typo from pasting, not actually in the code

#

i'll give the comma a try, did not realise that

#

still i don't get why the second way won't work

bright fog
fresh lodge
#

Refill LighterFluid bottle

bright fog
#

But what is that item ?

#

That's the vanilla lighter ?

fresh lodge
#

vanilla LighterFluid

#

is a drainable item used to refill lighers

bright fog
#

Ok and what does your OnCreate do here ?

#

Because you showed the recipe but it doesn't look like this is the important part of your whole issue here

#

It's the OnCreate that actually refills the lighter right ?

fresh lodge
# bright fog It's the OnCreate that actually refills the lighter right ?

Here's the code i was trying to get working originally:

-- media/lua/shared
local function editRecipe(recipeName, field)
    local recipe = getScriptManager():getCraftRecipe(recipeName)
    recipe:getInputs():clear()
    recipe:Load(recipeName, field)
end

local function editRecipeRefillLighter()

    local field =
    [[{
        inputs
        {
            item 1 [Base.Lighter] mode:keep flags[NotFull;ItemCount],
            item 1 [*],
            -fluid 0.005 [Petrol;Alcohol;Cologne;Perfume],
        }
    }]]

    editRecipe("RefillLighter", field)
end

Events.OnGameBoot.Add(editRecipeRefillLighter())
fresh lodge
# bright fog Because you showed the recipe but it doesn't look like this is the important par...
-- media/lua/server
local function getInputs(craftRecipeData, character)
    local fuelStats =
    {
        ["Petrol"]    = {distance=5, strength=1.2, delta=0.35},
        ["Alcohol"]    = {distance=5, strength=0.6, delta=0.25},
        ["Cologne"]    = {distance=4, strength=0.4, delta=0.3},
        ["Perfume"]    = {distance=4, strength=0.2, delta=0.5},
    }
    local inputItem = false
    local fuelType = false

    local items = craftRecipeData:getAllConsumedItems()
    items:addAll(craftRecipeData:getAllKeepInputItems())

    for i = 0, items:size() - 1 do
        local item = items:get(i)
        if item then
            if item:hasTag(ItemTag.LIGHTER) then inputItem = item end
            if item:getFluidContainer() and item:getFluidContainer():getPrimaryFluid() then
                local candidate = item:getFluidContainer():getPrimaryFluid():getFluidTypeString()
                if fuelStats[candidate] then fuelType = candidate end
            end
        end
    end
    return {inputItem, fuelType, fuelStats}
end

local function refillLighter(craftRecipeData, character)

    local inputs = getInputs(craftRecipeData, character)
    
    local lighter = inputs[1]
    local fuelType = inputs[2]
    local fuelStats = inputs[3]

    if not lighter then return end
    if not fuelType then return end

    if lighter:getCurrentUsesFloat() == 0 then lighter:setActivated(false) end

--    lighter:setLightDistance(fuelStats[fuelType].distance)
--    lighter:setLightStrength(fuelStats[fuelType].strength)
--    lighter:setUseDelta(fuelStats[fuelType].delta)
    lighter:setCurrentUsesFloat(1)
    print("LIGHTER REFILLED")
end

RecipeCodeOnCreate.refillLighter = refillLighter
bronze yoke
#

do you see LIGHTER REFILLED in multiplayer?

fresh lodge
#

YES

#

That is what i making me furious 😂

#

And to make it worse, it works in SP

bronze yoke
#

try calling sendItemStats(lighter) after setting the uses

mellow frigate
fresh lodge
thorn bane
#

Trying to get my head around the new B42 Item API, why does this code work in SP but not when hosting MP?

client

local MOD_MODULE = "PostMortem"

local function onCreatePlayer(playerIndex, player)
    sendClientCommand("PostMortem","RetrieveSpawnID", {})
end

Events.OnCreatePlayer.Add(onCreatePlayer)

Server

local MOD_MODULE = "PostMortem"

local function giveSpawnID(player, fullType)
    local inv = player:getInventory()
    local spawnID = instanceItem(fullType)

    if spawnID then
        inv:AddItem(spawnID)
        sendAddItemToContainer(inv, spawnID) -- sync to clients
    end
end

local function OnClientCommand(module, command, player, args)
    if module ~= MOD_MODULE or command ~= "RetrieveSpawnID" then return end

    giveSpawnID(player, "PostMortem.Alive_Player_Dogtag")
end

Events.OnClientCommand.Add(OnClientCommand)
thorn bane
#

Added some prints to the OnClientCommand on the server, it appears correctly on SP but not on MP. I suspect it's a quirk within the in-game hosting functionality?

quasi kernel
#

@bronze yoke hate to pester, but is the modding place undergoing renovations or something? If you know?

#

Nevermind

molten kernel
winter bolt
thorn bane
#

No difference when on a dedi server. No idea what I'm doing wrong aaaa

queen oasis
rich reef
#

Hello, I am trying to have some Lua code run when someone drags an item into a container. Does anybody know where I could find the vanilla code for this to tie into and run my code off of?

I currently use the item's AcceptItemFunction option to allow only certain items into the container, but I don't believe I can use that to do what I'm planning.

I would like the 'stackable' items I have to be automatically consolidated when dragged into a certain container. I have the consolidation code working manually with a context menu, but was hoping to have it automated any time someone drags an applicable item into the container.

Does anybody have an ideas? Trying to avoid having to override any vanilla code, and just hook into a function for this, but not sure where to look.

Thanks!

queen oasis
gray otter
#

Hey, fellas... I am wanting to get into modding.. For my first mod, I was just wanting to add some IRL comics in game to find and collect. I made the basic mod folder structure. I was looking at how the in game comics are generated as a reference but I have some questions.. If anyone is willing to help, please let me know. Thanks

rich reef
bronze yoke
#

i think it's any time the ui is redrawn, so even more frequently than that

rich reef
#

Hmm.. That may be too much overhead if I'm trying to just do a drag/drop of an item into a container to run a function once..

queen oasis
#

I didn't know it was called that often

bronze yoke
#

i think it's any time the list of available containers could change (not necessarily that it did change, just something happened that *might* change it, which is basically any item transfer, certain objects spawning in or being built, moving, etc)

gray otter
bronze yoke
rich reef
bronze yoke
#

it's probably lua, but i don't remember if i ever collected anything about it

queen oasis
rich reef
#

Say I have a custom container, lets call it "specialbag", is there a way to determine from ISInventoryPage, if it belongs to that container?

queen oasis
#
JBLogging.Storage.OnRefreshContainers = function(inventoryPage, state)
    if state ~= "end" then return end
    if inventoryPage.onCharacter then return end

    local containers = inventoryPage.backpacks
    if not containers then return end

    for _, backpack in ipairs(containers) do
        local container = backpack.inventory

        if container and container:getParent() then
            local object = container:getParent()

            local modData = object:getModData()
            if modData and modData.JB_AutoLogStorage then
                container:setAcceptItemFunction("JBLogging.Storage.Accept")
                JBLogging.Storage.UpdateSprite(object)
            end
        end
    end
end```
rich reef
#

So inventorypage in this case, would be the players main inventory window?

queen oasis
#

if not inventoryPage.onCharacter then it's a loot window

rich reef
#

Alright, interesting. Thanks for the help! I'll get to digging at things and see if I can get it to work.

By chance, do you know of a way to stop an 'unauthorized' player from accessing a container/items in a container? Say, only accessible to an admin, or to someone tagged as the owner with moddata? Is there a function for this? Or do I have to override vanilla stuff for that?

gray otter
#

Does the OnCreate determine how it is generated within the world?

queen oasis
queen oasis
gray otter
verbal yew
#

how to set this trigger to craftRecipe?

#

isCanWalk = true, dont work

#

into tags same

bronze yoke
gray otter
rich reef
verbal yew
#

like, u just can spin around

queen oasis
rich reef
gray otter
#

Lets goooo

rich reef
#

It looks like I may be able to override the 'addContainerButton` function, to completely hide the item's inventory from an unauthorized player in this case. Even if they equip it, it won't show them the container button to click on. Hmm..

queen oasis
#

I just used moddata to check if it should be shown or not

molten kernel
rich reef
#

I basically have a special player only container with personal items I want to be able to isolate from other players in case a player dies, or whatnot. So the player can come back and retreive their stuff without lotting things. Also, the convenience of consolidating important/common used items when they drag them into that special container. I've got a lot of it working the way I want, but these last few things I'm trying to do are giving me some issues. I'd prefer not to have to override anything major, or at least run my code and let the original run if my checks aren't valid.

What about ISInventoryTransferAction. Is this something that can be used for my first use case of Item Consolidation?

rare basin
#

Does anyone know how I can make a raw item still give unhappiness on consumption after being cooked?

thorn bane
#

I've been scratching my head for the better part of an hour right now. Does anyone know why this code returns Object tried to call nil in giveSpawnID on idData:transmitModData()?

rich reef
bronze yoke
#

that was true in build 41, but not build 42

#

oh but

gray otter
#

So I got the comic into the game. I am wanting to swap the "ComicBook_01" texture with the same png comic cover that I added. Both 64x64 png. Would that work? If I put texture = "my_png.png"? model ComicBookGround { mesh = WorldItems/MagazineOpen, texture = WorldItems/ComicBook_01, scale = 0.3, attachment world { offset = 0.0 0.0 -0.605, rotate = 0.0 0.0 0.0, } }

bronze yoke
#

since the item didn't exist before this, you don't need to do anything to send its mod data

#

item:transmitModData() does not exist so the error is accurate

#

for reference you would use syncItemModData(player, item)

rich reef
#

Thats good to know moving forward. still in B41 land for now

gray otter
thorn bane
#

thank you sm :)

gray otter
#

module Base { item Infinity_Gauntlet_001 { DisplayName = Infinity Gauntlet (1991) #1 DisplayCategory = Literature, Type = Literature, Weight = 0.4, Icon = Infinity_Gauntlet_001, BoredomChange = -30, StressChange = -20, UnhappyChange = -20, StaticModel = InfinityGauntlet001, WorldStaticModel = InfinityGauntlet001Ground, Tags = Picturebook, } }

#

` model InfinityGauntlet001
{
mesh = Magazine_Open,
texture = ComicBook_Open,
scale = 1.0,
attachment Bip01_Prop2
{
offset = 0.0 0.0 0.0,
rotate = 90.0 0.0 180.0,
scale = 0.125,
}
}

model InfinityGauntlet001Ground
{
    mesh = WorldItems/MagazineOpen,
    texture = Infinity_Gauntlet_001,
    scale = 0.3,
    attachment world
    {
        offset = 0.0 0.0 -0.605,
        rotate = 0.0 0.0 0.0,
    }
}`
#

So.. it pops up as just a big PNG when I do that lol

bronze yoke
#

when the icon appears in world like that, it usually means it can't find your model script at all

#

is that the full file? it should be in a module block if it isn't

verbal yew
#

?!

#

without any transmit, nope?!

gray otter
thorn bane
#

i have a cold right now and I'm not thinking at 100% capacity lmaoo

verbal yew
# thorn bane that was a leftover of troubleshooting, whoops
local cmpTestTubeWithInfectedBlood = InventoryItemFactory.CreateItem("LabItems.CmpTestTubeWithInfectedBlood");
local iMod = cmpTestTubeWithInfectedBlood:getModData();
iMod.IsInfected = player:isInfected();
player:getInventory():AddItem(cmpTestTubeWithInfectedBlood)
brave bone
#

is there a way to suppress body wetness?

verbal yew
verbal yew
thorn bane
gray otter
verbal yew
#

antoher deal with math

bronze yoke
#

i think the texture path starts from media/textures/ and does not include the extension

#

so this would be looking for media/textures/Infinity_Gauntlet_001.png

brave bone
verbal yew
# brave bone is there a way to suppress body wetness?
local currentWetness = player:getStats():get(CharacterStat.WETNESS)
local delta = 0.8
local changer = currentWetness * delta
if changer < 0 then changer = 0 end
player:getStats():set(CharacterStat.WETNESS, changer)
gray otter
winter bolt
#

what folder is your texture in?

gray otter
#

So I have tried with texture = textures/Infinity_Gauntlet_001 and texture = Infinity_Gauntlet_001

gray otter