#mod_development

1 messages ยท Page 224 of 1

bright fog
#

How would you know a clothing is cotton ?

#

That would be cool

crisp rock
#

or a product is paper

past pollen
past pollen
crisp rock
#

could work i suppose

past pollen
#

I dont know how to code I was just searching for a mod of this type and there are none

crisp rock
#

doesnt sound like a bad idea but its kinda niche

bright fog
#

It's just rip clothing

past pollen
#

Oh really?

#

Either way cotton and denim are compostable irl

bright fog
#

Denim ? Didn't knew that

outer crypt
#

almost any clothing is compostable if its not synthetic... how about a zombie chipper? Toss the hold critter in, clothes and all and compost the mulch. lol

shy hearth
#

Anyone got a handy way to detect when an attack is a stomp? A stomp attack counts as 'Bare Hands' in OnPlayerAttack with no obvious way to differentiate from a shove

bronze yoke
#

attacker:isAimAtFloor() and attacker:isDoShove()

shy hearth
#

you're my hero albion

#

i've lost track of how many times i've said that

#

or thought it at least

austere sequoia
#

Can I make it that my mod overwrites its own data in case another certain mod is installed alongside it? And if so, how exactly? ๐Ÿ™‚

#

As in "if this mod is also installed, dont use ItemXYZ, use Item ABC instead"

desert kelp
#

if getActivatedMods():contains("<mod you want to use in a condition>") then
<put your statement here>
end

austere sequoia
#

Awesome dude, thank you! This goes where in lua?

desert kelp
#

try server

#

or shared

#

if you're planning to tweak item to obsolete, go shared i guess

austere sequoia
#

and I assume I have to use the mods ID (the one with letters, not numbers)?

desert kelp
#

you can try looking at other mods how they do things, it should give you a general idea

austere sequoia
desert kelp
#

Try Better Sorting

#

they have Item tweaker there

austere sequoia
#

awesome, thank you!!!

bronze yoke
#

don't use item tweaker

#

it causes a lot of lag and it just changes the syntax for one thing

desert kelp
#

Anyone have an idea how/ why this is happening?

I applied a code change through another mod with Crafting Enhanced Tables where I fixed where it displays the actual item count of Blowtorch instead of the units needed and added some few tables myself (from Cold Arms of China) but when I load it in with other mods, it's not working properly? Heck , even my edited translation is not applying.

Below is the actual fix I did loading only the Crafting Enhanced Core + Cold Arms + my fix on the mod

Edit: Found the issue. Medieval Armory is using the same lua file from Crafting Enhanced Core thus overwriting the file again

bronze yoke
#
local item = ScriptManager.instance:getItem("MyModule.MyItem")
if item then
    item:DoParam("Parameter = Value")
end
```does exactly the same thing as item tweaker without dependencies or lag
austere sequoia
bronze yoke
#

it prints every single change it makes

#

with lots of mods using it it can make loading take an absurd amount longer

mellow frigate
thick karma
#

Anyone know if there is an easy way to make the first version replace all here? Or am I going to need to make a fancy helper function where I break the string into tokens containing the target?

#

(sorry)

bronze yoke
#

when using * it matches the longest possible string, which is the entirety of the string from the opening of the first RGB to the closing of the second one

thick karma
#

Well, shit.

bronze yoke
#

- matches the shortest possible match, which catches each individual one

thick karma
#

I had literally just finished some stupid recursive function for this lol

bronze yoke
#

never underestimate string manipulation

thick karma
#

Lmao I just could not find what I needed to know and could not guess in the right direction

bronze yoke
#

in general be very careful when using ., *, and especially both of them together

thick karma
#

Thank you for being the hero of legend

bronze yoke
#

- is usually more useful

ebon briar
#

Hey guys! I'm just starting with PZ modding and one of the things I wanna do with the mod involves crafting using broken items, which means I need to include the item code for broken items in a recipe script. However, I can't seem to figure out where that information is stored in the media folder, does anyone know where I'd find it?

#

Or are they not stored as unique items codes? In which case I'd like to ask how the game knows when something is completely broken

small topaz
ebon briar
onyx sage
#

anyone know how to make bullbars an item that can be installed like in KI5;s 91 range rover mod

small topaz
# ebon briar Interesting, so is there a Lua script or something that prevents you from using ...

As far as I understand the vanilla code, the game looks at an item and checks via a java a function in which recipes it can be used. It then displays the make-recipe option for all those recipes in the right-click menu of the inventory (or in the craft menu). This check involves making sure that all recipe ingredients are available and probably that they are non-broken. So, in case there isn't a parameter for the recipe script.txts which allows making a recipe out of broken items, I guess it is difficult to mod the game so that recipes with broken ingredients are possible since checking-for-available-nonbroken-recipes-ingredients seems to happen on java side. But not 100% sure though.

Edit: see albion's comment below

bronze yoke
#

broken item filtering is a script parameter, you can disable it (not sure if it is even enabled by default)

#

you can use an OnTest function to filter for broken items only

steady lagoon
#

Do you guys know which class is used to identify an item in the world? I would like to find a specific item existing in the world + character's inventory and not just inside the character's inventory, so something which is not ISOPlayer class.

#

I hope the question makes sense.

small topaz
steady lagoon
#

I managed to enable inf ammo on this specific weapon but only when a player character is using it. I noticed that using superb survivors, the survivors can't benefit from this Lua logic and they keep reloading the weapon after a single shot ( this weapon has only 1 bullet which never depletes). I tried using ISOgamecharacter instead but it doesn't work so I was thinking about finding that weapon in the world and changing its behaviour through LUA.

#

I can't find it when the game starts as I didn't add a logic to load it into the world, I spawn it myself.

chilly hemlock
#

does anyone know if it's possible to swap out inventoryitem's underlying item? My end goal is to swap out inventory items 3D mesh, one way would be to create different item's with different models I guess as I have not yet found a way to swap out single item instance mesh

onyx sage
#

Anyone good with car mods that know how to make new things such as a bullbar installable like in alot of KI5's mods, i cant figure out how to do it, i have all the models textures files ect just cant get it to work!

chilly hemlock
#

Have you checked how KI5 does them?

onyx sage
#

i have but i dont understand how theyve done it, it dont make sense ๐Ÿ˜ญ

chilly hemlock
#

looking at KI5 F-350 he has 3 fbx files, body, all the attachables and wheels
then he has models.txt file where he maps all the attachments like bullpars and such from the _objects.fbx file (i think it uses object names in fbx file)
then he has _bumpers.txt file (vehicle template file) where he creates templates for his car so that the car has slot for bumpers (can have different kinds)
the visual what you see when you inspect the car in game is a lua script file ending with Overlay.lua, looks pretty straightforward
I would import those fbx files into blender or smth to make sure that model it setup correctly tho
seems quite a bit of work and many different kinds of configs but otherwise should be doable when looking into KI5 mods

onyx sage
chilly hemlock
#

I don't think I can be much more help, I have not yet touched vehicle modding at all, this is what I gathered from looking the files
if you don't understand them try modifying/play around KI5 mod until you get some idea how it all goes togethere, at least this is how I'm gonna try to find out how it all works when I finally start making cars

onyx sage
#

im putting a bounty up for anyone who can do it for me

balmy atlas
#

could anyone help me figure out how to call for items equipped on hotbar (back/belt/holster) and get/set their weight when equipped?

slow graniteBOT
#
adn3n19 has been warned

Reason: Bad word usage

onyx sage
#

frog hello everyone im looking for someone who can help me finish my vehicle mod! all that is left to do is some codeing for the bullbar to be a installable peice just like in some of ki5s mods, im willing to pay for the help! dm for more info frog

shy hearth
#

you've a better chance of getting someone to help you there

onyx sage
#

ty

slow graniteBOT
#
adn3n19 has been warned

Reason: Bad word usage

shrewd sable
#

Is there any way to write a recipe so i requires an item, allowed to be in ground, and not be moved in the process of crafting?
For example, require a computer, but don't move it while processing data

shy hearth
#

could write a function to check for a computer on a tile nearby

shrewd sable
#

Yeah well, that's always a correct answer xD But i just can't handle lua yet, and don't want to push that wall right now

#

thought it could be done in a simpler way

#

thanks

shy hearth
#

well if you want to get started on lua this would probably be an excellent onboarding task lmao

#

oh wait, there's also a NearItem parameter that might work

shrewd sable
#

Hahahah thank you very much, i will try it right now. I thought i have seem that but somehow missed when checking the wiki. Tunnel vision after some time without progress is my curse. Thanks a lot mate, hope that works

shy hearth
#

don't tell the wiki folks i said that

shrewd sable
#

Doesn't work ><

bright fog
shy hearth
# bright fog It's just useless overall

it's handy enough for finding more obscure resources without asking here, for whatever reason search engines just don't return results when i search for stuff

bright fog
#

We plan on reworking the whole way modding resources are shared bcs rn it's bad

shy hearth
#

seems like a huge task tbh, if i can help lemme know

shy hearth
shrewd sable
#

NearItem seems to not work as expected xD Has anyone used it?

#

recipe Open codified data
{
destroy SecretFile,
NearItem:Computer,
Result:FilesRead,
Time:600.0,
OnGiveXP:Recipe.OnGiveXP.SecretFile,
}

shy hearth
#

so when you try to do this it just works without being near a computer?

shrewd sable
#

it requires an item "Computer" i've created, and it's placed on the ground

shy hearth
#

ahhh

shrewd sable
#

yeah if i remove NearItem:Computer it works perfect

shy hearth
#

is the Computer like an installed piece of furniture or a loose item on the ground?

shrewd sable
#

if i place Computer as an ingredient it moves it on the ground, and what i want is it to be required but not moved in the process, nearitem sounded good

#

it's a 3D item to be dropped on the ground

shy hearth
#

try using computer as an ingredient and set CanBeDoneFromFloor:true, then remove the NearItem

shrewd sable
#

mmm ok

shy hearth
#

remember to set the computer ingredient to 'keep' or else it'll be consumed

#

but i assume ya know that

shrewd sable
#

recipe Open codified data
{
keep Computer,
destroy SecretFile,
CanBeDoneFromFloor:true
Result:FilesRead,
Time:600.0,
OnGiveXP:Recipe.OnGiveXP.SecretFile,
}

Doesn't work either ><

shy hearth
#

it's probably nothing but you're missing a comma after the true

#

idk if that'll help

#

does it just not work as a recipe or does it move the computer like it used to?

shrewd sable
#

it works now, was that comma

#

in comma is how i will end if i keep modding xD

#

Thank you very much, now it works as expected

shy hearth
#

perfect :) trust me, you're not the first or the last to make that mistake lmao

#

always helps to get a second pair of eyes on it

shrewd sable
#

I have C# background but i'm so lost with lua, and specially with how Zomboid handles stuff indeed it's a f* labirynth

#

tyvm

shy hearth
#

my pleasure, best of luck with ya work

shrewd sable
#

For now it all works. Added some simple lua functions so when you open files it will level up any skill not at level 10 by 1 whole level. I think i have some struggle with the % of xp received as it doesn't seems to be precise, but it's ok, it is for a custom server so, no problem

random tangle
#

Hallo! GMhappy Does anyone know if there's a way to iterate over all items that have already been spawned in the world? I'm looking to be able to replace all of a certain item with an updated version of that item for save game compatibility. It seems that PZ keeps the instance's object data even after updating the script for that object in the mod.

shy hearth
#

i don't but i just wanna say your custom emoji is extremely cute

#

happy little mage

random tangle
spark talon
#

I think the 3d model is working but the problem is probably a texture ?
Idk

#

I need help please

shy hearth
#

Am I using modData incorrectly? I want a table to persist across play sessions but can't figure it out.

#

and in my initialise function I do

neon bronze
#

Not null but nil

#

Also you can just do
If _fatigueTable then

#

That is an existence checl

shy hearth
#

ya fair, but that function never seems to trigger anyway so i don't think that's overwriting it

#

lemme double check

#

yea i don't have that null check trigger anyway, but i'll make the changes

#

aside from that can you see any reason this wouldn't be persisting across sessions?

neon bronze
#

Cant really say without the bigger picture

#

Or where you check gets called from

shy hearth
#

understandable. the LoadLongTermStiffness gets called only during OnCreatePlayer, and the Save is called OnDisconnect and EveryHours

#

the table that they're saving is only changed in this function

#

and the table works as intended within one play session

#

but is empty when I leave and rejoin the server

#

might be a bit much to digest without the entire script but don't wanna just dump the entire body into the chat

#

so whatever help yez can give is appreciated but no pressure

neon bronze
#

You could try with player:transmitModData()

#

But i am not so sure

shy hearth
#

i'll give it a shot, thanks

chilly hemlock
#

hmm.. I'll take that running animations on WorldStaticModel models is not possible?

bronze yoke
#

it is not

stray willow
#

How do items like...Beta Blocks and Painkillers work?

When I go on the wiki to see the code snippit for them

item Pills
{
    Weight = 0.2,
    Type = Drainable,
    UseDelta = 0.1,
    UseWhileEquipped = FALSE,
    DisplayName = Painkillers,
    Icon = PillsPainkiller,
    Tooltip = Tooltip_Painkillers,
    StaticModel = PillBottle,
    Medical = TRUE,
}
item PillsAntiDep
{
    DisplayCategory = FirstAid,
    Weight = 0.2,
    Type = Drainable,
    UseDelta = 0.1,
    UseWhileEquipped = FALSE,
    DisplayName = Antidepressants,
    Icon = PillsAntidepressant,
    Tooltip = Tooltip_PillsAntidepressant,
    StaticModel = PillBottle,
    WorldStaticModel = PillBottleGround,
    Medical = TRUE,
}
item PillsBeta
{
    DisplayCategory = FirstAid,
    Weight = 0.2,
    Type = Drainable,
    UseDelta = 0.1,
    UseWhileEquipped = FALSE,
    DisplayName = Beta Blockers,
    Icon = PillsBetablocker,
    Tooltip = Tooltip_PillsBetablocker,
    StaticModel = PillBottle,
    WorldStaticModel = PillBottleGround,
    Medical = TRUE,
}
#

Where is the code that causes these items to reduce depression, pain, and panic?

#

I figured it would be part of the item itself

#

Similar to like, food

#

Like

PainReduction = 7,
#

or

StressChange = -15,
stray willow
wheat kraken
#

hey, i released a mod to spotlight and showcase (with short useful description) others mods

with/by community moderation and collaboration

so if you want to be part of (as player or modder)

you can use the discord bot, and that updates the mod content

so share yours must have, underrated, should be in vanilla mods there!

(suggestion: mods with new mechanic, game changers...

preferaby with that and less than 100k subs)

https://steamcommunity.com/sharedfiles/filedetails/?id=3188518356

neon bronze
stray willow
#

Like I wanted to do, read this book, reduce panic.

#

or to get that ...Panic Reduction or Painkiller aspect of sorts

bright fog
stray willow
#

into other items, tldr I don't want to change but

bright fog
#

bcs I'm looking at some lua code and I'm not too sure

stray willow
#

use that same code

neon bronze
#

it calls JustTookPill in the IsTakePillAction

#

which performs getType in its java code

bright fog
#
--***********************************************************
--**                    ROBERT JOHNSON                     **
--***********************************************************

require "TimedActions/ISBaseTimedAction"

ISTakePillAction = ISBaseTimedAction:derive("ISTakePillAction");

function ISTakePillAction:isValid()
    return self.character:getInventory():contains(self.item);
end

function ISTakePillAction:update()
    self.item:setJobDelta(self:getJobDelta());
    self:setActionAnim(CharacterActionAnims.TakePills);
end

function ISTakePillAction:start()
    self.item:setJobType(getText("ContextMenu_Take_pills"));
    self.item:setJobDelta(0.0);
    self:setOverrideHandModels(nil, self.item);
end

function ISTakePillAction:stop()
    ISBaseTimedAction.stop(self);
    self.item:setJobDelta(0.0);
end

function ISTakePillAction:perform()
    self.item:getContainer():setDrawDirty(true);
    self.item:setJobDelta(0.0);
    self.character:getBodyDamage():JustTookPill(self.item);
    -- needed to remove from queue / start next.
    ISBaseTimedAction.perform(self);
end

function ISTakePillAction:new (character, item, time)
    local o = {}
    setmetatable(o, self)
    self.__index = self
    o.character = character;
    o.item = item;
    o.stopOnWalk = false;
    o.stopOnRun = true;
    o.maxTime = time;
    return o
end

neon bronze
#

self.character:getBodyDamage():JustTookPill(self.item);

bright fog
#

yeah so he basically needs to call that ?

#

(adapted with right variables)

neon bronze
stray willow
neon bronze
#

he cant call it cause they hardcoded the types of pills that the effects apply to

bright fog
#

what ?

stray willow
#

I just don't see it mentioned

bright fog
stray willow
#

That blows

bright fog
#

not in the lua

neon bronze
#

i might be stupid

#

but

bright fog
#

so what he sent

bright fog
neon bronze
#

you could make your own module

bright fog
#

But that's a vanilla function here

neon bronze
#

and then add smth like Volke.PillsBeta

bright fog
#

no need for modules or shit, just he has to check whenever the player is taking the pill, or create a custom action which triggers the function

neon bronze
#

cause it only checks the type not the full type

bright fog
#

also that's not hard coded

#
-- have the same effect as the base game pill, replace pillItem by either painkiller, or other type of pill (NOT YOUR OWN CUSTOM ONE)
player:getBodyDamage():JustTookPill(pillItem);

--or
-- create an action for your item which is basically "Take Pill" and make the changes on the player whenever he's done taking the pill
stray willow
#

I saw another mod that has:

function ISUseChem:perform()

    local Fix = 0
    if self.item:getType() == "MedX" then

        self.character:getBodyDamage():setPainReduction(65.0);
        self.character:getStats():setPain(self.character:getStats():getPain() - 40.0);
        self.character:getStats():setFatigue(self.character:getStats():getFatigue() - 0.3);
        self.character:getStats():setStress(self.character:getStats():getStress() - 0.5);
        self.character:getBodyDamage():setUnhappynessLevel(self.character:getBodyDamage():getUnhappynessLevel() - 40.0);
        self.character:getBodyDamage():setBoredomLevel(self.character:getBodyDamage():getBoredomLevel() - 35.0);
        self.character:getStats():setDrunkenness(self.character:getStats():getDrunkenness() + 25);
        self.item:getContainer():setDrawDirty(true);
        self.character:getInventory():Remove(self.item);
        self.character:getInventory():AddItem("Base.EmptyMedX");

        self.character:playSound("Stimpack");

        if self.character:HasTrait("Hemophobic") then
        --Big blood baby trait time
            self.character:getStats():setPanic(self.character:getStats():getPanic() + 50.0);
            self.character:Say(getText("Tooltip_blood"));
        end
#
--***********************************************************
--**                    ROBERT JOHNSON                     **
--***********************************************************

require "TimedActions/ISBaseTimedAction"
require "TimedActions/ISTakePillAction"

ISUseChem = ISBaseTimedAction:derive("ISUseChem");
bright fog
#

works too

stray willow
#

Might try to do something like that then ๐Ÿค”

bright fog
#

Even if in vanilla it's partially handled in the java, it's ok you can write your own

neon bronze
#

yea i mean you could probably hook into the action that your item shold perform (Reading if its a book, eating if its a food etc..) and just call player:getBodyDamage():JustTookPill(InventoryItemFactory.CreateItem("Base.PillsBeta")) or smth else

bright fog
#

yeah

bright fog
bright fog
#

Either you do that and have your pill have the same effects than the vanilla ones

bright fog
stray willow
bright fog
#

take his command line, it's more exact than mine

#

with the ItemFactory thing

#

Bcs you need to reference an item basically

drifting ore
#

Dear leaders, I am a new developer from China, and I am deeply interested in the development of mod for Zombie Destruction Project. Sadly, there are no decent mod development tutorials in China, and I am not particularly familiar with the foreign environment, so I hope you can recommend some suitable mod development tutorials to me. I have tried to learn a part of lua and understand a part of other mod files, but I still have doubts about some functions and tables that PZ can call. Perhaps such a request is a little abrupt, but at least in our country, we ask questions to others in this way. If you are offended, I hope you can be tolerant. [shy]

slow graniteBOT
#
doafe has been warned

Reason: Bad word usage

thick karma
# drifting ore Dear leaders, I am a new developer from China, and I am deeply interested in the...

I would say that part of the process requires basic study of the programming language you're using or the publicized rules for whatever scripts you're trying to write. Part of it is studying what other mods have done, and learning how various goals can be accomplished one-by-one. There is no single place to learn everything you might end up needing to know. Some stuff is unpublished and discovered by reading decompiled code, game Lua files, game script files, and public Java documentation on the game. Material does exist, but you have to be just-specific-enough when you ask Google or YouTube to connect you with the kind of knowledge you want. If you're too specific and no one has done something before, you won't get anywhere, but if you ask questions that are broader than that but much less broad than "how do I mod Project Zomboid", you tend to get better answers.

bright fog
#

hey, welcome

#

Your request is fine don't worry, this place is here to help each others

thick karma
# drifting ore Dear leaders, I am a new developer from China, and I am deeply interested in the...

That said, I do have a tutorial project here that you can use to try to learn the basic structure you need for a very ordinary workshop item involving trait creation and a little function decoration. https://github.com/Zendachi/Wookiee-Tutorial-Party-Animal/tree/main

GitHub

Contribute to Zendachi/Wookiee-Tutorial-Party-Animal development by creating an account on GitHub.

bright fog
#

Those can help getting into modding

thick karma
#

There are also some 2-3 hour full tutorials on YouTube walking people through modding from start to finish.

#

Any of them may be helpful if you think you'll absorb some things better that way.

drifting ore
# thick karma I would say that part of the process requires basic study of the programming lan...

This is a good answer, I think I should know how to learn how to make a mod, and how to start. I know that there is no place where I can learn all the contents that I need to make mod eventually. After all, no one can record all the contents that I have learned. Moreover, people's cognition is spiraling. Only by constantly solving problems and encountering problems can we truly understand and learn things. In other words, everyone is different. Thank you for your experience on how to learn a thing. This is really a sharp suggestion that hits the nail on the head, but I think I don't have a specific problem to solve now. Compared with this problem, I think I should learn more about some relatively formal mod tutorials. The tutorials and methods I can find in our country are either lacking in weight or have no end, so that they just talk about it. In fact, in other words, I also hope to find a new problem and a new research goal for myself through a relatively different tutorial.

slow graniteBOT
#
doafe has been warned

Reason: Bad word usage

drifting ore
bright fog
#

We'll most likely never meet IRL but sure lol

drifting ore
drifting ore
bright fog
drifting ore
bright fog
#

it's the same for anyone who's not familiar with it dw lol

#

It's not user friendly at all

drifting ore
#

hhhhhhh

drifting ore
bright fog
#

lol np

#

the modding resources are not great overall tho

drifting ore
#

Yes, at least I can see it from some files in mod that I have studied.

bright fog
#

๐Ÿ‘Œ

drifting ore
bright fog
#

not exactly but that works lol

drifting ore
#

Hhhh, this is very interesting. I think I need to learn more about foreign cultures.

bright fog
#

it's probably not that different from yours, we're humans afterall

drifting ore
#

But it's really novel, just like getting used to seeing the buildings in the city and suddenly seeing a large forest.lol

#

Of course, this is not derogatory, just an expression that makes people feel refreshed.

bright fog
#

I see what you mean yes

#

You could probably watch PZ videos in english

drifting ore
#

I have tried to watch English videos of PZ in the past, but my English level is very poor. I can only try to use some factual subtitles to watch while learning English.

bright fog
#

๐Ÿ‘Œ

drifting ore
#

For China netizens, most things on the extranet are novel, and the whole world seems to us to be divided into two branches, one inside the wall and the other outside the wall. For the simplest example, I can't see some boring verification mechanisms and some automatic jumping mechanisms that make people's blood pressure rise in the hottest software abroad. Even speaking, they are all humanized, at least as far as the corresponding software in our country is concerned. In a sense, we are like overprotected birds, but our country still turns a blind eye, leaving a channel for some of us who are willing to explore the unknown to the outside world.stressed

bright fog
#

interesting

#

Yeah we kind of have this vision of China has a closed wall

sour island
steep cloak
#

I'm happy to announce that Save Our Station has also received a new update today, which includes new and improved (user-submitted) translations, along with adding even more Sandbox Options - letting you further customize your Broadcast Repair experience and tweak the mod's difficulty to your liking.

The update is backwards compatible with existing saves (as will all our updates until B42 releases - aka when we intend to add Basements to the stations, and so some overall map reworks/updates). If you want to change the new options in an ongoing save, you can use a mod like "Change Sandbox Options (by Star)" to do so in-game and have the new settings apply immediately.

A more comprehensive changelog can be found on the workshop item's Changelog page.

Enjoy - a bigger update is coming fairly soon ^^

drifting ore
#

For the network environment, compared with foreign countries, our country is more like the capital-oriented world described in Cyberpunk 2077. Traffic, money, these deeply corrupt all projects and platforms, just like the products of those big companies we use, they often want to tie users under themselves and let them build a cocoon of death for themselves, whether it is the communication platform used in our country to push those meaningless games of changing skins and making money. Or the pseudo-scientific content pushed by the news and information platform they control that misleads people's political inclination and cognitive logic or something else [and basically most people are convinced of it], and most of the cyberspace is corrupted by these big companies. One of the simplest examples is that Minecraft was represented by Netease [a big company] in our country and became a page that was forced to jump to Netease games in MC official website. And use all kinds of inappropriate behaviors to guide players to recharge their batteries, and make the player community become a place where young people quarrel. Among them, "mod" is the most corrupt place for big companies. They constantly steal the works of mod authors from outside the network and sell them at the expense of money without authorization. The above is also a large part of the reason why I feel awe and novelty on the Internet.

steep cloak
#

SOS and EHE still play together amazingly well :)

bright fog
proven laurel
#

Hey, could someone help me tell the difference between mapdata and chunkdata?

#

I'm trying to use the tool but have no idea what am I deleting

bright fog
#

chunk data is most likely a 10x10 area of tiles

#

map, no idea

proven laurel
#

when I used all 3 checkbox it did reset a part of the map I highlighted on the tool so I'm wondering what is this map data about

drifting ore
# bright fog sounds terrible, could you perhaps move out in another country ?

For the people of China, home and country are often permanent habitats, or we are naturally reluctant to migrate. Although he has various defects, we will not abandon him. On the contrary, we will try to repair him. Even if we can't do anything personally, we will still try to change him. Even if we don't make changes, we will find our own way out without being controlled and deceived by big companies and without adding trouble to our country. And as far as I am concerned, our country is a very comfortable place, except for some system and management problems left by the rapid social development [this passage has even been compiled into textbooks]. We have excellent infrastructure for us to connect with every inch of our country, or to reach the westernmost point of Russia directly through our country's railway. Our life safety is also regarded as a godlike belief, and our country does not allow our life safety to be threatened. In a word, our country is a child or a mother who is full of problems but equally excellent for each of us in China. What's more, she didn't try to tie us down. She was just overprotective. Just like me now, our country provides a channel for us to turn a blind eye so that individuals can communicate with the outside world. We in China will not abandon our mother or our child because of a little defect, or leave him, just like every mother and child in the world.

proven laurel
#

I think I'm gonna most likely end up checking the source code

bright fog
drifting ore
proven laurel
#

@bright fog if you see the save directory it auctally differenciates between chunk and map files

#

so i guess one checkbox deletes ones and the other deletes the others

#

but no idea what is a real difference between them

bright fog
#

a chunk is a 10x10 area

#

but here, they named it chunk but it's a 300x300 tile area

#

And basically names for cells, chunks and fuck what always changes depending on where you look

proven laurel
#

Im just wondering what will happen if I delete map without chunk file and the other way around

#

what would be the difference ingame

bright fog
#

no idea

proven laurel
#

gonna fiddle with that then

#

but thank you anyways Sir!

bright fog
#

๐Ÿ‘Œ

grizzled fulcrum
#

also I read somewhere that globals are bad, so I've been making literally everything I can a local, is this good practice to maintain?

bronze yoke
#

you can but this is a very old version of the lua standard, modules aren't usually done like this anymore

#

yes, you almost never need to use a global and there isn't really any benefits to using one either

#
-- modulename.lua
local modulename = {}

return modulename

-- in another file
local modulename = require "modulename" -- loads the module returned by the file modulename.lua
grizzled fulcrum
#

I have done it like that so it's good to know I wont have to rewrite everything

bronze yoke
#

i recommend looking for a newer lua manual, the one you linked is from 1996 ๐Ÿ˜…

grizzled fulcrum
grizzled fulcrum
#

but I am not using that manual to learn thank god that would suck

bronze yoke
#

if you're trying to access files from other mods/vanilla that don't return anything you just use the globals, using them is generally fine just avoid creating them

#

you can pull globals into local local MyVar = MyVar to save a bit of performance when accessing them but it's not vital

grizzled fulcrum
#

ok I see, thankyou

plain crest
#

okay i'm p sure i'm doing something wrong but i'm not subscribed to my mod, deleted any files associated with it, etc., and when i try to replace the DBX files in my workshop folder to like. test/update some things, it doesn't change tot he new model

#

implying there's some leftover files somewhere

#

any insight..?

#

figured it out i think--i had copied my mod folder to make a diff mod and i think i left the workshop file intact. whoops!

oblique estuary
#

.fbx files should be useable for weapons models, right?

#

Is there anyone that can tell me what I need to define in the script for a melee weapon at
"Weapon sprite" I searched the chat already as I thought that question most likely had been asked before, but I didn't really feel like I got to understand what I need to do. Is it the name of the "Model" in model script.. Is it the model file or the texture file?
The weapon doesn't show up in the game is the main issue, it's just transparrent

bright fog
plain crest
random minnow
#

I have a friend who is a senior programmer, and playing project zomboid has said that it would be quite easy to integrate the Inditex mode of Minecraft , which consists of a box that can access all the other boxes around where you can take any object directly from the "mother" box without having to go moving around the base and go to the container where it has the object you want. Is this possible to create because of the limitations of the game? Because I find it strange that no one has done it.

grizzled fulcrum
#

Is there any situation where the user can change the language of the game without restarting the game or reloading lua? I am currently caching translations because I hate calling getText so frequently, though I am worried if the user is able to somehow change language without reloading the mod, the cached translations wouldn't update. If so, I am not worried as I can just re-cache them when the game's language is changed.

bronze yoke
#

i don't think so, but i will add that's a very odd thing to do and it would only happen to someone who speaks both languages anyway so it's a temporary minor inconvenience at most

grizzled fulcrum
#

Is the cache an odd thing or changing languages mid-game?

bronze yoke
#

changing languages mid-game

#

i don't think you can without triggering a reload but it just seems like a very strange thing to do regardless

grizzled fulcrum
#

thanks for helping ๐Ÿ™

twin harness
#

hello everyone

#
-- Define a global table to store logout times
local logoutTimes = {}

-- Define the function to save logout time
function saveLogoutTime(playerId)
    logoutTimes[playerId] = os.time() -- Save current server time as logout time
end

-- Define the function to calculate tiredness adjustment
function calculateTirednessAdjustment(logoutTime)
    local currentTime = os.time() -- Get current server time
    local offlineDuration = currentTime - logoutTime -- Calculate duration offline in seconds
    local offlineHours = offlineDuration / 3600 -- Convert seconds to hours
    
    -- Assuming 8 hours of sleep makes you fully rested
    local maxSleepHours = 8
    local tirednessAdjustment = math.max(0, maxSleepHours - offlineHours)
    
    return tirednessAdjustment
end

-- Hook into the player logout event
Events.OnPlayerLogout.Add(function(player)
    local playerId = player:getUsername() -- Get player's username as their ID
    saveLogoutTime(playerId) -- Save logout time
end)

-- Hook into the player login event
Events.OnPlayerLogin.Add(function(player)
    local playerId = player:getUsername() -- Get player's username as their ID
    local logoutTime = getLogoutTime(playerId) -- Retrieve logout time from storage
    
    if logoutTime then
        local tirednessAdjustment = calculateTirednessAdjustment(logoutTime)
        player:getStats():setFatigue(player:getStats():getFatigue() - tirednessAdjustment)
        -- Optionally, notify the player about their rested status
        player:Say("You feel refreshed after your sleep.")
    end
end)

-- Function to retrieve logout time from storage
function getLogoutTime(playerId)
    return logoutTimes[playerId] or nil
end
twin harness
# twin harness ```lua -- Define a global table to store logout times local logoutTimes = {} --...

i am working on a mod that simulates sleep for players even when they're offline, so they don't have to wait for their characters to sleep in real-time on a multiplayer server. the point of this is to allow the passage of time to be set to set to real-time for a more realistic experience. is anyone interested in helping me test it? i don't own a multiplayer server so i can't test it our myself, otherwise i would have tested the code already

#

this is my first lua script for this game

#

can anyone provide me with feedback??

runic siren
#

heyoooo!

#

i was wondering if someone could possibly make a really simple mod that just gives Park Ranger either the Herbalist trait, or at least the abilities it gives you without the stat increases by giving them a unique skill

coarse sinew
# twin harness i am working on a mod that simulates sleep for players even when they're offline...

I suggest you to not use ChatGPT to write code for PZ. It hallucinates function names and it will take longer to debug that code than if you created it from scratch. Also those Event names don't exist, here's a list of all events https://github.com/demiurgeQuantified/PZEventDoc/blob/develop/docs/Events.md

GitHub

Tool for generating Lua documentation for Project Zomboid events and hooks - demiurgeQuantified/PZEventDoc

verbal yew
#

vaccine 2.0 in progress
my personal brain orgasm

bright fog
#

Doesn't exactly do the same but could possibly be modified to take inventories far away too

bright fog
#

While there can be one or two differences with real servers I've heard, it still acts as a server

verbal yew
#

?!

#

This mod allows you to rest/sleep your character while disconnected, when you reconnect, you will have slept as much as the world has advanced in time (based on the age of the PZ world).

#

okay...

slow graniteBOT
#
kelvinthelazycat has been warned

Reason: Bad word usage

balmy atlas
#

could anyone help me figure out how to call for items equipped on hotbar (back/belt/holster) and get/set their weight when equipped?

balmy atlas
#

YES thank you, I don't know why I just find it difficult to find things on workshop

verbal yew
#

just it's can help take info for your request

#

if we can't change actualweight, just need swap standard weight i think

balmy atlas
#

I like authentic Z backpack + mod and ability to attach things to it and getting extra hotbar icons but I dont like thats it is kinda "pointless" to do because you are better of putting things inside the backpack, thats why I am trying to get items attached to backpack to inherit encumbrance reduction. Not sure if someone did it already but I am also just trying to learn new things

desert kelp
#

Anyone know a way to rename a way to rename an item like

player:getInventory():AddItem():setDisplayName() ?

Something like how caught fishes are renamed. Would appreciate it. Thanks!

hollow current
hot void
#

is there a way to make make up show when you click another player

desert kelp
#

@hollow current thanks it worked for me โค๏ธ

slow graniteBOT
#
nadolphin has been warned

Reason: Bad word usage

compact rampart
#

are these tiles even used in the game?

bright fog
#

I don't think so

compact rampart
#

thats a shame

verbal yew
#

guys, how to get recipes to existing professions?

#

without overriding

#

or skill with exp boost

#

like Axe +2 for example

desert kelp
verbal yew
#

nah, not event

desert kelp
#

You want to redefine creation menu?

#

Just redefine the profession then add the bonus

verbal yew
#
local tailor = ProfessionFactory.addProfession("tailor", getText("UI_prof_tailor"), "icon_tailor", 2, getText("UI_profdesc_tailor"))
    tailor:getFreeRecipes():add("Craft Thread");
    tailor:getFreeRecipes():add("Craft Twine");
    tailor:getFreeRecipes():add("Craft Yarn");
    tailor:getFreeRecipes():add("Tailor a Sheet");
    tailor:getFreeRecipes():add("Tailor a Tarp");
    tailor:getFreeRecipes():add("Tailor a Pillow");
    tailor:getFreeRecipes():add("Tailor a Sack");
    tailor:getFreeRecipes():add("Knit a Scarf");
    tailor:getFreeRecipes():add("Knit Winter Gloves");
    tailor:getFreeRecipes():add("Knit a Balaclava");
    tailor:getFreeRecipes():add("Knit a Winter Hat");
    tailor:getFreeRecipes():add("Knit a Woolly Hat");
    tailor:getFreeRecipes():add("Knit Long Socks");
    tailor:getFreeRecipes():add("Knit a V-Neck Sweater");
    tailor:getFreeRecipes():add("Knit a R-Neck Sweater");
    tailor:getFreeRecipes():add("Knit a P-Neck Sweater");
    tailor:getFreeRecipes():add("Knit a Long Johns");
    tailor:getFreeRecipes():add("Make a Sling");
    tailor:getFreeRecipes():add("Make a Belt");
    tailor:getFreeRecipes():add("Make Ammo Straps");
    tailor:getFreeRecipes():add("Make a Sling");```
#

like this?

#

in New func with event

#

but its override!? no?

coarse sinew
# verbal yew ```lua local tailor = ProfessionFactory.addProfession("tailor", getText("UI_prof...

Or you can do something like this:

-- On Player Load, check their professions and if it matches
-- one we're expecting, add some free recipes to their character
function BMAddRecipesToExistingPlayers(id, player)
    local profession = player:getDescriptor():getProfession();

    -- Adjust Engineers with Glass Smelting by Default
    if profession == "engineer" then
      player:learnRecipe("BMPrepareGlassShards");
    end
end

-- Character loads into the world
Events.OnCreatePlayer.Add(BMAddRecipesToExistingPlayers);
desert kelp
small topaz
# verbal yew ```lua local tailor = ProfessionFactory.addProfession("tailor", getText("UI_prof...

alternative if you want to modify the actual profession and not the specific player:

engineer:getFreeRecipes():add("Generator")
engineer:addXPBoost(Perks.Mechanics, 1)```

This will also show the mechanic +1 skill point in the occupation screen during character creation. Disadvantage of addXPBoost() is that will override the profession's vanilla XP boost in case it has one (or overwrites any XP boost it gets from mods loaded before yours).
small topaz
# verbal yew very nice, thats what i want

oh wait... to get the "+1 mechanic" also shown in the occupation menu, it may be necessary to add some additional lines of code. Not sure anymore but I'll take a short look at my profession mod to see how it works again...

verbal yew
#

i check it tomorrow

small topaz
small topaz
#

btw in my code example from above, it is probably not necessary to apply
BaseGameCharacterDetails.SetProfessionDescription(prof)
to all professions but only to the ones you actually change...

grizzled fable
#

Hi all, how to mod for not let spawn a specific item? can i overwrite the loot distribution?

small topaz
grizzled fable
small topaz
mellow frigate
#

Hello there, has someone any idea on how I could change an ingame text line association (from text_key to text) dynamically from lua ? I want Java text traduction process to be impacted.

small topaz
#

in case this somehow works, you have do this for all distribution lists using suitable iterations...

but in fact, I guess there are easier ways to make an item not spawn in the game...

Also, lua has a command for removing elements from tables. I wasn't able to figure out how exactly it works by a quick web search but in case you learn it, you can probably use that command to remove items (instead of my code).

EDIT: error in my code: I think you need "ipairs" instead of "pairs" in my first for-loop

bronze yoke
#

there's a vanilla function to remove an item from all distributions

#

i don't remember its name but i think it's defined in the main distributions file

#

to remove elements from tables normally you just use table.remove(table, index)

#

when using table.remove in a loop always loop from the end of the table or you will skip elements

#

i think it's technically undefined behaviour in pairs/ipairs loops

small topaz
bronze yoke
#

in ipairs i can imagine it causing the same problem as a numeric loop but for pairs i don't really know what would happen, i don't think the lua specification defines it

grizzled fable
#

ok ty

ebon briar
bronze yoke
#

true but it's a little complex and iterators are discouraged

#

ipairs is just a numeric loop but insanely slower, pairs is only useful for tables that don't have consecutive numeric keys, which you don't need table.remove for

ebon briar
#

Slower? huh. Never really noticed a speed difference. Would've thought the underlying C implementation would just be some sort of custom iterator system using pointers. Maybe not though.

bronze yoke
#

in regular c lua ipairs is only a little slower, in kahlua (java implementation pz uses) it is significantly slower

ebon briar
#

Aaah. Yeah, that makes sense

#

Java be like that

bronze yoke
#

weirdly it isn't actually natively implemented in java at all, it's lua from a stdlib file somewhere

#

i think kahlua does implement it so i'm guessing the native implementation was somehow even slower

#
local function ipairs_iterator(t, index)
    local nextIndex = index + 1
    local nextValue = t[nextIndex]
    if nextValue ~= nil then
        return nextIndex, nextValue
    end
end

function ipairs(t)
    return ipairs_iterator, t, 0
end
ebon briar
#

I imagine since Java doesn't have pointers the implementation must do some sort of really roundabout way of doing iterators.

ebon briar
bronze yoke
#

i benchmarked it recently and it was around five times slower than a numeric loop

#

it's actually much slower than even pairs so there's absolutely no reason to use it

ebon briar
#

Oooh, cause it's a function call

#

Just saw that

#

Yeah, function calls are slower cause of how it works in ASM, that's why iterated functions aren't really seen in practical software

#

Only in educational environments

#

Makes sense it'd be a lot slower

bronze yoke
#

in general, it's best to use tables as array-like objects and use numeric loops, or as hashmap-like objects, to avoid both iterators

slow graniteBOT
#
5463sh has been warned

Reason: Bad word usage

ebon briar
#

Question, is the OnTest function called separately for every item that is used to craft something? I'm noticing all the OnTest functions used in the base game lua files only take a single item

#

Whereas the OnCreate function for the exact same crated item takes multiple ingredient items as its argument

bronze yoke
#

it's called for every item that is considered to craft the item

#

it's used to filter out items based on their specific properties, if you return false the item won't be allowed to be used in the recipe

#

(if it doesn't jump to it automatically, the script callbacks are at the bottom of the page)

ebon briar
#

Appreciate it

#

One last thing, is there some sort of console or a way to output text for the purpose of bug testing? I'm trying to set up a condition for a recipe based on the result of "getDisplayName()" but for some reason it's not returning as true.

#

Wanna see what getDisplayName() is returning so I can see if it's what I expect it to be

bronze yoke
#

if you run the game with the -debug argument there's a lua console which prints output to, as well as some other tools

ebon briar
#

Gotcha. Thanks.

bronze yoke
#

you can also check console.txt in %UserProfile%/Zomboid (windows)

ebon briar
#

Appreciate it

ebon briar
#

Hey so I assumed "getDisplayName()" would return the name of something as displayed in the UI but that doesn't seem to be the case

#

Since this spear is showing "Crafted Spear(Broken)" but the function is still returning "Crafted Spear"

bronze yoke
#

try just getName()

#

the internal name is *usually* (tired) called the type instead

ebon briar
#

Gotcha

bronze yoke
#

getDisplayName probably returns the DisplayName from the item script, which is a legacy feature from before it was all done with a translation system

ebon briar
#

Aah, gotcha

#

Yup, that was it

#

Alright one last question, truly. How do I associate associate a new item with a model/inventory item

#

Like I have the recipe and item scripts, but when I craft it the item is not put into my inventory

#

Which makes sense kinda cause idk how to associate the item script with a model

#

Rn I don't have a unique model, I just wanna associate it with an already existing model

bronze yoke
#

the model needs a model script, the name of that model script would be referenced as the item's WorldStaticModel

#

the item should still be created by the recipe without one set though

ebon briar
#

It isn't. I know the item script is working cause my inventory weight increases by the amount I set the item to, but it doesn't actively appear in the inventory

bronze yoke
#

i don't remember what causes that, i think the inventory ui likes to hide items with a certain criteria...?

ebon briar
#

Actually I just checked and the weight wasn't changing anymore. I think I modified the scripts at some point and don't remember

#

Probably when I try trying to solve the recipe issue

#

It threw out an error

#

I'm horrible at reading Java errors

#

It feels like trying to decipher ancient hieroglyphics.

#

All I got from it is "Cannot invoke "Zombie.inventory.InventoryItem.getScriptItem()" because "<localg>" is null"

toxic narwhal
#

You have a null pointer exception, which means you're trying to access something that does not exist (yet). you might want to check spelling mistakes

bronze yoke
#

yeah, this is the more annoying kind of error where the java is the part that's erroring

#

it's usually still your mod's fault, you just have more layers of obscurity

#

Cannot invoke "Zombie.inventory.InventoryItem.getScriptItem()" because "<local9>" is null makes me think it failed to create the item when crafting it

#

the cause is possibly an error in the item script, or a typo in the recipe script

#

oh, did the error happen when crafting or when you tried to open the crafting menu?

#

the crafting menu explodes if a recipe has an invalid Result, so that would pin the cause down to that

ebon briar
#

When crating it. I'm just confused why.

#

I mostly just copied from the CraftedSpear files and modified them

toxic narwhal
#

You're missing a comma after* AllowOnlyTrue

ebon briar
#

Ahhhh

toxic narwhal
#

There may be more, like after spear. I don't know if this is the root cause but it can mess stuff up for sure

bronze yoke
#

yeah, always check commas when you're having issues like this

#

whenever you miss a comma it usually causes a cascading issue where literally every line after that mistake isn't being read

ebon briar
#

Yeah that fixed it

exotic ember
#

Anyone want bragging rights to say their smarter than ChatGPT? I'm offering you a once in a lifetime offer to solve the unsolvable math equation (apparently) ๐Ÿ˜…

This is what I have at the moment:

defaultTimeMovementSpeed = 1
defaultDayDuration = 6
desiredRealTimeDuration = 30
newTimeMovementSpeed = defaultDayDuration / desiredRealTimeDuration
minutesInDay = newTimeMovementSpeed * 360 / 60

The part I am struggling with is the minutesInDay, where I am trying to convert the newTimeMovementSpeed Back into the form of minutes, where a calculation of 1 * 360 / 60 = 6 Minutes, using that same equation cannot be done once the time speed has been lowered as: 0.2 * 360 / 60 = 1.2 (Not the 30 Minutes that I need)

So mainly what I need is the Krusty Krabs Secrete formula for the desired outcome ๐Ÿ˜…

I understand this could all be hard coded without the need of Mathematics though I wish to have the desiredRealTimeDuration be dynamic and changed at will, so I need the equation to handle the Mathematics of, okay 0.2 = 30 minutes, 0.5 = 12 minutes, 1.0 = 6 minutes, 2.0 = 3 minutes etc

Any help with this would be greatly appreciated ๐Ÿ™‚ if its not obvious already I suck at math ๐Ÿ˜›

drifting ore
#

Guys, is there any way to add meta table rules to the sub table name of meta table chayezi = set meta table ({name = {}}, {})?

#

I tried to ask AI, but the answer he gave me was to set chayezi.name in the meta table again.

#

It's stupid to add meta tables again and again.

#

I need a better solution

bright fog
drifting ore
bright fog
#

What you want is an equation linking time = f(coef), could simply be time = a*coef + b, that's a classic math problem

#

(something like that)

#

It will most likely be 1/coef looking at it

drifting ore
desert kelp
#

@drifting ore this what you're looking for?

-- Creating a table
outerTable = {}

-- Creating another table
innerTable = { key1 = "value1", key2 = "value2" }

-- Putting the inner table inside the outer table
outerTable.inner = innerTable

-- Accessing the inner table
print(outerTable.inner.key1) -- This will print "value1"
print(outerTable.inner.key2) -- This will print "value2"

exotic ember
# drifting ore Could you please describe the problem more accurately? It's bothering me.

It's a bit off topic, but I've reached out all over trying to find a solution for this, but its for a Unity Project, the actual code is:

(See Below)

Though I'm just at a complete loss now, I thought it was just converting back into minutes was the issue, but am still having a re-occurring issue where my Desired Minutes Per Day just aren't being calculated correctly.

My desired Day length is 30 minutes... but the only numbers I have access to in my EcoSystem Framework are a Time Speed of 1 which mean that the Sun will rotate 1 unit of rotation every Real Second, therefor it would take 360 real seconds to achieve a full 24 hr cycle (360 seconds = 6 minutes), I want to be able to input a desired Day Length in Minutes, which the script then calculates what the timeSpeed should be based on those factors

#

But there's obviously more wrong than my math equations than I thought, because at a speed multiplier of 0.2 (in theory) should equate to a 30 Minute Day Cycle, given that at a speed of 1 it takes 6 Minutes, which going by 6 = 1, 12 = 0.5, 24 = 0.25 etc, it seems plausible that 0.2 would equal roughly 30 minutes, however I've had my game Idling in the background while seeking help in for over an hour and it still hasn't completed it 30 minute day cycle, it started at 7am and is only now at 8pm after about an hour and 10 minutes so, im just completely lost at the moment

#

It also doesn't help that discord Crams code together and all in one color, makes it very difficult to understand ๐Ÿ˜› this might be a bit easier

modern dirge
#

I might be misunderstanding this but if you want 30 minutes from 0.2 you can do 1/timespeed * 360/60

desert kelp
#

@drifting ore check if this is what you want hahaha AI did the work

-- Creating a table
outerTable = setmetatable({innerTable = {}},{
__index = function (table, key)
if key == "tumi" then
return "chayezi"
end
end
})

-- Creating a metatable for innerTable
innerMetatable = {
__index = function (table, key)
if key == "tumi" then
return "chayezi"
end
end
}

-- Set the metatable for innerTable
setmetatable(outerTable.innerTable, innerMetatable)

-- Now both outerTable.tumi and outerTable.innerTable.tumi will return "chayezi"
print(outerTable.tumi)
print(outerTable.innerTable.tumi)

frank elbow
#

I just did java modding for the first time (due to having no other way to address something) and I was under the impression that it would involve more than decompile โ†’ change โ†’ recompile. I thought I remembered there being a concern raised somewhere about bytecode mismatches, but that's all it took. Is there something I'm missing?

exotic ember
# modern dirge I might be misunderstanding this but if you want 30 minutes from 0.2 you can do...

๐Ÿ˜ฑ That seems to check out, I will try that out

Though I do feel that my calculations to get newTimeMovementSpeed is still wrong (0.2), The only thing I have to go off, is the Developer of the Cozy 3's word (The Weather system used to handle Time of Day, Weather etc in my game) where he stated that the Sun rotates 1ยฐ per second based off of the timeMovementSpeed and that's the only information given in relation to Time and how it operates. and the only Number presented to me for modification of the Time of Day Speed is the timeMovementSpeed variable, therefor if the timeMovementSpeed is 2 the sun would rotate either 1ยฐ every 0.5 second or 2ยฐ every 1 second.. but these numbers are just not matching up with In-Game results, and the calculations just don't seem to be giving me any form of accurate baseline to go from besides the word of the Asset Developer, as I've had my game idling in the background for over an hour now, and it still hasn't even achieved a full 24 hr cycle on what is suppose to be a 30 minute day, despite the 1/0.2*360/60 Equaling 30 Minutes

drifting ore
modern dirge
#

Well 0.2 seems correct to me not sure how your asset works but 1800 seconds for 360 degrees would be 0.2 degrees per second so maybe your issue lies elsewhere

drifting ore
exotic ember
# drifting ore I have a rather crazy suggestion and attempt here, maybe you could try setting t...

I had just set it to 1.0 which in theory should have been 6 minutes, though just did a recording with a 5 minute timer going on screen, and in that 5 minutes it only achieved about 4 hours, which clearly is not going to play out as a 6 minute day cycle, I also did a video of 30 Minutes (speed setting of 0.2), which after 10 minutes I worked out it was running at 2 Hrs every 10 Minutes, so 5 mins for an hr in game 5*24=120 Minutes certainly does not equal 30.

Ill watch back the 6 Minute video to see what the actual 1.0 speed value represents

https://youtu.be/mobxse2tt_w

#

72 minutes apparently it would take to achieve a 24hr cycle on a 1.0 speed that is suppose to represent 6 Minutes ๐Ÿคฆโ€โ™‚๏ธ ugh my brain zombie

drifting ore
#

Hhhhh This is really a strangHhhhh This is really a strange question.e question.

exotic ember
# drifting ore Hhhhh This is really a strangHhhhh This is really a strange question.e question.

Tell me about it ๐Ÿ˜› all good I appreciate the help all, I've definitely gone off-topic far too much, it started out as what I thought may just be a simple math problem, but obviously opened the can of worms to something bigger ๐Ÿ˜… Ill try get in touch with the developer again and try get a more concrete baseline of what the heck a unit of 1.0 is even suppose to represent, as Himself and users of his community have stated that on default 1.0 settings its a 6 minute cycle (or atleast that 1ยฐ of sun rotation hapens per second if that speed is set to 1), so who knows, I'll try figure it out otherwise ill just keep tweaking the number until I get around the 30 minute mark and that'll be good enough, because its just not making any sense at all at the moment ded ๐Ÿ˜…

exotic ember
# drifting ore it doesn't matter

Now that a unit of 1 apparently represent 72 minutes, I'm now baffled how a unit of 0.2 equals 120 minutes, going off that number you'd think halving the speed multiplier to 0.5 would double the default value of 72, doubling 72 = 144 so we've already surpassed 120 Minutes that was occurring at a 0.2 multiplier... so literally all common sense seems to have gone out the window for these calculations ๐Ÿ˜›

#

And honestly I think I'm done using ChatGPT for my math equations, its done nothing but sent me on a wild goose chase every time I run into a math issue, it use to be so dang reliable, now it just cant even understand a simple command ๐Ÿคฆโ€โ™‚๏ธ

modern dirge
#

Try and find how to set time directly would be my advice then you can increment the seconds ie in a update function secondsElapsed += (secondsinday/desiredSecondsInday) ร— Time.deltaTime then find away to set the time bt seconds or convert

exotic ember
# modern dirge Try and find how to set time directly would be my advice then you can increment ...

I managed to find the true baseline of 20 Minutes per Game Day at a speed of 1.0, not the apparent 6 that it is suppose to be, so using that new correct baseline I was able to get the calculations working as expected ๐Ÿ™‚

I've got the baseline of 20 / 30 (my requested day length) = 0.6666... as the time speed which seems to work as expected.

Then using (1 / 0.6666....) * (1200 /60) = 30
Equals 1.5 ^^^^ Equals 20 ^^ 1.5 * 20 = 30

I had to change to the 1200 number from 360 for the discrepancy between the 6 minutes suppose to be equaling 360ยฐ but instead its 20 minutes (6 * x = 20) where x = 3.3333... then using that 360 * 3.33333.... = 1200 which seems to solve the discrepancy that is happening ๐Ÿ™‚ ๐Ÿ‘

bold quail
#

Um, are there any folks here who might be able to help me with some questions regarding how zomboid is coded and how hard/easy some mods would be to make.

  1. how do the map zones function, I know they have regions for zombie density and spawn, and loot zones like industrial or farming or military. Can other zone types be added, like power/water regions, watershed districts etc..

  2. I know loot can be added to a loot table to spawn in specific random locations, but can it be set to spawn in a specific building in a specific container.. Or on the map in a specific location..

  3. Is it possible to edit map all map tiles of a certain type, like to just add a new asset next to every tile of X type?

I know my questions may sound a bit... odd, but I'm considering finding someone to make a mod for an rp server I'm involved with.

ebon briar
# exotic ember Anyone want bragging rights to say their smarter than ChatGPT? I'm offering you ...

Yeah ChatGPT isn't great at mathematics unfortunately.

So from what I'm gathering you're saying x * 360 / 60 = 6, when x is 1, and x * 360 / 60 = 1.2 when x is .2, and and you wanna change the value of x such that x * 360 / 60 = 1. Correct me if I'm wrong.

in that case it can be solved in this fashion:

x * 360 / 60 = 1
360x / 60 = 1
360x = 60
x = 60/360
x = 6/36
x = 2/12
x = 1/6 or .166666...7
So it'd be

(1/6) * 360 / 60 = 1

#

I'm not sure what you're trying to do here but if you converted it into an algebraic equation that is what the solution would be

#

Otherwise the only other thing I can figure out is you're trying to understand how to calculate the amount of minutes a 'cycle' will take given the baseline that 6 minutes = 1 full cycle and giving it a coefficient to modify the baseline. In which case you just divide by that coefficient given the results you're asking for.

So if the baseline is 6, and you want to modify the baseline so it's 1/10 of the original, the result would be 6/.1 = x where x is the new amount of minutes it'd take, which in this case would be 60.

#

So if you have a baseline of 6, y = final minute results, and x = sliding modifier to that baseline of 6 minutes, the full formula would be

6/x = y

#

Otherwise I don't really understand what you're trying to do ๐Ÿคทโ€โ™€๏ธ

#

And this is what the equation looks like

hollow current
bronze yoke
#

you can also use the event fired by squares loading to find a container on that square and spawn the item

#

there's no direct way to do it but there are a couple ways like that

modern dirge
#

Just curious really is it possible to get the name of a mod or mod_id from a modded item object?

austere sequoia
#

You mean just from the itemfiles themselves? Not that I would be aware of. Ingame you can often see the mods name on modded items though, if that is what you mean

small topaz
modern dirge
#

Thanks there must be a way to get that name

austere sequoia
bronze yoke
#

:getModID() on an InventoryItem instance

modern dirge
#

That sounds like it, do you happen to know what a vanilla result would return ? The idea is to load modded items from text if the mods are detected

proud carbon
#

Does anyone know if there is a mod that divides the map into colored sectors and turns it into a conquest mode? Showing up which faction killed anyone there, how many sectors they rule, etc..

slow graniteBOT
#
4grammm has been warned

Reason: Bad word usage

lofty mica
#

Hello, I had an idea I hoped to implement but Iโ€™m running into some trouble as I am not very well versed in Lua. Would it be possible to give a new free recipe to a vanilla profession? I thought one way could be to edit shared/NPCs/MainCreationMethods, but Iโ€™m not sure if itโ€™s a good idea. I use modded occupations and I believe this would make the two mods incompatible, isnโ€™t that right? Another idea I had was to maybe edit the variables from another file but I donโ€™t think itโ€™s possible since theyโ€™re local, and other functions related to occupations are staticโ€ฆ What do you recommend I do?

onyx sage
#

anyone whos good at lua help me with my custom car upgrade mod, im using the standardised vehicle upgrade template but i am struggling!

jade crane
#

Hello, im trying to make a mod that adds a plushie to the game, but when i try to attach it to the backpack with the noirs attachments it looks like this

#

anyone knows how to fix this? i have no clue how

#

i want it a bit higher on the backpack

#

other plushies from other mods like the santa spiffo from authethic z look right

bright fog
#

What is it supposed to look like I mean

bright fog
jade crane
slow graniteBOT
#
tonyztark has been warned

Reason: Bad word usage

jade crane
#

this is how i would like to make it look like

#

thats the spiffo from authenthic z lite mod, i tried looking at the code, both from the original game and the mod but i couldnt see anything that helped me

plain crest
bright fog
jade crane
#

the only problem i have is the position when attached

#

i can place it correctly on the floor

stray willow
#
require "TimedActions/ISReadABook"


local originalISReadABookPerform = ISReadABook.perform


function ISReadABook:perform(...)
    if self.item:getFullType() == "WritingExpanded.NutritionistMagazine" then
        local characterMetaTable = getmetatable(self.character)
        local originalReadLiterature = characterMetaTable.__index.ReadLiterature
        characterMetaTable.__index.ReadLiterature = function(character, ...)
                local traits = character:getTraits()
                if        not traits:contains("Nutritionist") then
                    traits:add("Nutritionist")
                end
            end
        local result = originalISReadABookPerform(self, ...)
        characterMetaTable.__index.ReadLiterature = originalReadLiterature
        return result
    end
    return originalISReadABookPerform(self, ...)
end
#

How would I make the book get deleted after use?

#

So it functions like a consumable ๐Ÿค”

bright fog
#

So just rotate the model, either within the script file of the model or in Blender

#

But it will also change what it looks like when placed on the ground

jade crane
#

how i do it on the script? on blender doesnt work

bright fog
#

Show your model script file

#

actually I'm not sure you can do it via the script file

neon bronze
#

also do you mind me asking what you doing with that ReadLiterature function?

stray willow
neon bronze
#

i mean with that metatable function

#

cause it seems more complex than what you want to do

#

i think you want to add a trait at the end of reading the book?

stray willow
#

Basically

#

๐Ÿ˜…

verbal yew
neon bronze
#

i think it would be enough if you moved the if - statement at the end and added the trait there

#

without overriding the metatable function

#

im just kinda anxious about overriding java functions but if it works for you you can leave it in

stray willow
neon bronze
#

also at the end

#

you would probably let it do its original :perform and then add your stuff afterwards

neon bronze
#

lol

stray willow
#

To figure out how to do it

neon bronze
#

hey thats how you learn stuff

#

through copy pasting and smashing code together

jade crane
#

its really simple

bright fog
#

yes

neon bronze
#

is it an .fbx model?

chilly hemlock
#

Hello! If I call AddItems on ItemContainer on server then my player will not see container updates until I leave cell and come back. Is there a way to sync container contents when I update it server side?

bright fog
#

Do a command that's sent to every clients to do the exact same action ?

jade crane
neon bronze
#

You could try maybe playing with the origin point?

jade crane
#

i didnt think about that :D

slow graniteBOT
#
tjdownchurch has been warned

Reason: Bad word usage

coarse sinew
chilly hemlock
stray willow
#

I've now got it working for burglar/nutritionist; I'm trying to look at if its possible to remove a trait from reading a book

#

Because

function ISReadABook:perform(...)
    if self.item:getFullType() == "WritingExpanded.BurglarMagazine" then
        local characterMetaTable = getmetatable(self.character)
        local originalReadLiterature = characterMetaTable.__index.ReadLiterature
        characterMetaTable.__index.ReadLiterature = function(character, ...)
                local traits = character:getTraits()
                if        not traits:contains("Burglar") then
                    traits:add("Burglar")
                local inventory = self.character:getInventory()
        inventory:DoRemoveItem(inventory:getItemFromType(self.item:getType()))
                end
            end
        local result = originalISReadABookPerform(self, ...)
        characterMetaTable.__index.ReadLiterature = originalReadLiterature
        return result
    end
    return originalISReadABookPerform(self, ...)
end

Is working so I thought

function ISReadABook:perform(...)
    if self.item:getFullType() == "WritingExpanded.SundayDriverMagazine" then
        local characterMetaTable = getmetatable(self.character)
        local originalReadLiterature = characterMetaTable.__index.ReadLiterature
        characterMetaTable.__index.ReadLiterature = function(character, ...)
                if        traits:contains("SundayDriver") then
                    traits:remove("SundayDriver")
                local inventory = self.character:getInventory()
        inventory:DoRemoveItem(inventory:getItemFromType(self.item:getType()))
                end
            end
        local result = originalISReadABookPerform(self, ...)
        characterMetaTable.__index.ReadLiterature = originalReadLiterature
        return result
    end
    return originalISReadABookPerform(self, ...)
end

Maybe that would work?

#

@coarse sinew

#

Just to learn about traits

bright fog
coarse sinew
# stray willow <@333616402818662410>

Yes, you can also combine them:

function ISReadABook:perform(...)
    local itemType = self.item:getFullType()

    if itemType == "WritingExpanded.BurglarMagazine" or itemType == "WritingExpanded.SundayDriverMagazine" then
        local characterMetaTable = getmetatable(self.character)
        local originalReadLiterature = characterMetaTable.__index.ReadLiterature

        characterMetaTable.__index.ReadLiterature = function(character, ...)
            local traits = character:getTraits()
            local inventory = character:getInventory()

            if itemType == "WritingExpanded.BurglarMagazine" then
                if not traits:contains("Burglar") then
                    traits:add("Burglar")
                end
            elseif itemType == "WritingExpanded.SundayDriverMagazine" then
                if traits:contains("SundayDriver") then
                    traits:remove("SundayDriver")
                end
            end
            inventory:DoRemoveItem(inventory:getItemFromType(self.item:getType()))
        end

        local result = originalISReadABookPerform(self, ...)
        characterMetaTable.__index.ReadLiterature = originalReadLiterature
        return result
    end

    return originalISReadABookPerform(self, ...)
end
stray willow
#

Yall so smart with lua stuff ๐Ÿ˜… , I'm just a baby, only really been doing simple scripting

slow graniteBOT
#
wildrexo has been warned

Reason: Bad word usage

jade crane
#

tysm

neon bronze
#

glad to be of help

mellow frigate
#

CS1.6 ?! not only by heart..

ivory lance
#

Hey, I've been thinking

#

is there some discord <if not here> where I could find programmers willing to take commision for programming some small mod?

#

I have smth on my mind but I do not have enough skill in coding

#

can do the modelling tho

#

and I know someone's work is worth something so I'd like to reward it somehow with humble coin when job is done

#

I'll probably get more into modding with b42 release but thought I could give it a try with some small thingy

ivory lance
#

new car with some special function <tank?> or smth

stray willow
# coarse sinew Yes, you can also combine them: ```lua function ISReadABook:perform(...) loc...

I tried to include more; would it look like this?

require "TimedActions/ISReadABook"

local originalISReadABookPerform = ISReadABook.perform

function ISReadABook:perform(...)
    local itemType = self.item:getFullType()

    if itemType == "WritingExpanded.BurglarMagazine" or itemType == "WritingExpanded.SundayDriverMagazine" or itemType == "WritingExpanded.NutritonistMagazine" then
        local characterMetaTable = getmetatable(self.character)
        local originalReadLiterature = characterMetaTable.__index.ReadLiterature

        characterMetaTable.__index.ReadLiterature = function(character, ...)
            local traits = character:getTraits()
            local inventory = character:getInventory()

            if itemType == "WritingExpanded.BurglarMagazine" then
                if not traits:contains("Burglar") then
                    traits:add("Burglar")
                end
            elseif itemType == "WritingExpanded.NutritonistMagazine" then
                if not traits:contains("Nutritionist") then
                    traits:add("Nutritonist")
                end
            elseif itemType == "WritingExpanded.SundayDriverMagazine" then
                if traits:contains("SundayDriver") then
                    traits:remove("SundayDriver")
                end
            end
            inventory:DoRemoveItem(inventory:getItemFromType(self.item:getType()))
        end

        local result = originalISReadABookPerform(self, ...)
        characterMetaTable.__index.ReadLiterature = originalReadLiterature
        return result
    end

    return originalISReadABookPerform(self, ...)
end
#

(not sure how to send color text in that format

neon bronze
#

you do 3 of those " ` " before and after your code

#

you can also specify that it is lua if you put lua inbetween those upper characters and your code

stray willow
#

I did not know that

bronze yoke
#

if you're trying to overwrite on a single object you don't actually need to touch the metatable

#

self.character.ReadLiterature = function() and then set it back to nil after

#

or the original incase another mod has already messed with it on the object

neon bronze
#

he changes the function only for the original perform and then resets it back to the original one

#

which in this case arguably is a waste of code but i digress

bronze yoke
#

it can be useful for injecting code into the middle of a function, but i'm not sure it's really necessary here

neon bronze
#

@stray willow you could use the metatable method to overwrite the pill interaction you wanted to do on sunday

stray willow
neon bronze
#

probably as you do it rn which is manually checking for the magazines you need and then remove the coresponding trait

stray willow
#

Because my thing isnt working for it :c

#

Right like this one works, mine doesn't , I'm assuming the issue is the way I'm adding it or if I'm missing something critical

toxic narwhal
#

I have a quick question regarding crafting, namely adjustable resources.
I want to make wire with scrap metal, I have set it cost it 1 by default but I would like to make it adjustable in the mod options/sandbox vars in-game.

I currently have it set up that the option is there in-game but changing the values does not update the crafting requirements

    {
        ScrapMetal=1,
        BlowTorch=0,
    keep Base.Screwdriver,
        keep WeldingMask,
    SkillRequired:Electricity=1,
        Result:Wire,
        Time:100.0,
        Category:Electrical,
    OnGiveXP:Recipe.OnGiveXP.DismantleElectronics,
    }

and the lua:

require('NPCs/MainCreationMethods');

local AMOUNT_SCRAP;

local function setLocalSandboxVars()

    AMOUNT_SCRAP = SandboxVars.CraftableWire.AmountofScrap;
    if AMOUNT_SCRAP == nil then
        AMOUNT_SCRAP = 1;
    end

end

local function initWire()
    setLocalSandboxVars();
end

Events.OnGameStart.Add(initWire);

It should be simple but apparently I can't figure it out, can anybody give me some pointers?

thick karma
stray willow
#

I have no idea what I'm doing fully ๐Ÿฅฒ

thick karma
#

Mmmm. I would strongly recommend using lines of code only when you fully understand their purpose... So your goal is to simply add or remove a trait from a player when they read specific books?

#

Or am I missing part of your goal?

thick karma
thick karma
#

Okay my first recommendation is that you use the debug console in debug mode to test whether a trait can even be added twice, or whether removing a trait that a player doesn't have will even throw an error. My gut says the function won't let you double-add a trait OR break on removal of a trait someone doesn't have, and if that's true, you're unnecessarily checking whether players do or do not have traits before doing what you need to do

#

Also, you can remove the require line because vanilla files load before mod files, so it is as far as I know not possible for your file to load before ISReadABook

bronze yoke
#

it will let you double add, it's basically just an ArrayList<String>

thick karma
#

Mmm fair enough

#

Booooo to that. Haha

bronze yoke
#

i don't think it throws an exception if you remove a trait that isn't there though

thick karma
#

Is there some good reason they didn't just use a dict?

#

And just nil or unnil things directly?

#

Weird choice to allow double-adding...

bronze yoke
#

it's slower to iterate through

#

(i'm going for the performance argument because i don't really know)

thick karma
#

Fair enough... How often would you need to iterate through all traits if you just used the trait id as a key?

#

I mean checking the trait's existence would be basically immediate

#

No loop

bronze yoke
#

every frame while rendering the traits ui

thick karma
#

I see. Fair enough. I figured the traits UI could pull that info once and adjust it if a change is detected

bronze yoke
#

that sums up the entire problem with pz's ui rendering

thick karma
#

What about double-adding specifically?

#

Why not prevent that?

#

Is there some purpose I'm missing to having the same trait id twice in your array?

bronze yoke
#

no, it'd only cause problems, but not significant ones

thick karma
#

I see.

bronze yoke
#

the only issue i can see it causing is trying to remove the trait wouldn't work

thick karma
#

Right

bronze yoke
#

since ArrayList.remove just searches for the first occurence of the object

thick karma
# stray willow Effectively ๐Ÿ™‚

So if removal of nonexistent trait is safe you can at least remove that condition... But based on what albion is saying you need to keep the condition on adding.

thick karma
# stray willow Effectively ๐Ÿ™‚

Now, if you need to quickly check whether the book is among many books to which you want to react, I recommend making a table outside of the function and using it for a list like this:

-- If you're not putting your functions
-- in modules yet, I'd start now.
local YourModule = YourModule or {}

YourModule.dynamicTraitBooks = {
   ["WritingExpanded.SundayDriverMagazine"] = true,
   ["WritingExpanded.NutritionistMagazine"] = true,
   ["WhateverEtCeteraMagazine"] = true

}
#

And then you can just say

if YourModule.dynamicTraitBooks[itemType] then
   etc()
end

to check all valid item types in 1 check

#

I'm guessing the override of ReadLiterature is to make sure the attempt to read didn't fail or something before deciding what to do with traits

#

I am not on PC so I'll have to check later if that has a purpose that would be relevant to you

coarse sinew
thick karma
coarse sinew
#

Definetely

thick karma
#

And reduce it to 1 quick bool check

thick karma
chilly hemlock
#

I have been messing around trying to add create a new inventory item and add it to item container (that is not player inventory) and for the life of me I can not make it sync on server - only when I leave the cell and come back it is there...

#

tried even sending a command to client and tried to call the same AddItem fn but it just yeets it like it would be an illegal item

neon bronze
#

Whats the code?

chilly hemlock
#

on server its pretty much

container:AddItem(InventoryItemFactory.CreateItem(itemType))
#

container is ItemContainer instance

coarse sinew
# stray willow I'm using What Elyon wrote above, I'm just wondering how i would add additional ...

An upgraded version to allow more magazines without a large ifelse chain

local originalISReadABookPerform = ISReadABook.perform

function ISReadABook:perform(...)
    local itemType = self.item:getFullType()
    
    -- Define a table that maps magazine item types to their effect on player traits
    local dynamicTraitBooks = {
        ["WritingExpanded.BurglarMagazine"] = {trait = "Burglar", add = true}, -- Adds 'Burglar' trait
        ["WritingExpanded.NutritonistMagazine"] = {trait = "Nutritionist", add = true}, -- Adds 'Nutritionist' trait
        ["WritingExpanded.SundayDriverMagazine"] = {trait = "SundayDriver", add = false}, -- Removes 'SundayDriver' trait
    }

    -- Check if the item type is in the dynamicTraitBooks table to determine if special logic should be applied
    local effect = dynamicTraitBooks[itemType]
    if effect then
        local characterMetaTable = getmetatable(self.character)
        local originalReadLiterature = characterMetaTable.__index.ReadLiterature

        characterMetaTable.__index.ReadLiterature = function(character, ...)
            local traits = character:getTraits()
            local inventory = character:getInventory()

            -- Check if the trait should be added or removed based on the magazine effect
            if effect.add then
                if not traits:contains(effect.trait) then
                    traits:add(effect.trait) -- Add the trait if it's not already present
                    -- You can also remove the magazine here if the trait has been successfully added
                end
            else
                if traits:contains(effect.trait) then
                    traits:remove(effect.trait) -- Remove the trait if it is present
                    -- You can also remove the magazine here if the trait has been successfully deleted
                end
            end
            -- Remove the magazine from inventory after reading
            inventory:DoRemoveItem(inventory:getItemFromType(itemType))
        end

        local result = originalISReadABookPerform(self, ...)
        characterMetaTable.__index.ReadLiterature = originalReadLiterature
        return result
    end

    return originalISReadABookPerform(self, ...)
end
thick karma
#

Nice, that way you can just expand the table at the top. Nice

#

This is the Way

minor olive
#

Hi guys, I would like to know how can I make an item that was modified return to its original state, for example the water bottles, when they run out of water they are empty again. How can I do that? (I know it may be very basic but it's my first time modding)

chilly hemlock
neon bronze
#

otherwise you could call :transmitCompleteItemToClients() on the container

minor olive
#

Yes, but i mean that i want to implement this to other types of items that are not containers

chilly hemlock
#

trying the :setDrawDirty one
with :transmitCompleteItemToClients() it duplicated container on client side for some reason (duplicated container was synced with correct items inside)

neon bronze
#

can you get the container from the client?

chilly hemlock
neon bronze
#

you could call it on the client's side container perhaps

small topaz
chilly hemlock
# small topaz when is your command executed? do you use an event or append it to vanilla code?...

for now on server I have added fn to EveryOneMinute, I do getSquare(...):getObjects(), search for stove, using FindAll I get my items and basically do

                local id = item:getID()
                local newItem = InventoryItemFactory.CreateItem(toType)
                container:addItemOnServer(newItem)
                container:removeItemOnServer(item)
                container:setDrawDirty(true)
                container:getParent():transmitCompleteItemToClients()
                tileToUpdate.itemID = id -- also contains x, y, z properties
                SendCommandToAllPlayers("OEConvertItem", tileToUpdate)
#

I can confirm that the command makes its way to client where I do

function OEConvertItem(args)
  local tile = getSquare(args.x, args.y, args.z)

  if tile == nil then
    return
  end

  local items = tile:getObjects()
  for i = 0, items:size() - 1 do
    local groundItem = items:get(i)
    if groundItem.getObjectName and groundItem:getObjectName() == "Stove" then
      local item = groundItem:getContainer():getItemById(args.itemID)
      if item then
        print("Sync container items")
        groundItem:getContainer():setDrawDirty(true)
        groundItem:getContainer():transmitCompleteItemToClients()
      end
    end
  end
end
#

and still the same - leaving the cell and coming back will sync it but my code does not

bronze yoke
#

try sendItemsInContainer(IsoObject obj, ItemContainer container)

#

even if it works transmitCompleteItemToClients will create a duplicate object on top of the existing one, not update it

chilly hemlock
#
sendItemsInContainer(container:getParent(), container)
#

is this what you mean?

bronze yoke
#

yeah, something like that

chilly hemlock
#

or is IsoObject something else

#

oki, trying

bronze yoke
#

i've had to manually sync a container before but i think that was because sendItemsInContainer doesn't work specifically for corpses

#

unfortunately adding items from the server side is a nightmare U_U the entire game expects items to be added from the client and most facilities to do it from the server aren't exposed to lua

chilly hemlock
#

thank you ma'am, it works, at least the adding part, it did not remove the old one tho

#

but still

neon bronze
#

Here is praying it changes in b42

chilly hemlock
small topaz
#

not an answer to anything but a question out of curiosity: what if you just use the command
container:addItem(item)
on server side? Would that be a problem. Cause the vanilla code uses such a command all the time on client side without any issue (item is also in container for other players in multiplayer).

bronze yoke
#

it doesn't sync to clients when you do this, it will be transmitted to clients who load that chunk after the change happened but those who are already there won't see it until they leave and come back

small topaz
#

omg! that's weird. cause when you do this on client side, it syncs completely fine

chilly hemlock
bronze yoke
#

it's annoying because the client has addItemOnServer which sends the item to the server and then the server updates the clients about it, there's just no way from lua to trigger that update from the server side

#

so the client is actually able to trigger code on the server that the server can't U_U

chilly hemlock
#

oh wow, okay, my life has been a lie

chilly hemlock
bronze yoke
#

yeah

#

addItemOnServer called from the client syncs perfectly, the method does absolutely nothing if called from the server side though

chilly hemlock
#

I was so sure it did not work that way so I did not even try it even tho it went by my mind

bronze yoke
#

it's technically true that containers are server auth but the server lua doesn't actually have access to the things the client lua does to mess with them

#

it's a frustrating design

chilly hemlock
#

I'm checking out what you did in your ammo maker out of curiosity, thank you for the hint

bronze yoke
#

that's not what your code does though? your code just manually syncs them

#

the code to do this already exists in the server java, addItemOnServer triggers it by proxy, it just isn't accessible to lua from the server side for basically no reason

small topaz
bronze yoke
#

nah, player inventories are completely client auth

#

it wouldn't really matter either way since nobody else can see your inventory anyway, doesn't matter if it desyncs

frank elbow
#

The inventory being largely moved to the server is included in b42, yeah? I remember that being mentioned but idr whether it was next build or nebulous future. Leaning towards the former though

bronze yoke
#

it's for b42

small topaz
#

ok. that was probably the source of my confusion since I only had examples in mind here where adding smth to inventory is applied to the player...

chilly hemlock
#

noyce, I can yeet all that server code away...

small topaz
#

wouldn't moving the player inventory management to server make things even more complicated (at least for modders)?

bronze yoke
#

probably a little bit, but it's a critical cheating exploit as it is

chilly hemlock
#

if you have single source of truth then theoretically it should be less complicated

small topaz
#

I am quite afraid of b42 then when it comes to making my mods compatible ๐Ÿ˜…

chilly hemlock
#

cant imagine the work some modders will have to go through...

#

so if I want to sync mod data between clients then is there similar fn for syncing or now should I use command to sync only data that I need? I'm feeling syncing entire modData might be at some points very expensive

#

there is transmitModData function on isoobject that I see in api docs

bronze yoke
#

yeah, that's what you should use

#

something to remember is you should *always* transmit even if you don't need it to be synced

#

transmissions from other clients/the server overwrite your local mod data so staying synchronised is the only way to prevent random deletion

chilly hemlock
#

very good point indeed... currently for my hydroponic basins mod I'm holding plant growing state in it's on table and use commands to sync it so that I can use partial updates and only send the data that is needed (when player connects he gets entire table and receives only small updates afterwards)

#

this way I can run calculations even when player is not in the cell

small topaz
#

what is then the correct procedure for writing stuff in player's or an item's modData so that it works on multiplayer? I guess for the player you don't have to do anything special but for an item?

bronze yoke
#

items don't need their moddata transmitted

modern dirge
#

does anyone have any info on changing the state of Mainscreen.lua to the main menu and hide any open menus? , i am struggling to find hints in the lua files

bronze yoke
#

i'm not really sure exactly how it works but they don't even have a transmit function

wind wasp
#

Hello, how do I remove certain items from spawning in the game, so even when zombie dies it doesn't drop a loot of the item I want to remove?
Looking at other games like Teardown (https://teardowngame.com/modding/api.html) there is whole page with functions that I can call from Lua, and description of them - in Project Zomboid I see the docs are pretty messy and it is hell hard to find any info on how to do such simple thing as removal of item spawn.
Thanks in advance! I really enjoy the game.

stray willow
#

@coarse sinew Just want to say thank you ^_^

mellow frigate
cold whale
#

Hello Friends! Does anyone is experienced with mod making in project zomboid? I need some help please ๐Ÿ˜ฆ

errant bluff
#

I can't get the mask/helmet model into the game correctly. I have used the Gas_Mask template but nothing. In blender the scale is applied as well.
#modeling message

hollow current
#

This should work if I am not mistaken. Make sure to replace the Base.Item with the actual full type of the item you want to remove. You can also change ProceduralDistributions with other types of distributions

#

I am not very sure if the same approach will work with removing the item from zombies drop loot, but you could test with SuburbsDistributions

bronze yoke
#

if you're removing vanilla items you should use the short type too

#

since the module base is assumed when none is given a lot of the vanilla distributions don't include it

cold whale
#

I am new on making Mods and I have encountered a problem and I am not very sure if it is a bug or something. I have finished my mod which adds 3 new types of candies. I have already organized my files prior to do some testing in the C:\Users\Username\Zomboid\mods fille location and named correctly all of my folders. However, when I launch Project Zomboid (debug mode) and try to add the mod, I click on enable but nothing happens, it just can't be added to the game.

Please note that the game gets the poster/preview image, ID and the rest of the information in the Mod interface. It just doesn't add to the mod list when I click on ON/Enable.

Any ideas/suggestions?

grizzled fulcrum
#

Is Global ModData the way to go for storing information about players across game restarts? In Lua, I have some variables I would like to persist but I am not sure where to look on doing that.

bronze yoke
#

if it's about players you might want to put it on the player's moddata instead

drifting ore
#

how is the sound file for beta blocker called
or bandages if they have one

drifting ore
#

where are all the ui icons

simple tide
#

Yo - trying to create a mod rn that adds a weapon to Firearms B41 and for some reason enabling it bricks the game. Previously, I got the gun added but a bunch of stuff was wrong. If anyone was willing to take a look at it / help fix it I'd be happy to send over a couple bucks for the trouble. DMs are open.

minor olive
#

How can I check if an item is spawning in the world naturally?

final finch
#

In mod.info, is there a way to set a mod to load after another, without requiring it?

somber marten
#

I want to start modding this game. Do I need to have both Lua and Java experience? Or is java enough? I havent worked with Lua before, but I have a fair bit of experience with Java

final finch
#

I don't know either, and I'm successfully making my own little tweaks.

final finch
somber marten
#

I feel decently comfortable with java, Ive made a mod with it (not zomboid), and have about 1 year of Uni experience with it. On the other hand, Lua is a completely foreign concept to me, I dont know anything about it

final finch
#

I don't know enough about either to say "it's the same bro", but it feels like it is. Crack open a mod that does something similar to what you want to do, look at the lua, and you'll probably feel right at home. It's pretty straight forward.

somber marten
#

Ok thanks!

#

Which of these should I use?

final finch
#

Not sure, I use Notepad++ and VS Code and I don't remember installing that for VS Code

somber marten
#

They are Lua plugins for IntelliJ. I got prompted by IntelliJ to use any of those, because I opened a .lua file, and I got curious on which one is better

#

Ill just use both I guess

verbal yew
#

EmmyLua i think...

somber marten
#

Ok thanks

#

I got some errors for using both, but a clean install fixed it

somber marten
verbal yew
#

i think

somber marten
#

Well I tried enabling both, and got critical startup errors, so I had to clean install IntelliJ

#

Also, this is from the link you sent

bronze yoke
#

i wouldn't recommend using intellij for lua

#

i did for a long time, it's not impossible, but you're giving up a lot of intellisense

#

modern emmylua doesn't support indexing at all, and older versions just aren't that great

somber marten
#

Ill manage

cold whale
glad canyon
#

o/ A question: I'm making a custom texture pack with multiple types of stackable crates. For now, each unique crate just have "stackable" item property checked in Tilezed, and it is set to Low position. Question is: Is this enough, or do i have to make 3 tiles for each crate, representing all 3 stacking positions (low, middle, high) ? In the case i need to use 3 tiles for single crate, how do i make the game know that all 3 tiles are related to the same furniture piece?

coarse sinew
glad canyon
coarse sinew
#

Well, using this property. You can also check the properties of game's tiles to see how they are defined

hollow current
verbal yew
#

how to write x^2 in lua?

frank elbow
verbal yew
frank elbow
#

There's math.pow and the exponentiation operator (which I'm pretty sure is in kahlua, anyway), but for the power of 2 you can just multiply by itself

#

You can multiple a variable by itself

#
local x = 2
print(x*x)
verbal yew
#
local x = 2
if something == true then
  x = 4
end
frank elbow
#

Yeah, but again for a power of 2 it's faster to just multiply

verbal yew
#

but if x = 4, its should be 4^2

frank elbow
#

Premature optimization to be sure but easy enough that there's no reason not to

verbal yew
#

not 4*4

frank elbow
#

Mathematically, a power of 2 is equivalent to multiplying something by itself

#

4^2 = 4*4 = 16

verbal yew
#

wait a minute...

#

shiet...

#

yep, thats true xD

#

thanks xD

frank elbow
#

No problem

verbal yew
#
zreFirstAidBonus = math.ceil((-1*zreFirstAidReq) + ((zreFirstAid*zreFirstAid)/2.5));
final finch
#

Does anyone know how spawnChance in VehicleZoneDistribution works?

Like if I have 3 vehicles at a rate of 10, 20, & 100 does it...

A) Spawn them at a ratio of 1:2:10 ?

B) Check the first one with a 10% chance of success, but if it fails, moves to the second car. If it fails again, in this example, it would then have a 100% chance to be selected? (Not taking into account spawnRate and Sandbox Settings.)

C) Something else?

onyx sage
# final finch Does anyone know how spawnChance in VehicleZoneDistribution works? Like if I ...

my understanding is that each spawn zone will run through its possible car list then say the 1st car on the list is 10 thats 10/100 chance for it to spawn, if it fails then it moves to the next in list and if that one fails it moves until the end and if none succeed in the 'roll' then the space is left empty. if its at 100 once the list gets to that one it will be spawned as its 100/100 i wouldnt recomennd this as every zone that can spawn the 100 chance vehcile will spawn it unless a previous car wins the roll before the list gets it it

final finch
#

Perfect. That's exactly the information I was looking for. Do you happen to know how it determines what order to do them in? I would guess it's by index number, and the -1 just indicates that it should be added to the current list?

#

Also your explanation was very clear ty

onyx sage
#

its either index or load order / decending order in the code

#

im not 100%

#

but if you want a certain vehicles to spawn more than others a easy way is just increase its spawn chance as long as its not 100 and also its in the correct disruption zones,

coarse sinew
# final finch Does anyone know how spawnChance in VehicleZoneDistribution works? Like if I ...

Yes, spawnChance in VehicleZoneDistribution basically works as a weighted probability that each vehicle will spawn in its assigned zone. The code sums up all the initial chances of spawning in a zone and then calculates a factor by which each chance must be multiplied to make sure that the total sum reaches 100%. This is called normalization and is for making the random selection process fair, as the vehicle with 100% chance will not always spawn. Here's a simplified explanation:

  • first, it calculates the total spawn chance of all vehicles (in your example, 10+20+100=130)
  • then, it determines a normalization factor (100 / total spawn chance) to adjust each vehicle's spawn chance so the sum equals 100%. e.g. 100/130 = 7.69
  • new spawn chances: CarA = 7.68, CarB = 15.38, CarC = 76.92
    And then vehicles are evaluated in sequence based on their adjusted spawn chances, and the first one to 'win' the roll spawns, preventing others from spawning in that spot unless none meet their chance, potentially leaving the spot empty.
    ^ This is from decompiled java code
final finch
#

Oh wow, thank you very much! That makes things easier!

onyx sage
#

i guess i was wrong ๐Ÿ˜ฆ

onyx sage
#

im trying to make a addon mod for my car mod that allows the installation of a roof rack and bullbar how do i do this

cold whale
#

Hello pals! Does anyone has experience making and testing mods? I have a couple questions with a very small and simple mod I made. If anyone can help me and take a look at my mod I will be very glad to send some bucks for the time. I am kind of desperate because I am stuck in this little project ๐Ÿ˜ฆ

bright fog
#

#4

chilly hemlock
#

Hi!
hmm is it possible to get list of players in a cell or I would need to loop over all players?

wicked crane
#

What is the mod? Items, vehicles, lua or scripts? All of the above? Does it load in game for you?

reef vine
#

Hello ! I made a mod for custom crates But I get this space in recipe list ! And I don't understand why ?

wicked crane
#

When writing scripts and translation

reef vine
#

Notepad++

#

but I think, this name "caisse de jardin" is is propreties tiles

#

in custom name

sour island
#

So if you try to get an isoPlayer near the other player if an object is returned then it exists

reef vine
verbal yew
#

but moveable. hidden like big space

#

result in recipe

#

just need create custom item for moveable object

#

and do this item like result

reef vine
verbal yew
#

hmm

somber marten
#

Can someone help me with this step? I cant find those buttons on my IntelliJ

bronze yoke
#

don't use this guide, it's old as hell

wheat kraken
#

after 1 year, i did a new web scrape compilation from steam workshop page
03/2024

its is more automated now, i can do it from time to time
https://docs.google.com/spreadsheets/d/16E1hI9HjKxZTeRAVgZyA2SYM9OI3IK8TqjdQ3jpxSHk


and i can use it to filter out, mods that are less than 100k subs, for the community insert some of them with 50 length short description (about most useful use of it)

at first glance, my new modspotlight will be a incubator for mods until they reach 100k subs, in the future will have a section/version for popular/mainstream ones

if you are a player or a modder, and want to participate on our community modspotlight be part of here
https://steamcommunity.com/sharedfiles/filedetails/?id=3188518356

atm, its is working like that
people (both players and modders) -> discord bot -> file -> modspotlight

and players using the mod get new content every game start, and can passively discover new mods

as community guide lines, content added can be moderated via discord and removed

(modders) feel free to upgrade the UI

lofty mica
#

Is there a way to remove/rename a vanilla recipe from the game?

small topaz
# lofty mica Is there a way to remove/rename a vanilla recipe from the game?

Removing a recipe: For hiding a recipe from the craft menu, you can use something like this:

recipe:setIsHidden(true)```
To hide the recipe from the right click menu, you can simply add an item which doesn't exist to the ingredients:
```recipe Open Jar of Broccoli
    {
        CannedBroccoli,
        My_ImpossibleItem,

        Result:Broccoli=5,
        Time:30.0,
        OnCreate:Recipe.OnCreate.OpenCannedFood,
        Category:Cooking,
        OnGiveXP:Recipe.OnGiveXP.None,
        Override:true,
    }```

Important is to set Override = true to make it work.
lofty mica
small topaz
#

I use this trick in one of my mods and it seems to work without any errors XD

small topaz
bright fog
#

You actually might want to lower that lol or you will have 99% of the workshop's mods that complete the rest of your conditions

wheat kraken
fickle prairie
fickle prairie
#

QoL mods easily fill 400

#

But alot stopped development cause of B42

wheat kraken
#

crunch stats from subscribers count of 1470 mods, from #1 to #40

fickle prairie
wheat kraken
wheat kraken
fickle prairie
#

Hmm but idk if subs = quality

#

But other variables will complicate stuff I think

wheat kraken
fickle prairie
#

There are some mods with thousands of subs but long since abandoned

fickle prairie
#

I mean if most mods work either way then why not I guess, go for it right?

#

I recognize alot of mods from the list as mods I'm subscribed to

wheat kraken
fickle prairie
#

Yeah true. But manually filtering out bad apples is too tedious right?

#

Ie. I just found eris_nightvision_goggles in your list, but that mod is broken without a patch

night pier
#

Hello comrades,
I'm creating a mod that (for now) makes a zombie NPC, which doesn't bite and chases you and just walks around randomly, but I'm running into the problem that if I set the setUseless setting it doesn't obey the pathToLocation code command, and If I deactivate it, it starts chasing me again. Any ideas on how to make this work? I swear it will be a cool mod

toxic narwhal
steady lagoon
#

Do you guys know if it is possible to alter vanilla methods? Essentially overriding those within a mod?

teal slate
#

Is there an easy way to make a weapon unbreakable? I want to make a gimmick/joke weapon that's hard to get and doesn't break.

grizzled fulcrum
# steady lagoon Do you guys know if it is possible to alter vanilla methods? Essentially overrid...

I know that in Lua you should be able to do it. For example, if I wanted to override handleCompost function in ISWorldObjectContextMenu.lua I could do

-- Store original so we can call it before or after our code if needed.
local origFunc = ISWorldObjectContextMenu.handleCompost
-- Match the function signature from the original function
ISWorldObjectContextMenu.handleCompost = function (test, context, worldobjects, playerObj, playerInv)
    print("Before original function!")
    origFunc() -- Call or discard, your choice
    print("After original function!")
end
#

So it can act like a function override or a kind of pre and post hook depending on what you want to do with it.

errant bluff
#

Does anyone know what I have to do to get a full beard? the full beard and for example if I wear glasses also wear them.

#
<m_HatCategory>default</m_HatCategory>
#

i should remove this:

<m_MasksFolder>media/textures/Clothes/Hat/Masks</m_MasksFolder>

?

granite lintel
#

how do you make a crafting recipe yield more than one of an item?

grizzled fulcrum
granite lintel
#

return more than one

grizzled fulcrum
#

I am not actually sure if you could specify 2 results in the recipe script but maybe you could use OnCreate to give the player the other items?

#

but you can use keep MyItem in the script so that you don't lose an item

#

and you can keep multiple items too

grizzled fulcrum
#

From looking at Open Sack of * recipe, when you open the sack it gives yo uthe food and the sack. The food is the result of the recipe and in the OnCreate method specified it gives the player the other items like:

function Recipe.OnCreate.OpenSackProduce(items, result, player)
    result:setAge(items:get(0):getAge());
    player:getInventory():AddItem("EmptySandbag");
end
granite lintel
#

i think i figured it out actually

grizzled fulcrum
#

๐Ÿ˜ฎ

granite lintel
#

the mod i was using for reference had an item named weird and made me thing you needed to put M= instead of just =

#

yeah

grizzled fulcrum
#

did you just use 2 Result: tag?

granite lintel
#

` recipe Chisel Nails {
SharpedStone,
keep Hammer/HammerStone/Sledgehammer,

    Result:Nails=5,
    Sound:Hammering,
    Time:60.0,
    Category:Survivalist,
}

`

#

ok so for some reason in game the result is 25 nails

tame knoll
#

Hi I'm trying to learn how to make mods for PZ and was wondering how one would go about making guns visible when shooting out of cars windows? Would you make a custom model and attach it to a vehicle when the player aims? Or would it be more like modifying the car model itself?

candid magnet
#

I want to make an mod that replaces every texture with a picture of
Chris Allen. Where do I start?

outer crypt
#

find a photo of Chris Allen...

#

the start is not the issue, but the journey and the end...

candid magnet
#

Hm what then?

candid magnet
grizzled fulcrum
#

At what stage is Lua in a mod loaded?
For example, if I had just one file in my mod at /lua/client/main.lua and it contained a single print call, when would that call be executed?
I can only assume it gets executed when the game boots by default, but then what purpose would registering a callback for OnGameBoot have?

sturdy salmon
grizzled fulcrum
sturdy salmon
#

I have used the events from the list. I haven't created many mods, but I use the event I specifically need. I don't make a global call.

bronze yoke
#

often times it's just because many of the game's systems init during that event and their mod might rely on those systems

#

for others it might just be that they don't really know what the events do and are trying to be safe ๐Ÿ˜“

sturdy salmon
#

It may be due to lack of knowledge, it has happened to all of us and continues to happen to us.

bright fog
bright fog
#

Reload of lua is not unique to game start, while OnGameBoot is

grizzled fulcrum
#

I see

#

thanks!

verbal yew
#

guys. maybe who know how to remove recipe from knowledge of player?
player:getKnownRecipes():remove("LabResearchToVaccineTo2lvl");

verbal yew
errant bluff
#

Does anyone know how to fix the beard showing under the protective visor?

onyx sage
#

anyone know how to texture vehicles?

bright fog
errant bluff
#

for chromaskeys i guess

dreamy birch
#

Hey guys, so I've noticed there is no mod on the workshop for removing tiredness from drunkenness, or I can't find one, so I thought of quickly making one. However I don't know the first thing about modding. I've found the function that makes you tired, it's in ProjectZomboid\zombie\characters\BodyDamage\BodyDamage.class, now how would I go about removing that line and making it a mod? It's unfortunately in the games java so I assume it's gonna be harder to do. Could someone help please?

frank elbow
# dreamy birch Hey guys, so I've noticed there is no mod on the workshop for removing tiredness...

To answer the question directly: after removing the line & saving a copy of the file elsewhere called BodyDamage.java, download the jdk so you have access to the javac command & run javac --class-path <game-path> -d ./out --release 17 BodyDamage.java. I think this would be possible without a Java mod, though, by grabbing all of the alcoholic items & setting up an OnEat function that reverses the sleepiness change

#

The way that just removes the line would be more straightforward on your end, but the Lua-only way would mean there's no need for players to replace a .class file

#

An additional consideration is alcoholic stuff that already has an OnEat function (maybe only true for modded items, I don't see any vanilla alcohol items like that), but mod compat issues could be avoided by saving a copy of the original & calling it in yours

dreamy birch
#

ah! omar jumpscare

frank elbow
#

Unless you meant the OnEat part, which does warrant further explanation if you want to go that route

dreamy birch
#

yes i would like an explanation

#

it would be easier if people could just download and use the mod rather than replace files

hollow current
# dreamy birch please seรฑior

When defining any food item in the game script, you can assign a function to its OnEat property. You can create a function that reverses the tiredness from alcoholic items, and assign it to the OnEat property of each alcoholic item in the script

#

Imma go on PC so I can help better

dreamy birch
#

If its not too difficult, can you give me an example then of how I would write on eat to remove tiredness? I can't find an example of another item doing so in the lua

#

And thanks for the help

granite lintel
frank elbow
#

Getting them programmatically & using DoParam would let it apply more broadly (i.e., would make it work for modded items). Unfortunately I'm no longer at home to check on the details of that, but using ScriptManager it should be doable

#

Also re. reversing tiredness, should be a matter of redoing the same calculation done in the snippet shown, but multiplied by -1. var2 ultimately comes from I believe the percentage eaten, but I think it's transformed somewhere before then. Need to check the Eat and JustAteFood (or smth to that effect) methods

hollow current
#

In \media\scripts\items_food.txt, you'll find all definitions of the vanilla items. Let's say we're going to work with Red wine. The definition of red wine is:

item Wine2
    {
        DisplayName = Red Wine,
        DisplayCategory = Food,
        Type = Food,
        Weight = 1,
        Icon = Wine2Full,
        EvolvedRecipe = Beverage:4;Beverage2:4;HotDrink:4;HotDrinkRed:4;HotDrinkWhite:4;HotDrinkSpiffo:4;HotDrinkTea:4;WineInGlass:4;PastaPot:4;PastaPan:4,
        /*EvolvedRecipe = Beverage:4;Beverage2:4;HotDrink:4;HotDrinkRed:4;HotDrinkWhite:4;HotDrinkSpiffo:4;HotDrinkTea:4;Soup:4;Stew:4;PastaPot:4;PastaPan:4;WineInGlass:4,*/
        FoodType = Wine,
        Alcoholic = TRUE,
        CantBeFrozen = TRUE,
        EatType = Bourbon,
        Packaged = TRUE,
        ReplaceOnUse = WineEmpty2,
        HungerChange = -20,
        ThirstChange = -20,
        UnhappyChange = -20,
        Calories = 510,
        Carbohydrates = 0,
        Lipids = 0,
        Proteins = 0,
        CustomContextMenu = Drink,
        CustomEatSound = DrinkingFromBottleGlass,
        StaticModel = RedWineBottle,
        WorldStaticModel = WineRedGround,
    }```

Normally, in order to do what you want, you can copy the script into your script file and add a paramter called ```OnEat = myFunction``` for example, but this won't be a very good way since it'll overwrite the vanilla item (and other changes that may be made by other mods). Instead, go to your mod's shared folder, create a new file with the appropriate functions, for example:
#
local MyModule = {}

-- This is the function used for OnEat callback. Check them on:
--https://github.com/demiurgeQuantified/PZEventDoc/blob/develop/docs/Events.md
MyModule.MyFatigueReductionFunction = function(item, character, amount)
  character:getStats():setFatigue(0.0) --Sets player's fatigue to 0. Feel free to change it to whatever you want. Might wanna do some calculations here based on amount consumed and current player's fatigue
end

MyModule.ParamEditFunction = function()
  local scriptManager = getScriptManager()

  --DoParam is used to edit item parameters in realtime rather than editing the script itself
  scriptManager:getItem("Wine2"):DoParam("OnEat = MyModule.MyFatigueReductionFunction")
end

Events.OnGameStart.Add(MyModule.ParamEditFunction)

return MyModule```
#

then you want to add the ParamEditFunction to an event after ScriptManager is initialized, though I am not sure which is the most appropriate one. Maybe @frank elbow can assist in that regard

frank elbow
#

Probably safe to just use OnGameStart. Likely later than necessary, but no one will be drinking before then. I can't explain how I'd do the collection of alcoholic items without being at home, but it would essentially be the collection of items + a loop + the DoParam call in the above code

hollow current
#

Yea, so just append

Events.OnGameStart.Add(MyModule.ParamEditFunction)```
to the end of the script
dreamy birch
#

oh my

#

this is above what i thought i was getting myself into

frank elbow
#

There are resources in the pins for learning more about file structure & all that for mods

#

I imagine it seems like a lot, but hopefully the resources help

bright fog
granite lintel
#

haven't tried it

#

won't be able to until i get home in like 8 hours

hollow jackal
#

Hello there.
Please, how can I assign a property to the item so that it can only be placed in the character's main inventory and prevent the player from putting it on the backpack? Thank you

reef cairn
#

New to the modding scene trying to make some custom recipes like Crafting a Needle and other things that make sense. If someone was able to give me a general run down that would be sick. DM me if possible

tranquil kindle
bright fog
#

It has a bunch of recipes which are examples for you to see what's possible

reef cairn
#

This*

#

Like just stepping in

tranquil kindle
#

You could also look at other similar mods and reverse engineer them.

reef cairn
#

Thank you for this

#

And then for the module reference the mod name I would be using

bright fog
#

Just check the file he told you about, there's literally every recipes in the game in it

bright fog
reef cairn
tranquil kindle
#

I'd suggest sticking to Base module. At least for now as it might be confusing for starters

reef cairn
#

Iโ€™ll look into this for sure

somber marten
#

If I am making a mod that I only intend to use in singleplayer, do I still have to do the server and shared directories?

bronze yoke
#

files load shared -> client - > server so if your mod needs something the game handles in server it might not exist yet

#

but there aren't any special properties of the folders except when/if they load, so you don't necessarily need them

somber marten
#

Got it. So I could theoretically place the files that are in the shared and server folders in the client folder, and as long as they keep their structure, it should be fine?

bronze yoke
#

in most cases

somber marten
#

If I give more info on what I am trying to do, will you be able to give a more detailed explanation and answer?

bronze yoke
#

yeah

#

an example i can give of the type of issue that can happen is that the game creates the Recipe table containing recipe code in the server folder, if you tried to access that at load time in any other folder (e.g. adding your own recipe functions) it'd be an error

somber marten
#

Im taking Dynamic Traits and SOTO, and mushing them together. I am only doing this for myself, and wont post it anywhere. I like both mods equally, and I hate that they are innately incompatible, so I am gonna create a derivative of them for myself that makes them compatible (and also removes a few features I personally dont like)

bronze yoke
#

i don't know their full inner workings but i can't think of any specific issues that you would be likely to run into doing that

#

trait stuff is usually done in shared so changes in load order shouldn't be a concern

somber marten
#

I dont know. Both of them have server, client, and shared folder, so I dont know what to do with that

bronze yoke
#

oh, one thing is the Translate folder in lua/shared isn't actually lua (tired) and can't be moved

#

i'd say it might be more effort than it's worth to reorganise them but i can't think of anything that would be likely to break

somber marten
#

Hm

#

I really want to have a compatible version of them. I dont know if Ill be able to pull it off, but if I do, my game hours will SKYROCKET

#

I would officially ask someone else to do it, but I dont have a way to support them financially, so Ill try to do it myself as best as I can

somber marten
#

Oh I could just delete all the translation files that arent english, since I play the game in english