#mod_development
1 messages ยท Page 224 of 1
or a product is paper
The option โrip cotton clothingโ
Paper and pages ripped from books specially
could work i suppose
I dont know how to code I was just searching for a mod of this type and there are none
doesnt sound like a bad idea but its kinda niche
Wait what, that's not a thing ?
It's just rip clothing
Denim ? Didn't knew that
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
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
attacker:isAimAtFloor() and attacker:isDoShove()
you're my hero albion
i've lost track of how many times i've said that
or thought it at least
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"
if getActivatedMods():contains("<mod you want to use in a condition>") then
<put your statement here>
end
Awesome dude, thank you! This goes where in lua?
try server
or shared
if you're planning to tweak item to obsolete, go shared i guess
and I assume I have to use the mods ID (the one with letters, not numbers)?
you can try looking at other mods how they do things, it should give you a general idea
actual ID that's written in mod.info
I tried, but somehow failed to find some in my modlist. Do you happen to know one?
awesome, thank you!!!
don't use item tweaker
it causes a lot of lag and it just changes the syntax for one thing
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
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
That is great, thank you! ๐ Do you happen to know a mod that uses something like this?
what lag ?
it prints every single change it makes
with lots of mods using it it can make loading take an absurd amount longer
oh yeah I removed that from my local version long ago, I forgot about it.
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)
string.gsub(tooltip, "<RGB(.-)>", "<RGB%1> <LINE> ")
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
Well, shit.
- matches the shortest possible match, which catches each individual one
I had literally just finished some stupid recursive function for this lol
never underestimate string manipulation
Lmao I just could not find what I needed to know and could not guess in the right direction
in general be very careful when using ., *, and especially both of them together
Thank you for being the hero of legend
- is usually more useful
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
Broken items do not have separate script entries.
Interesting, so is there a Lua script or something that prevents you from using it like a non-broken item?
anyone know how to make bullbars an item that can be installed like in KI5;s 91 range rover mod
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
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
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.
In which situation do you want to find it? For example "find all those items when game starts"?
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.
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
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!
Have you checked how KI5 does them?
i have but i dont understand how theyve done it, it dont make sense ๐ญ
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
can i send you a dm reguarding it?
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
im putting a bounty up for anyone who can do it for me
could anyone help me figure out how to call for items equipped on hotbar (back/belt/holster) and get/set their weight when equipped?
Reason: Bad word usage
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 
https://discord.com/channels/136501320340209664/1125248330595848192
There's a modding community discord where you can post requests/commissions if you're interested
you've a better chance of getting someone to help you there
ty
Reason: Bad word usage
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
it could be done with lua probably, with the OnCanPerform parameter
could write a function to check for a computer on a tile nearby
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
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
i've not messed with it before but here's where i'm finding this info: https://pzwiki.net/wiki/Scripts_guide/Recipe_Script_Guide
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
nah tbh the modding section of the wiki is a labyrinth i don't blame ya
don't tell the wiki folks i said that
Doesn't work ><
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
We plan on reworking the whole way modding resources are shared bcs rn it's bad
seems like a huge task tbh, if i can help lemme know
can I see what ya wrote that didn't work?
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,
}
so when you try to do this it just works without being near a computer?
it requires an item "Computer" i've created, and it's placed on the ground
ahhh
yeah if i remove NearItem:Computer it works perfect
is the Computer like an installed piece of furniture or a loose item on the ground?
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
try using computer as an ingredient and set CanBeDoneFromFloor:true, then remove the NearItem
mmm ok
remember to set the computer ingredient to 'keep' or else it'll be consumed
but i assume ya know that
recipe Open codified data
{
keep Computer,
destroy SecretFile,
CanBeDoneFromFloor:true
Result:FilesRead,
Time:600.0,
OnGiveXP:Recipe.OnGiveXP.SecretFile,
}
Doesn't work either ><
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?
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
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
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
my pleasure, best of luck with ya work
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
Well, I did the thing.
https://steamcommunity.com/sharedfiles/filedetails/?id=3188427307
Hallo!
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.
Lol. Thank you! 
I think the 3d model is working but the problem is probably a texture ?
Idk
I need help please
probably better to ask in #modeling
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
Not null but nil
Also you can just do
If _fatigueTable then
That is an existence checl
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?
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
i'll give it a shot, thanks
hmm.. I'll take that running animations on WorldStaticModel models is not possible?
running animation from what ?
it is not
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,
most likely in a .lua code
I figure, I just don't know where to look for it
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
hardcoded in java
Is there a way to apply panic reduction to items?
Like I wanted to do, read this book, reduce panic.
or to get that ...Panic Reduction or Painkiller aspect of sorts
you sure ?
into other items, tldr I don't want to change but
bcs I'm looking at some lua code and I'm not too sure
use that same code
it calls JustTookPill in the IsTakePillAction
which performs getType in its java code
--***********************************************************
--** 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
self.character:getBodyDamage():JustTookPill(self.item);
Where does that apply the uhh...panic/pain/boredom change.
like he said
he cant call it cause they hardcoded the types of pills that the effects apply to
what ?
I just don't see it mentioned
in the java
That blows
not in the lua
so what he sent
Hardcoded means he can't modify it
you could make your own module
But that's a vanilla function here
and then add smth like Volke.PillsBeta
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
cause it only checks the type not the full type
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
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");
works too
Might try to do something like that then ๐ค
Even if in vanilla it's partially handled in the java, it's ok you can write your own
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
yeah
ooo I can try that too yeah.
that's only if you want the same vanilla effects
That's exactly what I wrote here
Either you do that and have your pill have the same effects than the vanilla ones
Or you make custom ones that way
Yeah I'll probably use what you wrote to have the same effect
take his command line, it's more exact than mine
with the ItemFactory thing
Bcs you need to reference an item basically
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]
Reason: Bad word usage
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.
hey, welcome
Your request is fine don't worry, this place is here to help each others
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
Those can help getting into modding
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.
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.
Reason: Bad word usage
Thank you for your enthusiasm. I don't know how to express my gratitude in simple words. If I can, I hope I can give you a hug [shy]
This looks good, but I think I need to learn how to use github [laughs]
Wow, I saw them. I think I'll try.
Just open it and read, it's just a wiki
Of course, but the UI of github is somewhat strange and unaccustomed to us. Even some people need to check the tutorials on bilibili to download some content using github.
it's the same for anyone who's not familiar with it dw lol
It's not user friendly at all
hhhhhhh
Wow, the completeness of this article is amazing compared with what I can find in our country.
Yes, at least I can see it from some files in mod that I have studied.
๐
Oh, this abbreviation is a bit difficult to understand, but it may mean that although we won't meet in reality, we will get along well.
not exactly but that works lol
Hhhh, this is very interesting. I think I need to learn more about foreign cultures.
it's probably not that different from yours, we're humans afterall
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.
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.
๐
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.
Expanded Helicopter Events update out now, details in the reddit post.
https://www.reddit.com/r/projectzomboid/comments/1bh8443/expanded_helicopter_events_update_last/
What a coincidence
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 ^^
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.
๐ Great minds I guess
SOS and EHE still play together amazingly well :)
sounds terrible, could you perhaps move out in another country ?
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
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
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.
I think I'm gonna most likely end up checking the source code
aaah, then chunk is probably a 300x300 tile area, also called a cell or at this point no one knows wtf it's called
@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
yes it does, but the game is shit at naming so what they call chunk here isn't supposed to be what it is
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
Im just wondering what will happen if I delete map without chunk file and the other way around
what would be the difference ingame
no idea
๐
hiii, can I use lua modules like normal for pz mods? (this what I mean https://www.lua.org/manual/2.4/node37.html)
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?
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
I have done it like that so it's good to know I wont have to rewrite everything
i recommend looking for a newer lua manual, the one you linked is from 1996 ๐
but how would I access a pz lua file's functions if it doesn't export anything?
I didn't think about that, I just used the first link about modules since this is how I've always done it (roblox uses same method)
but I am not using that manual to learn thank god that would suck
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
ok I see, thankyou
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!
.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
having the mod in /workshop also makes it active
yea that's the only place i had it active, and that was where iw anted to like. work on it.
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.
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.
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
Is the cache an odd thing or changing languages mid-game?
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
thanks for helping ๐
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
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??
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
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
That already exists
And something similar:
https://steamcommunity.com/sharedfiles/filedetails/?id=2847184718
vaccine 2.0 in progress
my personal brain orgasm
Doesn't exactly do the same but could possibly be modified to take inventories far away too
You can test your mod by using the host feature of PZ
While there can be one or two differences with real servers I've heard, it still acts as a server
?!
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...
Reason: Bad word usage
could anyone help me figure out how to call for items equipped on hotbar (back/belt/holster) and get/set their weight when equipped?
maybe this is mod can help you:
https://steamcommunity.com/sharedfiles/filedetails/?id=2617651659&searchtext=weight+reduction
YES thank you, I don't know why I just find it difficult to find things on workshop
but this is mod not work
just it's can help take info for your request
if we can't change actualweight, just need swap standard weight i think
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
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!
Check the code for my mod "Everything has a name", you should find the logic there for renaming items. I unfortunately don't remember the exact method right now since I'm on phone
is there a way to make make up show when you click another player
@hollow current thanks it worked for me โค๏ธ
Reason: Bad word usage
I don't think so
thats a shame
guys, how to get recipes to existing professions?
without overriding
or skill with exp boost
like Axe +2 for example
Fire a onplayerupdate or EveryDay event maybe
nah, not event
yep
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?
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);
genius!
yes it's override
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).
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...
can u get link on your mod
i check it tomorrow
here is what should work for you:
My mod is here: https://steamcommunity.com/sharedfiles/filedetails/?id=2675128168 But not worth to study the code since it contains much more stuff than you need (and not the best coding tbh ๐ quite old work...)
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...
Hi all, how to mod for not let spawn a specific item? can i overwrite the loot distribution?
This would work but it will make your mod incompatible with any mod which changes something about the loot distribution.
Better take the vanilla distribution table and try to delete only the item from it via lua coding.
did you have an example for that?
give me a moment... structure of the vanilla distribution table is a bit unhandy... ๐
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.
But no guarantee that it will work. Just made this example out of my head...
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
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
I see... distinction between pairs/ipairs shouldn't matter in the above case...
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
ok ty
You can also save the indexes of the items you want to remove in a separate table, and once you're done looping through the table just remove all the elements at those indexes, that way you can still use iterators (pairs/ipairs loops) if that's the preferred style of doing things.
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
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.
in regular c lua ipairs is only a little slower, in kahlua (java implementation pz uses) it is significantly slower
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
I imagine since Java doesn't have pointers the implementation must do some sort of really roundabout way of doing iterators.
Doesn't seem like too bad, looks pretty straightforward.
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
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
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
Reason: Bad word usage
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
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
i've documented the script functions here if you need some guidance https://github.com/demiurgeQuantified/PZEventDoc/blob/develop/docs/Events.md#Recipe_OnTest
(if it doesn't jump to it automatically, the script callbacks are at the bottom of the page)
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
if you run the game with the -debug argument there's a lua console which prints output to, as well as some other tools
Gotcha. Thanks.
you can also check console.txt in %UserProfile%/Zomboid (windows)
Appreciate it
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"
Gotcha
getDisplayName probably returns the DisplayName from the item script, which is a legacy feature from before it was all done with a translation system
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
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
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
i don't remember what causes that, i think the inventory ui likes to hide items with a certain criteria...?
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"
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
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
When crating it. I'm just confused why.
I mostly just copied from the CraftedSpear files and modified them
You're missing a comma after* AllowOnlyTrue
Ahhhh
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
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
Yeah that fixed it
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 ๐
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
I'm not too sure I know what that is, probably a lack of vocabulary from me, yet a good chance I actually used that
Perhaps the error caused by translation software is too big. XD
I'd have to write that on paper, if you didn't get an answer later, don't hesitate to DM the problem tomorrow
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
Could you please describe the problem more accurately? It's bothering me.
you can try to execute your sample code in https://www.tutorialspoint.com/execute_lua_online.php
@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"
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
I might be misunderstanding this but if you want 30 minutes from 0.2 you can do 1/timespeed * 360/60
@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)
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?
๐ฑ 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
While this result is still no different or even more complicated, I'm still happy to be able to all the responses
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
I have a rather crazy suggestion and attempt here, maybe you could try setting the value to 0.8
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
Hi All,
Get Scrapping Simulator Today!
Steam Store Page:
https://store.steampowered.com/app/14...โ
Humble Store Page:
https://www.humblebundle.com/store/scrapping-simulator
Join our Discord:
https://discord.gg/Rw5qxNqfBT
Visit our Website:
https://defectgaming.com/
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 
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
๐
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 ๐คฆโโ๏ธ
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
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 ๐ ๐
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.
-
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..
-
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..
-
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.
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
i found this, should this work?
https://steamcommunity.com/sharedfiles/filedetails/?id=2708663892
Regarding question 2, it's possible but not in a direct way. You can use the event that fires when an item spawns in a container, then check if that item is the target item, and if it is, check the coordinates of the square of the container it spawned in. If it's not in the location you want, just delete it from the container
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
Just curious really is it possible to get the name of a mod or mod_id from a modded item object?
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
I don't know this mod. Maybe have a look at it.
Thanks there must be a way to get that name
what exactly are you trying to do?
:getModID() on an InventoryItem instance
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
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..
Reason: Bad word usage
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?
anyone whos good at lua help me with my custom car upgrade mod, im using the standardised vehicle upgrade template but i am struggling!
start read from here
#mod_development message
tysm ๐
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
Also @plain crest that might interest you
u mean the other plushie?
Reason: Bad word usage
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
aww yay
I mean your plushie, what is it supposed to look like ?
the plushie itself is that
the only problem i have is the position when attached
i can place it correctly on the floor
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 ๐ค
goddamn it lmao
It takes the model of the plushie placed on the ground
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
how i do it on the script? on blender doesnt work
local inventory = self.character:getInventory()
inventory:DoRemoveItem(inventory:getItemFromType(self.item:getType()))
also do you mind me asking what you doing with that ReadLiterature function?
I figured you read the magazine and it gets consumed
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?
lol
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
Where would I add the piece of local inventory ?
also at the end
you would probably let it do its original :perform and then add your stuff afterwards
https://steamcommunity.com/sharedfiles/filedetails/?id=2901033394 It's a copy-paste code I doubt they knew what it was doing
lol
๐ I was looking at this one and the burglar magazine one
To figure out how to do it
can i just upload the 2 scripts here?
its really simple
yes
is it an .fbx model?
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?
Do a command that's sent to every clients to do the exact same action ?
yup
You could try maybe playing with the origin point?
i didnt think about that :D
Reason: Bad word usage
Hey, it's okay. But it's important to understand what you found. Also to do that you can simply remove the ReplaceOnUse parameter from the item script.
thanks! I was not sure if that was the correct way to go about that
๐ฎ I see
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
I think that's how to do it
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
I see ๐ฎ
Yall so smart with lua stuff ๐ , I'm just a baby, only really been doing simple scripting
Reason: Bad word usage
glad to be of help
CS1.6 ?! not only by heart..
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
new car with some special function <tank?> or smth
ty, i'll take a look
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
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
I did not know that
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
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
it can be useful for injecting code into the middle of a function, but i'm not sure it's really necessary here
@stray willow you could use the metatable method to overwrite the pill interaction you wanted to do on sunday
I'm using What Elyon wrote above, I'm just wondering how i would add additional magazines that add or remove traits how it would look ๐ค
probably as you do it rn which is manually checking for the magazines you need and then remove the coresponding trait
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
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?
Out of curiosity, why override ReadLiterature instead of just removing / adding trait after perform?
Because I copied someone elses code as a base using the nutritionist and burglary magazine mod
I have no idea what I'm doing fully ๐ฅฒ
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?
Secondary question, do you know how to use debug mode yet?
Yes
Effectively ๐
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
it will let you double add, it's basically just an ArrayList<String>
i don't think it throws an exception if you remove a trait that isn't there though
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...
it's slower to iterate through
(i'm going for the performance argument because i don't really know)
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
every frame while rendering the traits ui
I see. Fair enough. I figured the traits UI could pull that info once and adjust it if a change is detected
that sums up the entire problem with pz's ui rendering
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?
no, it'd only cause problems, but not significant ones
I see.
the only issue i can see it causing is trying to remove the trait wouldn't work
Right
since ArrayList.remove just searches for the first occurence of the object
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.
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
But they still need to check the magazine types to know what traits to add/remove. They could define a table that maps magazine item types with their effect on player traits.
Correct but this would eliminate a potentially large if-else chain of books
Definetely
And reduce it to 1 quick bool check
This is a good idea too though. But a bit more complicated and I can't phone-text a good example for Volke right now... ๐
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
Whats the code?
on server its pretty much
container:AddItem(InventoryItemFactory.CreateItem(itemType))
container is ItemContainer instance
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
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)
when they run out of water then they are literally empty no?
try adding container:setDrawDirty(true) at the end
otherwise you could call :transmitCompleteItemToClients() on the container
Yes, but i mean that i want to implement this to other types of items that are not containers
trying the :setDrawDirty one
with :transmitCompleteItemToClients() it duplicated container on client side for some reason (duplicated container was synced with correct items inside)
can you get the container from the client?
yes
you could call it on the client's side container perhaps
when is your command executed? do you use an event or append it to vanilla code? and where do you get the container object from?
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
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
indeed this is exactly what happens
sendItemsInContainer(container:getParent(), container)
is this what you mean?
yeah, something like that
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
thank you ma'am, it works, at least the adding part, it did not remove the old one tho
but still
Here is praying it changes in b42
I had impression that all player stuff is client sided (player inventory too) but other than that containers and such are server sided hmmm...
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).
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
omg! that's weird. cause when you do this on client side, it syncs completely fine
im logged in my server from my pc with 2 clients and only the client who calls it sees the sync for me
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
oh wow, okay, my life has been a lie
so do I understand correctly, when I call addItemOnServer client side it might sync it for all players that are loaded on that cell?
yeah
addItemOnServer called from the client syncs perfectly, the method does absolutely nothing if called from the server side though
I was so sure it did not work that way so I did not even try it even tho it went by my mind
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
I'm checking out what you did in your ammo maker out of curiosity, thank you for the hint
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
is the addItemOnServer command also necessary if you put smth to the player inventory?
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
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
it's for b42
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...
noyce, I can yeet all that server code away...
wouldn't moving the player inventory management to server make things even more complicated (at least for modders)?
probably a little bit, but it's a critical cheating exploit as it is
if you have single source of truth then theoretically it should be less complicated
I am quite afraid of b42 then when it comes to making my mods compatible ๐
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
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
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
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?
items don't need their moddata transmitted
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
i'm not really sure exactly how it works but they don't even have a transmit function
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.
@coarse sinew Just want to say thank you ^_^
You wanna try something else ? Check Water World mod and create your own Kevin Costner story in flooded Kentucky: https://steamcommunity.com/sharedfiles/filedetails/?id=3187166008
Hello Friends! Does anyone is experienced with mod making in project zomboid? I need some help please ๐ฆ
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
require "Items/ProceduralDistributions"
local function removeFromDistribution()
RemoveItemFromDistribution(ProceduralDistributions, "Base.Item", nil, true)
end
Events.OnPostDistributionMerge.Add(removeFromDistribution)```
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
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
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?
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.
if it's about players you might want to put it on the player's moddata instead
how about zombies?
yes it is, tysm
how is the sound file for beta blocker called
or bandages if they have one
where are all the ui icons
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.
How can I check if an item is spawning in the world naturally?
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
It's more Lua than Java from what I've seen, but if you feel comfortable with Java, I don't think Lua will give you any trouble.
I don't know either, and I'm successfully making my own little tweaks.
Maybe crank the spawn rate up really high then start a new game?
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
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.
Not sure, I use Notepad++ and VS Code and I don't remember installing that for VS Code
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
EmmyLua i think...
Thats a VSCode plugin
yep, but it's should be same on your programm
i think
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
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
Ill manage
If it is about an item added in a mod, you can check se distribution file in the lua folder
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?
You need to create 3 different tiles and use the StackReplaceTileOffset property
TYVM. And how will the game know all three tiles are related to the same crate? Give all three tiles the same name? Or give them the same group name? Or is it done somewhere else?
Well, using this property. You can also check the properties of game's tiles to see how they are defined
Zombies use SuburbsDistributions. Try to replace Procedural distributions with it
how to write x^2 in lua?
x*x
nah, x - it's variables
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)
local x = 2
if something == true then
x = 4
end
math.pow(x, 2)?
Yeah, but again for a power of 2 it's faster to just multiply
but if x = 4, its should be 4^2
Premature optimization to be sure but easy enough that there's no reason not to
not 4*4
Mathematically, a power of 2 is equivalent to multiplying something by itself
4^2 = 4*4 = 16
No problem
zreFirstAidBonus = math.ceil((-1*zreFirstAidReq) + ((zreFirstAid*zreFirstAid)/2.5));
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?
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
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
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,
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
Oh wow, thank you very much! That makes things easier!
i guess i was wrong ๐ฆ
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
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 ๐ฆ
Hi!
hmm is it possible to get list of players in a cell or I would need to loop over all players?
Can try posting here too
https://discord.com/channels/136501320340209664/1125248330595848192
What is the mod? Items, vehicles, lua or scripts? All of the above? Does it load in game for you?
Hello ! I made a mod for custom crates But I get this space in recipe list ! And I don't understand why ?
What text editor are you using?
When writing scripts and translation
Notepad++
but I think, this name "caisse de jardin" is is propreties tiles
in custom name
Technically speaking each client has access to only the players within their loaded cell
So if you try to get an isoPlayer near the other player if an object is returned then it exists
I added a new type of crate and I get the same problem ^^
moveable.Caisse blablabla
but moveable. hidden like big space
result in recipe
just need create custom item for moveable object
and do this item like result
thanks for your answer @verbal yew but i don't get it ๐ In my mod I created 7 sorts of crates. Works perfectly except this space, and I copy/paste the tiles properties of others crates (except the name) I f want to have a look, here's the mod : https://steamcommunity.com/sharedfiles/filedetails/?id=3188714481 ๐
Can someone help me with this step? I cant find those buttons on my IntelliJ
don't use this guide, it's old as hell
you can get better typings than the one it generates from umbrella https://github.com/asledgehammer/Umbrella and you can decompile using beautiful java https://github.com/quarantin/beautiful-java or just use intellij's decompiler directly
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
Thanks
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.
Thank you so much! I had figured out the first part but I wasn't sure about the second.. Thought the game would throw a fit or something since the item isn't valid lol
I use this trick in one of my mods and it seems to work without any errors XD
btw I have no idea how to rename a recipe cause the english names like "Open Jar of Broccoli" are also used as some sort of ID for the recipes. Maybe there is a way using the translation files...
100k subs is absolutely massive man
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
xD well, from #1 to #40 pages, it means 742 mods
do you suggest some number?
I'm subscribed to more mods then that
Top 100? 500? Idk man, 1000 seems fine too
QoL mods easily fill 400
But alot stopped development cause of B42
crunch stats from subscribers count of 1470 mods, from #1 to #40
Wait what do these variables mean? Minimum what, fish, bananas or subs?
im planning to separate in tiers, options to select
subs, can generate analysis, graph, using the table that i post
corelate with collection increase aprox too
but you can figure out, a neat formula and share it :))
There are some mods with thousands of subs but long since abandoned
Yeah but you are prob better at that then me
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
a data scientist are better than both of us,
maybe statistical people too
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
Can ask here too https://discord.com/channels/1002947509670400071/1005817931386605709
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
Can you also add a recipe to the game by means of Lua?
I would like to adjust the crafting materials (only the quantities) based on user input.
I have been looking in the documentation but can't seem to find anything that would help me but perhaps you (guys) know
Do you guys know if it is possible to alter vanilla methods? Essentially overriding those within a mod?
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.
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.
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>
?
how do you make a crafting recipe yield more than one of an item?
You mean like return more than one item? Or like require more than one item
return more than one
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
I think this is how the game does it
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
i think i figured it out actually
๐ฎ
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
did you just use 2 Result: tag?
` 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
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?
I want to make an mod that replaces every texture with a picture of
Chris Allen. Where do I start?
find a photo of Chris Allen...
the start is not the issue, but the journey and the end...
Hm what then?
Tell me what next.
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?
It depends on how it is programmed and what it does, but generally, it is the events that call the code. https://pzwiki.net/wiki/Lua_Events. Unless your mod overwrites some existing functionality or adds functionality to something that already exists and is called at some point. But it will depend on the event.
I am trying to figure out why people add an OnGameBoot event callback when mods (to my knowledge) get loaded when the game starts anyway.
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.
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 ๐
It may be due to lack of knowledge, it has happened to all of us and continues to happen to us.
Try putting 1 instead of 5
It is launched after a lua reload so even when you reload lua in the menu or specifically the file, it will throw the print while if it was in OnGameBoot it would throw only on game boot
Reload of lua is not unique to game start, while OnGameBoot is
guys. maybe who know how to remove recipe from knowledge of player?
player:getKnownRecipes():remove("LabResearchToVaccineTo2lvl");
because:
item Nails
{
DisplayCategory = Material,
Count = 5,
Weight = 0.01,
AlwaysWelcomeGift = TRUE,
Type = Normal,
DisplayName = Nails,
Icon = Nails,
MetalValue = 1,
SurvivalGear = TRUE,
WorldStaticModel = Nails,
}
count = 5
anyone know how to texture vehicles?
Why the fuck is the character background green
for chromaskeys i guess
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?
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
ah! omar jumpscare
this is already beyond me
Simpler than it may seem, if we ignore murphy's law
Unless you meant the OnEat part, which does warrant further explanation if you want to go that route
yes i would like an explanation
it would be easier if people could just download and use the mod rather than replace files
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
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
sphaghetti code my beloved
I was omw to work sorry, hopefully I've given enough info for someone else to help but it'd be better to not redefine scripts
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
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
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
Yea, so just append
Events.OnGameStart.Add(MyModule.ParamEditFunction)```
to the end of the script
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
did it work lol ?
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
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
Just visit this location in your steam folder: steam\steamapps\common\ProjectZomboid\media\scripts and look for "recipes" txt files. Its fairly easy to create base recipes, but there is possibility to go crazy on them.
Oh does this give examples
Well, yeah lmao ???
It has a bunch of recipes which are examples for you to see what's possible
My apologies I am very new to the history
This*
Like just stepping in
You could also look at other similar mods and reverse engineer them.
Just check the file he told you about, there's literally every recipes in the game in it
That's not obligatory, that's only if you want to put it in a different category
Ah okay for sure thank you for this
I'd suggest sticking to Base module. At least for now as it might be confusing for starters
Great advice
Iโll look into this for sure
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?
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
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?
in most cases
If I give more info on what I am trying to do, will you be able to give a more detailed explanation and answer?
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
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)
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
I dont know. Both of them have server, client, and shared folder, so I dont know what to do with that
oh, one thing is the Translate folder in lua/shared isn't actually lua (
) 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
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
So I should keep that in the shared folder?
Oh I could just delete all the translation files that arent english, since I play the game in english

