#mod_development
1 messages ยท Page 149 of 1
i meant for example
I use auto-complete for values yeah? I'm saying though like a item template for a certain type of weapon category or maybe a template for heavy vehicles.
Ah.
item Bag_ToolBag
{
DisplayCategory = Bag,
Type = Container,
DisplayName = Duffel Bag,
ClothingItem = Bag_ToolBag,
CanBeEquipped = Back,
WeightReduction = 65,
Weight = 1,
Capacity = 18,
Icon = Duffelbag,
OpenSound = OpenBag,
CloseSound = CloseBag,
PutInSound = PutItemInBag,
RunSpeedModifier = 0.95,
CanHaveHoles = false,
ReplaceInSecondHand = Bag_DuffelBag_LHandTINT holdingbagleft,
ReplaceInPrimaryHand = Bag_DuffelBag_RHandTINT holdingbagright,
WorldStaticModel = DuffelBag_Ground,
}
theres a lot more possible parameters and also some could be omitted
Exactly.
I agree with you on this 100%.
The idea of templating is to help reduce time writing the same properties again and again.
What if I wanted to make an extended bags mod..
Create new Bag
Hit enter and then this template is then applied to your document.
Creating templates for very common scripts will reduce a lot of time spent building from scratch. =)
The problem: I have no experience scripting so I wouldn't know.
@drifting stump Here's some of the helper features in the extension.
very nice
should mention in the icon it should be think it was 16x16
because the vanilla inventory render function doesnt scale the icon and anything else will mess it up
I can edit the PZWiki page to mention that.
Thanks.
I've improved a couple dozen pages today for properties for simple inconsistencies or some wording issues.
Hm, so if I want to get the script name of an item, not a DisplayName with translation or something, would it be getName() or getFullName()? What's the difference between these functions?
Do you mean the name of the item after "item" in the script? It's referred to as the "type" and the "full type" is the fully qualified name including the module
I know for full type it's getFullType, I assume for type it's getType. Less certain bc I prefer the former when it's needed
when i try to get the game to recognise that this item does have a 3d model it just throws me a questionmark
here is the code
`module Base
{
item alexshead
{
Type = Clothing,
DisplayCategory = Accessory,
DisplayName = Alex Helmet,
ClothingItem = Hat_alexhelm,
BodyLocation = FullHat,
Icon=Item_alexhead,
CanHaveHoles = false,
BloodLocation = FullHelmet,
BiteDefense = 100,
ScratchDefense = 100,
BulletDefense = 100,
DisplayCategory = Armor,
ChanceToFall = 0,
Insulation = 0,
WaterResistance = 0.40,
Weight = 1.0,
Tooltip ="This is alexs head its unique",
WorldStaticModel =alexshead,
}
model alexshead
{
mesh = WorldItems/alexshead,
texture = WorldItems/alexhead,
scale = 0.5,
}
}`
Icon
The icon for the item. The file must:
Start with Item_
Use the extension png
Be located in the media\textures\ directory.
Example: media\textures\Item_JarBox.png
Food Icons
You can specify icons for rotten, cooked, overdone, and burnt food by adding the suffix Rotten/Cooked/Overdone/Burnt.
Example: media\textures\Item_PikeCooked.png
Icon = JarBox,
Your icon format is wrong.
Icon_ is for the file name.
so i should change it to this
Icon=alexhead,
Depends on what you call it.
But yes without the Item_ prefix.
ah perfect
then what about
model alexshead
{
mesh = WorldItems/alexshead,
texture = WorldItems/alexhead,
scale = 0.5,
}
ty
can i make trunks NOT spawn items?
lol i just was wondering if it was like a "nofill" command or something
setExplored or set the car some table with no items
does anyone have an example i could follow for creating a context menu for a tag.. or how they did the PillsVitamins iv been struggling while looking threw the base game files for how to do this and im just getting more confused by the second
Yeah one sec
first, we need to patch OnFillInventoryObjectContextMenu
local function OnFillInventoryObjectContextMenu(player, context, items)
--# When an inventory item context menu is opened
local playerObj = getSpecificPlayer(player);
items = ISInventoryPane.getActualItems(items);
-- Get table of inventory items
local isVape = nil;
-- Define a variable to hold the potential vape item
for _, item in ipairs(items) do
-- Check every item in inventory
if item:getDisplayCategory() == getText("IGUI_ItemCat_Vape") then
-- If item is a gnome bar, it is caught in a variable.
isVape = item;
-- We check if it's our item first to reduce load time since this is called every time an option is right clicked.
-- // (item:getFullType())
break
end
end
if item:getDisplayCategory() == getText("IGUI_ItemCat_Vape") then This might be the part you're looking for
I check for display category rather than tag
then, after we see if it's the vape item
if isVape ~= nil then
-- # if the clicked item is a vape, add the vape context menu item
local isFav = context:getOptionFromName("Favorite");
local opt
local CMIcon = vape_config.ModOptions.options.box3 and true
-- !! if option is not enabled, true. If it is enabled, false
-- // print(CMIcon)
if isFav then
opt = context:insertOptionAfter("Favorite",getText("UI_vape_action"), isVape, callVapeAction, playerObj)
-- !! Need to also pass the player object here so the timed action can use it | Insert after "favorite" so it's in the normal "smoke" position
else
opt = context:insertOptionAfter("Unfavorite",getText("UI_vape_action"), isVape, callVapeAction, playerObj)
-- !! Inserting option after unfavorite. If neither exists, it will just add it to the bottom of the stack by default.
end
if CMIcon == true then
opt.iconTexture = getTexture('media/textures/context.png');
-- Icon that displays adjacent to context menu item
end
if not (isVape:getUsedDelta() > 0) then
--print("no charge")
opt.notAvailable = true;
opt.tooltip = "this vape is dead"
end
-- local op2 = context:insertOptionAfter("Favorite","Check Flavor", isVape, getFlavor) --DEBUG
end
end```
and after that, we run the vanilla code
Events.OnFillInventoryObjectContextMenu.Add(OnFillInventoryObjectContextMenu) -- !! When vanilla code is ran, add this custom code
this is what is actually creating the context menu
opt = context:insertOptionAfter("Unfavorite",getText("UI_vape_action"), isVape, callVapeAction, playerObj)
callVapeAction is a function that gets called when the context menu is clicked
local function callVapeAction(vape,player)
-- # Callback function to start the hitvape timed action - triggered by hitting "vape" context menu
ISTimedActionQueue.add(hitVape:new(player,vape));
end```
and that function calls my custom timed action (the vape action)
check out the vanilla ISContextMenu.lua
that's where most of this stuff can be found
so how do i get that context menu to apply StressChange and UnhappynessChange, as when i was looking at the pills it does not let you just put that in the code for a drainable but yet they have some of the pills (antidepressants) for example change the players unhappyness over time
is that still done threw the context menu or is that filled out in another script when calling back for it?
That's why I have my action as a new timed action
There's no simple tag or something to be able to do what you're trying to do
You're going to need custom Lua script to do that
Probably using the same timed action method I did
That way you can inject your own status effect code
One sec I'll show a little how I did it
would you be able to VC? might be easier to explain lol
thats okay ill try to follow along as best as i can then
local bodyDamage = character:getBodyDamage()
local stats = character:getStats()
stats:setStressFromCigarettes(stats:getStressFromCigarettes - CONFIGURE ME);
-- Removes stress from cigarettes
stats:setStress(math.max(((stats:getStress()) - (CONFIGUREME)),0))
-- Set regular stress to the players stress - your variable or 0 if it's under 0.
bodyDamage:setUnhappynessLevel(math.max(((bodyDamage:getUnhappynessLevel()) - happiness),0));
-- !! Add happiness bonus when hitting a vape
bodyDamage:setBoredomLevel(math.max(((bodyDamage:getBoredomLevel()) - boredomDecrease),0))
-- !! Reduce boredom when hitting vape
M's buckets adds new tags and makes use of them too ๐
inventoryItem also has this function
getTags()
which returns a table
you could check that table for your custom tag
declaration: package: zombie.inventory, class: InventoryItem
player:getForwardDirection():getDirection(); how would i get the vehicle version of this? as the angles are not the same using vehicle:getAngleY()
or wait
hasTag(String tag)
this will be even easier
you would just do something like
local function isVape(item)
return item:hasTag("vape")`
end
this will return true if your item has the vape tag
so im looking at the They Knew mod as they did pills as well and i found something weird, where they used a crafting recipe to make the take pills thing then they had there own TakePill.lua setting the players infection to 0 would this be done the same way? but idk how they got it to do that from a recipe
its probably something in TakePill.lua
i'm not aware of any script parameter that changes that value
The Lua is more detailed and powerful than script text
^
can you make it where when you craft a recipe it makes the players Unhappyness go down with a lua?
Yes
i just showed you that
thats kinda cool
right here
bodyDamage:setUnhappynessLevel(math.max(((bodyDamage:getUnhappynessLevel()) - happiness),0));
omg im slow im sorry
The issue I'm sure he's dealing with is seeing this code and having no idea how to implement it haha. I'm doing the same.
no worries i'm just trying to help ๐
i was supposed to be the art creator for this vape mod now im helping with code
i know how frustrating it can be
You are the most helpful โค๏ธ
i only started a couple weeks ago and was in the same spot
this is why i try to make my code have lots of comments
THANK YOU
so people seeing it can maybe understand better
yes truly helpful i screen grabbed it all to use for later! thank you so much Maemento!!
of course! I'm looking forward to seeing what you create
i would love to know where or what to name the scripts and where they go in the folders >.<
as that one gets a bit umm complex
ok so I am trying to make a new attachmentType for my item so I can reduce clipping when on the back an I am using Peach's backpack attachments mod as an base to work off but I am failing to understand what determines the name here in the weapon script. AttachmentType = Shovel, This is what I have so far in an attachment script I made that currently just takes the positioning of the shovel and gives it a new name ```module Base
{
model FemaleBody
{
mesh = Skinned/FemaleBody,
attachment daki_back
{
offset = -0.0390 -0.0990 0.1520,
rotate = -7.0000 87.0000 -55.0000,
bone = Bip01_BackPack,
}
attachment daki_back_bag
{
offset = -0.0040 -0.0980 0.1350,
rotate = 90.0000 0.0000 -179.0000,
bone = Bip01_BackPack,
}
model MaleBody
{
mesh = Skinned/MaleBody,
attachment daki_back
{
offset = -0.0390 -0.0990 0.1520,
rotate = -7.0000 87.0000 -55.0000,
bone = Bip01_BackPack,
}
attachment daki_back_bag
{
offset = -0.0040 -0.0980 0.1350,
rotate = 90.0000 0.0000 -179.0000,
bone = Bip01_BackPack,
}```
nothing is ever ugly
Yeah I only started yesterday, and already today managed to make a mod combining Crafting Core Enhanced, Yaki's Makeshift Clothing and all Scrap mods.
You learn every day, you just need to practice
Let me ask this of you @fading horizon (great username btw), if I make a custom lua file in my mod, will the game understand that script is talking about just my mod? Assuming of course I use local where needed and all that.
media\lua\client\ is where the ISUI folder is located. This is where you will create a new file for your custom tooltip if you want to go that route
in the same client folder is the TimedActions folder
OHHHHH
this is where my custom hitVape.lua (the custom timed action where most of the code I showed you is)
inside medi\lua\server you have the Items folder
this is where you create an itemsDistribution.lua
so is the TakePill.lua a timed action?
and handle how your items are spawned
one sec lemme finish this then ill answer the next questions
media\lua\shared is basically only for translation files from what ive seen but it may have other edge case functions
Ima leave that to the linguists.
its actually not hard and it gets your mod out there a lot more
I added russian translations and all of a sudden i had tons of russian ppl commenting
translation files are easy anyway
you literally just replace the english text with the foreign text
it depends
it needs a unique name for one
if you just name yours distributions.lua (or whatever the vanilla one is called, or another mods custom name), it will instead overwrite that file (depending on which mod is loaded first)
Ok so a nice prefix can fix that
but this is also why it's good to immediately do a check in your functions to determine if it's your mod or not
That is useful if you want to see tons of russian ppl commenting :).
such as here
local function OnFillInventoryObjectContextMenu(player, context, items) --# When an inventory item context menu is opened
local playerObj = getSpecificPlayer(player);
items = ISInventoryPane.getActualItems(items);
-- Get table of inventory items
local isVape = nil;
-- Define a variable to hold the potential vape item
for _, item in ipairs(items) do
-- Check every item in inventory
if item:getDisplayCategory() == getText("IGUI_ItemCat_Vape") then
-- If item is a gnome bar, it is caught in a variable.
isVape = item;
-- We check if it's our item first to reduce load time since this is called every time an option is right clicked.
-- // (item:getFullType())
break
end
end
if isVape ~= nil then
do whatever
so basically when any item is right clicked (the OnFillInventoryObjectContextMenu function, which is vanilla)
it grabs a table of items in the inventory
then it checks the item to see if it has the "vape" displayCategory immediately
We check if it's our item first to reduce load time since this is called every time an option is right clicked.
let me check
but yes, most likely
so if i wanted to make it check for a tag instead of checking if it has the displayCategory id put hastag where you have getText?
damn, it's vapechat time
xD yes it is
mostly me just learning lua or trying to understand it cuz youtube was not helping at all
player:getForwardDirection():getDirection(); how would i get the vehicle version of this? as the angles are not the same using vehicle:getAngleY()
i am still trying to get this answered lol.
yes
it is
C:\Program Files (x86)\Steam\steamapps\common\ProjectZomboid\media\lua\client\TimedActions\ISTakePillAction.lua
ISTakePillAction.lua
okay so timed actions is what gives that call back for making the players unhappyness (Ex.) to change? or is the takePillAction used in something else that im skipping over
no, you're correct
yay i learned somethin!
basically every timed action will have the following functions
luckily
i commented this out so i can show it
lmao
COMMENT YOUR CODE KIDS
Documentation even.
so how do i tie this into crafting?
most of my code happens in the "perform" section
so now that you understand timed actions, lets go back here for a moment
id probably lose the vaping sounds though
local function OnFillInventoryObjectContextMenu(player, context, items)
--# When an inventory item context menu is opened
local playerObj = getSpecificPlayer(player);
items = ISInventoryPane.getActualItems(items);
-- Get table of inventory items
local isVape = nil;
-- Define a variable to hold the potential vape item
for _, item in ipairs(items) do
-- Check every item in inventory
if item:getDisplayCategory() == getText("IGUI_ItemCat_Vape") then
-- If item is a gnome bar, it is caught in a variable.
isVape = item;
-- We check if it's our item first to reduce load time since this is called every time an option is right clicked.
-- // (item:getFullType())
break
end
end
so this is me creating the context menu
if isVape ~= nil then
-- # if the clicked item is a vape, add the vape context menu item
local isFav = context:getOptionFromName("Favorite");
local opt
local CMIcon = vape_config.ModOptions.options.box3 and true
-- !! if option is not enabled, true. If it is enabled, false
-- // print(CMIcon)
if isFav then
opt = context:insertOptionAfter("Favorite",getText("UI_vape_action"), isVape, callVapeAction, playerObj)
-- !! Need to also pass the player object here so the timed action can use it | Insert after "favorite" so it's in the normal "smoke" position
else
opt = context:insertOptionAfter("Unfavorite",getText("UI_vape_action"), isVape, callVapeAction, playerObj)
-- !! Inserting option after unfavorite. If neither exists, it will just add it to the bottom of the stack by default.
end
if CMIcon == true then
opt.iconTexture = getTexture('media/textures/context.png');
-- Icon that displays adjacent to context menu item
end
if not (isVape:getUsedDelta() > 0) then
--print("no charge")
opt.notAvailable = true;
opt.tooltip = "this vape is dead"
end
-- local op2 = context:insertOptionAfter("Favorite","Check Flavor", isVape, getFlavor) --DEBUG
end
end```
that's the context menu created
I filled out a decent portion of properties for the extension
and thats under ContextMenu.lua?
local function callVapeAction(vape,player)
-- # Callback function to start the hitvape timed action - triggered by hitting "vape" context menu
ISTimedActionQueue.add(hitVape:new(player,vape));
end```
callVapeAction gets called when the context menu is clicked.
callVapeAction adds my custom "hitvape" timed action to the timed action queue
this is all in the same lua file, just a custom one in timedActions folder
so where i need to start first is making a timed action
that's how I did it at least
I tried modifying vanilla functions
tried using pills too, actually but I also ran into issues
i tried a bunch of different stuff because making a timedaction seemed overwhelming
but in the end, if you want full control and no vanilla wonkyness, making your own timed action is the way to go
๐
sorry Skizot >.<
I forgot to reply to this, but good job! Keep it up
bumping this
bc idk but i'm sure someone does
time for me to go learn how to make a timed action ๐ซก
Any idea how to set up a console.txt error file? My mod has seemingly broken the item list in debug mode, and I can't figure out how to see the error that shows up when I reload lua at the start screen.
C:\Users\YOURUSERNAME\Zomboid\console.txt is where it should be located
then you can ctrl+f for "stack trace" or "error"
found it, thanks so much.
Caused by: java.lang.NullPointerException: Cannot read field "name" because "this.module" is null
at zombie.scripting.objects.Item.getModuleName(Item.java:1009)
I have given everything custom names, but do I need to rename my custom items with a prefix to my mod?
at the beginning of your item script file do you have something like the following?
{
imports
{
Base
}```
I do. It doesnt seem to be working.
item LargeSaltContainer
{
DisplayName = Large Salt Container,
DisplayCategory = Food,
Type = Food,
Weight = 0.75,
Icon = Salt,
CantBeFrozen = TRUE,
EvolvedRecipe = Pizza:1;Soup:1;Stew:1;Pie:1;Stir fry Griddle Pan:1;Stir fry:1;Burger:1;Salad:1;Roasted Vegetables:1;RicePot:1;RicePan:1;PastaPot:1;PastaPan:1;Sandwich:1;Sandwich Baguette:1;Taco:1;Burrito:1;Beverage:1;Beverage2:1;Beer:1;Beer2:1,
Spice = true,
HungerChange = -10,
ThirstChange = 20,
UnhappyChange = 20,
WorldStaticModel = LargeSaltContainer,
FoodType = NoExplicit,
Tags = MinorIngredient;Salt,
}
WARN : Recipe , 1681339127130> RecipeManager.resolveItemModuleDotType> WARNING: module "Base" may have forgot to import module Base
Hello, trying to create a fire starting/stopping tool however on key presses nothing happens
CheatCoreCM.CM_TempCoord = nil;
function CheatCoreCM.OnKeyKeepPressed(_keyPressed)
if CheatCoreCM.FireBrushEnabled == true then
local GridToBurn = CheatCoreCM.getSqObjs()
if _keyPressed == 49 then
GridToBurn:StartFire();
elseif _keyPressed == 33 then
GridToBurn:stopFire()
if isClient() then
GridToBurn:transmitStopFire()
end
end
end
``` Its supposed to be N to start and F to remove fire
java.lang.NumberFormatException: For input string: "LargeSaltContainer" at FloatingDecimal.readJavaFormatString.
ERROR: General , 1681339127126> DebugLogStream.printException> Stack trace:
java.lang.NumberFormatException: For input string: "LargeSaltContainer"
And it was all working a couple days ago.
my method of troubleshooting would be removing one line at a time from the item script until something changes
or take a look if any of your recipe code is using that item and maybe theres an error there if that doesn't work
are GridToBurn:StartFire(); and GridToBurn:stopFire() still valid vanilla functions to use?
why DONT vehicles have getForwardDirection??
is getForwardVector() no good?
Ok this is weird "The NumberFormatException is an unchecked exception in Java that occurs when an attempt is made to convert a string with an incorrect format to a numeric value."
So then why is it trying to convert my items name into a number?
"java.lang.NumberFormatException: For input string: "LargeSaltContainer" at FloatingDecimal.readJavaFormatString."
player:Say(tostring(vehicleangle)) ```
it gives me shit on the first line
nowa better quest.. and might save me a TON of grief. how can i get all objects in a parts area?
Ok, here's where I think the issue is happening.
It appears to be trying to create a table of items from my module and is just failing at it. Any ideas?
Off the top of your head, how difficult would it be for me to make an "it follows" mod with basic understanding of lua but the motivation to learn?
By "it follows" I mean spawn a single zombie that knows where you are at all times and has infinite health
Not sure, what you meant by F code thing, Im using visual code community edition.
Im about to make a forum post about it. Ill share the link when its up
Is there any documentation for creating a custom zombie entity or class?
@fading horizon so where it says IsInfected would i put IsStressed?
so it would be SetStress?
Check out here
That has the functions
Sorry, afk rn
lol thank you Maemento for the fast reply also Jab get some sushi its healthy โค๏ธ
Of course! Happy to help
I've eaten a fair bit last week.

so how do i change IsInfected?
to check for stress unless its in that code one sec ill look over it again i have ADHD im everywhere atm
getStress() is how you get stress
You got is infected right
You just set it to false
well infected is from the mod we are using as a reference point
we are using the timed action from They Knew to kind of get an idea
tbh im a visual learner and am struggling with this
2 things of sushi later (one cooked, one raw), I'm feeling a bit better.
Has something materially changed with the game in the past 48 hours? Any patches or anything like that?
I'm using PantryPacking as an example and copied it to a T, but my mod that was working perfectly two days ago is no longer functional and I can not troubleshoot it further. Now, not even pantry packing is working in debug mode. I've hit an absolute wall and can not progress my mod any further.
we haven't had a patch since 2022
Are you testing on the same save you been testing on? Maybe the save is the issue
Ive been generating a new save with each test.
And what's so frustrating is I have duplicated the mod, split a single item into each mod, changed all naming conventions and id's so there's no overlap, and it's still not working.
But one will work randomly lol
Here's the entire code if you want to take a look and tell me what obvious thing Im missing.
module BusketsBaking
{
imports Base
{
}
model LC_Salt
{
mesh = WorldItems/LargeSaltContainer,
texture = WorldItems/LargeSaltContainer,
scale = 0.1,
}
item LC_Salt
{
DisplayName = Large Salt Container,
DisplayCategory = Food,
Type = Food,
Weight = 0.75,
Icon = LargeSaltContainer,
CantBeFrozen = true,
Spice = true,
HungerChange = -10,
ThirstChange = 20,
UnhappyChange = 20,
WorldStaticModel = LC_Salt,
FoodType = NoExplicit,
Tags = MinorIngredient,
}
recipe Pack up Salt
{
Salt = 5,
Result = LC_Salt,
Time:20,
}
}
Have you already checked console.txt
Sure have. Found plenty of errors, none of which make sense. I'm starting to think that the mod I was using for reference wasnt done properly. It also does not work in debug mode.
Yup, confirmed. The PantryPacking mod is no longer functional. Gonna try it without my mod activated.
My mod was interfering with PantryPacking. Gonna swap some file names around and see if that does the trick.
I think I found it.
Result = LC_Salt, should be Result : LC_Salt = 1,
so we keep getting this error when we call to our function in our timed action, but in our timed action we have it labeled the same are we missing something?
the function might be local
what does that mean?
so right now this is the thing we are trying to get the timed action to call to
so when it is created it will make the player do an animation a sound and then change the players stats so the OnCreate: RedVapeUseVape is the function and in the timed action it does not play and throws that error
not sure if im making things difficult doing it this way but we choose this way as it seamed simpler
how do i create a new function
require "TimedActions/ISBaseTimedAction"
UseVape = ISBaseTimedAction:derive("UseVape");
function UseVape:isValid() -- Check if the action can be done
return true;
end
function UseVape:update() -- Trigger every game update when the action is perform
print("Action is update");
end
function UseVape:waitToStart() -- Wait until return false
return false;
end
function UseVape:start() -- Trigger when the action start
print("Action start");
end
function UseVape:stop() -- Trigger if the action is cancel
print("Action stop");
ISBaseTimedAction.stop(self);
end
function UseVape:perform() -- Trigger when the action is complete
print("Action perform");
ISBaseTimedAction.perform(self);
end
function UseVape:new(character) -- What to call in your code
local o = {};
setmetatable(o, self);
self.__index = self;
o.character = character;
o.maxTime = 30; -- Time take by the action
if o.character:isTimedActionInstant() then o.maxTime = 1; end
return o;
end
This is what we have so far (Note: changed it from RedVapeUseVape to = UseVape but when we try to call it from the recipe above it just says it cant find that function or says, function does not exist
uNF
dammit... so close
the remove is ALWAYS up left
which looks great if you are facing bottom right
stupid matrixes crap.
can i pay someone to sit in a VC and teach me how to make a timed action ๐
You did it! Good job!
@fading horizon how did you get the function to work? i keep getting no such function "UseVape"
well yes and no.
i need to get the exit point to be the middle of an area.
I want the following line of code to give me 5 salt items instead of one, but Im unsure of the syntax here. I can just copy paste it 5 times, but I'm wondering if there's a simpler way to do it.
player:getInventory():AddItem("Base.Salt");
Im going to do some useDelta checks to give only the full portions of a large combined item back.
you can use AddItems with an additional argument for how many
@unborn radish The first thing I would check is does the mod come with a server side lua file. It may not be designed for MP at all.
The top comment on April 11th, says it does not work in MP and the creator has yet to respond.
@sour island I finally saw that bolded S, and it works like a charm. Thanks so much. I JUST WROTE MY FIRST CUSTOM LUA FUNCTION WOOOOOO!
Yeah, I probably should have been more specific 
lol wanna help me out captin XD
I can try man, but Im as new as you. You wanna hop in a VC? I'll give ya 20 minutes to look this over then back to the grind for me.
Ok im in #1095920594110906498
You're talking about the original car mod or my edit to it?
the original car mod does work in MP, they just spawn with their original names instead of my edited ones
in singleplayer, however, my edits work
in MP you need to set the required mods order manually, make sure the mod is after the base mod
@frank elbow thanks you dude for everything, it was 3 night shift in order to do it, but I managed to learn how to develop mods on LUA using official API, and successfully created the respawn timer that I needed.
thanks you very much! let me know if any of wants to take a look at the code or something ;))
I am almost certain i set it right, that's why I was asking for someone else to please check on their end
this seems like #mod_support issue then
if you have something specific or explain what you do to change the names then this is the place. You'll still have to test yourself probably though.
Hey guys, just got a syntax question. There's this ---@ symbol in the following code. Just wondering if it's saving the variables type and passing it onto the next declared variable, or it if does something else entirely.
for k,savedUse in pairs(savedUses) do
---@type DrainableComboItem
local newItem = inventory:AddItem(itemToAdd)
newItem:setDelta(savedUse)
end
it's a comment that doesn't affect the execution of code
Hello, could someone help my failing google-fu and remind me, how to adjust WorldStaticModel scale without changing actual model?
I seem to recall there was a way to do it, inside of model itself.
But is there a way to adjust scale for specific items only, without changing the model properties?
Or is it impossible because the only thing actual item has, is a reference to a model, and the rest is just a model property?
scale = 0.1,
That's in the model, yep.
But I am curious if there's a way to adjust scale of a specific item only, it seems like the answer is no
No. Youd need to create another model, use the same mesh, and adjust the scale accordingly.
You could do a model that was large, medium, and small and then call which one you wanted.
@frosty stirrup I'd also suggest checking with the modeling group chat. They're a bit more helpful than the mod dudes, lol.
I guess your question could go either way though :\
The game has an item Football, and other throwables. Or you can just remove it from inv. and place it near wall.
PhysicsObject = Ball
Hello everybody ๐
I'm trying to increase the foodsicknesslevel of players in conditions on a server with my mod and i'm encountering difficulties : do you know a lua function or something that time or wait for few seconds or something ? Like a Wait(10) or something like that ? it could be really usefull because foodsicknesslevel increase really to quickly even if i use 0.001 unit
You can use the EveryOneMinute or EveryTenMinutes events, these are in-game times.
What did he do to you?
i'm just gonna copy the description since it explains it perfectly
Do you also have a never-ending hatred towards that disgusting rodent who plagued both our eyes and our minds as he presented his unparalleled evil to us in its rawest and most disgusting form?
Don't believe me? Go ask him where he was on November 22nd, 1963...
I've heard he even facetimes the orphans back at the orphanage just to rub salt in the wound.
Heโs got an annoyingly smug face and I donโt understand how he tried to get into a relationship with a bird (a completely different species) and also the fact that the Little family adopted him instead of orphaned children who obviously needed it a lot more than Stuart.
I have terabytes of accumulated hate speech against Stuart Little but I will spare you the details.
thank you a lot i'll try
Understandable, have a nice day.
player:getInventory(); how do I get something like this but for backpacks as well?
getItems() if im not wrong
Thank you!
do you know a vanilla lua file which use this function to see how it works please ? ๐
Which lua version are you using to modding PZ? i cant create a module cause it says its deprecated
PZ uses Kahlua, it's sort of Lua 5.1.
Automatically exported from code.google.com/p/kahlua - kahlua/manual.txt at master ยท krka/kahlua
i see , thank you
can anyone help me with exporting weapons? Are you supposed to export them under the X axis because when I do they appear correctly in your hands but when I try to make adjustments for back placement using the attachment editor they are placed all wrong. Exporting them above the x axis like I would asume you should fixes the attachment editor but then breaks the hand positioning.
I'm beating myself over the head with how you handle weapon models

My avoidance of scripts has come back to hurt me -- in recipes what's the difference between just using the ingredient as a line and including destroy?
example for destory would be a drainable like battery will be removed instead of used
ah
trying to use parseScript in realtime to create a recipe from a sandbox option
it's refusing to work with [getypefunction] for some reason
defaults to a black digital watch that isn't really a black digital watch
There's some functions in Recipemanager like OnLuaLoaded I think.
Otherwise you can autopopulate the source items.
Give ingredients gives me paper but it refuses to become valid - I wonder
ah I left the oncanperform function empty
that wasn't the issue
seems like the issue is using parseScript in real time
hello gentlemen
I have a problem with one of my mods. What the mod basically does is adding a search button to containers, then when type a string, it sorts the items in said containers according to best matching items. The problem with the mod is that if the container has a really big amount of items, it may cause extreme FPS drops, sometimes even freezing the game
I've tried different approaches with the logic, and at this point I am not sure if the problem is even fixable with that kind of mod, or if I am looking in the wrong place
-- Function to return similarity score between two strings using the Jaccard similarity coefficient algorithm
function searchContainers:stringSimilarity(a, b)
local n = #a
local m = #b
if n == 0 or m == 0 then
return 0
end
local min_len = math.min(n, m)
local max_len = math.max(n, m)
local intersection = 0
local j = 1
for i = 1, min_len do
local c = a:sub(i, i)
while j <= m do
if b:sub(j, j) == c then
intersection = intersection + 1
j = j + 1
break
end
j = j + 1
end
end
return intersection / max_len
end```
The function used to measure similarity between strings
function searchContainers:sortByStringMatch(items, searchString)
-- Create tables to store matching and non-matching items
local matchingItems = {}
local nonMatchingItems = {}
-- Loop through the items and add them to matching or non-matching table
for _, item in ipairs(items) do
local name = string.lower(item:getName()) -- convert name to lowercase for case-insensitive comparison
local match = string.find(name, string.lower(searchString)) -- check for partial match
if match then
table.insert(matchingItems, item)
else
table.insert(nonMatchingItems, item)
end
end
-- Sort the matchingItems table based on how closely the item's name matches the search string
table.sort(matchingItems, function(a, b)
-- Calculate the similarity score for each item's name compared to the search string
local scoreA = searchContainers:stringSimilarity(string.lower(searchString), string.lower(a:getName())) or 0
local scoreB = searchContainers:stringSimilarity(string.lower(searchString), string.lower(b:getName())) or 0
-- Sort the items in descending order based on their similarity score
if scoreA == scoreB then
-- If the similarity scores are the same, sort alphabetically
return a:getName() < b:getName()
else
return scoreA > scoreB
end
end)
-- Concatenate the two tables to create a new sorted table with all items
local sortedItems = {}
for _, item in ipairs(matchingItems) do
table.insert(sortedItems, item)
end
for _, item in ipairs(nonMatchingItems) do
table.insert(sortedItems, item)
end
-- Return the sorted table
return sortedItems
end```
Function used to actually sort the items
ISInventoryPane.itemSortBySearchContainer = function(a, b)
local sortedItems = ISInventoryPane.sortedItems
local sortedIndex = {}
-- Create a lookup table for the sorted items
for i, item in ipairs(sortedItems) do
sortedIndex[item:getName()] = i
end
-- Compare the positions of the items in the sorted table
local aIndex = sortedIndex[a.name]
local bIndex = sortedIndex[b.name]
if aIndex and bIndex then
return aIndex < bIndex
elseif aIndex then
return true
elseif bIndex then
return false
else
-- If both items are not in the sorted table, use the default sorting function
return ISInventoryPane.itemSortByNameInc(a, b)
end
end```
Rest of code ^
there are a few irrelevant lines in between to put the code together
Full code ^
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
You are running this for every frame or just when the search bar is changed?
the code runs when the player clicks "ok" in the modal that pops up after you press "search"
Supposedly, at least.
function ISInventoryPage:onSearchSuccessful(button)
-- Check if the OK button was clicked
if button.internal == "OK" then
-- Check if the textbox input is not empty
if button.parent.entry:getText() and button.parent.entry:getText() ~= "" then
searchString = button.parent.entry:getText()
self:onSearchContainer(searchString)
end
end
end```
then onSearchContainer calls searchContainer function
function ISInventoryPage:onSearchContainer(searchString)
self.inventoryPane:searchContainer(searchString)
end```
Sorry for the dumb question but is this python?
no its Lua
Never heard about it but thx i will check it
Plus no question is dumb, feel free to ask as you want โค๏ธ
Thx im trying to learn programming and also modding :)
PZ mods are generally created using Lua. It has few similarities to Python but also has some differences when it comes to syntax. Its generally easy to understand to work with
Best of luck though :)
Thx u rn im learning java so gonna take a while
Ty
Hello, how would I go about deleting a specific item in LUA script?
There doesn't seem to be item:delete() or item:remove()
Just to explain what I want to do. I want to improve weapon upgrade in Scrap Guns mod.
It currently says "REMOVE MAGAZINE" in recipe, and it basically destroys the original gun and then creates a new one.
I want to keep the condition, magazine etc.
I am trying to do something like this
- At first I "keep" the item in the recipe
- Then
function Recipe.OnCreate.UpgradeSAR(items, result, player)
local addTypeBase = "Base.LeatherStrips"
for i=0,items:size() - 1 do
local item = items:get(i)
if item:getType() == "SAR" then
--<the code to inherit properties of item goes here>
item:destroy(?)
end
end
--<the code to create SARB goes here, and then the code to inherit properties>
end
Can't figure out how to destroy the item porperly
And I've just realized that it's also unclear how to get the actual magazine object from inside of the gun, since HandWeapon doesn't have such field or method...
Ah, I think I found a solution, sorry for spamming
so i have managed to get the item ingame, but when i try to drop the item it throws errors, i can equip the item as i yoinked the motercycle helmet code
i just cant seem to get the 3d model in game
what am i doing wrong?
If someone finds my question and doesn't know how I solved it, here it is
function SAR_Upgrade(items, result, player)
for i=0,items:size()-1 do
local item = items:get(i)
if item:getType() == "SAR" then
result:setCondition(item:getCondition())
result:setCurrentAmmoCount(item:getCurrentAmmoCount())
if result:haveChamber() and item:haveChamber() and item:isRoundChambered() then
result:setRoundChambered(true)
end
if item:isContainsClip() or ( item:getCurrentAmmoCount() > 0 and item:getMagazineType() ) then
result:setContainsClip(true)
end
local modData = result:getModData()
for k,v in pairs(item:getModData()) do
modData[k] = v
end
result:attachWeaponPart(item:getScope())
result:attachWeaponPart(item:getClip())
result:attachWeaponPart(item:getSling())
result:attachWeaponPart(item:getCanon())
result:attachWeaponPart(item:getStock())
result:attachWeaponPart(item:getRecoilpad())
player:setPrimaryHandItem(result);
player:setSecondaryHandItem(result);
return
end
end
end```
I call this in OnCreate, so all source item properties including attachments etc are passed to target item
What errors do you get?
one sec let me pull the file
is there a simpler way to write a distributions.lua for a mod with a ton of items
This is why I'm writing a formatter.
PLEASE. FIX. YOUR. SPACING.
lol
Sometimes this modding thing can be painfully annoying. I have been stuck with this attachment editor issue for like 3 days doing everything to get my weapons to appear the way I want to no avail only to finally figure it out by.. literally doing what I've been doing that was failing. Idk if I was just missing something the past few times or PZ just wants me to rip my hair out but I am just happy to be done with it.
module Base
{
item alexshead
{
Type = Clothing,
DisplayCategory = Accessory,
DisplayName = Alex Helmet,
ClothingItem = Hat_alexhelm,
BodyLocation = FullHat,
Icon = alexhead,
CanHaveHoles = false,
BloodLocation = FullHelmet,
BiteDefense = 100,
ScratchDefense = 100,
BulletDefense = 100,
DisplayCategory = Armor,
ChanceToFall = 0,
Insulation = 0,
WaterResistance = 0.40,
Weight = 1.0,
Tooltip = "This is alexs head its unique",
WorldStaticModel = alexshead,
}
model alexshead
{
mesh = alexshead,
texture = alexhead,
scale = 1.0,
}
}
Trust me, keeping things orderly and formatted will help with your sanity.
I'm going to be drafting two format options for ZedScript.
At this point I'm going to assume that I'll be the only one to set standards with ZedScript.
TYSM
so to do this you press tab for each section of code inside of the brackets?
I use VSCode so my tabs convert to spaces. (I set it up this way)
i will look into that thanks
In computer programming, an indentation style is a convention governing the indentation of blocks of code to convey program structure. This article largely addresses the free-form languages, such as C and its descendants, but can be (and often is) applied to most other programming languages (especially those in the curly bracket family), where w...
This is also a good reference for industry-standard formats for c-style bracing.
I use this
C# uses Allman bracing.
any ideas on how i could write a simpler distribution file that would work with more items. Like would i be able to somehow set items just to spawn completely at random
without specific loot tables
haskell style is truly the best identation style
you want all loot tables to be the same?
pretty much

i want to be able to have all my items as one singular called item and able to implement it into the distributions
you can iterate over the distribution table and assign the same table to the leaves of the tree
I wanted to say HUGE THANKS to everyone that helped me learn. Two sleepless nights later, it's done.
Only patches, no overwrites! And only fixes ๐
https://steamcommunity.com/sharedfiles/filedetails/?id=2961796641
i had to learn the language at uni
I'm so sorry for your loss.
@drifting stump Oh hey, huge thanks to you personally too.
It feels so nice when your mod is finally functional 100% you want it to be ๐
I have that huge influx of endorphin now
@drifting stump still confused
Just wait until you have a project consuming nearly a year of your life finally working as intended.
The mental lift from that experience may pull you from reality for a bit.
the distribution table is a tree
you have tables containing other tables which are branches
tables at the edges meaning no child tables contain the actual information and are called leaves
you can iterate over it and any edge table you replace with your table
just iterate over it
how
xD
for key, value in pairs(hashTable)
--do your thing
end
for index, value in ipairs(arrayTable)
--do your thing
end
im still new this is my second day learning all this so im sorry if im not understanding fully
for key, value in pairs(ProceduralDistributions["list"])
table.insert(value.items, "Vape?")
table.insert(value.items, 0.05)
end
...so the hashtable is the things like the procedural list and the other lists of sorts?
a hashtable is a table in the style of table["key"] = value
arraytable is table = {"aa", "bb", "cc"}
one is accessed with keys and other with indexes
so would i use the array to list the items and the hashtable for the distributions locations
Couldn't you simply call it without array-like-syntax?
when you do table.insert it inserts at the final index
ProceduralDistributions.list.SecurityLockers.items
yes
Seems like excess to do it the way shown.
[""] is only needed when there are spaces in the key
Or illegal characters yeah.
im just looking for the easiest way to build a distribution of my items
Don't mind me.
I'm not helping anyone by saying this. xD
Programming is a hell of a learning curve for first-timers.
So be patient with yourself.
It'll take time.
ive been doing nothing but trying to learn this for i think 2 full days now and im working on 2 mods
was getting aggravated with my first one as i bit off more than i thought and this one i thought would be easier
Hi guys, i need some help. Any idea about how to reference a function from a new item into his action function?
This is looing for the OnInject_ExperimentalSyringe function, i have created it on client with the same name in a lua file, but i think im missing something to connect there two functions
as long as the function is global and named correctly it should connect
I think its because im trying to use it in a server environment
The server-side of PZ is in such a mess right now..
I see so much of this problem here.
yeah, it was just that. I just had to add that file in the server side, ahg! Thanks ๐
I'll explain what I did if that helps. I'm sorry, it's just pretty straightforward
So the original mod has got one file where all the names are. I copied it to my mod, changed it, then uploaded it
There is no other name file in the original mod as far as I can see
and I did check
I fought and lost the battle to avoid saying "or keywords" just so we've covered all our bases
Haha.
I'm too technical to be helpful to most people here.
Striking that balance can be difficult & I don't think I always get it either
I help people with solutions.
There have been a few times here where I've explained something and then someone else has had to explain it in better words
Or more accessible words, I suppose
Yeah.. It's a tradeoff to get how things work.
You lose some of your humanity in the process.
Working on clothing properties
Enum templates are powerful.
Means less time spent looking up definition tables in Lua code.
It might also be a good idea to look at possibly generating these Lua functions and storing them on the OS's clipboard.
I can see copying generated functions as a good way to aid in implementing Lua properties for scripts.
More useful that those generated functions could provide documentation of the parameters passed to it.
My workshop is down for some reason
There was an error loading user files: 16```
Anyone knows about this
There are problems with workshop now for everyone
Insurgent is gone?
Oh
Errors for everyone
maybe thats it
My notification area says the item was deleted though 
i create an working ban hammer mod by steam id for servers admin use when players go against ToS or their rules (heavy server tool to use at moderation heavy issues)
https://steamcommunity.com/sharedfiles/filedetails/?id=2961832256
anyone know how to check the distance between a car and the center of a vehicle area?
I never really know if promotion is frowned upon around here but after much suffering I've finally been able to push out a new update for my Degenerate Dakimakura mod. if you try it let me know if I broke anything. https://steamcommunity.com/sharedfiles/filedetails/?id=2756636139
At least you're not templating or generating text that's corporate-speak to advertise it here.
(This actually happened)
It's not frowned here as long as you don't spam it.
lol nah I'm not that desperate. and yea good to know
Good idea, will do this for my next mod release
geez I just noticed that 48,000 people use that mod. I am equal parts disgusted and proud
much like my parents I assume
only not proud
I saw that ~40 people are using my extension even though it's not complete.
funny thing is only a little over 1000 people use my mod that is actually not a shit post and meant to be helpful..
and so I will shill that as well ๐ https://steamcommunity.com/sharedfiles/filedetails/?id=2914213621 good for true music users
ok I am done now

At one point I believe that several hundreds of thousands of people used my first Java patch mod.
Was during 2015-2016.
very nice.
did zomboid even have hundreds of thousands of players in 2016?
That's a pretty good question. I was much more of an on and off player before B41.
I was more DayZ back then
PZ was always that game that had a solid foundation but not enough to keep me gripped
I keep trying to get my friends to play the game with me
But they all hate the inventory system
I can't entirely blame them. It took a while for it to grow on me as well.
Yes.
Hydrocraft had over a million subs at that point.
your next update for the inventory will be awesome since I've always like the tertis style inventories
Hydrocraft and ORGM used my patch to add custom 3D models into the game at that point.
Really wish the core of my grid code was in TS
I need to refactor how moddata is stored and its a huge pain with lua
You can always change that.
I was nevver a fan of hydrocraft. still not tbh. it's not bad or anything but it's just too much for me. it reminds me of those super advance tech minecraft mods. Plus the art inconsistencies on things were not pleasing to the eye.
I always think of that one reddit post
of all the pets with different pixel art
Honestly considering it.
I look forward to seeing it.
PipeWrench is what I'm looking for?
No problem.
Lua is great for fast development and smaller mods, but this one has deifnitely passed the sanity threshold
does anyone know if Nolan still updates his mods? I love the backpack attachment mod, but unfortunately the insurgent backpacks haven't been included in it
I would argue that lifting PZ's Lua code into Typescript would be a good move.
Lua is not made for this scale of code.
I'd argue that it's fine for larger mods; you just have to think more about structure
good luck. between your mod and the TLOU update for susceptible my SP save is gonna get a huge improvement.
LUA helps maroons like me mod
Of course I haven't seen the code you're referring to, so maybe it truly is better suited for TS. But I don't think languages are often to blame for things like that
You'd be surprised how much more Lua hurts you.
Iโve made a few personal mods for recipes
Iโm not a coder so I wouldnโt know much tbh
IntelliSense and safety guardrails.
My structure degraded when I added item stacking late, so it is my fault. TS would provide more assistance refactoring though because I could just follow the compiler errors around.
I get intellisense just fine through a somewhat annoying process of generating the type stubs
It forces you to follow rules and checks your code unlike Lua.
Once you do the process once, though, it's fine
I'm open about how helpful that is for my work. It makes me comfortable when in the PZ environment.
Dammit
???
Haha what was that.
No one saw that
Imagine this:
copy pasta i sent on a private server earlier
Lmao
Damn bro take a lap.
Courtesy of NalMac actually
the only major issue i have with lua is performance (pz especially), but ts won't fix that
Yeah. PipeWrench isn't targeting this problem and can't fix it.
there's a few things that bug me (i think a global keyword would make more sense than a local keyword) but nothing that makes me not want to use it
Only rewriting the Lua code to TS might have a performance effect however the Java Engine PZ has is the biggest component of performance issues.
I've only run into performance issues once with Lua. Building air quality modeling in Louisville for the upcoming Susceptible update.
wait what? i missed it
Society would be so much better if Lua variables were local by default
We would have flying cars by now I think (I agree that'd be preferable, to be clear)
I copy pasta'd ur steam description on another server, and accidentally pasted it here while correcting a typo I made.
Life would be even better if modules were used in the PZ vanilla code.
that is truly gold
yeah, ts generated lua might run a bit better than human written lua, but the main problem is lua itself
I am sad to have missed that
True
TS can compile to "other things" too. xD
Agreed.
especially with pz singlethreading it 
Having something guide you to optimize your work and compile to optimized Lua is a good idea.
PipeWrench also sells itself on IntelliSense combined with additional API / libraries to forward information on what you are using with things like Events.
Events.onObjectAdded.addListener((object: IsoObject) => {
if (object != null) {
print(`IsoObject added: ${isoObjectToString(object)}`);
}
});
You can waste a lot of time simply looking up what you're using.
Know
I'm solving the exact same issues with ZedScript as I did with PipeWrench.
I was thinking bodydamage but I'm not home to check
Sorry i had the wrong name, meant to ask if Noir still updates his mods?
infected wounds do basically nothing so there isn't likely to be anything interesting to find there
local function UpdateObject(isoObject, dir)
local square = isoObject:getSquare()
local lightSource = getWorld():getCell():getLightSourceAt(square:getX(), square:getY(), square:getZ())
if lightSource ~= nil then
local x = lightSource:getX()
local y = lightSource:getY()
local radius = lightSource:getRadius()
noise('Updating lightSource with radius '..radius..' at '..square:getX()..','..square:getY()..','..square:getZ())
if dir == "E" then
lightSource:setX(x+5)
elseif dir == "W" then
lightSource:setX(x-5)
elseif dir == "S" then
lightSource:setY(y+5)
elseif dir == "N" then
lightSource:setY(y-5)
end
lightSource:setRadius(13)
isoObject:transmitCompleteItemToClients()
isoObject:sendObjectChange('lightSource')
isoObject:transmitModData()
end
end
I'm calling this function using MapObjects.OnNewWithSprite, MapObjects.OnLoadWithSprite, and Events.OnObjectAdded.Add. It runs on the server and like the other files in the lua/server/Map folder I based my script on, it has a if isClient() then return end check. Why does it work fine in single player, but not do anything at all in multiplayer? (It's not due to the isClient check, the lightsource change doesn't function even with that commented out.)
is your noise showing up?
No message in the client console, I'm looking in the server console and it shows up there as expected without any error:
LOG : General , 1681414569606> 272,279,912> MOFloodLights.lua: Updating lightSource with radius 8 at 11556,7688,0
LOG : General , 1681414570118> 272,280,424> MOFloodLights.lua: Updating lightSource with radius 8 at 11540,7709,0
LOG : General , 1681414570120> 272,280,426> MOFloodLights.lua: Updating lightSource with radius 8 at 11540,7715,0
But I wonder if this later message is related?
LOG : General , 1681414644286> 272,354,592> SyncIsoObject: index=2 is invalid x,y,z=11540,7709,0
LOG : General , 1681414644769> 272,355,076> SyncIsoObject: index=2 is invalid x,y,z=11540,7709,0
LOG : General , 1681414646452> 272,356,758> SyncIsoObject: index=2 is invalid x,y,z=11540,7709,0
LOG : General , 1681414646960> 272,357,266> SyncIsoObject: index=2 is invalid x,y,z=11540,7709,0
LOG : General , 1681414652713> 272,363,019> SyncIsoObject: index=2 is invalid x,y,z=11540,7709,0
LOG : General , 1681414657304> 272,367,611> SyncIsoObject: index=2 is invalid x,y,z=11540,7715,0
is this from the server console?
the later messages, i mean
this error means that the server doesn't have the isoObject in the square's object list - now that i'm thinking about it i think the MapObjects functions run before they actually get added to the square
it uses the co-ordinates and square object list index to identify the same object on each end, so these changes can't really be networked until after they get added
Combining & categorizing my item property documentation in my VSCode extension. I expect the final list to be closer to 10000 lines.
Both those are from the server console. Sort of unsure what you mean, what would I need to do in order for it to work in multiplayer then?
basically it's working up until the part where it tries to send the changes to the clients
that's odd - now that i'm looking more into it, that error should only be printed when the server *receives* the update, but it's the one sending it
oh, is the isClient check still removed? that would explain that
Yeah, it didn't work when I checked earlier so I tried with that check removed to see if that made a difference
that sort of makes things even weirder though, because if the code is running on the client, then you should see the changes anyway even if the networking doesn't work...?
The latter messages might have been when I tried picking up and placing the type of lights the script runs on. Yeah I really don't get it, the lighting changes made by that function work with no issue in single player, but nothing happens at all in multiplayer to the lighting. Only thing that was affected was after removing the isClient check, the isoObject itself was duplicated (I assume due to the client running the client transmission, so to be expected), but no change to the lightsource.
There lies in my problem lol
I wanted to see if I could mess around
For scripts, is MaxAmmo used in anything other than Weapon types?
It's used by Normal types for magazines.
Looks like it was accidentally placed in the Normal type.
Ah.
Thanks.
Current Item properties I have translated / imported from PZWiki: https://github.com/asledgehammer/ZedScript-VSCode/blob/main/src/scope/item/ItemProperties.ts
Hey. Did you find why?
@bronze yoke That message still occurs even with the isClient check ๐ค
LOG : General , 1681418488529> 276,198,836> SyncIsoObject: index=2 is invalid x,y,z=11540,7711,0
It also duplicates flood light tiles even still, which is different from the light source change not being applied, but I assume I am using the transmit functions incorrectly?
isoObject:transmitCompleteItemToClients()
isoObject:sendObjectChange('lightSource')
isoObject:transmitModData()
Not sure whether or not any of these are right for what I'm doing to be honest.
isoObject:sendObjectChange('lightSource') doesn't do anything, lightSource isn't a valid change
isoObject:transmitModData() probably isn't relevant either
wait, is the lightsource even attached to the object?
if it's not then isoObject:transmitCompleteItemToClients() wouldn't be relevant either ๐
I assumed it is? The script modifies flood lights by finding their sprite, I just wasn't sure another way to get the light source than how I did there.
i didn't see any networking methods in IsoLightSource so if it's not attached to the object you might have to network it manually, at which point it'd probably just make more sense to have it run clientside instead
How would you network it manually? I'm new to lua and sorta just going off of looking at how other things work, which is making this difficult since there's only one example of anything similar to what I'm doing here (MOLampOnPillar.lua which is creating an object rather than editing an existing one).
this is more server issue but why isnt this 'updating' ?
is it possible to have a timed action reduce stress and unhappyness? if so what would be the command lines for it as iv been told you cant just use setStress or setUnhappyness
ISReadABook probably does exactly that
what do you mean by this could you explain further?
#mod_support is probably what you're looking for
this file is probably in client/TimedActions/
ill look into it thank you poltergeist!
going to bed
Oh.
do you have a guide to make java mods ๐
How does that work, can java mods be compatible if they try to change similar parts.
@fast galleon you are amazing i love you
these are cached stats it saves when you start reading I think
but i should be able to use those to change the players stress level right? im still learning how lua is writen
like i see setStress and a setUnhappyness but so what i wanna do is have a timed action that sets the stress and unhappyness to 0
This is not about Lua, this is finding the PZ java commands though. In this case you need to pass numbers to these functions.
Having a set number to use makes it one command simpler.
do you know what it might look like? when written out to just set stress to 0 for the player, as i cant find examples or guides anywhere for this stuff
function self.giveStats(player)
self.playerLock[player] = true
HaloTextHelper.addText(player,"Mood",HaloTextHelper.COLOR_GREEN)
local bodyDamage = player:getBodyDamage()
local stats = player:getStats()
bodyDamage:setBoredomLevel(bodyDamage:getBoredomLevel() - self.boredomMod)
bodyDamage:setUnhappynessLevel(bodyDamage:getUnhappynessLevel() - self.happinessMod)
stats:setStress(stats:getStress() - self.stressMod)
end
I should make one tbh.
not sure what the second line means >.< but i some what understand the rest thank you for your help!
It sets a value in table as true
Changed my script to clientside, but the change to light source position and radius still doesn't do anything in multiplayer unfortunately, and now there is no console message, so presumably it can't find the light source in multiplayer this way at all. It is beyond me why, so I might have to give up on getting it working unless someone here knows.
You need on client commabd
Then on server command back to all ither clients maybe
not sure if your still awake but what does self.stressMod mean? or self.happinessMod mean i dont know where that comes from
what is the easiest way to call to a function so i can test it in game to make sure the function i made works
also does anyone know if onCreate: work on calling a function cuz if it does then my function is not working
OnCreate works, what are you trying to do in that function?
we are trying to make a time action that comes from that,
so like this
when you "make" the vape on its create it would then call to the timed action that would then reduce the unhappiness and stress levels
atm every time iv tried i cant get the function to work iv even tried just trying to clear the Unhappiness on a timed action and it wont go threw in game so im not sure what im doing wrong
You're probably calling the timed action the wrong way but calling a timed action from a recipe is bizarre. You should call it from a right click option directly
lol yea but idk how to make a context menu XD
so we are using the crafting system to make a menu lol >.<
this is my timed action that comes from that recipe, idk if i have it typed up wrong but if i try naming it soemthing else and i go to craft it just tells me there is no such function UseVape so idk what i have wrong or where to go from here
@ socialtroglodyte (i dont like pinging people lol), any updates on the calm before the storm issues ?
i need guidance lol
bodyDamage isn't defined
use player:getBodyDamage()
also nothing is calling the giveStats function
I like to ask this is it possible for the lying and sitting mod to sit in many directions?
I just want to know if it's possible to code it
do you mean if it's possible to sit facing north/west? as the mod doesn't let you do that
the mod doesn't let you do that because there's no way to layer the chair/whatever over the player correctly, because it's 2d
that's expected to change with b42's weird pseudo-3d stuff
But is it possible to code?
You're passing the wrong parameters to the function. At the point youcall for player that variable doesnt exist
it's possible to code, it just won't look good
Oh I get what you mean
Well I hope the next update will improve a lot to come
Thanks Albion
iv used player as the function UseVape(player) and it still breaks
so would it be player:getBodyDamage(bodyDamage:setUnhappinessLevel()) = 0,?
also does that onCreate need to be onCreate or OnCreate?
lol i have no clue how to right this timed action or the thing that calls for the function >.<
It's case-insensitive.
I prefer you use PascalCase.
OnCreate
That is not a timed action and you dont need to create the function inside your oncreate function. Check what the correct parameters should be instead of _item. If I remember correctly they are Player, Items and Result but I dont remember the order
have someone helping me now thank you Soul ๐ โค๏ธ
how did you use the pascalCase?
It's a case not a function or method.
camelCase PascalCase snake_case
Hey guys, if I make a set of custom functions to execute on an items use, how do I go about calling them?
Recipes for creating and destroying an item are one thing, but if I want to use a drainable, say a pill, how do I actually call the functions I've made so that they... ya know.. do stuff.
im not sure i understand im sorry ๐ฆ
im still very new to all of this so my apologizes if i dont understand some of the words you use
iv tried looking up guides and teachings for lua and cant find videos on it, i am a visual learn and it is hard for me to learn just from text forms >.<
does anyone know if there's a mod that allows you to change zombie class stats. For ex- change it so that only sprinters specifically have low strength and only shamblers have high strength
im assuming this is an extention on VSC but im not sure how to use it as i found it but it gives no detail on how its really used
It's a WIP. Use Ctrl + Shift + P and select language as ZedScript.
thats what comes up when i do Ctrl Shift P
this is the one you where speaking of right?
anyone happen to know how to detach a trailer via lua?
had to install zedScript i didnt even know it was a thing omg
pascalcase is just a way of capitalising things, it's not an extension
itsJustA way_to_format_and_style YourFunctions andVariables
Hey guys, we're trying to make a custom lua script that reduces a players stress on the use of a drainable. Any recommendations on which call to use for this? We've attempted the OnCreate: DoFunction in the recipe with some limited success, but I'm beating my head against the wall on getting the function to work. I can use print() just fine, but when I add any other code to it, the games tells me it can't even find it for some stupid reason.
How do you handle reducing a players stats? Are you attaching code to the item itself, to the recipe, or what?
if the game can't find it after you add code, your code is causing errors, read the log
the only error we end up getting is this
ERROR: General , 1681448897563> LuaManager.getFunctionObject> no such function "UseVape"
there are no other errors when using it, if we remove the code and just leave the print ("hello") it works fine and runs the print but as soon as we add code it just stops looking for the function as shown in the photo below
what we are trying to make is a OnCreate: UseVape,
then calls to that function to try and get it to change the players stress level with lines like
function UseVape(items, result, player)
local o = player
print ("Good shit, that Super Food!");
o:getStats():setStress() = o:getStats():getStress() - 10;
return o;
end
if that makes sense?
If anyone makes a horror mod for PZ feel free to use this track: https://soundcloud.com/jabdoesthings/phantom-in-the-handheld
Listen to [Project Silence] Phantom In The Handheld by JabDoesThings #np on #SoundCloud
I really hate seeing it gather dust.
Was supposed to be haunting sounds you'd hear rarely from handheld walkie talkies and TVs with static.
local stats = character:getStats()
stats:setStress(((stats:getStress()) - (CONFIGUREME)))
put that somewhere in the lua function
it uses decimals
so to reduce stress by 5, you would change CONFIGUREME to 0.05
You are awesome, as always, thank you.

It looks like I set up a similar line of code but wasnt passing the arguments in properly. Seeing it here Im facepalming a little.
i used a simple version in what i showed you
but this is preferable
stats:setStress(math.max(((stats:getStress()) - (CONFIGUREME)),0))
that makes it so it doesnt go below 0
Now THAT's the coding I'm looking for!
max.max returns whichever is a higher number, your new stress value or 0
Ima go stomp some nerds in ARAM, then I'll try applying it.
why do you hate rats XD i saw your other mod XD poor stwert
the poor rats man
how did you go about scaling the bat down btw XD want to add a model for my vape when i have the coding done
just the scale setting in blender when you export
it updates on the fly
so you can keep the game open
and keep exporting with different scaling options to overwrite the file
and itll update
0.o thats cool
if not (luautils.stringStarts(obj:getTextureName(), "blends_street_01_0") or luautils.stringStarts(obj:getTextureName(), "blends_street_01_16") or luautils.stringStarts(obj:getTextureName(), "blends_street_01_21")) then
LastRoad = obj:getTextureName()
end
if (luautils.stringStarts(obj:getTextureName(), "blends_street_01_0") or luautils.stringStarts(obj:getTextureName(), "blends_street_01_16") or luautils.stringStarts(obj:getTextureName(), "blends_street_01_21")) then
obj:setSpriteFromName(toString(LastRoad))
end
why is it still setting it to 0 16 and 21 even though its not supposed to.
now if i do a SET name... it changes them.
but trying to use the name of the road near it.
it give me hell.
@fading horizon I watched that devilish little stress moodle wiggle. IT WORKED! ๐
this is related to the vape mod right
stats:setStressFromCigarettes(CONFIGUREME);
character:setTimeSinceLastSmoke(CONFIGUREME);
you'll need these too
And how do those work?
or else the character will probably start gaining stress when the item is used
basically if the character has the smoker trait, they get stressed if theyve gone without a cigarette for a long time
Oh I see.
so basically you want to reset the stress from cigarettes when the vape is hit
and then reset the time since the last smoke
if you want it to complete remove the stress, yes
Perfect
i have mine set to only reduce a little bit because 1 hit of a vape is not equal to a full cig
Watch AuthenticPeach with me on Twitch! https://www.twitch.tv/authenticpeach?sr=a
@fading horizon I am appalled at the lack of comments in mods. I shall be the change I want to see.
It's so vibrant!
I figured dark colors were more your thing. I need skull icons in my comments, then I can rest.
be careful of over commenting ๐
this supports regions, as well? Or should it be used on top of that?
no idea, sorry
kk, ty
never even heard of regions
very useful for those who write a lot of stuff
https://marketplace.visualstudio.com/items?itemName=vaibhavacharya.code-gpt-va
Think I've just seen heaven
https://marketplace.visualstudio.com/items?itemName=DanielSanMedium.dscodegpt
Could try this, too
yeah sorry, if I read more carefully I would just tell you to use the function with 0.
local bodyDamage = player:getBodyDamage() --0 to 100
bodyDamage:setBoredomLevel(0)
bodyDamage:setUnhappynessLevel(0)
local stats = player:getStats() --0 to 1
stats:setStress(0)
can anyone help or guide me to a resource or adding a 3D model to an item that I can place in the game world? I tried figuring it out on my own, I added the model fbx file and updated the item to include WorldStaticModel, but when I go to place the item in game, there is no model while placing, after I place it it just displays the sprite for the item instead of the model. thanks for any help!
@golden basin Hey bud, you here?
Tag me when you see this. I can give you a hand. Im about to work on my own models.
Hey man I appreciate it, I am here!
Awesome, lets jump in a DC room over on the left and get to fixing.
So far I'm working on getting the counter to save after quitting
No type annotations ๐ข
is there anyone knew about respawn cooldown of a player?
still need assistance with this.
is that not what i did?
I'm on phone, hard to see
sorry
is there a default value for LastRoad btw?
you should print the texture names and try that command from console too
if i put a default, that's all it sets it to.
is there a way to make this work. Im trying to make a table of all the items that i want to spawn in the distribution file and from that i am trying to get them to call back to a single word that i would put in place
I thint it would be better if you said that .items = Drugs
Since it may try to insert the table as an element there
ok i hover over it now and its calling the table let me test cause this is going to save so much work building the dist. table
Instead of if elseif
You can just add the rand as suffix
Do you still do table insert in the first?
yea thats all still the same
i just try doing the = drugs instead of .drugs and the code has a problem with it
so im wondering if i have to create the distr in a diferent way for it to work
You doin the table.insert(.items = Drugs)?
Do not make an existing spawn table = your table. You will delete everything that is already in there
Looks like what you're trying to achieve is a for loop that inserts each item in the table
how would i go about doing that
For i = 1, #drugs do
table.insert(spawntable.items, i)
table.insert(spawntable.items, spawnchance)
end
You must insert a numeric spawn chance right after inserting an item or you will break the spawn system
im confused
I'm not sure that you understand the fundamentals of programming applied in Lua.
It'll be very hard for you and hard for us to help you if you don't understand what you're working with / trying to code.
im sorry for trying to learn
I don't like how that's worded. I'm saying this to help you.
I recommend giving all of PIL a read. LearnXInYMinutes is a good reference, but PIL has more detail
well i feel like your trying to attack me for not fully understanding the language and trying to learn. i have limited knowledge rn and im trying to learn thats what counts i have troubles whith a lot of methods of learning. I cannot learn from a book
I don't think Jab was trying to attack youโwhat he said about it seeming as if you lack fundamental knowledge was accurate. It's okay to be learning
Ignorance is not something to be ashamed of (assuming you don't stay that way), it's an opportunity to learn more ๐ค
Well since you think I'm attacking you, other people in here can help. I'm giving you the straightest answer on what you'll need to do in order to get the best results. All good. Good luck on your project.
Jab, fissit.
@red tiger im sorry im frustrated. ive been trying to figure this out for 2 days now. I cant learn from a book i have to learn hands on by doing it. I understand that its going to be hard for me to understand what is going on.
local texName = obj:getTextureName();
if not (string.find(texName, "blends_street_01_0") == 0
or string.find(texName, "blends_street_01_16") == 0
or string.find(texName, "blends_street_01_21") == 0) then
LastRoad = texName;
end
if string.find(texName, "blends_street_01_0") == 0
or string.find(texName, "blends_street_01_16") == 0
or string.find(texName, "blends_street_01_21") == 0 then
obj:setSpriteFromName(texName);
end
There's some textual cleanup.
shouldn't all the tops ones be not?
Never thought abt that startswith shortcut (I tend to use sub). Obvious in retrospect
I think not 0 is meant to be ~= 0 though
Since they're mutually exclusive, I think you should just use else rather than checking everything again
This is your logic.
There's parentheses around those first conditions
anyone know would it be possible for fireplaces and stoves to be able to heat custom built rooms?
Unsure whether there are setters, but ClimateManager has functionality related to ambient air temperature so I'd look there
ty
That "categories" bit seems handy for avoiding confusion with some similarly named properties
It added a week or so to my workload for implementing item properties however yeah there's a lot of dead properties in the vanilla scripts.
A lot of misplaced and deprecated properties too.
Unfortunate considering vanilla scripts are the first place most people, including myself, would look for a reference ๐ although by now I know to check the source too
it's still reading 16 and 21 though
I'm adding notes on deprecated properties too so during my diagnostics feature's development I can display a warning showing deprecation.
All I did was tidy your script, not the logic.
lol
Have you debugged to determine the name of the texture to see that it's what you want?
yeah
Like chat gpt
but he problem is it's like it's reading the name but not giving any fucks about it.
It's not good to bring AI into this channel IMO. 

I also don't like being related to a bot.
I think people areโfor the most partโcapable of regulating conversations related to that so that they don't get to the point that's a cause for concern
Meant to bring that up when it came up before but became productive (that is, productive enough to put down discord)
what i want is for lastroad to be the name of the green tile. (blends_street_01_101 in this case.) and to NOT EVER be 16, 21, or 0. red is 16 and blue is 21
My bad boss
@red tiger won't happen again
The logic you posted doesn't involve coordinates.
Sure, however you're asking about position, correct?
no.
I don't know the specifics of tile names or their relation to your issue so I can't help further.
for i = 1, #drugs do
see all the smooth tiles? I want THEIR names. see those shitty dirt ones, LastRoad should never be that.
@nimble spoke yea i got that down im testing to see if it works
Maybe the collections you iterate aren't giving you everything.
so i can set the dirt tiles to the road near them
Any idea why getSquare returns a nil object when im using the same function for a vehicle spawning and it works? I might be missing something
Im getting this error:
"attempted index: getCell of non-table: null"
All chunks are not loaded at once.
You're calling to an unloaded or absent square.
Ohhh, so i need to a player to get in it to be able to spawn the item
The state will be saved after unload it? it wont be overriden if someone gets in and load it again?
Hey that's pretty neat. I didn't think of that. Thank you!
now it works! Thank you very much!
If it doesnt work
Try to use tostring()
Lua is not a real programming language.
This is the fix:
local texName = obj:getTextureName();
if not (string.find(texName, "blends_street_01_0") == 1
or string.find(texName, "blends_street_01_16") == 1
or string.find(texName, "blends_street_01_21") == 1
or texName == nil) then
LastRoad = texName;
else
print("foobar")
end
if (string.find(texName, "blends_street_01_0") == 1
or string.find(texName, "blends_street_01_16") == 1
or string.find(texName, "blends_street_01_21") == 1
or texName == nil) then
obj:setSpriteFromName(LastRoad);
end
I rest my case.
I don't think it does
it removed the default vanilla code folding function for me
but i do have custom comments with the '#' tag so that may be interfering
but I thought I would let you know regardless
Awesome, Thank you. I appreciate you and all the help you've given me so much!
Out of curiosity, how did you fix it?
I changed it to only spawn the object when a player gets in the square, so it doesnt return nil anymore
Is that the alternative to loadgrid thing?
yeah
I'm the same way, you should try to look around for examples then. I think you'll go crazy trying to figure out syntax (how programming is phrased) without examples. Google is also your friend here, even though this is PZ searching for 'how to do a for loop in Lua' would show examples.
I also like to test stuff here: https://www.lua.org/demo.html
Beats booting up the game to see if your lua isn't working.
ill have to check that out thanks
@dusty wigeon I also DM'd ValZaren with some info that will help y'all when they wake up
regarding animations and sound
ok awesome thanks. im working on my own mod while trying to work on that lol
tfw i'm stuck, all my mods are updated and complete & i can't think of any new features, yet all I want to do is code
i have an idea for a mod I just have legitimately no idea how to implement it

Take a break and come back again
Play the game
I haven't played the game in almost a month, i've just been making mods lol
Lurking on Twitch and Reddit to get more ideas
Try a year and three months.
The last time I played was to test my anti-cheat patch.
Many of my mods are feedback from Twitch
@dusty wigeon
Also if you're trying to add spawn chances that are different between the drugs creating a key paired table would help here.
---it is generally better to make variables local rather than global
--You can have things put into a module and returned for access later once you have a better understanding - it does not seem to be needed here so I left out that technqiue.
local Drugs = {
---keys using strings need to be encased in [], due to the string including `.` you can't forgo the [""]
["KIDrugMod.Shrooms"] = 0.1,
}
---Pairs() takes a Lua table and returns two sets of variables derrived from their keys and values
--You can rename `key, value` to `drug, chance` for clarity.
--Using `for var1, var2, etc in pairs() do` you can iterate through the returned set of variables.
for key, value in pairs(Drugs) do
table.insert(SuburbanDistributions["all"]["side--table"].items, key)
table.insert(SuburbanDistributions["all"]["side--table"].items, value)
end
It was funny reading "local drugs"
local itemNames = {
"GnomeBars.GnomeBarRB",
"GnomeBars.GnomeBarBlueRazz",
"GnomeBars.GnomeBarWatermelonIce",
"GnomeBars.GnomeBarPinkLemonade",
"GnomeBars.GnomeBarBlackIce",
"GnomeBars.GnomeBarCoolMint",
"GnomeBars.GnomeBarBananaIce",
"GnomeBars.GnomeBarLemonMint",
"GnomeBars.GnomeBarStrawNana",
"GnomeBars.GnomeBarCherryIce",
"GnomeBars.GnomeBarAppleIce",
"GnomeBars.GnomeBarGlitch",
}
-- # Add GnomeBars to zombie inventories
for _, item in ipairs(itemNames) do
table.insert(SuburbsDistributions["all"]["inventorymale"].items, item);
table.insert(SuburbsDistributions["all"]["inventorymale"].items, zombieChance);
table.insert(SuburbsDistributions["all"]["inventoryfemale"].items, item);
table.insert(SuburbsDistributions["all"]["inventoryfemale"].items, zombieChance);
-- // print("Loading GnomeBar ("..item..") to INVENTORIES ....... SUCCESS!");
end
-- # Add GnomeBars to generic locations
local GBLocaleGeneric = {"DeskGeneric", "BathroomCounter", "JanitorMisc", "BedroomSideTable", "OfficeDesk", "OfficeDeskHome", "PlankStashMoney", "PoliceDesk", "PrisonCellRandom", "CrateElectronics", "BedroomDresser", "WardrobeChild", "BreakRoomCounter", "BreakRoomShelves", }
for i in pairs(GBLocaleGeneric) do
if ProceduralDistributions.list[GBLocaleGeneric[i]] == nil then
print("FAILURE -- could not find " .. GBLocaleGeneric[i] .. "!");
else
if ProceduralDistributions.list[GBLocaleGeneric[i]].items == nil then
print("FAILURE -- could not find " .. GBLocaleGeneric[i] .. "!");
else
for _, item in ipairs(itemNames) do
table.insert(ProceduralDistributions.list[GBLocaleGeneric[i]].items, item);
table.insert(ProceduralDistributions.list[GBLocaleGeneric[i]].items, regularChance);
end
-- // print("Loading GnomeBar Generic items to " .. GBLocaleGeneric[i] .. " ....... SUCCESS!");
end
end
end```
@dusty wigeon here's an example of how I did some of my distributions
local zombieChance = 0.3
local regularChance = 0.2;
local schoolChance = 0.005;
local emptyChance = 0.075;
this is supposed to be at the top but I hit the character limit
a guy on youtube said I shouldn't comment my code so I don't 
Thanks guy from YouTube
nah his point was to make good names for functions and variables in the first place. i've not programmed much but when the code has been otherwise easy to read what i've missed is some larger overview of what the code does. some kind of flowchart or sth, dunno what is best to use
also probably there are automated tools to create those but i dunno how to use em :-D





