#mod_development
1 messages · Page 45 of 1
Moddata might be the best and easiest option
The UseDelta variable in drainable items such as batteries. Are they transferred over?
Like could I in theory create a "Infinite Battery" item with UseDelta = 0?
I'm assuming the second I put it into a Flashlight or w/e the UseDelta will be overwritten by the Flashlight's.
Eg:
local player = getPlayer()
local modData = player:getModData()
making infinite flashlight is easier
Hmm.. Looking into some adjustments to the Electrician skills and such and wanted to create stronger batteries.
So I assume the go-to would be to include my "stronger" batteries in a recipe to create a "stronger" flashlight that has a lower UseDelta than the original flashlight
what abt
if getUseDelta==0; then setUseDelta(10) end
Oh my infinite flashlight was just an example, I basically just want to create flashlights that drain 25%/50%/75% slower
ah i already did a infinite flashlight once
wait let me find it
item GlytchLightSmall
{
DisplayCategory = LightSource,
LightDistance = 25,
Weight = 0.7,
DisappearOnUse = FALSE,
Type = Drainable,
TorchCone = TRUE,
UseDelta = 0.0000000001,
LightStrength = 22,
TorchDot = 0.76,
DisplayName = Glytch Light 2,
ActivatedItem = TRUE,
Tooltip = SOS Admin Almost Unlimited Flashlight,
Icon = TorchSOS,
MetalValue = 10,
cantBeConsolided = TRUE,
primaryAnimMask = HoldingTorchRight,
secondaryAnimMask = HoldingTorchLeft,
WorldStaticModel = Lollipop,
AttachmentType = Knife,
}
UseDelta = 0.0000000001,
Lmao nice, WordStaticModel = Lollipop lol
haha
Would your UseDelta technically be infinite? Wouldn't it just take a long ass time to drain?
well as an admin i nver die and i had it on and never once saw it reduced
just add more zero if youre skeptic hehe but i asure you this will never die
Oh yeah 100% I wasn't trying to be technically I just wanted to make sure that it was draining hahah, I'm sure it will take like a year IRL for it to drain anyways
Is there a way for me to make a mod pack of my own for all the mods I like using?
lol idk about that but yeah thats possible i guess or if you do the math atleast to compute how long will it really take before it depleate
I want to do it to save time for making a server for friends
so long as its unlisted idont see why not
i would be sure to read the modpack section of the modding policy https://projectzomboid.com/blog/modding-policy/
will try now, i've tested over 200 dif ways in the past 7 days, been trying to learn lua 8 hours a day for no reason at all... i could use all the help i can get, my goal is to create a mod called "HyperRealism" which will overhaul & planned to be 10,000 of code +
But as im noob this may take months to years
do i leave the () empty or add a function or value in that
do urself a favor and don't plan a number of lines of code
lmao
that's a silly concept
things take however much they take
you don't get points for making it longer
nor shorter, tbh
not sure what your mod will contain but i applaud you for trying to dive in and do it
often the best way to learn 
Been doing research on the relationship between torque/hp/accel/etc for vehicle modding and if I've done my math right my IRL car should be able to get to 370km/h 🤔
Id rather YOU elaborate at what youre getting at
well one that you should always read the relevant policy before you do something in general, but particularly that glytcher told you 'as long as its unlisted i don't see why not' which may imply there are no restrictions on unlisted modpacks when there are
not large ones, but it's best to be aware of these things
Hello gentlemen
is there a way to reduce modded zombie spawn?
like for example under modname\media\lua\shared\NPCs
table.insert(ZombiesZoneDefinition.Army, {name = "Brita_Gorka", chance = 10})
I would like to reduce this chance to very rare like 0.01
is there a way to do that through lua with another mod?
currently brita's zed is spawning too much in the game after the latest update
if I create a new mod and load it after brita's, placing the lua at same path "modname\media\lua\shared\NPCs" with the same lua name, and same table.insert, will that work?
Ye i asked some of the modders with lockdown before and they replied if its unlisted its ok.
But your reply is definitely the best answer
No you probably doubled it. Since the line is still there on the table.
I see. If so, how do I edit the spawn rate through lua?
in lua u use table.remove()
alright, will research about it
Actually wait sorry. If you made the same filename on the same dir
I think that overwrites it. But i have only tried this with vanilla
Not sure if you can overwrite mods aswell
hmm
if I use this table remove, it will remove all brita's zed right? However, if I insert table insert with new rare spawn rate, it will get removed too right?
no i dont think so 🙂 since its a new table entry
you can overwrite mods - only the file belonging to the mod with the latest mod id is loaded (or maybe it's the earliest - unsure exactly)
ya, its Shared, then Client, then Server in stages, with each stage doing vanilla, then modded in alphabetical order, with duplicates going by mod load order. Not entirely certain how subfolders factor in
messing with already added distribution entries through lua is really annoying, so overriding the file is usually the preferred method of doing this
I see that table insert only requires a single line in the lua, I'm not sure if it will work if I do something like this.
In Shared (since brita is using Shared for zomb distribution):
table.remove(ZombiesZoneDefinition.Police, {name = "Brita_Sheriff"})
then in Server I add
table.insert(ZombiesZoneDefinition.Police, {name = "Brita_Sheriff", chance = 0.05})
i thought we were talking about item distributions 🤦 even though you made it very clear what you were talking about
im new to this, but very dedicated, i've spent about 80 hours in the last 7 or so days coding 8 hours or more a day (obviously jumping in with 0 knowlegde & brute forcing / learning from other code)
any & all help such a links to helpful pages with all lua & PZ code commands would be a great help
:Edit: also just naturally enjoy coding & like running ideas around, if anyone is interested in VC to talk about code or idea / help eachother im open for it
that wouldn't work, table.remove() takes the index in the table to remove, not the data
or should I just create new mod and create lua called BritaZeds.lua in Shared and override it to 0
u can also override the original mod's file if it's for a private mod
like for a server or sp game
ah
someone already got onto that.
for i = 1,#ZombiesZoneDefinition.Police do
if ZombiesZoneDefinition.Police[i].name == 'Brita_Sheriff' then
ZombiesZoneDefinition.Police[i].chance = 0.05
end
end
```is basically how you'd do it without overriding
of course if you're changing multiple you want a table of stuff to change
you'd think they would have just used the name as the key
guys where to report a bug in zomboid?
I see, thats one way to do it
i.e.
local nameToChance = {['Brita_Sheriff'] = 0.05, ['Brita_SomethingElse'] = 0.65}
for i = 1,#ZombiesZoneDefinition.Police do
local chance = nameToChance[ZombiesZoneDefinition.Police[i].name]
if chance then
ZombiesZoneDefinition.Police[i].chance = chance
end
end
hmmm, interesting
Thank you thank you
I would go with overriding method since that is easier
easiest to implement, hardest to maintain
so what I need is to just create the same file name "BritaZeds.lua" in media\lua\shared\NPCs and change the chance. Put the mod to load after brita. Is that correct?
table.insert(ZombiesZoneDefinition.Police, {name = "Brita_Sheriff", chance = 0.05})
the rest of the stuff
yeah pretty much
I hope it would be alright to maintain since brita hasn't really update the mod much
Thank you all, I really appreciate it
Forum
https://theindiestone.com/forums/index.php?/topic/43261-read-here-first-bug-reporting-guideformatting/
@smoky meadow
Before posting a duplicate report, please use the search function to see if another member has already posted a topic about the same issue. Duplicating an issue will not speed up the process of fixing it but only clog the system. If you are having crashing issues, please use the support section o...
i like to override the whole file but then write it as tables with loops anyway
personally
not that i've never just copypasted the file and changed the values
i def have..
require 'Items/ProceduralDistributions'
UdderlyRP = UdderlyRP or {}
UdderlyRP.Books =
{
"UdderlyRP.SneakingVol1",
"UdderlyRP.SneakingVol2",
"UdderlyRP.SneakingVol3",
"UdderlyRP.SneakingVol4",
"UdderlyRP.SneakingVol5",
"UdderlyRP.LightfootedVol1",
"UdderlyRP.LightfootedVol2",
"UdderlyRP.LightfootedVol3",
"UdderlyRP.LightfootedVol4",
"UdderlyRP.LightfootedVol5",
"UdderlyRP.NimbleVol1",
"UdderlyRP.NimbleVol2",
"UdderlyRP.NimbleVol3",
"UdderlyRP.NimbleVol4",
"UdderlyRP.NimbleVol5",
}
for _,book in pairs(UdderlyRP.Books) do
table.insert(ProceduralDistributions.list["BookstoreBooks"].items, book);
table.insert(ProceduralDistributions.list["BookstoreBooks"].items, 1);
table.insert(ProceduralDistributions.list["LibraryBooks"].items, book);
table.insert(ProceduralDistributions.list["LibraryBooks"].items, 1);
table.insert(ProceduralDistributions.list["ShelfGeneric"].items, book);
table.insert(ProceduralDistributions.list["ShelfGeneric"].items, .1);
end```
this isnt an override but this is the kind of stuff i will do
if necessary i mix that with a table with name as key to chance as value
if it's not as uniform
it's hard to rewrite someone else's thing into something like this unless it's shorter
but it's so much nicer
hell when there's a lot of spawn locations ill make that a list too
Wow
local ammoCans =
{
"Base.AmmoCan22",
"Base.AmmoCan9",
"Base.AmmoCan45",
"Base.AmmoCan38",
"Base.AmmoCan44",
"Base.AmmoCan223",
"Base.AmmoCan308",
"Base.AmmoCan12",
"Base.AmmoCan556",
"Base.AmmoCan762",
}
local ammoCansSmall =
{
"Base.AmmoCanSmall22",
"Base.AmmoCanSmall9",
"Base.AmmoCanSmall45",
"Base.AmmoCanSmall38",
"Base.AmmoCanSmall44",
"Base.AmmoCanSmall223",
"Base.AmmoCanSmall308",
"Base.AmmoCanSmall12",
"Base.AmmoCanSmall556",
"Base.AmmoCanSmall762",
}
local ammoSpawns =
{
"PoliceStorageAmmunition",
"GunStoreAmmunition",
"ArmyStorageAmmunition",
--"GunStoreCounter", --This is substituting for DisplayCase since it makes more sense for cans.
--"GunStoreDisplayCase" --This only makes sense for non-ammo-can ammo.
--"GunStoreShelf", --Redundant, things have this + ammo usually.
--"PoliceStorageGuns", --Use ammo one instead.. will include both normally on a container.
--"ArmyStorageGuns", --Use ammo one instead.. will include both normally on a container.
}
for _,can in pairs(ammoCans) do
for _,spawn in pairs(ammoSpawns) do
table.insert(ProceduralDistributions.list[spawn].items, can)
table.insert(ProceduralDistributions.list[spawn].items, .0000000025 / #ammoCans)
end
end
for _,can in pairs(ammoCansSmall) do
for _,spawn in pairs(ammoSpawns) do
table.insert(ProceduralDistributions.list[spawn].items, can)
table.insert(ProceduralDistributions.list[spawn].items, .000000075 / #ammoCansSmall)
end
end```
example
this one has hardcoded spawn chances but separate loops for the diff spawn chances since there's just two
but with a loop for the locations
u can combine all this shit together into one loop that covers chance-to-itemname and list of spawns
if necessary
Can i please copy your method for future distrib codes?
Thnx a bunch evelyn!
it's just loops not some proprietary shit
Yeah but i sooo pretty to look at and so neat hehe .
:)
What are the use of ammo canisters
This is #mod_support area but to answer your question.. they contain ammos . Treat them like bags you drop em and take the ammos inside
It basically speeds up the looting the proccess since you grab one thing instead of alot of boxes
Oh ok
These are actually mass storage that takes less space. It's like putting bullets in boxes... You're putting boxes in canisters.
Helps storing mass amount of items, as well as server performance
Anyone know if distributions have a way to ignore loot probability?
ya, I don't replace a whole file unless its absolutely necessary. I don't want to have to keep track of every time the other guy updates or be responsible for breaking someone else's interaction with the same code. Its last hope, hail mary territory. Especially when a small loop that adds like 2ms to the boot time is the alternative
i believe this was just discussed earlier by evelyn. and i recall buffy showed her work a while back thats all about loot distrib..
i do it regularly for distribution overrides
cuz id rather have to manually approve a new item being added to my server's loot pool than have it happen quietly
if it's the type of mod where im tweaking it already
worth thinking about, if ur rebalancing a mod's spawns already
u might not want, say, a new gun added to be super common if u nerfed spawn rates of 10 guns already

but yeah if it's not about distributions that's another story
then u 100% don't wanna override it too readily
depends on which mod ur talking about - in brita's u can do that but my ammo cans are items that have to be unpacked for performance like diakon said
they exist primarily to reduce N ammo to a single item
they spawn by default too, but they're not containers x3
So I tried VisualVM to check what's going on with the memory leak, but honestly that stuff is about 3 layers too deep for me.
Separately, I've also checked the timing of when the memory leak happens. It's hard to put it down to the Tee, but here's what I have
[02-11-22 14:19:31.280] WARN : Lua , 1667395171280> 0> LuaManager$GlobalObject.require> require("Vehicle/Vehicles") failed.
[02-11-22 14:20:59.057] ERROR: General , 1667395259057> 0> LuaManager.getFunctionObject> no such function "Recipe.OnGiveXP.None
Sound".
[02-11-22 14:20:59.057] ERROR: General , 1667395259057> 0> RecipeManager.LoadedAfterLua> no such function LuaGiveXP = "Recipe.OnGiveXP.None
Sound" in recipe "Grind Coffee Beans".
[02-11-22 14:21:02.850] WARN : General , 1667395262850> 0> ItemPickerJava.ExtractContainersFromLua> ignoring invalid ItemPicker item type "SMUIClothing.Hat_OG106".
[02-11-22 14:21:02.850] WARN : General , 1667395262850> 0> ItemPickerJava.ExtractContainersFromLua> ignoring invalid ItemPicker item type "AuthenticZClothing.ChickenHatJacket".
[02-11-22 14:21:03.556] ERROR: Mod , 1667395263556> 0> ZomboidFileSystem.loadModTileDefs> tiledef fileNumber 216 used by more than one mod.
[02-11-22 14:21:03.570] ERROR: Mod , 1667395263570> 0> ZomboidFileSystem.loadModTileDefs> tiledef fileNumber 5001 used by more than one mod.
[02-11-22 14:21:13.155] WARN : General , 1667395273155> 0> SpawnPoints.initSpawnBuildings> initSpawnBuildings: no room or building at 12700,1645,0.
[02-11-22 14:21:13.155] WARN : General , 1667395273155> 0> SpawnPoints.initSpawnBuildings> initSpawnBuildings: no room or building at 13617,1344,5.
There's more of every type except the LuaGiveXP error, which only appears once.
Though perhaps this is better off in #mod_support ? 🤔
ur missing a comma
probably
the newline and Sound are included
"Recipe.OnGiveXP.None
Sound"
shud be a comma after "None"
it probably means the sound wont play and it won't give xp
it MIGHT stop any further recipes from loading from that file too
perhaps
will check. Kinda doubt it causes memory leaks, though 
local function sortOutNils(tbl)
local newTbl = {}
for k,v in pairs(tbl) do if(v ~= nil) then newTbl[k] = v end end
tbl = newTbl
end
if VehicleZoneDistribution then -- check if the table exists for backwards compatibility
VehicleZoneDistribution.trafficjams.vehicles["Base.CarLightsSmashedFront"] = nil;
VehicleZoneDistribution.trafficjams.vehicles["Base.CarLightsSmashedLeft"] = nil;
[...]
(no end)
This looks like it could cause one, though 
for java modding, does reflection work? or does zomboid have protections/managers in place to prevent modifier resets/accessibility changes?
for java modding there's no restrictions, for lua you can only read fields afaik
me too just telling u what i saw in ur error :p
for k,v in pairs(tbl) do if(v ~= nil) then newTbl[k] = v end end
v can't be nil otherwise this key doesn't exists
Please, you can do line breaks
Neither of those codes are mine x)
One is from Sapph's, one is from Cyt's Kentucky Overhaul
but I left a report on Sapph's. There was one on Cyt's already
There is some mod clothing that use a Custom Body Location, but because of that, any of the protection to scratch, bite ou bullets are been applied to any Body Part protection. Is there a way to make this work for custom Body locations?
Does anyone know anything about selling fuel to players (server based) was thinking about making a gas station players could buy fuel from. Also a cool additional thing I thought about was making it where players can get fuel then sell it to the gas station. If anyone is interested in making something like that I’d pay for it, just give me a price.
IIRC body locations is just visual category, probably you mean BloodLocation, you can't create new ones
So to the protection be applied it's just setting the blood locations?
yes
Thanks
Is there any mod to make PZ like tarkov, ie remove the zombies from the world and add dangerous human rebels etc?
no
you can remove the zombies out of the box
and u can add survivors
but
they aren't deangerous rebels
they're more like incompetent derps
added by mods
Aw ok, would love to fake hostile players
How can i put multiple items in the Result: field of a recipe ?
use OnCreate
and attach a lua function
which will give the player the other items
no other way
hope they add multiple results as part of the recipe overhaul tbh
tedious to do that
thank you that worked fine
recipe BerryWine
{
Berry1/Berry2=5
Result:BerryWine,
Time:50.0,
}
Follow up question. What does this do Berry1/Berry2=5. Can it be a mixture of Berry1 and Berry2. Or does it have to be 5 from one specific ItemType.
I figured it out. You can tag the items u want. And then make recipes based on the tags.
---server.lua
if isServer() then
RegisterServerCallback("Server:Example", function(cb)
print(cb)
end)
end
Why I need confirm that a thing is server side, in a server side file?
I don't think server means that it's executed by the server per say... More that it's affecting the world as a general?
if you mean it's under the server folder, the client loads that too
servers only run code in server or shared
clients run code in client server and shared
why?

probably to help with SP/MP compatibility
yeah, but that should not be like that
any file you really really don't want to be loaded client side just throw if isClient() then return end at the top. As far as I'm aware the whole file will then be ignored
yeah, isClient() is usually better than isServer() as generally you still want server things to run in singleplayer
isServer() and not isClient() for dedicated server only, isClient() and isServer() for sp/coop, isClient() and not isServer() for dedicated client
but then sp/coop host won't run it
afaik
cuz both return true on sp
ya, that's why you'd have to really really be sure
that's why i recommend compound statements
cuz if u dont want it to run on a client... in dedicated, but work in sp
then u want something different from don't run on a client ever
isClient should not return true in SP. its used in the vanilla files this way too (see SFarmingSystem.lua and SMetalDrumSystem.lua for examples)
its explicitly set to true in 2 spots from my quick checking, both in LuaManager:
serverConnect() and serverConnectCoop()
and set to false in backToSinglePlayer()
-- | isClient() | isServer() |
-- Singleplayer | false | false |
-- Multiplayer Client | true | false |
-- Co-op Host (client process) | true | false |
-- Co-op Host (server process) | false | true |
-- Dedicated Server | false | true |
YourUtils.isServerOrSinglePlayer = function()
-- | isClient() | isServer() |
-- Singleplayer | false | false |
-- Multiplayer Client | true | false |
-- Co-op Host (client process) | true | false |
-- Co-op Host (server process) | false | true |
-- Dedicated Server | false | true |
--
-- This is a single player game or is a coop host server process or is a dedicated server
return not isClient()
end
YourUtils.isClientOrSinglePlayer = function()
-- This is a single player game or is a coop host client process or is a client connected to a remote server
return not isServer()
end
YourUtils.isSinglePlayer = function()
-- This is a single player game
return not isServer() and not isClient()
end
callback event
-- client.lua
local _ENV = require 'DislaikLibrary';
_ENV.CreateENV();
local onKeyStartPressed = function(key)
local source = getPlayer(); if not source then return end
if key == Keyboard.KEY_NUMPAD0 then
TriggerServerCallback("ServerCallback:Example", function (fromServer)
print(fromServer)
end, "THIS IS FROM CLIENT")
end
end
Events.OnKeyStartPressed.Add(onKeyStartPressed);
-- server.lua
local _ENV = require 'DislaikLibrary';
_ENV.CreateENV();
if isClient() then return end;
RegisterServerCallback("ServerCallback:Example", function(source, cb, p1)
print(p1)
cb("THIS IS FROM SERVER, " .. p1)
end)
alright fuckin got me then
i was misled by things

How would I overwrite vanilla items?
Want to overwrite the Battery, just by icon and some variables
u can change things without overwriting it entirely to play nice
but
to overwrite u just copy it into ur own script
with module set to Base
and then tweak what u wanna tweak
to just tweak stuff u can use DoParam on the item object or use ItemTweaker
how do i find a list or even link my file to a "call list" that relates to PZ natural entities
ex: _player:getdata() or some list like that with all possible commands that PZ will just "get"
i think what u need is to look at the java docs
(this is the most current one to my knowledge, the versionless one is older)
alternatively you can of course decompile the game and reference/search the results.
YES!!! thank you!
btw this was such an odd yet technically understandable way to ask that
xD
i assume what u mean by "link my file" you mean autocomplete/suggestion/etc.?
u can do that in some way with intelliJ or vscode i think
i haven't ever bothered
yo ty for the help, im really dedicated to my overhaul idea of HyperRealism mod, a 1 mod overhaul, yet i know nothing of lua & have been coding 10 hours a day for 7 days now lolol
Still waiting here @civic lava
DM you
_
Also is anyone willing to help me with some code? either thru text or screen share. the more help i get from knowledgable people the less work i have to do reading hours of shit i hardly understand, i learn much faster with a "lack of better word" tutor
if _player:panic > 50 then Trip = Trip - 2000; end
if _player:panic < 50 then Trip = Trip + 200; end
_
Is this proper, will this change the trip value relative to panic state?

now i understand all those "depressed coder" memes
i replied
Anyone have experience with Anti-Cheat Type 21?
strange: does anyone have any idea why ModData.add(WaterGoesBad) (and similar calls), specifically without quotation marks, was working? it was not a variable, there were no errors and it was working and persisting as expected
i would never have noticed if i weren't rewriting it...
maybe it was being stored under a key 'nil' lol?
does some1 know why i cant go in the back in the rv
i just move to the back seet with v
i have the mod installed
I don't see any id of trigger
1 > callback that uses only single func?
or 2 > adding inf count of functions without any way to delete any of ones
if both cases it's > 
I might be confusing it with 22, but I believe it was when the client fails to respond to the server's periodic request to provide a checksum of a file quickly enough
If a function runs for too long (like a few frames, e.g. 30 ms, to where the game stutters) it will cause it to fail and kick the player
local Roll = ZombRand(1, 200);
"how do i add without error another math to this EX:"
_
local Roll = ZombRand(1, 200(math.random(20, 50));
Would this be correct? if not could someone fix it?
just add another ZombRand
oh so the ( "brackets are fine" )( but the zombrand should be used instead of math.random()
need to add + or * in between the numbers, no idea what you're going for
regardless i got the info i needed, TY!
e.g 200 + ZombRand(20,50)
im new to lua. i just started coding & have been doing so for 7 days about 8 hours a day, its like a game & it feels like a beat a dark souls boss when i get something to work, so i've decided to dedicate myself to making an overhaul mod "HyperRealism" (detailed plans are too long to type) so ill be in here asking dumb stuff & looking for help most of the time
if lua is ur 1st lang then pz isn't better game to learn, to say the least xp
Not sure about your question, but in any case, you can check my library about how it works https://steamcommunity.com/sharedfiles/filedetails/?id=2882683094
- u can attach only 1 function to this trigger
- no func to remove trigger
- if trigger wasn't registered > trying to call nil
you are not seeing the complete panorama
if u're not a masochist then events module have to look like this:
:RegisterEvent(event_name, event_id, func)
events[event_name] = events[event_name] or {}
events[event_name][event_id] = func
:TriggerEvent(event_name)
iterate `events` table > iterate event table > call each one
:RemoveEvent(event_name, event)
.....................
it doesn't have to be, I've already seen it's done poorly
xd
I feel like I've seen you post this message every day for the past 7 days lol
I was hopping for another literature mod 😅
hello was just wondering if anyone could tell me if anything is wrong with this because my mod wont show up on my mod list in pz. im still new to coding in lua and modding in general so please be patient with me
Where did you put the mod folder?
\Mod_Name\Contents\mods\Mod_Name\media...
check ModTemplate in c:\Users\admin\Zomboid\Workshop\
You should put it on something like C:\Users\YOURPCNAME\Zomboid\Workshop there you find a mod example
ooohhhh
it will work in mods folder too, he don't have contents folder in his mod
oh I didnt have that in a previous mod I made and it worked. I will look into this in the example
thank you very much kind sirs
i really do appreciate the help
mb last time u created new mod in folder of already existed mod

ahhh maybe maybe. honestly i watched a very old video to make that little tiny demo mod i first made
just added a single item
he-he
true
ok it still wont show up
maybe i named something wrong
or wrong syntax on something
A thing I do when I can't find bugs/errors is start over and gradually add, you can create a empty new mod and add files gradually
where are the zombie textures stored?
C:\Program Files (x86)\Steam\steamapps\common\ProjectZomboid\media\textures\Body
thanks bestie
doing it anyway
100+ hours in, been doing it dialy
even paid for some tutoring
im very dedicated about my vision
i also have a question, i forgot how to print
is it
Print(trip)
is i want to print my trip value for debug
print
so the code would look like
_
print trip
print(val)
patronizing me is always fun, i simply forgot, i dont need to prove my skills & u can lack at my forgetfullness of () placement all day, this changes nothing, im making an overhaul mod & it may take months but i will do it, & some people are nice enough to simply just answer a question
just ignore that nasty guy
local stats = _player:getStats();
local panic = stats:getPanic();
local stress = stats:getStress();
local boredom = stats:getBoredomLevel();
local wet = _playerdata:wet();
local inja = _playerdata:injured() + _playerdata:injured();
local hype = _playerdata:unhappiness();
local pain = stats:getPain() + stats:getPain(); --negas 900
local hp = stats:getHealth(); -- possas 500
local endur = stats:getEndurance() + stats:getEndurance(); -- sp trip 3000 min 900 max 500 begin 3500 rv
local tired = stats:getFatigue() + stats:getFatigue(); -- +0,200 fr endur & tired
local hung = stats:_playerdata:hunger();
local Trip = 3000 - panic - stress - boredom - wet - inja - hype - pain + endur + tired + hung;
I want to debug the trip rate is all
XD
makre sure my math is right
m8 if u think I'm hate ur addon, I don't
hard to do when dealing with uneven changing values
I'm just trying to give u some help how to do better
CAN SOMEONE JUST .... ok ill get back to coding without the print in my debug.. w.e... i got lots to change
he is maybe one of those who say they have a girlfriend before the girl knows about it.
you don't have to stick to what I say but insult me for it is cringe)
I already said lul
print(val)
@civic lava not for u, it's fine
PZ modding, because paying for psychologists is overrated.
hehe
lol that was a good one
memories
i learned ALLOT since then tho
even tho me forgetting print code might make u doubt it
maybe his logic is that he has always heard from successful people that it was not easy and no one believed that he/she could make it. so he provokes negative comments and hate to be able to say the same thing later.
You've spent 100+ hours and you couldn't Google how to print in Lua??
The most important skill you need to acquire for programming is how to problem solve. This means trying to find the answer on your own through exhaustive research before asking someone else directly. Especially for something as basic as how to print a variable in Lua. Programmers are generally willing to help each other, but that can quickly go away if it appears you haven't put any effort in on your end. And saying "I've been programming 100+ hours over the past week" is not proof that makes asking "how to print " okay
And if you've spent 100+ hours over the past week working on your mod, then you definitely have time to Google your questions first.
Let him be guys.
I understand how you feel tho but
Lets keep the channel non toxic if thats ok with you guys.
I mean dont hate me for saying this. I have much respect for you guys
Anyways let me help u @limpid moon
Youve been trying for over a week now and i feel bad that you still havent been able to do the mod. Pm me
oooo ok interesting
If he wants to be successful, I think it's important to educate him on how to appropriately go about asking for help. I don't think it's toxic. It's beneficial to him and the communities he interacts with
I understand sir but there must be some way of doing this that doesnt involve shaming
Goodluck @limpid moon 🫡
thank you kind sir. i will do my best 🫡
Mmmmmm thank you. I will consider the possibility that I am doing this somehow
Y'all can anyone identify the file that generates the lefthand clickable sidebar in the UI? I have always hidden it by looping getUI() without knowing exactly what it is, but in order to fix certain conflict issues in a more rigorous way I think I need to know the precise object so I can check its visibility without needing to know its index...
I've been trying to implement this but no success so far
Where should I look to learn how to make a generator? I'm trying to make a simple, non craftable, non movable tile that generates power. I'm reading the code of different mods with generators but those are overly complicated compared to what I'm trying to do
I have a variable called container that derives from isoObject that comes fom a square:getObjects, so my container var is actually an ItemContainer. So I tried doing local test = getContainerOverlays():updateContainerOverlaysSprite(container:getParent()) but it gives an error java.lang.RuntimeException: Object tried to call nil in container
Any ideas what is going on?
square:getObjects returns not just ItemContainer
it returns literally all objects on square
I do filter per object that is a container
I may have skipped a bit, but I do
local size = objects:size()
if size == 0 then return nil end
local LastIndex = size -1
for i = 0, LastIndex, 1 do
local object = objects:get(i)
local s = tostring(object)
local container = object:getContainer()
if container then
return container
end
end```
So it becomes an ItemContainer in the end
try to just print it
print(container, container.getParent)
Maybe is that then
container < table
container.getParent < index func
container.getParent() < invoke this func
nope
Thats why its returning nil
.
k
not sure if it matters, first object is usually the floor and I've had some errors from that
I'm restarting my server here, but I can try to filter if the ItemContainer is floor
do u think floor object doesn't have getParent method?
it's pz but I think have to be there
or it returns nil most likely
if nil then there's cannot be Object tried to call nil in container
Im loggin on my server here
Since this mod is focused for MP I test it on a dedicated server, so thats why its taking so long
zombie.inventory.ItemContainer@14ee70c9 function 0x1290354786
function exists
This item is a bookshelf if it matters
wut
try container.getParent() instead container:getParent()
I don't remember how getParent invokes
I do use container:getParent() before on the same code and its working, but I am willing to try your suggestion
Javadoc Project Zomboid Modding API declaration: package: zombie.inventory, class: ItemContainer
Container do have a .parent field
it's unreachable key from lua cos it's java
As Ik it's working by this way

Being honest, I do know little about lua and java
My expertise lays on VB mostly, and some python
I'm doing something else and only barely following, I didn't see the exact line it breaks on.
The exact line you suggested haha
But its the line I need to add and make it work
as far as @jaunty marten is helping me, its something to do on how I am passing the IsoObject
it's strange cos in print u got function
I'm looking at my code I use container:getParent() and container:getParent():getTextureName() and it works
But I was passing as container:getParent() and now you suggested container.getParent()
Maybe it works now
but :getParent() and .getParent() never will call error like ur if getParent function existed
Maybe it errors because it requires a var and I was passing a function?
I dunno
My server just restarted
I'll test this version now
I checked and u can forgot about .getParent(), use :
are u sure errors due to this line? mb other one?
open admin chat and do
/reloadlua MyFile.lua
cos as I said it's unreachable
Do this work on a dedicated server instance?
I am uploading to the workshop and restarting the server on every change
doesnt reloading lua on servers usually crash them?
ah, I'm usually testing from same machine
maybe its just hosting via the client that does it
I'll go back to the starting point and going to paste the entire stack error
Maybe I am reading the errors wrong
I tried to check if the player is on a new square and then do some checks. So far I tried this:
local function OnObjectCollide(character, door, IsoGridSquare, IsoThumpable, IsoWindow, IsoZombie)
print("collided")
if IsoThumpable ~= nil then
print("isoThumpeble")
end
if SoulMod.shared.isSoloGame and IsoGridSquare ~= nil then
print("collided: " .. IsoGridSquare.getX() .. " / " .. IsoGridSquare.getY())
end
end
Events.OnObjectCollide.Add(OnObjectCollide)
I never get "isoThumable" or "collided: x / y" in the console. But the "collided" trigger when I hit a door or window. Does someone have experience with this. The primary goal is to detect when a player or zombie (does this even trigger?) gits a certain object (fence or an object on the square)...
I mean.. doors and windows are thumpable
Technically its not wrong
Maybe add extra filters to ignore doors and windows
isochracter and player dont inherit from thumpable
maybne isoobject if you really want to go that far
but why is the square always nil?
getCell():getGridSquare(x, y, z)
first of all needs to remove SoulMod.shared.isSoloGame
the lua event gives me the variables. so I expected it triggers on every square... but this doesn't seem to be the case...
function: onServerCommand -- file: clientupdate.lua line # 62 | MOD: ExtrasDescoladosCMDFORCEITEMRESPAWN
ERROR: General , 1667494627806> 68.793.510> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: Object tried to call nil in container at KahluaUtil.fail line:82.
ERROR: General , 1667494627807> 68.793.510> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: Object tried to call nil in container
at se.krka.kahlua.vm.KahluaUtil.fail(KahluaUtil.java:82)
at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:973)
at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:163)
at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1980)
at se.krka.kahlua.vm.KahluaThread.pcallvoid(KahluaThread.java:1812)
at se.krka.kahlua.integration.LuaCaller.pcallvoid(LuaCaller.java:66)
at se.krka.kahlua.integration.LuaCaller.protectedCallVoid(LuaCaller.java:139)
at zombie.Lua.Event.trigger(Event.java:64)
at zombie.Lua.LuaEventManager.triggerEvent(LuaEventManager.java:173)
at zombie.network.GameClient.receiveClientCommand(GameClient.java:1453)
at zombie.network.PacketTypes$PacketType.onMainLoopHandlePacketInternal(PacketTypes.java:1022)
at zombie.network.GameClient.mainLoopHandlePacketInternal(GameClient.java:638)
at zombie.network.GameClient.mainLoopDealWithNetData(GameClient.java:615)
at zombie.network.GameClient.update(GameClient.java:426)
at zombie.GameWindow.logic(GameWindow.java:231)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
at zombie.GameWindow.frameStep(GameWindow.java:764)
at zombie.GameWindow.run_ez(GameWindow.java:666)
at zombie.GameWindow.mainThread(GameWindow.java:494)
at java.base/java.lang.Thread.run(Unknown Source)
local test = getContainerOverlays():updateContainerOverlaysSprite(container:getParent()) this is line 52
you should be able to get the square off the character character:getCurrentSquare()
what i hoped for is that the first parameter "character" can also be a zombie which steps on a specific square or thumpable...
I'll test that. But I'm not sure if this helps, because if I walk into a fence or door. I'm on the square right next to it.
post the whole functions that lines 52 and 62 are in, in your clientupdate.lua file
Ok
Just a moment
local player = getPlayer()
if player:getOnlineID() == args.playerID then
local containers = getNearbyContainerscli(player:getX(), player:getY(), player:getZ(), args.range)
for i = 1, #containers, 1 do
local container = containers[i]
local items = container:getItems()
if items:size() == 0 then
local sq = container:getSourceGrid()
local cIndex = -1
for i = 0, container:getParent():getContainerCount()-1 do
if container:getParent():getContainerByIndex(i) == container then
cIndex = i
end
end
local info = { x = sq:getX(), y = sq:getY(), z = sq:getZ(), index = container:getParent():getObjectIndex(), containerIndex = cIndex }
sendClientCommand(player, 'object', 'clearContainerExplore', info)
container:removeItemsFromProcessItems()
container:clear()
container:requestServerItemsForContainer()
print(container, container:getParent())
local test = getContainerOverlays():updateContainerOverlaysSprite(container:getParent()) << 52
end
end
player:Say('O chat respawnou os containers perto de mim')
end
end
local onServerCommand = function(module, command, args)
if Commands[module] and Commands[module][command] then
Commands[module][command](args) << 62
end
end
Events.OnServerCommand.Add(onServerCommand)```
show 82 line
There is no line 82
serverside file
wtf
line 82 is in the kahlua files, you don't have access to that
@alpine scroll could be typo
I don't remember pz error structure 
kk, thx
updateContainerOverlaySprite
How to I know when something is a thumpable?
Oh god
Is a typo
HAHAHAH
God dammit
I BLAME YOUUUUUU (thx for the help haha)
the container bit was a red herring, it says that because you named your function container, not because of the container variable in the container function (you probably shouldn't have overlapping names like that, lmao)
Tecnically, it IS a container sooooo hahah, but yea
I have to study lua a bit more
its just good practice to make sure you name your variables and functions in a way that is recognizable, and not to name them the same thing
if it will fix the problem then strange
cos he have local container > locally override global value in current scope
to prevent this exact thing
Is container something that zomboid uses?
did u fix ur error?
I don't get
what did u change
local test = getContainerOverlays():updateContainerOverlaySprite(container:getParent())
It was updateContainerOverlaysSprite before
with 2 s
The correct is only one
ah
try to use argument just container object not ItemContainer
fk pz wiki
sec

I a bit didn't get ur code
what are u doing?
if container_items:size() == 0 then clear container
I basically copy pasted the admin code to respawn items on a container
The admin command clears the container before respawning items
I just forgot to remove the clear items part
container:requestServerItemsForContainer() is the relevant part

All I want is to be able to force a respawn of items on containers near the player
And update its visual
yo guys
OnPlayerGetDamage event doesnt work for me
it just errors and says it adds something of non-table in console log
the function is above the event ofc and its the correct name, spelling etc.
@frosty falcon you've sent me the entire list of events before, do you have any idea for this
wait fuck im an idiot its unstable LOL
ISInventoryPage.renderDirty = true;
The update I need is the bookshelf on the world, not the inventory page. Will this trigger the IsoObject?
item:getContainer():setDrawDirty(true)
or container:setDrawDirty(true) since it seems like you already have that
i know
@alpine scroll
if container then
--print("zx filling container: ", container:getType(), container)
container:emptyIt()
ItemPicker.fillContainer(container,nil)
--ItemPickerJava.updateOverlaySprite(container:getParent())
getContainerOverlays():updateContainerOverlaySprite(container:getParent())
container:getParent():sendObjectChange("containers")
end
I do this from server and it works
SendObjectChange
Thats different
However you do it on the server side, right?
My code right now is on the client side
But i'll try to implement it
last one updates the items inside container, though client will need to move or update the inventory to see the change
this is where the render dirty comes in play
Render dirty updated the inventory pages, but not the overlay
I think I need to pass it back to the server and trigger the overlay
Can I get a tileIsoObject from some sort of static manager class by handing it an ID ?
I want to save references of tileIsoObject in a text document, maybe csv. And later load the document and delete all tileIsoObjects that are older than 3 RL days.
you need moddata probably to add a var that contains the age i guesss
yeah that would be one solution, looping through all objects if a grid square gets loaded and then checking the mod data. however i want to directly get the reference of one tileIsoObject by either looking through a hashmap or using some sort of manger, that returns the object as is, without looping through everything.
but i dont see any unique identifier.
Is there a way to expose the traits menu mid-game? I'm thinking about making a mod that gives 1 trait point every 30 days the character is alive.
theres this thing about traps that you can find on a menu iforgot where... but it allows you to see all of the traps on the world
im not sure but it could be global object or something
its outdated (build 40 mod) but should find the code you need it here:
wow someone actually did it! i thought about doing something like this but i dont know much of ui coding
it was actually done as a joke for a friend a while back XD
they dropped the skill point system with build 41 though so it never got updated
are you planning to make one that works with current build? sure hope so
considered it, but would need some sort of replacement point system. unlikely i'll get around to it though
technically it doesnt open the panel, since the trait selection stuff its just various listviews on the character creation screen, it builds a additional tab in the skills/health panel and adds the list views there
ahh isee
Hey how do I use an item from another mod in my recipe?
Like I want to make a recipe using items from my mod, spit out items from a different mod, is there a way to do that?
yes just include its module
can you give an example of what item which recipe?
What would that be? I see most of them using Base as the module
I'm making a shop mod, I want to buy items from this mod here https://steamcommunity.com/workshop/filedetails/?id=2790147088
I am using this as a base https://steamcommunity.com/sharedfiles/filedetails/?id=2545933394&searchtext=
you can find the module name when you look at the mods script or itemviewer ingame or if you edit the item on the inventory if your admin
when you right click on the item then edit you see the module name there
Yea I am looking at scripts but most start like this
module Base
{
then thats the module 🙂
I am still getting an error though.... does every script file you have need that import?
Mine starts like this,
module Base
{
imports
{
Base
}
if you defclare a module then yes
Ok, do I need to be calling it via it's full descriptor maybe? Like Base.Stimpak ?
yes
well what does your recipe look like
10Money=3,
Result:Base.Stimpack,
Time:10,
keep WalkieTalkie1/WalkieTalkie2/WalkieTalkie3/WalkieTalkie4/WalkieTalkie5/HamRadio1/HamRadio2/RadioMakeShift/HamRadioMakeShift/WalkieTalkieMakeShift,
CanBeDoneFromFloor:true,
Category: SShop Medical,
}
recipe Buy Drugs Stimpack: $30
{
Base.10Money=3,
keep Radio.WalkieTalkie1/Radio.WalkieTalkie2/Radio.WalkieTalkie3/Radio.WalkieTalkie4/Radio.WalkieTalkie5,Radio.WalkieTalkieMakeShift,
Result:Base.Stimpack,
CanBeDoneFromFloor:true,
Time:80.0,
Category:Survivalist,
}
The mod does seem to work with base items at least
In the SShop mod
and its base?
So it's an internal one, the stimpack is external
No, its added by this mod, let me get the block
ye well what is the mods module for 10Money
module Base {
imports
{
Base
}
item Money
{
DisplayCategory = Junk,
Weight = 0.001,
Type = Normal,
DisplayName = 1 Dollar,
Icon = Money,
WorldStaticModel = Money,
}
item 5Money
{
DisplayCategory = Junk,
Weight = 0.001,
Type = Normal,
DisplayName = 5 Dollars,
Icon = Money,
WorldStaticModel = Money,
}
item 10Money
{
DisplayCategory = Junk,
Weight = 0.001,
Type = Normal,
DisplayName = 10 Dollars,
Icon = Money,
WorldStaticModel = Money,
}
I added the import, but otherwise it's as it was
this
Same error
hold on.. the other mod disabled itself somehow
that might cause an issue....
You sir, are a genious and a scholar.
God damn it lol, it was the disabled mod... Welp. At least I got it lol, thanks for the help
This does help with another mod I was trying to make though so it wasn't in vain 👍
Yea I'm gonna try to make Brita's attachments work with the fallout weapons, last time was a shit show, broke britas by doing whatever I did somehow... so we'll see lol
Hmmm 🤔
Would there be a way to make someone scream for a certain period of time after ingesting something? Like just keep shouting HEY! HEY YOU! etc
I'm trying to find the source code that runs when a character is initially infected with the zombie virus, and then sets level, mortality, and mortalityDuration. What I've gathered thus far is its a loop of code that checks isInfected on the bodyparts, then kicks everything off. Anyone know where that code is?
What is the syntax for multiple imports in a script file? I tried
imports
{
module1,
module2
}
you dont need to do multiple imports i believe.. and im not 100% sure but to do this you dont need to add the ,
its for another thing I want to sell that uses the module name "DW"
If u import the module you dont need to add the module on the items
If you dont then you need to add them
Which is why theres really no need to do this esp with your specific situation whereas all of your items are base anyways
@ruby urchin dude! How did you figure out how to do the animation! So awsome man
25 is the max as indicated on the comment. Your going to tell to do something it doesnt recognize. Idk what will happen since i havent tried doing something like this. But mostlikely theres going to be an error
AuthenticPeach and iBrRus did first, Authentic share me a template some time ago, but we had a problem with translation_data (that makes player directional movement) until we solved it
what animation are we talking about?
nice
if u were u would need the comma
that is correct
Is it possible to make onTest function check if a certain tile is near
onTest will call your lua function, so yes
Thnx
ok so i cant get my debug menu to print the rolls
i have the code in the area after the if
print(chance)
print(chanceinx)
but
when in debug i cannot see a roll, how to enable?
You have to put the print within the lua file cuz the variable is local and only happens within the function it exisits only there. So you can print it externally like from debug.
uhhhh
its in the file like this
_
if player:isSprinting() == true then
print(chance)
print(chanceinx)
chancemod = chancemod + 12;
elseif player:IsRunning() == true then
print(chance)
print(chanceinx)
chancemod = chancemod + 4;
_
so its within the trait
are you adding random tripping 😟
if your prints aren't showing up i would suspect the issue is elsewhere and this portion of code isn't being run in the first place
ok so i cant get my debug menu to print the rolls
he's back, I almost drowned with coffee
u cannot trip if u are not under (multiple conditions Ex Panic, pain, zombies nearby) that is just a snip of a larger code to show where the print is placed
patronizing me is always nice
i'm new to code, i want to make something called "Hyper Realism" (regardless) i can do all the math in my head, it would just be nice to see the print to get the math understood faster, rather then using my brainpower & time to do math on actually physical paper to reveal the odds of what im tying to have happen or % chance under a condition
bro, I tried helping you yesterday. why you mad.

You cant skip the process
Learn lua then Learn pz api lua
Thats the only way you will understand how print works.
You can use debug to print out each of your variables like your sprintinglvl
Only if you understand what sprintinglvl represents on your code cuz the debug wont recognize it since its declared as a local variable within your function
Meaning it only exsist there
So you have to find out what exactly local sprintinglvl is
Which is the getPlayer():getStats(Perks.Spriting)
I just typed this and im using mobile without reference so if im wrong pls dont blame me. Its just for you to understand where the variables point out
I even spelled sprinting wrong but im not gona correct that.
Anyways
As i recall you had
Local stress= _player:getStress()
So if you print this in debug it wont work
You have to use
print(getPlayer():getStress())
You have to understand how print works
How variables work
How function works
And which are the parts that is unique to pz
What lua specific stuff that doesnt exist aswell
Like your
Math random
Which is zombrand()
Hope this helps goodluck
what do u mean why am i mad?
i never showed aggression or angry in any way
i only said you are patronizing me
it doesnt make me "mad", it just shows who you are & how you think about people trying to learn
i come here to ask a question, i get better daily & work with this constantly, i assumed this channel was for getting answers to questions/help in some way. not to copy paste my messages to insinuate that im incapable of getting my dream to work

anyone knows how to execute a simple delay?
ive tried https://steamcommunity.com/sharedfiles/filedetails/?id=2875394066
but it doesnt recognize the variables from the parent function
imean the function that that needs to use the delay functions
im trying to understand this thing as i have ran into same problem
anyone would care to explain to me
I don't know this API but can't you just add a function to onTick or onEveryXXX and count up a variable to your delay and then remove itself from the ticks or whatever?
of course you can use the time to calculate instead of counting ticks... maybe this would make more sense...
I want to add a scratch to the right hand. So from LUA I call:
getPlayer:getBodyDamage()
and then? Can I somehow directly get the hand? or do I have to loop through the parts?
To further explain ny objective.
I made a mod that dig for ores
Then i added tile sprite to look more realistic but it will eventually make the world messy and so i need to be able to remove the tile after a few seconds of spawining it
So the i need the square and the obj variables
This api works but it creates another function which dont recognize my variables
Hmm... ok... what about storing them in an global "array" with the needed stats. for example removeTime, square, object and then check if there is an item that has to be removed...
Or maybe there's a more complex part in your question that I don't understand...
forgot to click on reply... see above...
playerObj:getBodyDamage():getBodyPart(BodyPartType.Hand_R)
playerObj:getBodyDamage():getBodyPart(BodyPartType.Hand_L)
thx...
actually im stupid
the reason why the delay couldnt recognize the var cuz it was outside of the parent function lol
i does recognize the var imean the api
so i guess thats that 🙂 thnx anyways @blissful salmon
is any chance this works?
function ()
function player:getFoodSicknessLevel()
return getSpecificPlayer(0):getBodyDamage():getFoodSicknessLevel()
end
player:getBodyDamage():setFoodSicknessLevel(player:getBodyDamage():getFoodSicknessLevel() + 20);
player:Say("I feel bit better")```
Hi, How to make tooltip show on admin only?
there's a method called getAccessLevel I think
I can use that on clientside?
Is there a way to alter the in game map? I wanna add labels or draw borders and name things, on a custom server. so when players join they can press M and see where safe areas are, stores, buildings, and so on.
I'm trying to set a scratch on the hand without the bleeding effect. I use this code:
hand_r:setBleeding(false)```
But I still get the bleeding. What am I doing wrong?
Found the solution... I added
hand_r:setBleedingTime(0)
Hi, i don't really understand how colors work on clothes.
I try to add a red variant to the cowboy hat, i've made the textures, i've remake the script :
module Base { item Hat_Cowboy { DisplayCategory = Accessory, Type = Clothing, DisplayName = Cowboy Hat, ClothingItem = Hat_Cowboy, BodyLocation = Hat, IconsForTexture = HatCowboyBlack;HatCowboyBrown;HatCowboyWhite;HatCowboyRed, CanHaveHoles = false, ChanceToFall = 50, Insulation = 0.3, WindResistance = 0.2, BloodLocation = Head, } }
And the GUID :
<?xml version="1.0" encoding="utf-8"?> <clothingItem> <m_MaleModel>static\clothes\m_cowboyhat</m_MaleModel> <m_FemaleModel>static\clothes\f_cowboyhat</m_FemaleModel> <m_GUID>ae7791f9-a5df-48d8-882f-a0749b8af2b1</m_GUID> <m_Static>true</m_Static> <m_AllowRandomHue>false</m_AllowRandomHue> <m_AllowRandomTint>false</m_AllowRandomTint> <m_AttachBone>Bip01_Head</m_AttachBone> <m_HatCategory>Group02</m_HatCategory> <m_MasksFolder>media/textures/Clothes/Hat/Masks</m_MasksFolder> <textureChoices>cowboyhat_black</textureChoices> <textureChoices>cowboyhat_brown</textureChoices> <textureChoices>cowboyhat_white</textureChoices> <textureChoices>cowboyhat_red</textureChoices> </clothingItem>
but How the game know what texture/color to put on the item ? And how the information is passed on the 3D model ?
Maybe i need to remake the tint system with lua ?
Actually only brown, white and black cowboy hat are presents in the game
But the kahlua table is fine, there's my red texture in it
IIRC the texture, color and hue is randomly picked once the game spawns the item
Okay, so why he doesn't take my new color ? 🤔
Is there a way to get the weight of an item without having an instance of it? So for example when I have a Thread then I want do get 0.1. As far as I know then drained items change their weight if they are not full...
item Thread
{
DisplayCategory = Material,
Weight = 0.1,
Type = Drainable,
UseWhileEquipped = FALSE,
UseDelta = 0.1,
DisplayName = Thread,
Icon = Thread,
ConsolidateOption = ContextMenu_Merge,
SurvivalGear = TRUE,
WorldStaticModel = Thread,
}
My primary goal is to create the right amount of an item when I got a weight based on other factors. So in the case of a thread I want to be able to use weight = 0.325 and based on that create 3 full threads and a fourth of a thread. So I need to know the full weight of a thread.
if you want a non-instanced version of a item, you need to fetch the script item, in this case you'd be looking at:
local item = getScriptManager():getItem("Base.Thread")
local weight = item:getActualWeight()
weight listed in the script .txt file goes into the ActualWeight field (theres no getWeight method for the script's Item.class)
Thx for the answer. Do you also know how I can set the remaining amount. Is this via the DrainableComboItem:setUseDelta()?
should be ya
ok... Trial and error 😄
thx for help. I think I'm on the right way now...
Is it possible for a server to limit the player to one character, by this i mean like limit a player to the character and even if he dies he still has to play as that character. And remove the option to create new character? It would simply be “respawn” option only.
I think I remember seeing a mod called respawns but I don't know
Oh man, I almost ended up spending one of my lazy tokens by asking a question in here. I decided to look up the answer instead. wipes brow that got close.
recognizing this earns you one free token.
Woohoo! I rule the wooooooooooorld.
I have some functions which I save in a variable und replace the original to add some checks and call the original in the replaced function. For example:
SoulMod.ISEatFoodAction.perform_orig = ISEatFoodAction.perform
function SoulMod.ISEatFoodAction.perform(mySelf)
-- doStuff
return SoulMod.ISEatFoodAction.perform_orig(mySelf);
end
Now I tried the same with the following code:
SoulMod.Recipe.OnCreate.CutFish_orig = Recipe.OnCreate.CutFish
I assume there is something special with Recipe. My goal is to overwrite the function CutFish in the file server\recipecode.lua
function Recipe.OnCreate.CutFish(items, result, player)
Anyone has an idea?
Forgot to paste the error:
function: SoulMod_FishOil.lua -- file: SoulMod_FishOil.lua line # 7 | MOD: Soul Mod
ERROR: General , 1667575169563> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: CutFish of non-table: null at KahluaThread.tableget line:1689.
ERROR: General , 1667575169564> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: attempted index: CutFish of non-table: null
what is line 7?
Howdy there, Zomboid modding folk. Incompetent scripting guy here again.
I recently made some more collectible items for my Pomp's mod and was curious on how to get an item that gives you something random upon opening it. I assume I'd make some sort of array list, though I wouldn't know how to get the script to function for a recipe. Would somebody be able to walk me through the process?
@blissful salmon Looks like you're trying to access an item in a variable you expect to be a table, but its a null value.
line 7 is this:
sorry for being unclear...
Yes... but I don't know why... In the file recipecode.lua the function exists... Or do I misinterpreting the error?
I assume Recipe.X does not lead me to the function I want. So I assume that the problem is in this part: = Recipe.OnCreate.CutFish
Pomp!! Love your mod; we use it on every instance of our community server >.>
That said, yeah that's the best way I can think of; make an array of items you want to spawn, and use the ZombRand() function to select one (or more) of the indices from that array (just use random number from total length, so you can keep adding to the array without changing any other code), and call it from a recipe via OnCreate().
I can probably whip up some psuedocode quick to illustrate that, if needed.
That would definitely be handy, I know very little about coding lol. And thanks for the kind words!
Feel free to DM me about it too, I didn't mean to take away from Soul's discussion
❤️ pony haters gonna hate
And cool, mind if I DM you it so as to... okay lolz, already answered that haha
Kahlua isn't the most verbose when it comes to error messages, and I'm not a pro at its finer points. Google tells me this error is often the result of mod conflicts, so eliminate any other mods you may have and only run the one you're working on. Then add some test code to where the null value may be.
yeah i was immediately going to suggest that you make sure you're not running any other mods
Ok. I try to disable the other mods. But this already happens on startup... Give me a second...
error is pretty clear, the Recipe table seems to not have a OnCreate table inside of it attempted index: CutFish of non-table: null (this states OnCreate is returning null)
2 questions:
a) is your file in server? (not client or shared?) though it should be failing on OnCreate if this is the issue... which leads me to the second question
b) is something overwriting the Recipe table?
As your stating the Recipe table seems not to have OnCreate but I don't know why. It's defined in the mentioned file. I also thought about that it's maybe an loading order so I already moved it from client so server to test, but the same error happened (I'll retest this again in the next minutes). So to answer your questions:
a. It is currently on client because as far as I know the order is: Base stuff (all) -> shared -> client -> server
b. not that I know, based on the other replies I removed every mod than mine...
For info I'm testing on Solo right now...
i moved some of my own recipe code into client and it totally broke, so that's your issue
it needs to be in server
the Recipe table is defined in a file in server folder, the server files are loaded last, so trying to reference it before its loaded (from client/shared) will cause it to error
Ok... I move it again...
I still get the same error when the file is on server...
Side comment, if anyone can point me in the right direction.
Need to figure out how to save a single int to a persistent storage, to track a counter between sessions. Prefer it to be both MP/SP compatible, though with MP, others don't actually need to access the data of other players.
@weak sierra @hearty dew So I've conducted a binary search on the mods and I've come to the conclusion that it's mostly https://steamcommunity.com/sharedfiles/filedetails/?id=2809058492 causing it.
But I'm not sure if it's just the size of the mod causing it or if it's actual genuine errors causing memory leaks. There's still a visible spike in ram, but it's more like 5gigs, rather than it just nuking all of the ram on the system
Isn't there a kind of namespace conflict between java object and Lua Recipes? (asking just to be sure)
I have noticed that there are multiple vehicles which are broken in one way or another or not made properly, but I'm not sure if that could cause leaks
i use the full version of that pack and while it's big it doesn't leak just takes a lot of memory afaik
"Motorious Zone" one
idk if the american-only 1993 one has issues
fhq and 1993 pack are 2 different packs
fhq is arguably just.. better
but a 223MB mod causing 10gig of RAM to just be erased is a bit confusing
use global moddata:
local modData = ModData.getOrCreate('unique string key')
if not modData.yourValue then
modData.yourValue = 0
end
and then just mess with modData.yourValue as normal and it'll be saved
huh technically, yes there is a conflict (never noticed this), however this should be a non-issue if the file is in server... the Recipe table definition in recipecode.lua should overwrite the exposed Recipe.class in lua's global table.
but that would explain why this was false in my first assessment: though it should be failing on OnCreate if this is the issue if the file was in client/shared
Oh, that's amazing, thank you. I'll go check that out now!
You're a gem ❤️
Woohoo! Another easy answer without me having to use a lazy token! I was going to trawel through my old PZ modding notes this weekend for that.
I think the thing must be white to take texture
Imean color
Oncreate function
Then do bunch of zombrands
Oops sorry someone already answered the question
Actually no, that doesn't fill my needs. Guess I still have to dive into old notes again. 😦 If I don't come back, send a rescue squad.
Sorry, I think I fucked up my testing... It has to be on the server but when I tested I moved the file to server. But somehow I generated a second one in the client folder. I don't exactly know how. Maybe already opened tab in VS Code and saved again or something like this.
Thx @quasi geode was a stupid issue. Today seems to be not my day... I already asked a lot of stupid questions...
Maybe I should start taking down notes for modding like I do for my geology class lol. Maybe then I wouldn't be quite as big of a dummy haha
Ill be honred to help you with your random recipe if you still need help on this
Ah I'm currently working on getting the models themselves into the game right quick, fixing sizing, etc. I'll let you know later on if I need help!
Because of my error:
How do you guys work on the mods? I currently have a git repo and a deploy script which copies the files to my userfodler. Before that I edited my mod in place. I'm still not sure what's the way for me...
Lol is somebody keeping a list of people with stupid questions?
oops now I am in it
What qualifies as a stupid question?
(Damn this question is going to add me to that list . But i cant help it)
Yes, give it to me :-p but sometime I have some expections to myself. So if I ask something that I think I should have known...
What ever.... Thx for your help 👍
I generally use a symbolic link pointing from my git folder to pz's mod directory. saves any copy/paste messiness
Ok, thanks... I assume you're using linux. On windows I don't trust the linking stuff 🙂
ya i use both but mostly linux for any dev stuff
Ok... I'm wondering what other windows users do...
At home I'm a fully windows user 😄 (exept for my raspberry stuff etc.,)
I mean, I create/edit them directly in the workshop folder... lolz
yeah i just have a bunch of git repos in the workshop folder
I don't even bother with Git for them; I'm not currently collabing with someone nor need access when away from PC, so no need for the extra clutter files from Git, IMO (your mileage may vary based on if you actually need access away from main PC or if you collab, for example).
i haven't had anyone collaborate with me yet, it's just that it allows me to use github as a portfolio
That's fair; not a terrible idea either.
BTW that suggestion worked like a charm @bronze yoke, thanks again ♡
i'm glad that worked ^_^
Cash mod is almost complete lolz
Now the actual hard part... figuring out how to make use of the ATM objects..

My understanding is you stick a card in it, pound on it with a hammer, then money comes out.
Ooooh. Have you thought about trying to implement the fact that credit cards are droppable items? So like, guess their pin number and get mola.
Nah, making it easy on players. Well, relatively easy. They're gonna have to create a credit card skimmer/hacker. High elec skill, a cash register, and several materials will combine into one.
Then they can skim the cards that get dropped/found in wallets.
I certainly wouldn't be opposed to looking into that idea though; but I would need to also learn more about how to attach a random pin number to each card item, and have that saved across instances.
Make 20% of the pin numbers == 1234
out of curiosity, how does this differ from better money system?
Wait... thats my luggage combo...
<insert SpaceBalls reference here>
Can't say as though I've looked into the details, but the premise is to make the one I'm working on as compatible as I can with both vanilla and other mods, as well as I'm using it in conjunction with other mods I have, as a modular mod system; it can be used as a base for a storefront, when combined with some of my crafting things, for example.
As to specific differences...
no clue lolz
hmm yeah, better money system isn't the most compatible as it uses its own money items
Look into how locks work.
As does mine, however it lets you convert between the vanilla "Money" item, and the one dollar bills mine adds; no cost, almost instant. Can convert back and forth for compatibility.
To expand on this.. mine lets you search wallets to find cash, but if you use some other store/trade/whatever system that uses the vanilla money item, you can always right-click the modded bills, and convert them to vanilla of the same amount... a 20 bill converts to 20 "money" for example.
Bottlecaps!
Oh, excellent point.. I'll look into that. The PIN guessing might not happen til a future update, but it's a great suggestion.
Calm down there pip haha
Considering the lack of contextual entry, you'll probably have to use the chat dialog to guess the number.
Yeah, that's the thing I think will be the hardest with an ATM, even with just withdraw/deposit.
I have no idea how to do a thing with UI elements yet lolz
I'd say just use chat instead of trying to make a custom UI.
Add a contextual menu option (right-click menu) to start the interaction, then read chat text input by the interacting user. In the future, provide a custom UI, but that's probably daunting enough that it'll cause you to drop the project if you're like me.
Chat could be an option too, yeah. Still, another area I'm unfamiliar with in the slightest, so no matter which way I go on it, it'll have some learning involved haha. Which I def don't mind; I just love making mods people will enjoy. But I wanna make it easy to use, which is why I was leaning towards the UI idea. Players are familiar with right-click on an object to use, etx.
There are a lot of examples of adding a button to the contextual menu. Its the graphical UI thing that'll be super daunting.
ui is a nightmare
- nod, nod -
Yeah, I don't disagree there. I might have the first released version of the mod be a bit cheesy to start, and work on it from there. V1 might simply let you withdraw the entire balance from the hacked reader, and deposit individual bills from inventory.
Immersion-breaking for sure... but then again, being able to craft a card skimmer is kinda fantasy in the first place lolz... at least for the average person IRL
in the 90s you would have needed a dialup connection to even handle the transaction anyway
I've never worked with containers, but another UI option is to have the ATM be a container object that's populated with dollars based on the account, then it reads amount added/removed to update the internal value.
yeah, true. so even if someone had the skill to make one... internettttt.... lmao
Yep! They'd also have a finite amount of cash, and a card reader wouldn't get you the pin, but I figured we were fudging the realism a bit.
my work on your mod is part of why i say that lol
....we'll just pretend they're all satellite connection, and infinite batteries >.>
and thats clean ui code have you taken a look at vanilla XD
And matter transporters for infinite bills!
well minus the function overrides to fix bugs in the vanilla code
it is very intentional that none of my mods interact with ui in a major way
So yeah, immersion isn't exactly required for how to withdraw/deposit funds I suppose LMAO
lol
as soon as i start doing ui everything becomes insane and there's massive blocks of code to do literally one thing
I wonder... I could probably make a requirement that the skimmer needs to be near power. That would solve that realism aspect at least.
now, if they had to find an ATM and power it to take the money out, and each atm only has so much money 👌
I had that thought too, yeah. Just working on baby steps one at a time, but yes lolz
that being said, the best way to get the money out of the ATM is probably the propane torch
Honestly realism is overrated. What's the point in pushing realism in a video game if I can literally go to a restaurant and see people wearing photoshopped hats?
i like how low level the ui code is gives a lot of flexibility but can understand why others dont XD
all depends on what you want out of the game, I only select mods that are "believable", if not entirely "realistic"
It irritates me that I can't use a crowbar to pop the trunk on wrecks, or pop open doors instead of having to break them down.
there's a mod to open doors and windows with crowbars, don't think it works on trunks though
oh, nope, it does work on trunks
you can use a crowbar to remove the entire window in vanilla iirc
lolz... why open a window, when you can simply remove it?
Just replace it after ya climb in, and boom, same thing.. kinda hehehe 
You can also use a hammer and screwdriver to dissassemble a locked door.
personally i don't like that it works on garage doors, that sounds like a huge stretch to me, so i've stayed away from the mod
Which is nifty, but they need to make that not possible with the security doors. I know there's a mod that does so, but I feel like that's something that was overlooked in the base game haha
it only opens the 1/2 or 1/3 of the garage door you're using it on too, lol, its a little jank
"A burglar can open a garage door from the outside in a matter of seconds with nothing more than a wire coat hanger. All they have to do is use a tool to pry open the top edge of the door, drive the hanger through the opening, grab the cord with the hook and pull."
Coat hangers, what can't they do?
if it is possible, i still don't like it from a balance standpoint, garage doors usually guard higher tier loot, but you could say it just brings the crowbar closer to the axe which can get through garage doors pretty easily too
Hmm, didn't know the axe could take them down.
most of the residential garages have windows anyway
well they don't usually have great loot, but stuff like the lockups
true true
Makes sense I guess. I was surprised when zombies broke down a garage door, last I remembered garage doors were impenetrable.
Would be nice if the military-style lockers had actual locks on them sometimes. Kinda the point of them in the first place; secured storage containers.
i wouldn't mind something like that
crates can have locks like that, it should work on all containers imo
Would be especially nice for MP servers so we can turn looting on for safehouses (I mainly keep looting and fire off, for reasons), and have players still able to securely store things in their safehouses. Would allow me to have players buy the safehouses ("rent" basically), and only leave the respawn and fireproof settings on.
Does anyone know where the code is that detects if isInfected is true and manages the zombie infection progression? I've been trying for 3 days to find that code.
I want to find the list of variables modified and their initial values when an infection just starts.
I think part of my problem is I don't understand the Lua event system and how it operates.
Does items consume energy when the chunk isn't loaded? ie. generators, car batteries, flashlights etc.
it seems to be this section in zombie.characters.BodyDamage
int var13;
if (!this.isInfected()) {
for(var13 = 0; var13 < BodyPartType.ToIndex(BodyPartType.MAX); ++var13) {
if (this.IsInfected(var13)) {
this.setInfected(true);
if (this.IsFakeInfected(var13)) {
this.DisableFakeInfection(var13);
this.setInfectionLevel(this.getFakeInfectionLevel());
this.setFakeInfectionLevel(0.0F);
this.setIsFakeInfected(false);
this.setReduceFakeInfection(false);
}
}
}
if (this.isInfected() && this.getInfectionTime() < 0.0F && SandboxOptions.instance.Lore.Mortality.getValue() != 7) {
this.setInfectionTime(this.getCurrentTimeForInfection());
this.setInfectionMortalityDuration(this.pickMortalityDuration());
}
}
if (!this.isInfected() && !this.isIsFakeInfected()) {
for(var13 = 0; var13 < BodyPartType.ToIndex(BodyPartType.MAX); ++var13) {
if (this.IsFakeInfected(var13)) {
this.setIsFakeInfected(true);
break;
}
}
}
oh, sorry, actually, this is something you were asking about the other day
i didn't read it fully and assumed it was the same 😅
that part is in the same file though
no, everything updates when they load.
Thanks that was my issue then!
How does it handle time passed?
I leave generator running, leave town for 2 irl days, return - should be 0% fuel right?
generator saves last time updated, think food does too
Alright, would DRAINABLE items do so too or should I code it in myself?
generator has a loop for passed hours and loops that many times
I wonder how newly generated items handle rot 🤔 , if its been so much time since the power went out they rot immediately I guess, since the game can assume there was no refrigeration all that time
Can you freeze food in game by putting it outside in the winter?
what kind of item, with batteries? not sure
also, looping the generator so many times seems kinda silly, lol. Coulda just done some quickmaffs
to be fair that only loops condition and fuel
If you leave while the washer/dryer is running, does it figure out when the cycle is done and draw less power after that?
It updates devices before loop, so probably the washer wouldn't count at all? Or more likely counts to be running all the time, considering it only updates it's list and not the actual devices.
I looked at this code 50 times and didn't realize its what I was looking for. 😦
For instance, you come back and it decides the freshness based only on the current state of the generator so it's either frozen all time or not.
hmm, so if you're moments from running out of power you should drive away and not come back until you have more fuel
I was considering figuring out a way to attach fuel barrels to the generator, but this makes things more challenging
best come just before it runs out, otherwise it will rot, I think.
well if it calculates the amount of rot based on the "current" state of the generator when you reload, is that current state before the generator does its cycles or after. If its before, as long as there was at least one cycle of power left then you're fine
looks like it runs after to me
driving away will actually make your food rot marginally more
that would prevent abuse, so it makes sense
Is there a way to schedule a function to run without using the timed action events?
I've seen people subscribe to the OnTick event and then have it trigger your function when you want it to. Dislaik or Tyrir may have even made an api for it by now
theres probably a few api's for it. heres mine.. bit dated now, that theres a event every minute (making its OnTick use redundant), should probably update it
is there a unique persistent identifier for a character, not an account? steamid and username are account wide and the same for splitscreen characters, and player num and online id aren't persistent
i'm considering just keeping my own identifier in player mod data, but is there a better way than that?
Does sqlID fit those requirements? I don't actually know
If not, I was going to say I think you'd have to create your own. Can generate a guid/uuid and stash it in player moddata
(or similar random number)
i don't know actually, i know new characters replace old ones in the sql but i don't know if the sqlid stays the same when that happens
do characters have a sqlID like vehicles do? I bet that would work
if there is anyone here thats doing a weapon crafting mod please consider using my mod's items as material. and just have it set as require.. thnx https://steamcommunity.com/sharedfiles/filedetails/?id=2882228912
Javadoc Project Zomboid Modding API declaration: package: zombie.characters, class: IsoPlayer
Can use getFieldValue to retrieve it
no good :( guess i'll just use a guid then
I was hoping there was a creation timestamp or something similar so you could use a tuple, e.g. (username, creation timestamp), but don't see anything usable in that way
i'm guessing from the way the sql is formatted that you might be able to consistently get the same splitscreen player with that, as new characters overwrite your old one - if a splitscreen player died and then left the server it would probably get lost though
look at me writing all this code for splitscreen when nobody in the universe, myself included, plays splitscreen
playerindex might do that anyway actually...
I didn't think anyone played with a controller either, but...
Hi, i search to modify items in container each time an item is removed from/added in a container
I tried these events : OnContainerUpdate and OnRefreshInventoryWindowContainers
None of them seems to work for this
I don't even know how to trigger them
for controller i know burryaga exists at least, but i don't know about splitscreen
When an admin activates SendCommandToServer("/reloadoptions"), can I catch that in my client folder? Or would I have to catch the command server-side and send a command to the clients from there? And would I catch it with OnServerCommand or OnClientCommand? I'm not sure, but as I'm reading the Lua Events page, it sounds like I would catch it serverside with OnClientCommand, and then I could use the global sendClientCommand to reply to the client, and I could catch that in a client file... Is this how it works? Anyone care to enlighten me?
I don't know the answer, but if I were to look I'd start with timed actions for using containers
How can i do this ?
The server doesn't load the client code, you would have to put it in /Shared or /Server. It would be OnServerCommand IIRC
OnClientCommand is for SendClientCommand, not SendCommandToServer
Actually I'm wrong, if you want to catch the command BEFORE it gets sent to the server, then you'd do it clientside
by decorating SendCommandToServer, if possible
Also, do you need to catch the function call, SendCommandToServer, only? Or also an admin typing /reloadoptions in the admin chat tab?
if not chatCommand then
if luautils.stringStarts(command, "/") then
SendCommandToServer(command);
Oh, the chat tab input is converted to a call to SendCommandToServer lua-side. I had thought it was done in the Admin chat tab object java-side. nm
so I'd expect the approach of decorating as described above would work
Again, I don't know the best answer. I'm fairly certain that transferring items to or from a container is a timed action, so if I wanted to figure out how to change that I'd find the action first in the code and come up with a plan.
most likely I'd decorate the action, or the function that calls it, but maybe it actually does throw an event you can listen for, I really don't know
I am confused, sorry... you're saying I need to use OnServerCommand to reply to an admin sending /reloadoptions?
@hearty dew
No. OnServerCommand is an event for SendServerCommand. OnClientCommand is an event for SendClientCommand.. SendCommandToServer is unrelated, despite the name similarities
Oh... crap
Hey everyone, looking for a way to get the moodle sprites from the game, cant find much documentation on it though
This should do what you want
I seeeee.... anyone happen to know where to find SendCommandToServer?
I'm seeing calls to it but not the def
Ohhhh, so I need to patch it
Yea
On a related note, anyone remember the way to call servermsg without doing SendCommandToServer("/servermsg")? someone posted it here and I was dumb enough to not write it down
You only need this handled on the admin's client, I'm presuming
The client-side pop up?
I don't understand the question, what pop up?
I was hoping that when the admin sends /reloadoptions, I could have the server send a client command signal to every client, and have every client react
you'd probably have to patch SendCommandToServer to SendClientCommand to then SendServerCommand... that is a lot of commands
found it, you posted it right here
There's a popup with certain admin broadcasts to all players. I was probably making some spurious assumptions about what /servermsg is and thought maybe that was the effect you were looking for.
that's what I was thinking from this convo... and yeah, oof
yeah that's really ugly, i hope there's a better way of doing things
yea, that just creates a client-side text popup```lua
AnonymousUtils.showNotification = function(message, durationInMs)
ISChat.instance.servermsgTimer = durationInMs or 5000
ISChat.instance.servermsg = message
end
i've gathered that intercepting chat commands is a nightmare though
or like, anything to do with them really
so if you do that server side, the text doesn't get sent to everyone?
nope
Bummer, but I can still use it
My concern is that I still don't know a very key step in my goal... I still don't know how to update my mod options setting in-game and then hop into the menu and see that change reflected.
You can do something using SendServerCommand and OnServerCommand with an event handler that calls showNotification
Nice pro-tip, that would be a nice touch
SendServerCommand allows you to direct a command to a particular client, right? Does it have broadcast capabilities or do you have to loop through the users yourself?
I have a few functions that make sending server/client commands like this a bit easier, if it'd help
I won't turn down learning from ya @hearty dew, though I do not know whether or not the code you have will make the difference or not. If I can't figure out how to make my mod options updates show up live in the options window when I open pause menu, the rest of my ideas won't get the job done...
That key final piece of the puzzle still eludes me
If you need every client connected to the server to act upon that command, that's what I'm thinking as well. If there is a lua-side way to react to the admin command, I don't know it offhand. There might be an event specifically for it. That'd be worth checking
Yes. It has both. If you provide an IsoPlayer object as a parameter, the command is send only to the client that has that IsoPlayer. If no player is provided, it is broadcast to all clients
Yeah not seeing anything... is there any more comprehensive list of events we can catch than this? https://pzwiki.net/wiki/Modding:Lua_Events
Can print out the fields of Events
Oh good idea
IIRC you can get it here .../ProjectZomboid/media/texturepacks, are UI.pack or UI2.pack you need unpack.jar, but I can't remember where I get that some time ago, but it's on the forum
sec, I posted it some time ago actually
Thanks
I got it now, but unfortunately the unpacker hangs for seemingly forever on UI2 :-(, hoping it'll eventually do it
.
thats what I thought, I'd just never tried
yeah the events page is getting a little outdated and is just inaccurate sometimes
i sent a pull request to clean up some of the omissions/errors i've noticed but it doesn't look like the host uses github very often anymore
local info = function(tag, s)
print(tag..s)
end
local debug = function(tag, s)
print(tag..s)
end
local error = function(tag, s)
error(tag..s)
end
YourUtils = YourUtils or {}
--[[
Server/Client Communication APIs
]]
YourUtils.CommandModules = YourUtils.CommandModules or {}
YourUtils.CommandModules.YourUtils = YourUtils.CommandModules.YourUtils or {}
if YourUtils.onClientCommand then Events.OnClientCommand.Remove(YourUtils.onClientCommand) end
if YourUtils.onServerCommand then Events.OnServerCommand.Remove(YourUtils.onServerCommand) end
YourUtils.onClientCommand = function(module, command, player, args)
local commandModule = YourUtils.CommandModules[module]
if commandModule then
local commandFunction = commandModule[command]
if commandFunction then
if isDebugEnabled() then
local playerName = player and player:getDisplayName()
local playerID = player and player:getID()
local playerOnlineID = player and player:getOnlineID()
debug("YourUtils.onClientCommand", string.format("Client->server command (%s.%s) received "..
"with player (%s, ID=%s OnlineID=%s) and the following parameter:",
module, command, tostring(playerName), tostring(playerID), tostring(playerOnlineID)))
--YourUtils.inspectAll(args)
end
local results = { commandFunction(args, player) }
if isDebugEnabled() then
debug("YourUtils.onClientCommand", string.format("Client->server command (%s.%s) return values:",
module, command))
--YourUtils.inspectAll(unpack(results))
end
else
error("YourUtils.onClientCommand", string.format("Unknown client command (%s.%s)", module, command))
end
end
end
YourUtils.onServerCommand = function(module, command, args)
local commandModule = YourUtils.CommandModules[module]
if commandModule then
local commandFunction = commandModule[command]
if commandFunction then
if isDebugEnabled() then
debug("YourUtils.onServerCommand", string.format("Server->client command (%s.%s) received "..
"with the following parameter:", module, command))
--YourUtils.inspectAll(args)
end
local results = { commandFunction(args) }
if isDebugEnabled() then
debug("YourUtils.onServerCommand", string.format("Server->client command (%s.%s) return values:",
module, command))
--YourUtils.inspectAll(unpack(results))
end
else
error("YourUtils.onServerCommand", string.format("Unknown server command (%s.%s)", module, command))
end
end
end
Events.OnClientCommand.Add(YourUtils.onClientCommand)
Events.OnServerCommand.Add(YourUtils.onServerCommand)
--[[
Usage example:
YourUtils.CommandModules.MyModule = YourUtils.CommandModules.MyModule or {}
YourUtils.CommandModules.MyModule.myCommand = function(args, player)
for k, v in pairs(args) do
print(string.format("args key=%s value=%s", tostring(k), tostring(v)))
end
end
local function myFunctionThatDoesBigThings(some, things, player)
-- Do big things ...
-- Only basic lua objects can be passed inside args. Java objects, like a player object, cannot.
-- But an online player id can be transmitted because it is simply a number.
local args = {
importantThing = "whatever",
otherThing = 25,
}
YourUtils.sendRemoteCommand("MyModule", "myCommand", args, player)
end
Notes:
If server-side provides a player parameter, the command is sent to the udp connection
that player is on. However, the receiving client does not receive that same player object
in its command function.
If server-side provides nil for the player parameter, the command is sent to
every udp connection (That means only _one_ event per client, even if that client has
multiple split screen players).
If client-side provides a player parameter, it must be a local player (one of the 4 possible
local split screen players), otherwise the command will not be sent. When the server-side
receives the command, the provided player object is used to distinguish which of the 4 local
split screen players the command is tied to by providing the player object as a parameter to
the server-side command function.
If client-side provides nil for the player parameter, the server side command receives an
unspecified local player object in the command callback. If there are multiple local
players (e.g. split screen), any of the local players may be used, which may cause issues
in split screen multiplayer if this command expects the player object to be set to a specific
player.
]]
YourUtils.sendRemoteCommand = function(module, command, args, player, sendClientCommandEvenInSinglePlayer)
if isServer() then
if isDebugEnabled() then
info("YourUtils.sendRemoteCommand", string.format("Server->client command (%s.%s) sent", module, command))
end
if player then
sendServerCommand(player, module, command, args)
else
sendServerCommand(module, command, args)
end
elseif isClient() then
if isDebugEnabled() then
info("YourUtils.sendRemoteCommand", string.format("Client->server command (%s.%s) sent", module, command))
end
if player and not player:isLocalPlayer() then
local playerName = player:getDisplayName()
local playerID = player:getID()
local playerOnlineID = player:getOnlineID()
error("YourUtils.sendRemoteCommand", string.format("The player object parameter "..
"(%s, ID=%s OnlineID=%s) provided to command (%s.%s) is invalid because it is not a "..
"local player (e.g. one of the split screen players). This will cause the command "..
"to fail to send. A local player should be provided or nil if the receiving "..
"server-side command does not need a player object.",
tostring(playerName), tostring(playerID), tostring(playerOnlineID), module, command))
end
if player then
sendClientCommand(player, module, command, args)
else
if isDebugEnabled() then
debug("YourUtils.sendRemoteCommand", string.format("No player object provided for "..
"command (%s.%s). An unspecified local player (e.g. one of the split screen players) "..
"will show up as the player object to the server-side command.", module, command))
end
sendClientCommand(module, command, args)
end
else -- Single player
if not sendClientCommandEvenInSinglePlayer then
error("YourUtils.sendRemoteCommand", string.format("Command (%s.%s) called in singleplayer",
module, command))
else
-- Calling sendClientCommand appears to work in singleplayer (but sendServerCommand does notthing).
if player then
sendClientCommand(player, module, command, args)
else
sendClientCommand(module, command, args)
end
-- Alternatively, we could invoke the command directly, but if the receiver modifies args,
-- the sender would be affected by those changes, so the semantics aren't quite identical.
--YourUtils.CommandModules[module][command](args, player)
end
end
end
Sec, I was in the middle of changing all my print statements to use debug, info functions. Forgot about that..
Fixed that.. not in the best state, but should work hopefully
Oh... but in UI you have what are you looking for
I do actually, thanks for making me take a double take there, had to look for it
Thanks, I'll definitely study this and learn from it if nothing else
YourUtils.CommandModules.MyModule = YourUtils.CommandModules.MyModule or {}
YourUtils.CommandModules.MyModule.reloadAllClientOptions = function(args)
YourUtils.sendRemoteCommand("MyModule", "reloadClientOptions")
end
YourUtils.CommandModules.MyModule.reloadClientOptions = function(args)
-- Put client-side stuff here to actually reload the options
end
local old_SendCommandToServer = SendCommandToServer
function SendCommandToServer(command, ...)
if command == "/reloadoptions" then -- Not certain this is the actual string. Double check that
YourUtils.sendRemoteCommand("MyModule", "reloadAllClientOptions")
end
return old_SendCommandToServer(command, ...)
end
❤️
I'm deciding whether to tackle my own menu first, or to try to find a way to force option updates to appear live in the menu...
@astral dune Can use this to to have one client send commands to all clients. Put a call to AnonymousUtils.showNotification in reloadClientOptions. You can pass a table containing arguments (e.g. the message text)
I'm thinkin maybe if I do my own menu first, I'll learn the answer to the other thing, or maybe even find a workaround. I dunno.
(just my own options tab)
Lookin at how Players on Map does it, their option tab looks pretty clean
Mod options nor that mod options alternative with more widgets (can't recall the name atm) won't work for ya?
I haven't tried that config menu
Mod Options is working but it has 2 limitations that I would like to overcome
1st, purely cosmetic, I'd love to move my options to my own tab
mcm does #1
That's tempting to try to switch. However, before converting everything, I'd probably want to test an MCM mod to see if I can meet goal 2: when I set one of my mod's options in the debug console, I want that change to be reflected next time I go check my Options
That is not the case in Mod Options. If I just set the option, or call :set() on the data object, the value changes, but the appearance in the menu will suggest it hasn't
I found the answer : OnRefreshInventoryWindowContainers on Server side
nice
Hello, I just joined the server, I've been making a car mod following the steps and using other mods as a guide for mine, because there aren't any more tutorials than the ones in the forum. I just discovered that there's a Discord server, so here I am. My mod seems to be working ok. I'm just having this problem that the car is not showing any damage or blood. It stays visibly perfect until a window breaks completely, and you don't see the window texture anymore. What's happening here?
Also just seen I had to post in #mod_development and not in #mod_support
you need to make damage and blood textures
Did you by any chance have the name correctly?
Or do you have a texture even?
Can you upload a mod to the workshop without owning the game? 🤔
In the shared folder I have a lua file with an OnGameStart event...
I expected that the file is executed on client and on server side. But if I do the following print I can find it only in the console.txt but not in the coop-console.txt.
local function OnGameStart()
...
print("OnGameStart Server: " .. tostring(isServer()))
...
end
Events.OnGameStart.Add(OnGameStart)
Output as expected in console.txt:
OnGameStart Server: false
But nothing in coop-sonsole.txt. Shouldn't shared code also be executed on serverside? Or is OnGameStart only a clientside event?
I would expect Events.OnGameStart.Add() to throw an error if Events.OnGameStart doesn't exist. Are there no errors in the co-op console?
its a client side event
So far I couldn't find anything in the coop-console.txt. For sure I can say no Error/Exception...
I've definitely had errors because I tried to add to an event that hadn't been created yet, I'm surprised that works from the shared folder at all, unless that event is added by the vanilla shared code. Strange that it would be a client only event in that case
Ok, thx... So I check for something else.
Based on the statement of Fenris_Wolf I assume that the Event just never fires on server side...
ya it doesnt trigger on the server side at all
I moved the code to OnServerStarted so now it will be executed on server. What I am missing now is the solo game. What I do in the function is add some Events or replace functions based on my SandboxVars. So if something is enable I set for example :
ISReadABook.isValid = SoulMod.ISReadABook.isValid
-- or
Events.OnZombieUpdate.Add(SoulMod.ZombieUpdateModData)
What I realised now is that some of my stuff should only be executed on clientside but for the other stuff it should be executed on serverside or when it's a sologame. Is there an event which only is being executed on server and solo game? Or an event that is exectued for all (client, server, solo) so I can check what should be executed (isClient(),isServer()).
I just don't want to double code. The reason I put in the onGameStart event was that I can't access the SandboxVars when the scripts are initialized (at least I think I did it because of that).
I know that I can use both events and put the part in a shared function and execute it from both events. But I just wondering if there's a better solution for this.
anyone use EmmyLua? And know how to alter/disable the autogenerated file headers?
for i, j in pairs(Events) do
local c = 0
local limit = 10
j.Add(function(...)
c = c + 1
if c == limit then
info(" >==-- Events."..i.." "..tostring(limit).." events raised. Discontinuing")
elseif c < limit then
info(" >==-- Events."..i)
end
end)
end
Try having this run both client-side and server-side. It will give you a good idea of what events fire when
Thx... I'll try this.
math.floor(value)
Oh! I thought math.* functions were blocked in kahlua.
Huh. Color me flabbergasted. And here I thought I had to twist myself into a pretzel to do basic things.
That was my lazy token for the day. Now all I need to do is remember how to store a value on the player object to give spent points persistence.
player:getModData().yourvalue = whatever
That must be relatively new. This is what I used to do:
`local player = getPlayer();
local steamID = getCurrentUserSteamID();
local dName = player:getDisplayName();
db[steamID] = db[steamID] or {};
dbref = db[steamID];
--dbref["descriptor"] = player:getDescriptor();
dbref["weight"] = player:getNutrition():getWeight(); --float
dbref["isFemale"] = player:getDescriptor():isFemale(); --boolean`
its not new XD
Last time I did mods for PZ was a very long time ago.
i've never seen anything like that 😨
its been valid for as long as i been modding pz (5 or 6 years now?)
I was writing a bioprinter mod a while back but abandoned the project when I stopped playing PZ. The idea was when you die you 'respawn' at a bioprinter object that prints your body out of meat you stored inside it.
It might be that moddata existed and I just didn't kjnow about it so was trying to hammer out something more complicated than it needed to be.
was added around 2013 or so I think
Yeah, that was before I was last playing PZ. So I was just doing things the difficult way.
what was that db table you were accessing? Did you have access to the player database?
No, I think it was just a local var that I was storing data from.
the player database however, is new (build 41 stuff)
Yep, that's all it was.
When I was doing the bioprinter stuff, it was definitely pre 41.
Its still a fun idea, making you print your own body from meat paste. The whole idea behind it was that you're a time traveler sent back in time to find patient 0. Once you find them, you sent them back to the future so a cure can be made. You, of course, are stuck in the past during the height of the infection.
Only enough power to return one person to the future, and that's not gonna be you.
hey guys, anyone know why Britaas weapon pack wouldnt work?
any expert out that can suggest a mod to craft fridge and other stuff???? also i played at a server and to craft more things u used to get magazines that u read 1 time from zombies any mod like that maybe????
no
this came up in the rimworld community stupidly often
partially cuz there was a GOG release
thats a shame. For privacy reasons I wouldn't want to release a mod from my main account, but also don't want to buy a second copy of the game either

