#mod_development
1 messages ยท Page 77 of 1
That works too, if you know that max is definitely always greater than current. The math.abs is just to ensure that it works when comparing it with a target value that it might be greater than or less than.
Poltergeist actually came up with the fix - seems as though it was triggering events with "no player" or the wrong "player".
I'll have that in mind, might need it at some point, now I just needed the greater than cases.
Excellent. I sense that I'll want to use this method of decoration (rather than using the event) rather soon ๐
I also wasn't able to solve the TV issue - so I just locked it out behind a sandbox option
I wanted a way to prevent stacking of XP earned from the same shows - but it would require hard overwrites of a few files
Hi everyone, does anyone know why when I change the description of my mod via steam, it changes the info on mouseover of the mod but not the description on the workshop page? Do I have to do it manually from my mod file?
U can change via steam page
There's two files - one for the workshop and one for the in-game mod. "Mods" can have as many "mods" as they want inside.
a better way to express it is, you have a workshop item, which can contain one or more game mods
The outermost folder structure should be "workshop package" and you have all your mods in the WP's contents folder
Ye
Great minds and all that
Wouldn't the suggestion I made before solve the tv problem? Rather than having skill journal give you skill levels outright make it give you a multiplier that equals the amount of skills you got. So if you had level 10 carpentry than your modifier will reflect that as if you read all 5 skill books.
Perhaps, but you'd still gain something from watching TV, dying, and watching it again
People were abusing the journal and dying on purpose
Yea but you won't gain on top of levels the journal gives you for free. It will just help build you back up
Yeah, it would be a nicer solution than having to force them to rewatch the TV shows
at that point, couldn't you have the journal record the TV shows they watched
well, if they read it afterwards you can examine what shows they snuck in and apply a penalty for the ones that match
And the radio interaction stuff is all localized to the point where I'd need to rewrite it all
Oh..my bad, I had modified the page for English readers and my workshop is set up for my native language. Thanks for the answers.
I was able to decorate addXP which let me at least identify what function was calling it
I don't think having it ignore TV XP is too bad for now
Kind of don't wanna touch the mod for a bit lol
My 5 comments a day has returned to 0 - which means the mod works
YoUR mOd cRasHeD mY GaMe
I also made the mistake of making sandbox options apply retroactively
Fun fact: don't do that
Thought I was smart - as new sandbox options appear as nil - so I made it account for that and apply what I made default. When I should have made it so what ongoing players expected.
at least you struggle with the complicated stuff... i struggle with everything in lua ๐
it was a victory when i managed to make a function that made the player char curse taking text from a randomline in a text a file
almost popped the bottle just to celebrate my victory
Hi guys, new here. Does anyone know exactly how the item 'weight' calculation works in ProceduralDistributions.lua? I'm making a map based on Akihabara and I am wondering why my electronics stores basically never spawn video games from the Video Games Consoles mod. I had a look at his distributions.lua, and he has given everything weights of 0.04. This seems to spawn Video Games ok in houses, where for instance they are competing in LivingRoomShelf with loads of items, many of which have low weights. However, ElectronicStoreMisc or ElectronicStoreMusic never spawn them (in my rough 10-20 test runs) even though the mod adds them to these tables. These loot tables only have a few items and they have high weights, like 10 or 20. Does the number of items on a loot table affect how the 'weight' calculation works? Because it still seems odd that they spawn so frequently in houses in comparison, despite the weight being the same at 0.04.
launch game in debug, visit said building, enable cheat Lootzed, right click container icon in loot panel and check info.
so hey, anyone want co creator credits on my trucking mod for going over it with a fresh pair of eyes?
i know that the turn in screen is wrong, and i still gotta sort out how i give you money, but the rest SHOULD work, and if not i could use the new eyes to look at my brokeness.
Thanks. According to Lootzed, it must just be plain bad luck as they have 0.95% chance in the electronic store vs. 0.45% chance in the house. Will keep testing, unfortunately refreshing the container appears to be setting it to magazines every time 
It adds up all the weights, so in a case with 2 items having 20 and 1 with 0.04 then the total is 40.04
With the 0.04 item having a 0.1% chance per roll
Thank you also ๐
browser!
skizot!
i am scared and would probably complain about too many things
you are SUPPOSED to complain.
i'm not a coder lol.
i'm an artist who uses code to make shit work. not necessarily work RIGHT but work.
Hit me up in 2.5h ill be off work
Hi. Is there anyway to check if a item has been added as a possible find when Foraging?
I cant find the item im looking for that ive added, but i cant tell if i am just being unlucky or its actually not spawning as a possible find as foraging
@sullen bobcat see here for how chances work
Oh! Thank you!
as for seeing it ingame check lootzed not sure if you can see foraging
Do items need to be created on both the server and the client? I tried using sendItemsInContainer after only creating the item on the server, but no luck
how did you do that, are you using the callstack shenanigans you used for fingerprint?
Yep
And then some
addXP calls from Java don't get caught with the decoration
So I have a fallback in Events.AddXP
If it goes through the call stack catch it sets a boolean to ignore the next event trigger
I'll have to scroll back and find that stuff, there are a bunch of places where I could REALLY use that information
If not it does some stuff there unrelated to what the call stack is looking for
the getCoroutineCallframeStack then parsing it with rawTostring2 is the crux of it, right?
does anybody has a link to a blender-addon which can export files as .x?
I don't suppose the callstack exposes the instances of the calling members, but just the file?
if you can't find an answer here I'm sure someone in #modeling knows
There's alot of stuff there but I kept hitting snags trying to get something more elegant
hi! is it possible to put an item into the player's inventory but make it so that it is not displayed in the inventory? one option is to not give the item a "display name" in its script.txt file but this trick cannot be applied in my case. Probably also possible to somehow manipulate the lua code which generates the inventory entries while in-game but I am hoping for a simpler solution...
The display name trick is probably the easiest - why can't it be done in your case?
the items I am working with still need a display name so that they are correctly displayed in the recipes tooltip. without display name, the recipe involving the item would probably show smth buggy-looking like "Base.ItemID" but I want to have it a bit more nice. should still look as in the vanilla game.
wait I saw just yesterday something like isHidden = true that you put in the script
thx! I'll check this out!!
probably doesn't work ๐ฆ
it adds that if there is no displayname
Hmm interesting problem to have
You could make the result the hidden item
OR a bit more involved - edit the on recipe function
Both of those options are easier than manipulating the inventory display
wdym? you mean the Recipe.OnCreate in lua/server?
Yes - recipes have 3 different parameters that can be direct _G. function names
As in they can't be local
One of them is onCreate -- it can be used to add more items as recipes can (for some reason) only have 1 result.
do not yet understand how this might help me
Okey thanks this was really helpful.
My game doesn't throw any errors now and by adding an additional else statement yesterday I actually managed to double the amount of used propane. So it does work in some way at least.
But for some reason my function won't do what it's supposed to and half the propane usage when the right trait is active and an propane torch is used. I suppose it is because the If statement isn't triggering. What could I change to finally get this working?
local DrainableCalc = buildUtil.useDrainable
function buildUtil.useDrainable(count)
local propaneUsed = buildUtil.DrainableCalc(count)
local itemUsed = getPlayer():getPrimaryHandItem();
local playerCheck = getSpecificPlayer(self.playerid)
if itemUsed = "Base.BlowTorch" and playerCheck:HasTrait("Blacksmithmetal") then
propaneUsed = propaneUsed / 2
end
return propaneUsed
end
You could make your recipe use the item with the display name but create a hidden one for your purposes.
it's because this code isn't calling the copy of the function anywhere
May help to know what your end goal is though - perhaps you don't need a hidden item at all?
oh, is it supposed to here? local propaneUsed = buildUtil.DrainableCalc(count)
reload the file will come to bug

a couple issues with this: your copy is just called DrainableCalc, it's not in the buildUtil table - not really sure why you wouldn't just get a straight up error for that
also, iirc, the original function edited the item's condition itself, so it would make more sense to change the count that goes into the function than change the return value
i'll need to check what the return value is actually used for though
oh, it's used for removing the correct amount when you need to source the condition from multiple items
meh, reloading the file is not something you do in normal play and its a bad idea while debugging/developing too
yeah, personally i just reload lua so i've never worried about it
it's right but better to say this info to ppl here cos if they don't know then it'll bug and will come useless questions about why this bugs
cachedfunction = oldfunction or cachedfunction would probably solve it I imagine
but really I would just say don't reload files, haha
or add reload call of original file
better just do like this way, it's safe + same optimise
yeah
Yep, I try to be more specific.
I want to allow the player making a fruit jam out of foraged berries. Problem is that the vanilla game comes with around 8 different types of berries (they are called Base.BerryGeneric1, Base.BerryGeneric2 and some more). Instead of making different recipes for each kind of berries, I want make things so that the player just needs 5 berries of any kind to make the fruit jam. For example, 5xBase.BerryGeneric1 should work, 5xBase.BerryGeneric2 should work and (3xBase.BerryGeneric1)+(2xBase.BerryGeneric2) should also work. So all possible combinations.
We also talked about this problem earlier but all ideas for an easy solution didn't work. Here is an example which didn't work (although the ideas were quite logical): #mod_development message
Using those "hidden items" was one idea of mine to solve the problem but maybe there are different, better and easier approaches...
make a recipe that needs one of these, count them OnTest, remove them OnCreate
there is actually a way to solve this without scuffed approaches
ok, this also a strategy I am palying around with atm. basically just hard coding the recipe in lua code if I get you right. but what I get up to now is still a bit clunky...
instead of specifying specific items you can call a functions to return the valid items
recipe Make Mortar and Pestle
{
Plank,
keep [Recipe.GetItemTypes.Saw],
Result:MortarPestle,
SkillRequired:Woodwork=2,
Sound:Hammering,
Time:50.0,
Category:Carpentry,
}
vanilla example
Yeah, that's the way to do it
I wonder if that supports more than 1? Or I guess you can list it 5 times
function Recipe.GetItemTypes.Saw(scriptItems) scriptItems:addAll(getScriptManager():getItemsTag("Saw"))
end
and heres that function
using Tags and listing it 5x is what I suggested, I'm told it didn't work
scriptItems is an array list
so you just need to add the items you want to the list
no
do you know how I could tell the game that it needs 5 items?
What happens if you try what Blair wrote?
function Recipe.GetItemTypes.Berries(scriptItems)
--add the berries to scriptItems
end
It should say 'can use: xyz' 5 times
You should be able to add that item scan as five different ingredients as well
resulted in a bug for me. described here #mod_development message
iirc, if you listed it five times, one item satisfied all five conditions
recipe Make Mushed Berries
{
[Recipe.GetItemTypes.Berries],
[Recipe.GetItemTypes.Berries],
[Recipe.GetItemTypes.Berries],
[Recipe.GetItemTypes.Berries],
[Recipe.GetItemTypes.Berries],
Result:Something,
SkillRequired:Smashing=2,
Sound:Hammering,
Time:50.0,
Category:Bodybuilding,
}
there you go
Ah that's the issue
ah yeah
You can use onTest to count them
forgor that was a thing
onTest can be used to prevent a context menu to appear if there's less than 5
thanks. I think this is a variant I haven't tried yet. I'll check it and see how it works
1 will satisfy all 5 i think
try
recipe Make Mushed Berries
{
[Recipe.GetItemTypes.Berries]=5,
Result:Something,
SkillRequired:Smashing=2,
Sound:Hammering,
Time:50.0,
Category:Bodybuilding,
}
i don't know if a getitemtypes function was tried, but using stuff like tags still required all 5 items to be the same type, not just 5 different items with the tag
so 1 item can satisfy 5 requirements for an item, and 5 items with the same tag can't satisfy the requirement for 5 tags, lmao. Great system
The system is as robust as they needed it to be - for better or for worse
They can't design with every possibility in mind
Although this is a pretty straight forward idea
i'm surprised this isn't supported but it makes sense
just get a chuckle that they would implement a tag system without allowing you to combine items of the same tag
sounds like using the recipe events you can create whatever functionality you want
Did you try:
BerryGeneric5/BerryGeneric4/BerryGeneric3/BerryGeneric2/BerryGeneric1/BerryBlue/BerryBlack;25,
Yet? (The ;25 should mean you need a total of -25 hunger from all the berries selected to cover your need).
This seems like it'd be a better way to handle it, as your berry jam is likely to have a hardcoded -hunger value.
I use this in my vinegar recipe, full example of that:
recipe Make Vinegar
{
Vinegar,
Water = 5,
Wine/Wine2/WildBerryWine;3,
EmptyJar = 1,
Result:JarOfVinegarBase,
Time:500,
Category:Cooking,
NeedToBeLearn:true,
SkillRequired:Cooking=5,
OnGiveXP:Recipe.OnGiveXP.Cooking10,
OnCreate:Recipe.OnCreate.StartFermentation,
Override:true,
}
(More specifically, this is an alteration of the recipe found in Renewable Food Resources)
So it will let you use any combination of those items as long as it adds up to a certain hunger value? I haven't seen that syntax before
As far as I know, yes. This is how vanilla uses Sugar, for example.
Doing Sugar;5, will let you use 5 hunger worth of sugar, from any number of items. So if you have 10 bags with -1 left, it'll just use 5 of them.
Even if one of them is brown sugar?
Assuming the syntax was Sugar/BrownSugar;5 then yes.
Sugar has a tag doesn't it? I wonder if [Sugar];5, or [Recipe.GetItemTypes.Sugar];5 or whatever will work, and its just using the ; instead of a = that will solve all the problems
The tag should also work, yep.
If not, I've got egg on my face, and work to do for a future mod 
this seems like a very good idea!!
I hope it works! I'm sure I've tested this, but it's over half a year ago so I could remember wrong ๐ค
I havent completely understood crafting food tho o have done some food mods
Idk how to use the evolve recipe thing yet
strange asf but there are still combinations which don't work although they should according to the recipe...
It's possible I left out some of the berry variants by accident.
Or maybe the game tries not to mix poisonous and non-poisonous berries.
Also remember that you need a total of -25 (assuming you set it to ;25) hunger amongst the berries you have in your inventory.
hmm, not sure... looks for me as if the game still only allows berries of one type with that recipe...
Ah, and then it just tries to find -25 in that single berry type?
I'd suggest creating an intermediate step, if the above didn't work:
recipe Crush Berries{
BerryGeneric5/BerryGeneric4/BerryGeneric3/BerryGeneric2/BerryGeneric1/BerryBlue/BerryBlack,
keep MortarPestle,
Result:CrushedBerries,
Time:100,
Category:Cooking,
OnGiveXP:Recipe.OnGiveXP.Cooking3,
OnCreate:Recipe.OnCreate.CrushBerries,
Override:true,
}
Then in the "CrushBerries" function, edit the result to have as much -hunger as the input berry. And change your jam to require CrushedBerries;25
This also adds a tiny bit of immersion ๐
I uh.. Went a bit crazy with my CrushBerries function.
function Recipe.OnCreate.CrushBerries (items, result, player)
local baseHunger = 0;
local hungChange = 0;
local thirstChange = 0;
local boredomChange = 0;
local unhappychange = 0;
local carbohydrates = 0;
local lipids = 0;
local proteins = 0;
local calories = 0;
for i=0,items:size() -1 do
local item = items:get(i)
if item:IsFood() then
baseHunger = baseHunger + item:getBaseHunger();
hungChange = hungChange + item:getHungChange();
thirstChange = thirstChange + item:getThirstChangeUnmodified();
boredomChange = boredomChange + item:getBoredomChangeUnmodified();
unhappychange = unhappychange + item:getUnhappyChangeUnmodified();
carbohydrates = carbohydrates + item:getCarbohydrates();
lipids = lipids + item:getLipids();
proteins = proteins + item:getProteins();
calories = calories + item:getCalories();
end
end
result:setBaseHunger(baseHunger);
result:setHungChange(hungChange);
result:setThirstChange(thirstChange);
result:setBoredomChange(boredomChange);
result:setUnhappyChange(unhappychange);
result:setCarbohydrates(carbohydrates);
result:setLipids(lipids);
result:setProteins(proteins);
result:setCalories(calories);
-- Todo: Adjust freshness
-- Probably disable boredom/unhappiness adjustments
end
haha. ok! that would be a completely different approach. but I prefer still to have a single and easy recipe for it... and it is a miracle that all those proposed solutions which seem completely logical do not work!!! XD but as @sour island wrote earlier, the game comes only with the predefined stuff it really needs...
Yeah it's a different approach 
I wish you all the luck in selecting the one that fits you best, though!
thanks!
@drifting stump again thanks for the idea with the GetItemTypes but this does also not work for me. I just saw that I tried this earlier (several month ago) with no luck: #mod_development message
you can just add a line like this to the item's script.txt entry:
EvolvedRecipe = Stew:3;Pie:3;Soup:3;Sandwich:3;Salad:3;Roasted Vegetables:3,
This example means that the item can be used for cooking Stew, Pie, Soup etc. and requires 3 "hunger value" to be used for it.
Here is more info: https://theindiestone.com/forums/index.php?/topic/15188-item-and-recipe-script-variables-brief-description/
Type = Normal,There are various types of items in Project Zomobid, below you will se each of them with a short description. Normal โ A basic item. Drainable โ An item that has a certain amount of uses before it's destroyed Food โ An item that can be consumed by the character Weapon โ An item that...
Cool awsome ty
Hi I just created an item in blender I'd like to put into the game. I have no clue how to mod the coding for this. Can anyone point me in a good direction?
clothing item or just some other 3d object?
Clothing item. I just repainted a bullet vest.
Does anyone know how to apply an XP multiplier from lua? ๐
#mod_development message
check the command
Ah, excellent.
it's (perk, value, minLevel, maxLevel)
This overwrites the modifier gained from, for example, a skillbook?
Oh, looks easy to get around with the handy hashmap also provided.
Iirc the Java code just loops through all the multipliers in the hashmap, yeah?
yeah, it took about a year for someone to finally work out it was dynamic traits messing up some of my skillbooks
pretty sure that's what it does, yeah. Until it finds the right one
I do not remember correctly.
It just takes the one dedicated to a specific trait, sad.
Oh well, using the AddXP event and one of the parameters I can simply toss in my extra XP and tell it not to throw an event.
Means the tooltip won't update in the skill list, but I can live with that.
You can disable boosts in addXP
It's one of the parameters
The boosts applied are boostMap (proff/traits) and multipliers (skill books)
Aye, but I don't want to disable multipliers.
I wanted to add an additional multiplier for a perk. I ended up just doing it as I said: Sending AddXP again, but with the one variable set to True that disables the AddXP event.
Now to add some sandboxvars and I've got a team of QA testers ready to go for the weekend to destroy everything I've built 
Aight here comes the dumbest question yall ready
When I update my mod to debug / test it, do I have to enable / disable it again in "Mods" to apply the changes or does it update by itself?

just an idea for any modders who're open to it
been brainstorming a bit, thinking about learning Lua and getting into Project Zomboid modding but I can't figure it out for the life of me. I've been wanting to make a prosthetics mod, a mod where you can add prosthetic/bionic limbs as an addon to the Only Cure mod
Sort of. If you leave the game running and make changes to your lua code, you'll need to get the game to reload the lua files somehow. Either by changing the enabled mods (any change in the mods you have enabled will do) or pressing the "Reload Lua" button on the main screen while in Debug mode.
However, oddly the game seems to load faster if you just close and reopen the game anyways (at least it does for me) and is less likely to crash when loading. A full restart also ensures all files in the mod are reloaded as with the Reload Lua button, it doesn't seem to get everything like Texture changes for example.
Thanks man! ๐
I'm spending a few hours daily trying to code a mod for this game and every day I quit and the next day I start again from scratch
It's hair tearing but I feel it's gonna be worth it ๐
as long as you learn something, it was worth it
How would I go about adding this into my code? do a local function separate to each traits effect, or add it as part of that?
they're usually 32x32
Does anyone have a door peephole mod?
there is way to make it works on pz 41.78 ?
oldProcessSayMessage = processSayMessage;
processSayMessage = function(spokenMessage)
if not spokenMessage then return end
local trimmedMessage = luautils.trim(spokenMessage);
if not trimmedMessage or #trimmedMessage == 0 then return end
getPlayer():setLastSpokenLine(trimmedMessage);
oldProcessSayMessage(trimmedMessage);
end
After update to. 71 it stopped working and idk why can someone try to help me?
I got an idea for any one concerned with mods on UI improvements. I think a number next to each item on the list that counts up from one, increasing as you go down the list will make moving specific amounts of items easier. For instance, if I wanted to move 10 9mm rounds, then I would shift click the 9mm round with "1" next to it, then scroll down and click the 9mm round with "10" next to it, selecting exactly 10 rounds instead of having to individually count each round.
yea lolol! i actually use shops and traders and didn't even realize it's totally borked atm lol
Borked how?
cant add money to wallet somehow or use money from wallet
i think you can use money in some cases actually
no. but i also havent barely noticed anything until just now
ill test around a bit more and see what shappening
not too worried as i would prefer to use wallet-less also
i guess it's just adding to wallet is the issue i'm seeing
lets say i have a shop setup to buy Base.Money 1-0-100 with no resale. under previous circumstances it would be able to accept the money at a rate of 1 dollar wallet value per base.money
now it just doesn't take them or will take them but doesn't apply to balance of wallet
i used 20 dollars for testing so it could see it consumed the wallet money just fine. just not sell to shop for wallet value
Oh I stopped allowing shops to deposit cash items
Outside of transactions
You can deposit cash by hovering it over the wallet button
Same as you got it, I imagine?
Also you can drag cash to other cash items to combine them
Drag the cash to the button
omg what a sneaky update
thanks dude
finishing up the auto server restarter today methinks
The drag to button has been in - I'm just bad at advertising it
Same with combining them
me playtesting my mods for the first time:
Is it possible to access and modify local vanilla function from a .lua file within my mod?
In vanilla, the respective code I want to touch is in /lua/client/ISUI/ISInventoryPaneContextMenu.lua and starts like this:
local CraftTooltip = ISToolTip:derive("CraftTooltip")
function CraftTooltip:addText(x, y, text, r, g, b)
-- some vanilla code here
end
What I would like to do is to modify the function CraftTooltip:addText in my mod with a typical construction like
local vanilla_code = CraftTooltip.addText
function CraftTooltip:addText(...)
vanilla_code(...) -- execute vanilla code
-- append my new modded code here
end
I don't how to do this since CraftTooltip is a local in the vanilla code. Any ideas?
love not being able to get any mods to load on my ded server
Is this in ISInventoryPaneContextMenu.lua? Because if so, CraftTooltip gets exported globally with this line
ISRecipeTooltip = CraftTooltip
so you can do
ISRecipeTooltip.addText = function(self, ...)
vanilla_code(self, ...)
--your code
end```
Yes!!!! There is also the line "ISRecipeTooltip = CraftTooltip". Didn't know what this meant so I didn't include it in my code example. Many thanks! I'll try that!
Managed to get it sorted ๐
For some reason the image that I used for my blacksmith trait is not working can someone help
Can you post your trait image?
It should be placed in /media/ui/Traits/ and have the name format of "trait_[TRAIT_NAME].png"
and its in that
Anyone here have fort redstone on a dedicated server?
It shouldn't be because of the transparency and the size looks okay.
What does your trait factory line look like?
TraitFactory.addTrait("Deprived", getText("UI_trait_Deprived"), -6, getText("UI_trait_Depriveddesc"), false);
And I assume the trait appears just fine in the character creation menus aside from the icon not showing?
ya
the code i used is
local function initBlacksmithTrait()
local Blacksmith = TraitFactory.addTrait(
"Blacksmith",
getText("UI_trait_blacksmith"),
5,
getText("UI_trait_blacksmithdesc"),
false,
false
);
Blacksmith:addXPBoost(Perks.Foraging, 3);
Blacksmith:addXPBoost(Perks.LongBlade, 1);
Blacksmith:addXPBoost(Perks.ShortBlade, 1);
Blacksmith:addXPBoost(Perks.Spear, 1);
end
Events.OnGameBoot.Add(initBlacksmithTrait);
This might be silly, but can you try renaming the file to "trait_Blacksmith.png"?
Maybe the capitalization is throwing it off.
Ok
And also some traits donโt work
I put four skills on a trait and I load in a game foraging is not there as I mean the +3 foraging is not on
It should be this for foragingBlacksmith:addXPBoost(Perks.PlantScavenging, 3);
Thx for helping
๐
you can find the internal names of skills on this page
declaration: package: zombie.characters.skills, class: PerkFactory, class: Perks
does a client have to load an object before the server can do work on it?
that code just returns the info in the second screenshot
if I add in local isohb = hbg:getIsoObject()
it returns nil
yeah, the server can't access unloaded objects either
that's what those 'found isoobject with luaobject' messages are about, it only links them when they load
ok, so how can I do work on it?
you can't: the point of the lua object is you can modify that and its properties will be applied to the java object when it loads
coming to release 
so, does this apply to rain barrels and such? If no one loads that chunk, it won't fill up if it's raining?
no, the lua object checks for rain and fills up
then when the java object loads, the lua object applies the water value it has to the java object
โ
my life though
Java and lua obj are diffrent things obviously but i just learned that from u now
you rarely need to worry about them, they're just for global objects
Like traps and campfires
I wonder if it would be better or possoble to turn my beartrap mod i to java obj
Cuz its not
the lua object is basically an abstraction of the java object so that we can modify* it while it's unloaded
you could just add it into the trapsdef file and let vanilla handle it
But in using vanilla tile
I don't understand why my modkeys aren't available then.
So i cant add anyother other properties
Like, looking at the rain barrel code:
if not RainManager.isRaining() then return end
for i=1,self:getLuaObjectCount() do
local luaObject = self:getLuaObjectByIndex(i)
if luaObject.waterAmount < luaObject.waterMax then```
I just made an ontick check if your standing on the tile
isn't your bear trap mod just for hurting other players? you wouldn't need this for that
Ye ow ok cool
oooh, I thought it actually trapped a bear xD
I mean, my code should work just like this, by if I try to return a key, it returns nil
Maybe u placed the function checkRain below whats calling it.. that happned to me before and wasted a whole day figuring out why my code isnt working
are you still having the issue where you can't grab the objects at all? or just nil keys?
nil keys
hbg returns that stuff up there if I loop through it
so I can return hbg.x, hbg.y etc
where are the values saved/loaded?
Was about to ask the same thing
hmmm yeah, that does look right...
it's gotta be something small that's not obvious
i really need to mess around with this system more
Maybe isValidModData()
Should return true?
I'm not sure that's even being called, let me try without it
Wait youre checking the arg modData on isvalid
You arent sure if its moddata but ur able to pass it as arg
Might not need that isvalid im guessing but i could be wrong
we know it's moddata, we just want to know if it's moddata from this mod
yea, the object calls that when doing stateto
But it nils it
The issue seems to be that the keys aren't getting passed to the luaobject correctly
i need to write a global object system soon so i'm sure i'll be able to help then
~=
now that i'm thinking about it, that is REALLY strange
it should at least have the default values from initNew
Didnt know that works
I mean i would have written an if statement and returned boolean
I should try this way looks more fancy
can you confirm stateFromIsoObject is actually running?
shouldn't matter, right? Since I'm not actually loading the IsoObject
I'm just trying to get the lua object
which should still have the keys available even without the iso, right?
yeah it should
Cuz thats where you initNew
So, all I need to make a lua object is
function SBioGas:initNew()
self.methane = 0
self.biowaste = 0
self.fertilizer = 0
self.lastHour = 0
end
function SBioGas:new(luaSystem, globalObject)
local o = SGlobalObject.new(self, luaSystem, globalObject)
return o
end```
i'm just curious what loads it in that case
the object system inits it, yea?
function SBioGasSystem:new()
return SGlobalObjectSystem.new(self, "HomeBioGas")
end
function SBioGasSystem:initSystem()
SGlobalObjectSystem.initSystem(self)
-- Specify GlobalObjectSystem fields that should be saved.
self.system:setModDataKeys({})
-- Specify GlobalObject fields that should be saved.
self.system:setObjectModDataKeys({'methane', 'biowaste', 'fertilizer', 'lastHour'})
end
function SBioGasSystem:newLuaObject(globalObject)
return SBioGas:new(self, globalObject)
end
function SBioGasSystem:isValidIsoObject(isoObject)
return instanceof(isoObject, "IsoThumpable") and isoObject:getTextureName() == "DylansRandomFurniture01_13"
end```
Specifically:
return SBioGas:new(self, globalObject)
end```
Statefromisoobject called self:fromModData()
Which is a function below it
Idk maybe its just stuff like this wuich is messing up the code
I don't see where you call toModData or stateToIsoObject? But not sure why it would be nil on the testme.
I've had to put prints on stateFromIsoObject before to see when it triggers as that can be an issue too. If you were testing on SP, you'd have access to these values directly from the console and you could do print regularly or use Aiteron's debug to show it in an UI. Print evewhere from the point it gets set, to any place it can be unset.
You must set the metatable and __index value on to make an object in lua.
setmetatable(o, self);
self.__index = self;
Put this in your :New function.
Full example:
---@param item Literature | InventoryItem
---@return MutiesDiary.Diary
function MutiesDiary.Diary:new(item)
if item:getFullType() ~= "Mutie.Diary" then return nil end
local object = {};
setmetatable(object, self);
self.__index = self;
object.item = item;
return object;
end
no, no, no
No?
it is already done on the other new
well, just a heads up this system warns not to mess with new as it is synced with java.
Fair.
I'm perfectly happy with my normal lua objects 
Unrelated: Any event I should hook unto if I want to load my sandbox vars at a good time?
I like the OnInitGlobalModData
That sounds good.
Just realised I haven't done strings or floats for sandbox vars before. Anywhere I can just look up how their default values should look? (and their type)
strings like drop down (enum)
No, freeform
I want the server owners to be able to define a list of traits that shouldn't matter when determining if reading an XP Diary should penalise the XP you get back. Needs to be freeform because mods add traits ๐
I think Extra Loot Settings does what I need, so I'll just download that.
I don't know about examples you can copy but you can search java for extends CustomSandboxOption
2nd day i dont have a mod commission proj ๐ฆ sooo bored
Anyone needs help on their mod
any darkwood ost yet?
Just continuing a conversation with @polar prairie in #modeling about how to go about adding a new bow to the Bow and Arrow mod: the way the Bow and Arrow mod was written, it's actually going to be fairly easy to extend.
Most of their functions are nicely set in a global "MandelaBowAndArrow" Lua object, so you can make changes to them pretty easily.
For instance, whenever the mod needs to check if a weapon is a bow, it calls MandelaBowAndArrow.Client.isMandelaBow(itemType), and that just checks if the item is in the Lua table MandelaBowAndArrow.Client.Bows
So you don't even need to override their function - if you stick the appropriate data into that table, it will start to recognise your item as a bow.
ah nice.
For example, the base crafted bow is stored like this:
Client.Bows["Base.MandelaBow"] = {
speed = 0.25,
aimingAngle = 30,
aimingDistance = 17,
weaponOffset = 0.9,
deviationMultiplier = 1.5,
--gravity = 0.003, --does nothing apparently
model = "MandelaBowAndArrow.MandelaBow"
};
(They previously set local Client = MandelaBowAndArrow.Client)
So you just make your custom item with its item name, and then set it on that table with whatever stats you want, and it Should Just Work ๐
thank you so far! i still have to figure some things out as i'm new to this.
No worries! Most likely you'll come across things as you work, so feel free to @ me with more questions.
thank you! very kind of you! :) i appreciate it!
The good news is, the mod was written in a really nice way which will make extending it much easier that normal... easier than many of the vanilla PZ Lua files, even.
good for me! :D
can OnCharacterDeath retrieve player inventory
Well, there are some things which aren't so easily modded... I commented on the original that they should add a "isHoppable" test to the arrow wall collision code, to allow shooting arrows over low walls. I'd add that fix myself, but those tests are embedded deep in a large function, so I'd have to duplicate that whole function to change that.
Which is a shame, because the same test is done three times (on the tile the arrow is over and two neighbouring tiles). If they'd just pulled out the common code into a function, and stored it in their object like the rest of the code, it would be dead simple to override that one small chunk of code.
(So instead I've just hacked my local copy of the mod so I can shoot over low walls ๐ )
it seems you have good experience with it. sounds so complicated.
I'm a software engineer in my 50s, so I have lots of experience with code. I only started looking at Zomboid modding recently though ๐
wow i see. but yea zomboid is such a good game.
and a lot of people trying to improvie it with sharing their mods, it's a good community.
๐ช My diary mod now exists on the workshop (and will undoubtedly have a whole slew of bugs) https://steamcommunity.com/sharedfiles/filedetails/?id=2913487911
I'm so glad the developers embrace modding as a way to make sure they can have much more content than they could ever make on their own.
It's very refreshing after too many games that say "Yeah yeah we'll definitely add modding, trust us" ๐
i still have problems with my texture that doesn't show ingame. something must be wrong with my model (material or something) i'm still new to blender. can i send someone with some experience in blender my .fbx model so that anybody can tell me where the mistake is? i cannot figure it out after hours. :/
Does the model look correct inside blender?
Did you set up a Model script entry that points to both your FBX model and the texture filie? FBX files don't contain the texture, unlike the .X files that a lot of the older models use.
@vast nacelleyea it should work fine. for now i'm just in the testing phase and using another mods scripts and just replace the model as .x and the texture as .png.
Send me the fbx, the texture file, and the txt with your model script entry and I'll take a look.
I wish theres a modelling guide with autodesk maya
Hi! How do print the names of all items in the player's inventory?
I tried this but gives an error:
local playerObj = getSpecificPlayer(player)
local playerInv = playerObj:getInventory()
local myList = playerInv:getItems()
for i=1,myList:size() do
print("Item: ", myList:get(i-0):getFullType())
end
what is the error you are getting?
one mom...
those 2:
you have i-0 by mistake. needs to be i-1 i think. to my memory the java arraylists are 0 indexed
whoops!!! haha! XD
that's probably it!!! very stupid mistake! haha! thanks!!
haha! works now! many thanks again.
np
another question: How do I remove all items of a given type from inventory? I tried smth like this
local playerInv = playerObj:getInventory()
playerInv:RemoveAll("Base.Item")
but this doesn't have any effect (items are still present in inventory).
According to the api docs (https://projectzomboid.com/modding/zombie/inventory/ItemContainer.html#RemoveAll(java.lang.String)) you don't need the module.
declaration: package: zombie.inventory, class: ItemContainer
Just playerInv:RemoveAll("Item")
@small topaz
thx! is "Item" then the display name of the item?
No. It's the Type ("Shotgun"), but not the FullType ("Base.Shotgun") or the DisplayName ("JS-2000 Shotgun")
ah... ok thanks! I'll play around with that!
btw, didn't know that there is a java doc including better documentation about all the commands. I just used a probably outdated version (here: https://zomboid-javadoc.com/41.65/). Good to know...
and follow that with Player.Kill() that will make sure they dont have it XD
Can I put commas in item names like this?
item ChineseTakeawayBoxUnfolded
{
DisplayName = "Chinese Takeaway Box, Unfolded",
DisplayCategory = PackingMaterial,
}
have you just tried? I guess this should work since the display name is just a string... not 100% sure though
when making your mod.info how do you make it require more than 1 mod?
like how should it be written
literacy mod uses
require=a,b
thanks
Why don't you upload your own fork of the mod? I Gluten says on his page he doesn't play PZ or mod much currently and the bow mod is one of my absolute favorites. It could really use some new features and updates. Kitsunes crossbow is another one that has plenty of unupdated forks. Maybe combine the 2 for the ultimate arrow battling mod.
happy new year, mod_development
We did it
I concede Mrogamming was a bad name, but I'm glad we got a more defined name in the end.
let's gooo
They did it after I put in a request yesterday to change it.
The straw that broke the camel's back or had we just been grumbling without actually asking it to be changed? ๐คฃ
Put in a request? If thats a thing its not like its advertised, haha
It's in the #frequentlyasked, not that anyone ever reads the FAQ... ๐
Can anyone help me figure out what this error means and how to fix it?
wrong arguments?
not sure. this is what is on line # 118 of my mod if inventory:getItemFromType(result) then
and line 58 of the vanilla game local resultItemCreated = RecipeManager.PerformMakeItem(self.recipe, self.item, self.character, self.containers);
if I remember right, result is InventoryItem already, the function you call doesn't have that implementation
I assume result is in same fashion as vanilla
I have no idea. I didn't put this together. I am just trying to see if I can fix it myself While I wait for a response from who did.
This is the whole action ```function Recipe.OnCreate.VinylPack(items, result, player) --> This function is executed when opening the packages.
local inventory = player:getInventory();
if inventory:getItemFromType(result) then
inventory:Remove(result);
end
--> Adds 3 random cassettes to player inventory
player:getInventory():AddItem(ItemsResearch.Vinyl[ZombRand(#ItemsResearch.Vinyl) + 1]);
player:getInventory():AddItem(ItemsResearch.Vinyl[ZombRand(#ItemsResearch.Vinyl) + 1]);
player:getInventory():AddItem(ItemsResearch.Vinyl[ZombRand(#ItemsResearch.Vinyl) + 1]);
end```
Hate to just butt in while another troubleshoot is going on. Have a quick question.
Anyone have any experience on working with the ISChat.lua? Trying to generate a second chat tab for non-admin clients that can only use specific chat streams, potentially up to 3 chat tabs. Anyone have any documentation on some of the functions?
maybe you can try result:getType() in that line
- no next line would make no sense
Interesting they removed the result there - there's a parameter for removing the result but it bugs out the UI
What is not working about it?
so basically I open a package and then a big error screen shows up and the items I should have recieved don't get given to me. This feature was originally working but I was also being given and "empty package" item that I shouldn't be getting.
in their attempt to get rid of the empty package this bug arrived
which line? 118?
I got a response from the modder I am working with so I should be abl to sort it out now
thanks for the responses
interesting, how the empty item gets added, is it the result item?
I'm curious if he has removeResult set to true in the recipe
anyhow chuck is right, result is usually removed like that
Getting an item like that could mess up getting the same item I think (?)
Hello, not sure if this counts as a mod, but I made a companion application to track read books and magazines. I used the icons for the books and magazines for the labels.
What kind of permissions do I need to distribute this for free?
@fast galleon @sour island Not to leave you both hanging but I had to change the error line to if inventory:contains(result) then
Sorry if I pinged anyone or everyone - my phone was active in my pocket
Had a message ready to go with 50 pings to the same person
And downloaded at least 12 messages ๐
Yeah - I figured the getItem was probably getting the wrong item
if I put say 400 small items into a container and run a sendCommand on postInventoryTransferAction
how hard would that hit the server?
Well, that's what the Alternative Drawing mod was - a total fork. But that created maintenance hassles when Gluten the sensitive started updating the base mod again (especially when Alternative Drawing kept the same mod ID)
I think it's probably more sustainable to make add-on mods
it's pretty easy to get 200+ veggies from even a smaller farm
Even the floor has a limit of 50 weight though
3D item models on the floor are a huge issue
I think that's why ripping clothes was changed
well, my thought process is to have an internal storage tank of 400, where 1 unit equals 1 item of food and over time it does work on that tank.
so, I'm just wondering if I should have all the loaded containers update on the hour, or do it postinventorytransfer
If your tank doesn't change how it looks over time you can do a bulk of the work when interactions occur.
Not sure what the food does for the tank in this case, but what if the food gets destroyed and converted into an integer?
yea, that's what I'm doing
this is my "on every hour" function
I don't really see an issue then I guess
As long as you're not displaying the items
Is this like a giant composter?
I mean the player can't access the contents can they?
probably all black, it'll just be a container that will convert food into propane and fertilizer
its still pretty harmful to have 400 individual items
it doesn't matter either way, if it's not food it sits in the container and does nothing.
It could matter if you make it able to hold 400
I'm just wondering if it's light enough on the server, I could iterate the biowaste variable on each inventory transfer, which is every single item.
or, if I should make users fill it, and then on the hour ticket update all loaded containers at the same time
CBioGasSystem.instance:sendCommand("addBioWaste", { { x = isohbg:getX(), y = isohbg:getY(), z = isohbg:getZ()} ,"put", additionalBioWaste})
No one has complained about lag - unless a horde is invovled
But why not send 1 command with the whole list
Unless I misunderstood -- you're not sending a command per item?
I'm currently not, I felt like it would be a lot with how fast you could transfer small items
I guess I could make a button to initiate the add process immediately on that specific object, that way if they're doing a mass load to top it off it would be 25-50 units at a time then on transfer.
Hello, does someone knows the difference between these two methods ?
It's in NetworkZombieManager class i wonder i can use the second one safely in a multiplayer mod
Only reasonable difference I can see is one accepting a param while the other doesnt

I haven't dabbled much in the networking side of things so I'm not sure what it changes beyond that.
is it possible to see how many items have been added to an evolved recipe?
Also, is there a place to see all the available fields on an evolved recipe?
Wait, can we not make our own evolved recipes?
we can
how to we specify what items can be added?
I see the lua method getItemsCanBeUse
is it itemsList
not sure, you'd usually just define it in a script
i think the items you can add are defined by the items themselves, not the recipe
like sugar knows it can be put in coffee
right, so do you have to overwrite every food item that you want to use in the evolved recipe?
it'd be better to do it through lua
but yeah basically
hmm... i don't see a getter ๐
they wouldn't...
"We're going to do things like the modding community." Proceeds not to make a way for the modding community to hook into the system.
hmm
it looks like even though it's defined in the item script, it might still belong to the evolved recipe object...?
this part of the code is kind of complicated, i just had a quick look through, but i think that's what it's doing
yeah, it just finds the evolved recipe and adds itself to its itemsList
in the field details it shows itemsList
so I'm trying that with, [Recipe.GetItemTypes.Food]
an awesome detail is it looks like evolved recipes only work in module base
because this part of the item script handler only searches base
I can import base, right?
yeah, it's just annoying - modded recipes will have to be in base, even though it's generally encouraged to keep things to your own module
it's just one item
anyway you just need to mess with the map you get from getItemsList()
might write a little util for that for my library, it kind of annoys me how roundabout that is
i guess you could DoParam it actually? i can't see how it'd overwrite previous values
i wasn't going to recommend it for that reason but it seems fine actually
I'm not sure how to do that
this may just be a rabbit hole I don't want to go down. I was thinking I could make an evolved recipe to make like a mash or something, and then when they add that to my sprite I could count the items in the recipe and iterate with that, but I might just have to make a button that kicks off the script
local item = ScriptManager.instance:getItem('Base.Sugar')
if item then
item:DoParam('EvolvedRecipe=Sandwich:1')
end
does that add to the existing list?
there is no existing list as far as i can tell
that information, despite being on the item script, doesn't seem to be stored on the item whatsoever
it just adds it to the relevant recipe when it gets parsed
i was specifically not telling you to do it this way because i had the same concern, but it seems fine
there isn't even a method for food items to getEvolvedRecipies (sorry if that's the getter you were talking about earlier.)
yeah that's why i thought we shouldn't do it this way, i couldn't find a way to not override things, turns out there was nothing to override lol
hmm, I'll have to go through this whole list, cause there's some items I'll have to exclude like cans that aren't open, but that should be easy enough
In a server, how to add one custom spawn point? And remove all the others?
What do you guys think would be more intuitive, combining food into a water pot and then dumping the mixture into the device, or adding a world context menu option to empty the container?
also, how to prevent some traits and professions from being picked?
if they are ISButton you can do Button.enabled = false
Yey our prayers have been heard! Mod development channel
I just friken noticed loool
Im sooo blind
No wonder i got lost last time searching for this channel
I instead teleport the player once they spawn
But theres probably a better way
I had the opposite problem before, my result is removed by default and I wanted to know the container of the source but both result and source have no container.
Make boxes of them instead to avoid creating so much items
yep, already did this hahaha
Hey guys, where would I look to reference character creation? I want to blacklist certain items from appearing when I enable all clothing to appear in char creation
I think it would be funny if there was a mod that made zombies randomly dance when they aren't pursuing someone
media\lua\client\OptionScreens\CharacterCreationMain.lua, line 985 is where you'd want to look
thank you
just wondering, I'm testing a mod right now. Let's say we cook hundreds of items like peanut/almond in the stove. Will it break the game or even worse a server?
No? There's no reason it would, unless the mod does something insane.
Do you have to pass character when doing a sendcommand()?
sendclientcommand? no, it's optional
does the module refer to SBioGasSystem in my case?
module can be anything you want
module and command are both just strings that get passed to the server, there's conventions for how you should use them but no actual limitations
I'm getting ERROR: General , 1673077385616> 36,977,847> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: at MethodArguments.assertValid line:123.
can you show your call?
CBioGasSystem.instance:sendCommand("empty","addWaste", { { x = isohbg:getX(), y = isohbg:getY(), z = isohbg:getZ()} ,waste})
return SBioGasSystem.instance:getLuaObjectAt(args.x, args.y, args.z)
end
function Commands.addWaste(args)
local hbg = getHomeBioGas(args[1])
if hbg then
print("Adding Waste")
hbg.biowaste = hbg.biowaste + args[2]
hbg:transmitModData()
end
end```
SBioGasSystemCommands[command](playerObj, args)
end
the debugger is hitting this for the error.
oh, it's a global object function? i guess you'd need to look at the definition for that- yeah
you will need to pass a player object in this case then
so it does require a playerobj then... I don't understand why, I don't use it. can I just pull getOnlineByPlayerID(0)?
i wonder if it's just a javaside proxy for sendclientcommand or if it actually works differently in some useful way
seems... jank
if it's the same i don't really know why this exists...?
that sort of describes my views on about half of the global object system
local playerObj = getSpecificPlayer(0)
local args = { x = obj:getX(), y = obj:getY(), z = obj:getZ(), fuelAmt = 0 }
CCampfireSystem.instance:sendCommand(playerObj, 'setFuel', args)
end```
from the vanilla code
if you don't want to pass a player, just use sendClientCommand i guess
i really don't know what this global object specific sendCommand is for
does that still hook into my SBioGasSystemCommands.lua?
i'd like to check if it's any different on the java side but i'm not at my computer
you need to handle it with an OnClientCommand event
yea, I'm doing that lo
i think maybe it's like sendClientCommand but it matches the system instead of using the module string
in any case they're probably basically the same thing and if you don't want to pass a player object just use sendClientCommand like normal
Yea that's true. Good point.
I think it's literally just for logging if you're not using it.
SGlobalObjects: receiveClientCommand HomeBioGas addWaste OnlineID=0
Hi hi, does anyone here know how i can make a furniture/object a requirement for a recipe but make it so my character doesn't pick it up when they craft. I want my character to be able to craft it when they're around the object but they don't need to have it in their inventory to craft
I tried this
{
[MaterialforCraft]=1,
keep [WorkBench],
Result : [...],
Sound : ClothesRipping,
Time : 100.0,
CanBeDoneFromFloor : true
Category : Tailoring,
AnimNode : RipSheets,
}```
But my character picks the workbench up
I also tried
{
[MaterialforCraft]=1,
NearItem: [WorkBench],
Result : [...],
Sound : ClothesRipping,
Time : 100.0,
CanBeDoneFromFloor : true
Category : Tailoring,
AnimNode : RipSheets,
}```
But my since the workbench is a 3d WorldItem it doesn't seem to recognize it when it's on the ground
Is it a sprite or just an item?
It's a 3d item
so it's something you can drop out of your inventory or place and rotate?
Yep
{
CigaretteMod.CigarettesOne=5,
Result: Brass57=5,
Time:60.0,
keep ATMReceiver,
NeedToBeLearn:false,
CanBeDoneFromFloor:TRUE,
Category:Shop Unique Market,
}```
is the workbench from another mod or is it base?
It's from my own mod, i don't have the workshop implemented yet so i use another object for reference. Here's the full recipe as of now
{
Leather=1,
DuctTape=2,
SmallSheetMetal=4,
Thread=1,
keep Needle,
NearItem:DestroyedCarTire,
Result : Makeshift_Vest_Junker,
Sound : ClothesRipping,
Time : 100.0,
CanBeDoneFromFloor : true
Category : Tailoring,
AnimNode : RipSheets,
}```
The "DestroyedCarTire" is where the workshop is supposed to be
is it workshop's metalworkbench?
Ok, thing is out again, now it'll stay 
https://steamcommunity.com/sharedfiles/filedetails/?id=2914075159
No no, it's going to be a Tailoring Bench
So i don't use this mod's workshop
ah, ok, well if it's in the same module, then you can just do keep "itemtype"
if it's not in the same module you'll need to do
keep "module.itemtype"
you'll not use quotes
{
keep MetalCutter,
LargePropaneTank,
keep MetalWorkbench,```
Hmm, yeah i tried to use "Keep (...]" but my character still picks the item up
huh, not sure then, the only time I use it in that specific scenario the item on the ground is either protected by valhalla (the earlier example of ATMs) or way to heavy to pick up (workbench).
Well i can try to make it too heavy to pick up, but that would mean the workbench would be unmovable, right ?
I tried making the object too heavy to pick up and it doesn't work :/
Oop nevermind ! Seems like i possibly made a mistake in writing the recipe! It works now ๐ Thanks for the help @humble oriole
sorry got wrapped up in my own code haha. Glad you got it working!
CanBeDoneOnFloor is enough of its an jtem
If its a tile
You need OnTest() check if you are near that tile's sprite
It's was not a tile but an item ^^ In the end CanBeDoneOnFloor was enough, i just didn't know you had to write "TRUE" in all capital unless it would not register
Is there a way to immediately initialize the luaObject after the isoObject is created?
HomeBioGas: found isoObject without a luaObject 10902,9773,0
Did you now? I thought it would work even if dont write it on all caps. Good to know
I think theres an event for when u create an obj try your luck there
Or you can make an ontick that removes itself
I wonder...
I doubt this will work, but I'm going to call my load function with MapObjects.OnNewWithSprite()
As if it were so easy haha. Oh well. I'll mess with that tomorrow.
probably the missing comma
Ow yeah its the comma
Now that would probably be why ๐ฅน I was wondering ahahahah
I just figured it was the capital letters since it worked after i rewrote it, but i didn't think of the comma
The whole script file didnt run i bet
Does it not do that or you want to skip the print or ... ?
@ SGlobalObjectSystem.lua line: 261
*You say created, but I don't think you want to do it before placing it ...
Hello, I am trying to write a mod for multiplayer and I want to know what the best way to debug it in game is. I want to get someone's steam ID
I'm using
local player = getPlayer();
local playerID = tostring(player:getSteamID());
But I don't know how to go about testing this in singleplayer ๐ค ?
It's vital for further development that I can test out this mod in game, should I just host a world as multiplayer, would that work?
Yes
Thank you very much, I appreciate it. ๐ โค๏ธ
Launch game with -debug
I am sorry if my questions come across as dumb or annoying, really trying my hardest to learn the language.
You can use the debug console (opened with backtick, `), in order to enter and test commands in game
for i = 0, getOnlinePlayers() -1 do
local chr = getOnlinePlayers():get(i):getSteamId()
print(tonumber(chr))
end
I typed this using mobile so if it doesnt work then u just fix that the error is saying
@drifting ore
I'm reading it now, will save it if for future reference. Thank you a lot! ๐
Just paste that on the lua console
U might want to
print(tonumber(chr))
Do that if it doesnt show the right id
Also its i=0 sorry bout that
You will need a comma after i = 0 and it's good practice to indent stuff between do and end.
There fixed it
When you say execute commands in the debug console, do you mean commands I make myself in LUA (if it's possible) or just general debug commands?
Because it would make my life a lot easier if I could just do /test and execute my function lol
Right now I'm juggling these events what they are called, to see if the code works
Half the time I'm not even sure if I've chosen the right event tbh
Show the code
Not judging just making sure they know. First code you see in a language can influence habits a lot
Lemme just quickly find the markup for posting code
Lua commands
However, local variables will cease to exist after hitting enter to submit the commands you've typed in debug console
function zedkills()
local player = getPlayer();
local playerID = tostring(player:getSteamID());
local moneyAmount = "500$";
local fileName = playerID;
local information = playerID .. "\n" .. moneyAmount;
local writer = getFileWriter(fileName .. ".txt", true, false);
writer:write(tostring(information));
writer:close();
end
Events.OnPostMapLoad.Add(zedkills)
Forgive me I was cleaning it up a bit might've messed some parts up
Basically, it's designed to write a .txt file to store just the value of "money", a local variable I'd introduce for a small economy mod for a RP server
I know I could've used JSON or ModData but for the life of me I couldn't figure out how
You intentionally wanted the cash to become a string
I would have loved to use Json
Right well its all gona be string anyways nvm what i said
One Json file to rule all those txt files that would appear...
I was following some famous tutorial on github how to use Json in LUA but it never worked out :/
U might have overwritten an existing thing with that i believe
When do u want the function to trigger
Well for testing purposes whenever I want right now, so I can test it out how it looks when I execute it
You can do the Every10mins i guess
Keypress event might be best used in that case I figure
Not sure how its written
Then use the onKeypress
return key
If key == whatver keycode
Will do and report back ๐
i could write it for u but im not near my pc . Look for other mods that has key commands i guess if you cant find it on the vanilla lua
No worries man, I don't expect from any of you to write anything like that for me !
I need to learn
Best of luck
I see so much potential here for mod making, really want to learn it
You could also put a function on the thing and just call it on debug to test if its working first
How do you call a function from within debug?
If its not local u just
functionName()
function myFunc()
print('hello world')
end
myFunc()
--alternatively you can just do
print('hello world')
@drifting ore One of the people here made this... pretty useful for debugging because it shows you the most likely need-to-know for most errors quickly, and can show more than one at a time in a clear way:
https://steamcommunity.com/sharedfiles/filedetails/?id=2896041179
If you want to store money associated with players, player:getModData().Simple = {} and player:getModData().Simple.money = 500.
That'll store a variable inside of player's save data
No need to write your own file if you don't want the money to persist between characters
Interesting
Anyone experienced with zed modding
Like their behavior and shit
The only thing I don't understand is the ".Simple" shouldn't that be something specific?
Like, in the sense of code not string
Or is that just like a value figure, like getting a persons name
where player is obtained via getPlayer() or a loop through getOnlinePlayers() or something like that.
Yeh thats the moddata u created
Nah you can name it whatever just an example of encapsulating your mod data in your own table in the player data
The Lingering mod that adjusted zombie behaviors like door opening is the only zombie behavior mod I know
@drifting ore what r u building anyways
Aye.. ill look at the one wiith the tank
Cdc i think
Im hoping the author is active here on mod dev channel
@drifting ore Glytch3r asks a fair question... If you are working on a shop mod, you may want to reconsider and just join forces with someone else to make their shop mod better
Yeah but for a first mod shop mod isnt advice able
I thought we weren't allowed to edit other peoples mods
Or do you mean asking for permission and helping them with their own?
Often the driving force of any passion/craft is success (my opinion)
So to get that its best to do something simple now that u see it working ubcan aim higher
For me
Collab
Collaboration
But yeah, I've got lots of ideas but they are all RP server related.
Should be agreed upon initially
And we are allowed to touch those free for all mods
But its only ethical to credit the author even so
For example, creating a mini-economy type thing with just being able to give, take as an admin money. Pay money as a citizen. Get paid on time spent playing etc
Oh really? We couldn't find anything similar ๐ฎ
Chuck
Is it on the workshop?
Ye
I'll try and find it later, thank you for letting me know! ๐
Also the author for a shop mod
His a legend type wizard hehe
Economies with money and ATMs and wallets and such have been done. If you wanted to add payment as a reward for any kind of player activity and those mods can't already pay on the trigger you want to use, you could write an expansion mod for something in the workshop that just adds extra ways for players to gain the money
Rather than reconstructing an entire monetary system, expanding on existing systems could be easier and result in more value to the community
E.g. I want a shop mod that has gamepad support, but I'm not gonna go making yet another shop mod for that... I'll just write a patch for someone else's.
There are two highly rated shop mods on the workshop, one of which is Chuck's, one of which I think was written by Noir. I do not know Noir at all but Chuck seems like he would be easy to work with on this @drifting ore
What do you mean by patch? As in, I code something and send it to them or via github?
I'm new to all this sorry ๐
Well in some cases maybe but in this case no.
In this case, because Chuck is a responsive human being and an active modder, you could work with him on adding things via a secondary mod, added as its own workshop item (if say you want some private recognition for your efforts)
If a mod uses global variables to do stuff that you want to change, you can generally change those global variables (even functon or table definitions) from another mod; you can also import variables from other mods using require IF those mods return access to the functions, fields, or structures that you hope to influence.
In this case, if you're just trying to give people money under a variety of conditions, the money added by Chuck's mod can be utilized by your mod. It's not exactly a global variable per se but the items (e.g., coins or money bills) added by a shop mod will be available to your mod as well. You can reference the item scripts defining the forms of money just as if you were writin code in one of Chuck's files without even being in the same directory.
Thus you can e.g. add items to a player's inventory from any other mod you have running
And if you open mod.info and add "require=someOtherModID" where you replace someOtherModID with the real mod id (not to be confused with workshop id) of the shop mod, you can guarantee your mod will not run without the shop mod on which it depends
(However, passing your code along to other modders is also allowed. My personal plan was to simply edit Chuck's code locally to add gamepad support and send it back to him, but I literally mod as flarkin "Burryaga" so clearly idgaf that much about my name on stuff haha. I just want to make mods that improve the games I play. And it's nice when people use them because that makes me feel less alone in wanting what I want for the games I mod.)
(But I'm pretty sure Chuck would list you as a contributor if you wanted him to do that and you gave him an expansion worthy of being added to his mod.)
hi! when defining the script.txt entry for an item, is it possible to add new data to it not predefined by the game? for example:
item MyNewItem
Weight = 0.5,
DisplayName = MyItem
NewData = add new data here
Not sure if it's cool to promote here but if any of yall use true music or the dancing mod I just uploaded a mod you might like ๐ https://steamcommunity.com/sharedfiles/filedetails/?id=2914213621
Its allowed. And congrats
Thanks but all the work was done by Dislaik so cheers to him for the quality stuff
So I'm working on making a light that follows the player, but I am curious about what happens to the light object when I reassign my lua variable to a new light object. Am I filling memory with unused light objects? (Seems likely.) If so, is there a way to delete these light objects I create as they become removed from cells?
Alternatively, is there a way to make a light track a player (preferably without any item in inventory or equipped) that is more naturally mobile than adding and removing an invisible lamp post all over the map as I move? (Doesn't seem to be lagging me in the first few minutes of testing, but I'm still concerned.)
Events.OnTick.Remove(doItToIt)
doItToIt = function()
local player = getPlayer()
if light then
player:getCell():removeLamppost(light)
end
light = IsoLightSource.new(player:getX(), player:getY(), player:getZ(), 0.3, 0.3, 0.3, 12)
player:getCell():addLamppost(light)
end
Events.OnTick.Add(doItToIt)
I tried...
Events.OnTick.Remove(moveWithMe)
moveWithMe = function()
local player = getPlayer()
if darkvision then
darkvision:setX(player:getX())
darkvision:setY(player:getY())
darkvision:setZ(player:getZ())
else
darkvision = IsoLightSource.new(player:getX(), player:getY(), player:getZ(), 0.3, 0.3, 0.3, 12)
player:getCell():addLamppost(darkvision)
end
end
Events.OnTick.Add(moveWithMe)
But the light doesn't move, unfortunately. Once it's added to the cell, its position is determined by something other than setting the light's position.
would be nice to have some mod announcement channel. modders could just post a link to their newest work and a specific channel for this could also make it easy for the non-modders here to stay updated about new stuff
yea thats been requested
I would recategorize WORKSHOP as WORKSHOP MODDING and the channels would be support, mods, requests, releases, mapping, development, modeling, and mods would be purely for links to mods and updates about them.
And underscores can just go away, ew.
that would make it so that modders are given more credit which i believe we deserve
Also we need a clear place not just for new releases but for mod requests
Requests get lost in our discussion channels all day
mapping can even have a sub category of tiles hehe
is there a mod that adds npcs you can buy/sell stuff to?
Sort of
what do you mean
that's fine too then
then that
They look like NPCs
does it support vehicles aswell
i can build you a vehicle shop mod for the right price ๐
3D Car model viewer, ( CarWanna pinkslip support only, or write your custom patch lol)
From the link
So you can not only buy cars it seems but rotate them and such
Kinda fancy
@sage bluff not sure what you found but Dislaik's guides are good.
yeah i found this guide, thanks
Dislaik also wanders through here occasionally if you get stuck. I misread a screenshot in his animation mod and he spotted what I missed quickly.
ok thanks
I also made a shop mod that you can assign to mannequins. No cars though.
Setup can be done in game as an admin/host https://steamcommunity.com/sharedfiles/filedetails/?id=2853615523
do not make us change it again.
This is so cool!!! I didn't know all this, thank you so much man. That will make life a lot easier!! โค๏ธ โค๏ธ โค๏ธ
@drifting ore No worries. Do you know how to read the code for any of your subscribed mods?
Also, @ anyone who knows, is there a simple way to get a float representing the overall lighting around the player (e.g., in their room), or would I need to try to write an algorithm for it (e.g. looping through nearby squares or squares in a room)?
do you really need to check the entire room? lighting shouldn't be that crazy anyway
i've used self.character:getSquare():getLightLevel(self.character:getPlayerNum()) for literacy
@bronze yoke Maybe not, I guess I could use a focusing system
I'm trying to tie the strength of a "darkvision" mechanic to the brightness of the room player is in
I tied it to square light level once actually, but it flickers rapidly as you run around and enter squares with wildly different lighting
I may try to add a timed adjustment mechanic where brightness fades in the direction implied by the square you're on after some minor delay, and see if that works better
another issue is I obviously impact the brightness of my square as the adjustment creates light on my location
Trying to see what options exist for working around those issues.
(Ultimately my darkvision is just a local light source with no sprite because I know of no other clean and simple ways of brightening the area around the player.)
Is it possible to mod the jawstab mechanic?
I know. By the way, is there a way to inject your own code into the mods code? For example, there's a frisk mod, but it only shows weapons. I would like to extend it to show other things too without editing the owners mod
So purely making your own code to extend that code to show other things
Like you said I could use require to use the variables from the code, but is this sort of thing possible? Guess it's the thing in reverse
Perhaps, just throwing out an idea here from my limited programming language.. Intercepting when a server executes a command to do the same thing + additional?
Ideally it would be a function that could use a "if" statement to check if another function is being executed so... if friskCommandExecuted... getUI - items were already added --- code to add more items to the existing UI
it would be similar to changing / hooking to vanilla functions
Is there any documentation regarding that I can check out to learn from? Or a mod you know as an example?
base concept is, save local reference to the old function and assign a new function in place of the old function
Wouldn't that mean I have to change the original code of the owners mod and upload it as my own?
Therefor breaking the rules?
Sorry if I misunderstood
Thinking of adding a 'edit' option to modData for debug tools- not sure how practical it would be
This is very interesting what you linked, I'll spend some time examining it so apologies if I don't respond
it looks like what I need
depends, some patch mods require minimal changes, other times you need to create same file to overwrite everything.
depends, minimum is like copy paste the example mod
an example from a patch file for multiple mods
Working on my Java API mod stuff today for modding tools. ๐
if getActivatedMods():contains("ReduceLagofCraftingMenu") then
require "ISUI/ISCraftingCategoryUI"
local function onCommandEntered(self)
return self.parent.parent:refresh()
end
local ISCraftingCategoryUI_create = ISCraftingCategoryUI.create
function ISCraftingCategoryUI:create(...)
local r = ISCraftingCategoryUI_create(self,...)
self.filterEntry.onCommandEntered = onCommandEntered
return r
end
end
I like when people write overwrite code for Lua that involves calling the original function inside of an intercept function they write.
I did this with the MainScreen.update() and MainScreen.render() methods.
Ovens don't use gasoline though
Sure?
Yeah it's not exploding
There's alot of stuff that doesn't interact with ovens
He means like it should be added that if you cook a gas can in an oven it explodes
if you want it fast, add HasMetal tag to it?
?
You suggest something: devs think and maybe do something about it in time.
Until that happens you can do something yourself. e.g things with HasMetal tag, start fire in oven already.
btw, @pseudo pewter #frequentlyasked has the answer to your question, this channel is for making mods
Hi guys! You've been very helpful so far.
Question: Is function CharacterCreationMain:initClothingDebug() specifically for when you enable all clothing options to be revealed? If so, I see that you can preface categories ala
-- self:createClothingComboDebug("Eyes", "Eyes")
-- self:createClothingComboDebug("Mask", "Mask")```
But is it strictly limited to categories? Is there a way to specify items to, say, not show up entirely in the char creation?
Sorry to interrupt if you guys are helping others, this one could be a quick answer. Is there a way to test multiplayer mods that work with other players while solo in game? Like, is there an object you can spawn that acts as another player?
AFAIK you can't run 2 instances of the game to test it out on yourself
check pins
Poltergeist is giving you good advice here imo. Often you can "decorate" or "hook" other modders' functions. At its simplest:
-- theOriginalClass.theOriginalFunction may be declared with : instead of .
-- However, it will still be referenced below using ., because : notation
-- is only used to define functions and pass variables (afaik).
local yourBackupOfTheOriginalFunction = theOriginalClass.theOriginalFunction
-- You could also replace : with . if you do not plan to use
-- this function with references to self. This example pretends
-- that theOriginalFunction is accessed using :, implying
-- that it WILL make use of a self object that gets passed implicitly.
function theOriginalClass:theOriginalFunction(theOriginalParameters)
-- Stuff you wanna do before that function happens.
-- You only need self below if you use a colon when calling this function.
-- If you had said theOriginalClass.theOriginalFunction (i.e., if that's how
-- the original function were defined), then you would not need "self, " below
yourBackupOfTheOriginalFunction(self, theOriginalParameters)
-- Stuff you wanna do after that function happens.
end```
oh, I thought chuck's message was about setting what you want, I think there are better instructions somewhere
You can run Zomboid from CMD as many times as you want; just add -nosteam and also -debug on the client you use for hosting if you want to be able to access debug console.
-nosteam on all instances of the game launched that way
This is all very good material to study from, thank you guys so much
You can also launch one -nosteam from Steam (ironically) using Launch Options. I do this for gamepad support.
to clarify something in here, your usage of : or . needs to match the original
Also, be aware that decoration only works if the method is global or has been imported.
Many vanilla objects and functions are global, allowing you to decorate them this way, but not all mods offer equal access to their functions / objects. Some you can access without concern, but others will need to be required using require, and others will be exclusively local, in which case you won't be able to decorate them. And some functions are defined anonymously, making their interception / modification beyond my knowledge (anyone else know whether anonymous functions can be found and modded by some super advanced hackery?)
Like say I add an anonymous function to OnTick, can you find that somehow and remove it? Could / how could it be identified?
I'm trying to connect into the game like how I read on the pins but it just won't allow it :/
I have 2 versions of the game but it either won't connect at all (it sees the server) or it wll say that the player is already connected to the game.
I'm dumb nvm
I read the pin but didn't read your comment here
function table:doSomething() end
-- shorthand for
function table.doSomething(self) end
i chose not to mention that since it's just uglier
haha I chose not to confuse them (more than I already have)
and calling a function with : passes the thing before as the self parameter
When you decide what function you want to change in someone else's mod, you might consider sharing it here. The details could affect the best way of doing whatever you're trying to do to it.
Curious what y'all would say: #mod_support message
Seems like it came out years ago, curious why it still has no gamepad support, wondering if it has just gone unused or what.
is there an event that fires when rotten food becomes compost?
actually to be specific im wondering if there's a way to change the input for a composter and the output. Like the 10% worms thing, maybe making a chance for rotten food to create seeds
I'm headed off to bed, but if you still don't have answers in like 8-9 hours, I'll look into this for ya.
Hello and good evening everyone.
I am completely new here and ended up here on the discord through my search in the indie forum.
I've been trying to figure out how to create a mod pack for a while.
Unfortunately, I couldn't find exact instructions anywhere.
I've been rummaging around here for a while, but haven't found anything yet.
I would be very happy if someone could give me hints in which posts or where I can find something like that. ty and greetings to all
where is the tailoring skill coded? like the processes of adding patches/repairs etc
to develop a mod, you write a lua script and access methods from this javadoc https://projectzomboid.com/modding/index.html
and you can research inside existing mods folders
and there is some useful vanilla lua script inside gameFolder/media/lua/client
package index
i believe i have found it just now nvm (ISGarmentUI.lua)
How doable would it be to make a mod like this https://steamcommunity.com/sharedfiles/filedetails/?id=2727440840 but without making the attack a timed action? I have been looking for a good duel weilding mod for so long but there are only 2 that I can find. This one which is ok but not updated and danger zone which is better but uses a combo method I don't care for. '
I want something to pair up with the fixed one true cure mod
also this one lets you use 2 handed weapons in offhand which makes them OP due to the attack speed. Ideally I would only want it usable for 1 handed weapons. If anyone think they can do it I would be willing to pay to have it done
Thank you for your answer but that was not my question. I donยดt want to know how to write a mod. I was asking about how create a modpack for making the work as a server owner easier. so you donยดt have to restart the server so often because of updates
oh i got it, i missunderstood what you mean by modpack
no problem. thank you for wanting to help
im using filewriter and filereader to detect when a file has been modified but it feels a bit... arcaic and stupid... is there any way to do that? Since that i know off, theres no way to use lfs
apart from using the method im using... which makes me compare the values of a stored file with the actual existing file every x time
i doubt it, filesystem stuff is pretty restricted
yeah... the only way i managed to do so was to read the file into memory, and every X minutes passed read the file again compare it to the stored one and use logic to get a result...
question.. if need reduce consumption of propane when a certain modded trait is active
i need to hook/overwrite the vanilla codes right?
tbh ihavent checked how the vanilla does it . im just assuming its on a lua code or is probably a recipe code which i doubt
but could be possible
the nicest thing i can think to do is if you're writing the input format, just have a single value that always changes (maybe a hash or something), so you only have to do one comparison
thats the way im gonna do it when everything works in a basic way... baby steps ๐
but was hopping there was another way to do so... for now if the file has text in it, copy it to memory and delete de file contents
then every x minutes check if the file content is not nill and copy it again to memory
basic but functional... feels "dirty" though...
and since im using json from the app that creates the file, eventually ill check only for change in some data fields or just one... and pull whatever i want from that file and leave it alone apart from changing one field from 0 to 1 or true to false or whatever flag i feel like using for the value... but it feel over complicated to do something so simple as to check if a file has been modified...
When looking at things such as
BiteDefense = 100,
BulletDefense = 100,
WindResistance = 100,
WaterResistance = 100,
Is there a list of all the types of Defence and Resistances, or is what I just put all that there is in the game?
Type = Normal,There are various types of items in Project Zomobid, below you will se each of them with a short description. Normal โ A basic item. Drainable โ An item that has a certain amount of uses before it's destroyed Food โ An item that can be consumed by the character Weapon โ An item that...
Sorry just checked its not there
Hello.
Anyone have some nice bot to display on discord info about killed zombi, deaths etc...
But i guess u got all of em
I appreciate it anyway, but thank you for posting that, that may come in handy for other things
what'd be best way to track how much time has passed since player did XYZ? Add timestamp in moddata and check against it every now and then?
you can find all valid parameters in Item.DoParam
i don't see any omissions jumping out at me but this list is a little old
You can make a mod that gets the data with something like
getPlayer():getTimeSurvived() - time alive
getPlayer():getZombieKills() - zombie kills
the bot... no ideia... i use an eggdrop for all my needs
@pulsar heath eggdrop ?
guys ive never really modded anything ever, but does anyone know how i would go about changing the item spawn locations, rates, etc? there are no videos on youtube about this and i think id be fun to mess around with
i guess what i really should be asking is where to start with modding pz. i dont know any lua, but i know some (and thats a stretch) python and ive heard theyre pretty similar. any resources/videos i could watch to get started?
Is there a way to change how players are perceived by zombies? like making them not look like a thread?
linux bot
Any way to catch any prints in lua files that are loaded on game boot? got some issue with traits system, wanna check if my stuff catches somethin correctly
creation methods and stuff
read the log file?
tried to buy maybe missed it, lemme try again
this game sometimes 
I was subbed to my mod while working on it in my dev workshop folder
and it was loading luas from workshop

Howdy folks! I've had an issue with my mod for, well, it's entire existence which has plagued me for a while. I can't really seem to figure it out, and some other folks who have helped me haven't been able to either.
I'm trying to get packages of food to give you the fresh/stale/rotten equivalent of the container, though no matter what they will always yield fresh items. I'm using OnCreate recipes for the results, here's an example from a Lunchable item:
--Medium Snackable Ham and Cheddar
function Recipe.OnCreate.OpenMedSnackableHamCheddar(items, result, player)
player:getInventory():AddItems("PompsItems.PIRitz", 5);
player:getInventory():AddItems("PompsItems.PIHam", 5);
player:getInventory():AddItems("PompsItems.PICheddar", 5);
player:getInventory():AddItems("PompsItems.POreoVanilla", 2);
end
The base recipe item is an empty container, while the OnCreate stuff is all the food. Would anybody be willing to help me out with getting this longstanding issue resolved?
If you setInvisible(true) on a player, they are only invisible to zombies... So essentially perceived as a nonthreat.
You just need to age the food. Taken from where the foraging system does it:
item:setAge(ZombRandFloat(item:getOffAge(), item:getOffAgeMax()));
but does sound still trigger them? I only would like to have zombies dont get triggered by a player visually (and also maybe if the distance is big enough xD)
AddItems returns an arraylist of the items you added, so you can just loop through each group with something like:
for i=0, items:size()-1 do
if items:get(i):getType() == "[YOURFOODBOXTYPE]" then
sourceContainer = items:get(i);
break;
end
end
local foodList = player:getInventory():AddItems("PompsItems.PIRitz", 5);
if sourceContainer then
for i=0, foodList:size()-1 do
local item = foodList:get(i);
item:setAge(sourceContainer:getAge());
item:setOffAgeMax(sourceContainer:getOffAgeMax());
item:setOffAge(sourceContainer:getOffAge());
end
end```
and I think that should get you your food items with the same age as your source
Ah, sweet. Thank you very much!
Howdy!
Isnt invi and ghost tied together
Question
If the function or variable is local on the vanilla lua
You can just use it even if you require am i correct?
no
you can't access a local from another file
unless it's returned by something, but afaik vanilla literally never does this
Anybody know a guide for erosion?
*found and old link from 2013, gonna check that later.
v.41.78
#1. erosion is not modable with code, mostly set with map tools.
#2. erosion objects spawn only once. Objects like trees can give false impression of that because of the speed they appear with.
Edit: As Albion pointed out, this solution probably won't work, as the IsoCompost.update function is called from Java, and not from Lua.
There's no direct event for when rotten food becomes compost, but you may have some luck using Chuck's Java decoration strategy to look at the IsoCompost's container when it updates.
As pseudocode:
local oldIsoCompostUpdate = getJavaMethod(IsoCompost.update)
function myIsoCompostUpdate(self)
local previousItems = makeListOfContainerContents(self:getContainerByType("composter"))
self.update()
local newItems = makeListOfContainerContents(self.container)
-- do what you will with previous and new items here
end
It won't be pretty (there's a bit of boilerplate to decorate Java functions), but it might be workable enough for your use case.
Note that items have IDs, so you can safely just make a third list of "itemsComposted" by removing all duplicate ids in currentItems based on the items in newItems, and vice-versa for "itemsGenerated"
The way to decorate Java methods can be found here < in Chuck's code, the functions called
patchClassMethod.create and patchClassMethod.apply()
https://github.com/ChuckTheSheep/Skill-Recovery-Journal/blob/main/Contents/mods/Skill Recovery Journal/media/lua/client/Skill Recovery Journal XP.lua
Hopefully this helps!
will this really work? messing with metatables should only affect methods when called directly from lua
I forgot the link to Chuck's code, but you may be right ๐ฆ
Yeah, you're probably right. Damn it, I actually thought this was a solvable problem for a tick.
So alternative solutions would be.. Using an event that fires every second and storing the IsoCompost tiles in moddata to check 'em out?
Would you find notes on StashSystem useful?
anyone knows where i can find the zombie knockdown.. the debug
function DebugContextMenu.OnSelectedZombieKnockDown(hitFromBehind)
local zombie = DebugContextMenu.selectedZombie
zombie:knockDown(hitFromBehind)
end
this didnt work for me
local function zedSnared(zombie)
if not zombie then return end
local sq = zombie:getSquare()
for i=0, sq:getObjects():size()-1 do
local obj = sq:getObjects():get(i)
local spr = obj:getSprite():getName()
-- print(spr)
if spr == snareOpen then
zombie:knockDown(hitFromBehind)
getSoundManager():PlayWorldSound('BearTrapSound', zombie:getSquare(), 0, 5, 5, false);
addSound(zombie, zombie:getX(), zombie:getY(), zombie:getZ(), 5, 1)
obj:setSprite(snareClose)
obj:getSprite():setName(snareClose)
obj:transmitUpdatedSpriteToServer();
obj:transmitUpdatedSpriteToClients();
if isClient() then obj:transmitCompleteItemToServer(); end
getPlayerLoot(0):refreshBackpacks()
end
end
end
Events.OnZombieUpdate.Add(zedSnared)
or maybe cuz the lua is on the client folder
what is hitFromBehind?
thats from vanilla
it's an argument to the function
debugcontextmenu
you need to find out what the value actually needs to be
In the base game usage, true or false.
In zedSnared, since its undefined, it'd be "defined" as nil here and evaluate as False, right?
you copied it but you didn't define hitFromBehind in your code
so you're just passing nil
hmmm
Morning all
in vanilla it was passed as an argument
so the regular stagger effect works on zed cuz i dont see where the knockdown function goes
Wondering how one would go about selecting a player you right clicked in code. I looked through other examples and it seems like you use something similiar or exactly to self.other but I cannot figure it out
worldcontextmenu
Passed to java?
Its not in the lua
In DebugContexMenu.lua:
option = subMenu:addOption("Selected: Knock Backward", false, DebugContextMenu.OnSelectedZombieKnockDown)
option = subMenu:addOption("Selected: Knock Forward", true, DebugContextMenu.OnSelectedZombieKnockDown)
But knockdown is indeed a java func
replace it with a boolean value
Maybe theres a setKnockDown
Ill look at the wiki for zed stuff
Ill try this thabk you
Ow shiz didnt see that before
Yeah found that ah missed it
๐ apologies and thank you