#mod_development
1 messages ยท Page 265 of 1
30s means 30s after as many players as you configured joined
its 1 player
so its already expired
we will see he is joining now
i always test it with 1 player
to start right away
I never tested Hosting. always dedicated.
Yeah, its not working for us, stays in nonPVP
for me simple hosting is a lot more benefical
a battle royale is like, i run it on my comp, and they join in, after that i close the server
i had used about 100+ mod with your royale mod, all of them worked correctly.
thats why i think that there cant be any difference.
@night ironhey
Hey hey
Ok, you know better than me on this. Then check Start PVP Off Delay in your server sandbox init file. I see no other reason.
im not, you are right, im just a beginner.
checking the ini file
Im just loving your work, dont want to be overwhelming.
Also i will support your royale project with some money in the future. if it becomes good.
I can do really big streaming events in zomboid.
ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
i think maybeeeeeeeeeeeee...........
i found something
@mellow frigate your PVP shield also work on custom standalone maps? because i using that.
maybe the problem is that it only works in the basic map. which is a problem for me.
not map dependent
then idk, i found a server configer guy, maybe he can help, need a few minutes
maybe that can be a problem if i set to "1" player.
trying with "2" player. maybe gonna work.
My friend also tested it, sadly he also cannot get it work.
Is there any helper function / method to get an items texture without instantiating it? assuming we have it's full 'class' name
ScriptManager.instance:getItem("Module.Type"):getNormalTexture()
thanks
Guys, if I want to have a table on the server side, do I need to place it inside the function that is called by the "OnClientCommand" Event or can I leave it "free" in my code? Just because my code is inside the server folder, would the game interpret it as a server table?
all code in the shared and server folders is ran by the server
you may want to start server-specific files with if isClient() then return end to prevent them from also running on the client but in a lot of cases not doing this won't actually cause problems
Good to know, it helped me a lot
I'm trying to migrate my code from single player to MP, but there are so many challenges
I don't know if this is the appropriate channel but I made a mod I hope it helps many administrators
https://steamcommunity.com/sharedfiles/filedetails/?id=3345167560
That can definitely be useful for infinite water plumbing
Anyone got any good documentation on how animations are called?
does anyone know how to make having two trunks on a vehicle work right?
im trying to add a trunk and truckbed but the truckbed only allows acces when standing on the area of the trunk
now that i have finished my inventory pane rewrite i could finally pull this one off for my improvised tools woo hooo:
when salvaging these improvised tools there will be a chance, based on skill, to recover each of the material used to make them ๐
Check the animation viewer in game
Nice ! Why did you not use tooltips instead ? Bcs your rewrite will be incompatible with other mods that do so, notably Inventory Tetris
๐
Inventory tetris can't show this for sure
Which is why I'd find tooltips more suited
It's what Susceptible does for example to show a custom durability bar on its filters or oxygen tanks
I find the tool tip option not optimal specilly when you want multiple items displaying information for comparison etc
I can however also show the mats on the tooltip though
I see what you mean yeah
That'd probably be a good idea
So what's your mod concept exactly ?
Modifying weapons ?
Also my rewrite opens doors to a lot of new ideas. Rows can now vary in height and bespoke renderes can be done for specific items
My original intent is to ease on the gatekeeping, through endless search for key items, of a LOT of game features. So I'm introducing very flimsy but salvageable alternatives to this crucial items to get you going until you find safer and more durable alternatives
Where does one find this?
debug menu
Get in game
In a save
Then debug menu (left icon)
Second panel and you should have "Animation Viewer" or smthg like that
Let me quickly unbreak my mod and I'll check it out haha
For balance reasons I'm going to make this recipes take a realy long time to make, the durability be based on skill and materials used, probably introduce a chance of injury when failing critically both creating and salvaging the items. Also the material recovery will also depend on skill and be time intensive
you legend ty
refer to the AnimSets
and its called using various ways actually but setVariable is the most common one or setAnim i think for timed action
theres also an emote function
I've seen a couple mods have used the radial emote feature. Been trying that so far
It's annoying though, certain emotes in the zombie AnimSet are pretty cool and I'd like to use them but emotes have a different set altogether. Is it a copy paste, rename job. Emotes seem to check for something like Bob_EmoteDance strings
Shame you can't just do "player:playAnim("zombie/walk") like the docs imply
what doc ?
I know
It's still listed in the docs tho
I've tried many test animations for it and doesn't seem to do anything
If it worked I'd assume mods like True actions would use it
But they use the emote radial stuff
yeah this is really old api, probably from when characters used sprites
none of it does literally anything```java
public void PlayAnim(String string) {
}
public void PlayAnimWithSpeed(String string, float float1) {
}
public void PlayAnimUnlooped(String string) {
}
but of course it's not marked deprecated why would it be
So that's why I never got any errors LOL
ILuaGameCharacter was probably the old standard then I assume
no most of that is still used
Oh right ๐คจ
there's just not really any consistency about these things i'm afraid
Yeah, trial and error til it works
hello, where would i start learning how to mod zomboid
i wanna make a mod where you can make cookies that have a 1/100 chance of making you explode for no reason
ah pinned
anyone around willing to point me in the right direction on how to add a random injury to a character? (just trying to spare my self some time digging around)
(Repost)
does anyone know how to make having two trunks on a vehicle work right?
im trying to add a trunk and truckbed but the truckbed only allows acces when standing on the area of the trunk
this one is driving me crazy.... so BodyTypePart has a static method to get an array of all bodyparts
but when i try to do anything with the result of this i get some obscure error message that seems unrelated to this like it fails to get somethings type
in game
@night iron try using this advice burryaga gave me a while back and see what you can make of it
thanks!
oh and im not sure if he was looking at the exact function names at the time so you might have to double check. i think the one for getBodyParts is right tho
right now i'm struggling with this:
local bodyParts = BodyPartType.values();
for i in pairs(bodyParts) do
print('========>');
end
i can't figure how to iterate through that supposed array
i wouldnt know. i dont have proper coding experience
good luck figuring the rest out!
thanks he he
there are plenty of mods that get random body parts tho so you can always look around
maybe it doesn't return a lua array but a java one, so it might not be able to loop through from lua properly idk
i got it from here: https://zomboid-javadoc.com/41.65/zombie/characters/BodyDamage/BodyPartType.html
Javadoc Project Zomboid Modding API declaration: package: zombie.characters.BodyDamage, enum: BodyPartType
i think the one u can read in lua is getBodyPart
so if it is a java array that's it it;s just unusable?
if you cant do this BodyPartType.FromIndex(0) then you probably cant access it or something
not necessarily
I can't find it anywhere what
let me check
oh ik why nvm
but that requires you to input a BodyPartType as the arg
yeah so there is getBodyParts and getBodyPart, which both do separate things
getBodyParts returns ArrayList<BodyPart>
and there is a table somewhere that tells you the name of every body part, but i dont remember where i found that
but you know what
it was years ago
local a = ... getBodyParts()
for i = 1, a do
local part = a:get(i - 1)
print(part:getType():ToString())
end
thats an example. but it might work
there are mods that do something like this already btw
like a lib? or in general
meaning free real estate
hummm i may just end up making my own list of bodyparts i can randomise through their numerical indexes that is if i keep to my original plan to restrict which body parts could get injured as opposed to just use
oh ya it's nothing special, but I was just showing example that might work
the page i linked as the vanilla list of all body parts
oh it does
epic
is there a way to make a table of exclusions instead of rewriting the table while excluding some?
it sounds intuitively wrong to copy the whole thing unless the code simply doesnt allow it (like when i was suffering with the health panel)
you cannot use arrays
when people say 'array' here they mean arraylists, actual arrays do not work in kahlua whatsoever
so that method is useless then?
having fun in lua lmao
https://theindiestone.com/forums/index.php?/topic/61-robomats-modding-tutorials-updated-12112013/ i'm tryna follow this but none of the images load
lol nice
2013
Ignore that post
hmm tho looking at it the codes look clean
i just need a guide to lay everything out and get a basic mod loaded then i should be able to do the rest
tyty
ohh true, I thought they used ArrayList exclusively instead of Array :/
Hi everyone, I had a question regarding True Music (TM). While digging around its files, I noticed that they have a folder containing some .wavs titled 'TCBoombox_service', 'TCBoombox_stop', 'TCVinylplayer_service', and 'TCVinylplayer_stop'.
I was interested in creating a mod that adds sounds for inserting cassette tapes into TM's boomboxes (along with taking them out, same for their record players) which is why I discovered these in the first place. As someone that has no idea on how to go about implementing something like this (read: no coding experience), where would I start?
In short, I want to achieve the following:
- Make a custom sound play when you insert a cassette tape into a boombox (using the Device Options GUI), and
- Make a custom sound play when you eject a cassette tape out of a boombox (using the Device Options GUI).
Thanks in advance. 
I'd recommend trawling through the vinyl player itself, which should have precisely what you're looking for, and then effectively copying that for the boombox
I can imagine it being a pretty simple few lines of code tbqh
~~ There's a video tutorial on the True Music mod page on how to add new cassettes ... ~~ nvm
This was my implementation for bodyparts
That's not his question
This ignores custom body parts tho ?
Isn't there some very rare mods that add their own ?
Yeah it probably will but I haven't downloaded any tail mods lol
What I would suggest is to find the code that handles the inserting and removing of cassettes in their code
What I meant by that is that you can possibly adapt your code to go through every bodyparts instead of just 16
Could do tbf, in my use case I don't think it's necessary
But you could adapt the code to check length of array before iterating through it
I suppose yes, looking at BodyPartType tho there didn't seem to be a way to get the number of body parts
You can possibly do:
local bodyPartTypes = BodyPartType.values()
local size = bodyPartTypes:size()
?
BodyPartType.values() is an array
you can get the count of bodyparts from the bodydamage
i don't think mods can add new ones but it's preferable to get the count just to avoid magic numbers
and potentially it will be more forwards compatible
local size = BodyDamage:getBodyParts():size()
just got to retrieve the player BodyDamage
local BodyDamage = player:getBodyDamage()
Something like that
oh it's just an enum lol
I've not seen a mod that's been able to add a new array entry to bodyparts as of yet. The only one I've seen (maybe) was that limb removal mod where you can cut your arm off
you can get the count with BodyPartType.MAX:index()
but unless you have a reason to specifically loop over body part types and not the player's body part array it's preferable to just use the regular arraylist loop syntax
Right yeah I didn't see the max
Yeah actually you can just use getBodyParts()
No point getting BodyPartTypes here ?
local bodyParts = bodyDamage:getBodyParts()
local bodyPart
for i = 0,bodyParts:size() + 1 do
bodyPart = bodyParts:get(i)
bodyPart:addHealth(100)
bodyPart:setInfected(false)
end
is separating the local declaration faster in kahlua?
No
it is actually slower on an extremely microscopic level
and it's a readability + scope nightmare so please don't do this ๐ญ
Is it ?
I've always done that
Alright, time to clean my entire code lmao
I've developed this habit of doing it bcs I figured having to declare a local every time would have an impact, guess not then
How can it even be slower ?
Presumably it's not creating a new variable every time it's just wiping it?
i don't really know why it's slower but i figure it's either smart enough to notice this kind of case (DOUBTFUL TBH) or declaring a variable just isn't an expensive operation to begin with
internally locals are stored in an array so 'creating' one may not actually require memory allocation
(the value you assign to it may though)
If the performance is negligible I wouldn't worry ๐ As long as it works
hmm
That's the thing that makes everyone's fucking mods laggy: not giving a shit lmao
it's not really a performance concern here and more 'you probably sacrificed readability because you think this runs better, but it doesn't'
It's especially important if your code runs every ticks, and it's particularly NECESSARY when your code runs every tick * every zombies
yeah basically
Well I'm happy I can ditch it ngl lmao
would this be considered a good practice? or is there a more efficient way to create iterable `arrays' in lua / kahlua?
local toolBodyParts = {};
toolBodyParts[0] = BodyPartType.ForeArm_L;
toolBodyParts[1] = BodyPartType.ForeArm_R;
toolBodyParts[2] = BodyPartType.Hand_L;
toolBodyParts[3] = BodyPartType.Hand_R;
toolBodyParts[4] = BodyPartType.UpperArm_L;
toolBodyParts[5] = BodyPartType.UpperArm_R;
toolBodyParts[6] = BodyPartType.UpperLeg_L;
toolBodyParts[7] = BodyPartType.UpperLeg_R;
toolBodyParts.size = 8;
count from 1, not 0
ok and other then the starting index?
if you start from 1 you can use```lua
for i = 1, #toolBodyParts do
local v = toolBodyParts[i]
end
i believe keeping size as an explicit field here might be marginally faster but it's not really necesary and could leave you open to mistakes
notice i'm not actualy using all parts just the ones i feel make sence to get injured while crafting an improvised tool
the idea is to then randomize the index and get a random body part from this list
and it's all going to get encapsulated in a getRandomToolBodyPart or something along those lines so my question is more in terms of good practices / performance
you can also create it like this```lua
local toolBodyParts = {
BodyPartType.ForeArm_L, BodyPartType.ForeArm_R,
BodyPartType.Hand_L, etc
}
ok good to know
if you need a specific key you can use string = value, or [anytype] = value,, otherwise the keys are 1, 2, 3...
i did try with { 0 = value } but the language doesnt seem to like numercial indexes at creation does it?
if you wanted to do that you'd do [0] = value,
it's a little weird because strings don't need the brackets
(as long as they're valid lua identifiers at least)
and for the length? is there a better option then set it speficaly as another index of the table?
would this make any sence at all? toolBodyParts.size = #toolBodyParts
not within the initialiser
oh you weren't even using the initialiser syntax that's not what you meant ๐
yeah, that's valid, most people would just use # when they need it though (haven't tested the exact performance difference but it's likely negligible)
lol ok i just ran a few tests:
- sequential 0 to 7, # = 7
- sequential 0 to 6 with last index as 8, # = 8
- sequential 2 to 8 with last index as 1, # = 8
- starting index 10, sequencial 3 to 8, last index as 1, # = 10
so # returns the highest numerical index hum?
Hey if I were to make weapon sound replacements how might I go about that?
yeah
a lot of people make the mistake of thinking it counts the number of pairs in the table but that's not what it's for, it'd actually be effectively useless if it did that
local bodyParts = getPlayer():getBodyDamage():getBodyParts()
for i=1, bodyParts:size() do
local part = bodyParts:get(i-1)
print(part:getType())
end
for i=0, BodyPartType.MAX:index()-1 do
local part = BodyPartType.FromIndex(i)
print(part)
end
function getRandPart()
return getPlayer():getBodyDamage():getBodyPart(BodyPartType.FromIndex(ZombRand(BodyPartType.ToIndex(BodyPartType.MAX))));
end
print(getRandPart():getType())
i use something like this for body parts
print(BodyPartType:getRandom())
Hello, somebody knows setBumpType types?
Check AnimSets
in game files?
setBumpType is not a zombie getting stunned
It's a custom animation
Related to bump state
probebly a dumb question but... what is the string argument of 'derive' for? is it just a unique identifier or something along those lines?
yeah
..such a based answer ๐ฅน
yeah it's a dumb question? :x
no, that's all it is
it gets put into the new class's Type field or something like that, it doesn't actually do anything, i don't think anything in the game even reads it
like would this cause any sort of circular dependency issue?
ExtendableItemInventoryPane.derive('ImprovisedTools.overrides.ExtendableItemInventoryPane')
Some UI or joypad code does check the Type field to determine behavior iirc (i.e., special behavior for a certain type) but like albion said it generally doesn't do anything. It's just a string, so this should be fine
Although you'd want :derive
ops! yeh i did miss that!!
Does anyone know how to avoid this with texturing vehicles?
Hey guys, I think I might be missing something, I can't find where the sound object is mapped to the actual sound file. Like generator.ogg, where is it mapped to the GeneratorLoop sound?
isn't it just in the sound definition?
if you can, please show me it as I am away from my computer rn
im probably out of my depth here, but how would i go about editing an occupation? I want to tweak some of their stats
Nevermind I found a way using one of the cheat mods.
is there a way to stop guns from emiting light when shooting?
messing with a mod for airguns and i'd like to make them that tiny bit more accurate (alongside attempting to remove muzzle flashes)
Is there a function somewhere that triggers on zombie death? I'm trying to add loot to their corpses under specific conditions (so, not something that I think I can just do with distros)
Oooh, thanks! That looks exactly like what I need
smh my head I was looking for "onzombiedeath" but it's "onzombiedead"
Technically it should be death and not dead
i'd argue it should be onzombiedie but i don't really like how that sounds
Yeah. I still remember struggling with strawberry code once, because for some reason it's strewberrie
On Death of Zombie
OnZombieDeath
That sounds way more natural
vegitation
hueh
i'm tryna add an item:
StaticModel = Kitty,
WorldStaticModel = Kitty,
Icon = Kitty,
model Kitty {
mesh = Kitty,
texture = Kitty,
scale = 0.019,
}
but it wont load the model
Alright, OnZombieDead works like a charm
i mean something happened
You do Item_Kitty only for icons, not for texture and mesh
Although I'm a bit confused now. Items are added to a zombie's inventory after they die?
its still doing this
in the log it says "Failed to load asset, asset path: ..."
do I have to put the full path?
do i have to restart my game every time i make a change
For models failing to load, most likely
I'm not entirely sure how it works, the way I see it is that the zombie still exists OnZombieDead, but when you receive that call the zombies has an inventory and you add to its inventory. And this inventory is added to the body created from the zombie
I would suggest having a model and item name which is more unique
I see you have scale thing in model txt. It might be either Small or huge that it does not show up
Bcs that might clash with another mod calling their model or item "Kitty"
i dont have any other mods enabled
i've tried 0.01 and 1
Long story short I'm trying to add an item to zombies when they have a firearm on them. I wasn't sure if I had to check their attached items or just normal inventory, but my prints seem to work just fine with getInventory():GetItems()
If you plan on releasing the mod
Since (outside of mods like brita's) I believe all firearms are visible on zombies?
i'm probably gonna delete this after I just wanna get a model loaded
You have no errors with failed to load?
nope
The inventory is created for the zombie OnZombieDead I believe
When you right click and place, does it show mesh with random texture?
nope
Strange. My function triggers with onzombiedead but it detects when they have a weapon just fine. Maybe it happens one frame after the base game function and that's enough for it to work properly...
I meant created just before
No things are done in step, if you run a code a tick before something else, it's impossible to detect from that tick things from then next tick
yeah nah still nothing, ill try 0.0000001
Well, I don't know what form of voodoo the game runs on, but it works just fine for me.
I can show you the code if you're interested.
do i need to restard the game every time i change something
Yes because I said it adds the loot in the zombie BEFORE OnZombieDead
So when you received OnZombieDead, the loot is already created in the zombie
If you're using debug, you can simply reset lua in the main menu. Or ingame by pressing f11, finding your edited file, and reloading it
Alright, that explains it then. Thanks. I haven't touched zombies yet in my mods so I had no idea their loot went through so many hoops to be generated haha
no, the weapon is there because it is visible on the zombie
only visible items on the zombie are added as loot at that stage
When you change item script, restart save, if you change Lua you quit save in bottom right there is reset Lua, if you change model and it did load, you don't usually need to restart and it should refresh in-game, unless error occured, then game restart is required
Loot is generated before or after OnZombieDead
after
Wasn't sure
its still not showing up by the way
Your problem is possibly not the size then
random items on a zombie corpse only appear when a player has entered looting range of the corpse (so usually immediately after it becomes a corpse, unless they're using a gun)
Well in any case I got my function to work and I'm too scared to break something by playing around with it so I'll keep it like this
yeah probably
Do you use custom module?
I found that if you have models in custom modules it can cause issues, so usually have custom module with import base and there I keep item scripts, but models are module Base and separate file.
yeah nah still not working
Did you rename your model and texture from Item_kitty to just kitty and checked if it's same as in model.txt
Another question if you don't mind. What governs the durability on items found in containers? I'd like to simulate it for my own item so it's not always 100% when found.
the texture 100% loads
nevermind it might not
nevermind it does
is my situation hopeless
Anyone know if PZ has lua profilers. I want to see if my mod has performance improvements but its hard to tell without one 
I'll be home soon so I'll help you further
Are you sure your model file is not empty?
ty ty :D
As it actually contains model
yeah I opened it with an editor in vscode
i got a low poly model if it matters
Does it have single material?
Shouldn't matter tbf
I mean there's not a lot of chances that breaks it besides it not having the right texture I guess
It can't have more than one material
For some reasons
Shouldn't matter, yes. Does it matter in PZ case? Also yes
why do I keep getting this error
I used to play with my twin sis like year and half ago, 330 mods no problems
suddendly i cant launch the game even after just adding car mods
which is barely anything
wdym
i just downloaded it
it only has one texture if thats what you mean
Can you send it to me?
Its Huge
I think even with your 0.19 scale you had it would still be way bigger and would simply be out of screen
Try with this one.
Once you download it let me know, ill delete it
its right
I know because I chose the same png for the icon
and if i comment out the mesh it loads the texture as a big box
IF it can't find mesh/load model it will show ICON instead
Here you have mesh, but do not have texture
If you were to not have both, it would cause the item to show icon when on ground
I am using the same texture as an icon
actually maybe
wait hang on
commented out the icon now it gives me error -2 in the corner
when i drop it
says ...:getTex() is null
Why would you do that?
I told you that your pathing to texture is most likely wrong
the icon file was just the texture file
i thought maybe it was having trouble opening the file while it was already opened somewhere else
again, show me your model.txt and folder in which you have said texture
You're telling me you still havent changed Item_CatPlushEmmMod to just CatPlushEmmMod?
As uncommenting icon?
yep
IM not sure why you did that in first place
because you need "Item_yourIconname" and then in script file you just write icon =Youriconname without "Item"
Yeah
Try eating that cat now
well, thats where origin point for that model is
yeah i saw that
ill fiddle with the coords tomorrow, i'm off to bed!
ty for your help :D
Hi all! I have a server with Discord integration configured. Recently the bot just went crazy and started doing unpredictable things. Spam messages, duplicate them, and so on. I found out that the bot's code was written using an outdated library. That's why he behaves this way. I want to rewrite it from scratch, can anyone tell me where the integration code is and if there are ready-made solutions?
Its fresh dig in
is it possible to stop specific guns from lighting up an area when shot?
or is the light just baked in and unremovable
Got a question for anyone with experience using Procedural Distribution
I'm assuming the item number between these two lua files is a one to one, so any numbers higher than the average will have higher chance of spawning when rolled based on; no. of items & weight value
Yes, if you want exact % you can enable lootzed in debug mode and check containers and it will tell you % chance, however more items from mods can further dilute it
Thankyou!
Just want to make sure I don't start breaking the current loot system so I can keep it in line with vanilla, will keep the weights to a similar value to prevent it being too common
The moment you make weapon ranged it might already make it so swing anim will trigger it. You could check maybe bow mods to see what they did, unless they did not remove it and just kept it?
You can always make your airgun melee, but use gun animations? Unless that light up is maybe tied to animation itself?
Just seen your grenade mod aswell, is there any way to call a 3D Model instead of the 2D sprite when it's thrown?
Also a version of the mod that uses foraged stones you can throw to attract zombies via noise would be a pretty dope one to have if it's possible
nvm it's already a mod
Does anyone have a snippet of code for a debug print helper to print out table data?
key = value pairs ?
i dont think so.
this is also what i was thinking but irc ive looked thru this before
and found none but i could be wrong
you could probably create a custom toss animation and animate the props bone
just make sure that you prevent player from rotating
but if you do this then it will throw exact distance everytime
How can I get the coord of a vehicle drivers side tire ? like the square coor where is part of the car it is..., can someone helpme with that ?
nom nom nom
You're not supposed to love him, you're supposed to eat him ๐
love him and eat him
WHAT
NO
how can I add things to the graffiti you do on walls?
i dont think u can'
shame
Is it possible for normal players (by my choosing) to have a custom tag in front of their name?
So that something like this could say "Booster, donator, ruby, golden, etc"
I don't believe so (using the same method as the vanilla game does) as it seems to be hardcoded in Java
You could do it in Lua via a UI element but that would require some effort
Doesn't advanced trajectory use 3d model when throwing bombs? I used it once year ago and I think it did what you want, but I'm not sure
Haven't used it yet so I'll check it out, cheers!
There exists a graffiti mod
How would you remove the magazine type of an existing weapon (so it has an internal magazine, basically)? I know how to edit that sort of stuff with ScriptManager but not remove it entirely
Well, if anyone knows how to use DoParam (or something else) to remove item parameters I'm all ears. Can't figure it out.
Is there anyone here that I can hire for a commission for a simple Helmet cosmetic and make available for any starting character?
https://discord.com/channels/136501320340209664/1125248330595848192
Careful about DMs. There are a few bots skimming for the word "commission".
Sorry, it just says unknown and I think I might have missed something on how to access it.
If you click it, it should take it to the community section in this discord.
Is it possible to disable / override vanilla or other mod recipes and items?
yeah, just redefine them in your script
if it's from another mod make sure your file is alphabetically later than the original definition file
hummm so how does the override occur is it by it's name? or file name? and if instead of override if i wanted to completly supress it?
by its object name
you can override files too with the usual rules (multiple mods have a file with the same filepath = only the file from the mod latest in the load order runs)
if you want to remove it entirely some script objects (afaik all the ones that it would be useful for) have an obsolete = true, property
otherwise you can fall back on overriding the file
i do recommend avoiding file overrides since load order isn't something people usually have much control over
kk thanks for the info @bronze yoke
You can disable with a lua command actually
Just need a way to identify the recipe, either by knowing its name, or possibly automatically if you manage to find a way to do that
There is this one in sounds_object.txt
sound GeneratorLoop
{
category = Object,
clip
{
event = Object/Generator/Running,
}
}
event means it uses an fmod event rather than linking directly to a sound file
so when you ask how it's mapped to the actual file, well it probably isn't, i don't think fmod events use sounds from outside of the banks
many of the loose sound files are old and now unused
Good to know but for now i'm going to try the obsolute = true along with same name recipe / item redeclaration for now
๐
The thing is that if another mod replaces the recipe too, you're fucked
yeh i know on the other end i leave it moddable ๐คท
hmm I see. Thanks for your answer
Is there a guide of some sort regarding sounds? the modding guide on github does not expand on the matter
instead of using event use file = media/sound/whatever.wav
does the mod load order influence recipe / item override or only file name alphabetic order?
only file name
hummm that is a problem then
there is a lot of misinformation about load order, literally all it does is resolve file name conflicts
hummmmmm
it doesn't actually in any situation change the order in which anything loads ๐
i understand i might actualy switch to the code override instead then
Thanks albion, I'll try that
Also, I have this issue I have trouble wrapping my head around, it feels simple but somehow I have a weird thing going on
I'm trying to register and update specific cells, the active cells with player inside. But everytime I call player:getCurrentSquare():getCell(), the same cell is returned, even when I drive far away and I'm not sure why
Here is what I do, am I doing it wrong?
RegisteredCells = {}
-- given the players in the game, get the cells they are in (MP and SP)
local getPlayersCells = function()
local players = getOnlinePlayers()
if (players == nil) then
players = ArrayList.new()
players:add(getPlayer())
end
if (players == nil) then
return {}
end
local cells = {}
for i=0, players:size() - 1 do
local player = players:get(i)
local playerSquare = player:getCurrentSquare()
if (playerSquare == nil) then
return {}
end
local cell = playerSquare:getCell()
if (cell == nil) then
return {}
end
table.insert(cells, cell)
end
return cells
end
-- register a cell to be updated
local registerCell = function(cell)
local cellHash = tostring(cell)
print("registering cell "..tostring(cellHash))
if (cell == nil or cellHash == nil) then
print("cell is nil")
return
end
if (RegisteredCells[cellHash] ~= nil) then
print("cell already registered")
return
end
table.insert(
RegisteredCells,
cellHash
)
print("Cellhash "..tostring(cellHash).." registered")
end
local refreshPlayersCells = function()
local cells = getPlayersCells()
for i=1, #cells do
registerCell(cells[i])
end
end
Events.EveryTenMinutes.Add(refreshPlayersCells)
I also saw there was chunks, but not sure how they work or what they are precisely
there is only one cell
IsoCell has nothing to do with the 300x300 areas in maps also called cells, those have little relevance at runtime
IsoCell is an object that stores the entire currently loaded area
Damn, I got this fully sideways. Thanks for the info.
Then, could chunks be what I'm looking for?
Given my idea might not be performance friendly, I'm trying to limit the affected area to what player can see, 300x300 felt like it was convenient (when I thought they were isoCell) but I could do smaller
chunks are 10x10 areas, they're the units the game actually saves/loads in
(so a chunk will never be partially loaded, it's either loaded or it isn't)
So I could get the chunks around players in a 5 chunk radius or something
humm not having any luck with disabling recipes by their name... unless i also use the same file name but this requires me to include all recipes not just the ones i want to disable.... tried scripts/zexclude_recipes.txt and scripts/zexclude_recipes.txt
module Base {
imports { Base }
recipe Make Stone Axe {
IsHidden:true
}
(...)
}
but if i name the file scripts/recipes.txt then it disables those recipes but unless i include all the other orinal ones it also removes those :/
ohh for recipes you need to use Override:true actually
i forgot, multiple recipes with the same name is valid
if you want to override a vanilla recipe with multiple definitions like that you need to use lua because they did not think that out at all
kk i'll try that then
Worked like a charm thanks @bronze yoke
btw what is that import for?i did see it on someone else's mod and hoped that would fixe my issue but now i'm a bit confused what use is that import for
it doesn't do anything
all imports do is let you reference objects from that module by their short type, you can already do that for same module objects so it doesn't do anything
i think people do this because there's a common error message "WARNING: module <module name> may have forgot to import module Base", which often says Base forgot to import Base, because they literally wrote the error wrong
๐
it shows up when a recipe references an item from another module without importing it, but instead of saying 'module <recipe module> may have forgot to import module <item module>', it says 'module <item module> may have forgot to import module Base'
so the information the error gives you is quite literally always wrong
i see, thanks for the explanation
Hello frens ๐
I've been working on a mod (I think it should be simple, but who knows) all it is, is a piece of furniture (like a vending machine) there's no inventory or anything special about it, i've just been trying to get it to work while getting my feet wet in modding, but i've been on it for two days, and have good portions complete and working-ish, but i would love some help if anyone would be willing to msg me ๐
If a mod changes a base item, for instance Base.Money is there a way to tell that it is not the original one and which mod it came from?
item:getModID()
Does this work for DoParam aswell or just script overwrites?
just script overwrites
if you wanted to catch doparams you'd have to patch the function
i know we are not suppose to delete lua files when updating a mod
but can we delete other files? like animsets ?
only scripts and lua are checksummed so only they will break servers if deleted
however leaving other kinds of files could cause unintended behaviour in some cases, animsets seem likely to
getItemModID(String fulltype) If I had the fulltype already, should this work as well?
i don't think i see where that's defined
Class WorldDictionary
that isn't exposed
yeah i think youre right cuz the server still have the file and it depending on the xml if its server triggered maybe
cuz there are folders named network so i bet that could cause issue.
but can we leave the xml blank?
probably yeah
anyone here knows where the dig grave action is defined? i found the shovel ground timed action but this one only seems to be used to fill sacks with dirt, sand and gravel, and i am able to find similar timed actions for filling graves, bury bodies and empty graves, but the actual grave digging is elluding me so far
hummm could it be this? ISEmptyGraves:new ?
client/TimedActions/ISBuryCorpse.lua
maybe
server/BuildingObjects/ISEmptyGraves.lua
client/TimedActions/ISFillGrave.lua
thats all i could find
i think i found it... it doesn't have a specific timed action instead it uses the generic one
lua\client\Tests\TimedActionsTests.lua
Tests.dig_grave = {
run = function(self)
local square,x,y,z = getSquareDelta(2, 2, 0)
local square2,x2,y2,z2 = getSquareDelta(1, 2, 0)
removeAllButFloor(square)
removeAllButFloor(square2)
square:getFloor():setSprite(getSprite("blends_natural_01_21"))
square2:getFloor():setSprite(getSprite("blends_natural_01_21"))
local item = newPrimaryItem("Base.Shovel")
local bo = ISEmptyGraves:new("location_community_cemetary_01_33", "location_community_cemetary_01_32", "location_community_cemetary_01_34", "location_community_cemetary_01_35", item)
bo.player = PLAYER_NUM
bo.build = true
bo.canBeBuild = bo:isValid(square, bo.north)
bo:tryBuild(x, y, z)
end
}```
my idea is to have any action involving my new improvised tools to have a large chance to break it... i wonder if i can find a central place where i could do this check only once :/. so far i have been placing the check on individual recipes and timed actions
this is promising:
function ISShovelGround:perform()
(...)
ISBaseTimedAction.perform(self);
end
guess i could check the characters equiped items on this one: ISTimedActionQueue:onCompleted :/
i wonder if crafting recipes are considered timed actions
i dont think so but that im also not sure
client/TimedActions/ISCraftAction.lua
Has anyone ever tried using, "Fixing" scripts for items diffrent than weapons?
I completly forgot about vehicle parts. Maybe because i haven't really touched vehicles yet. I need to check how does it work with clothing if it even does anything. For things like Bulletproof vests and such tailoring system isn't the best, unless there is a way to add more than 3 base "Fabric Type" so maybe Fixers would be better.
Multiple colors for Commonwealth Armor + Crafting
https://steamcommunity.com/sharedfiles/filedetails/?edit=true&id=3309563418
my suggestion is almost perfect as it is triggered for both the take some dirt and all other crafting recipes... except the dig graves action grrrrr
what are you trying to do anyways?
as i've explained earlier today i'm making a mod that allows you to craft improvised tools but these are very flimsy (really low condtion) and now i wnat them to have a high chance of breaking whenever they are used
since there isnt any onUse sort of trigger that i know related to items i need to find a place common to all usages of said tools and trigger a chance to brea them there
i think you can just hook on the perform
and just manually add damage to it
or just make the usedelta set to 0.5 or something
that way it will break after used twice
youre adding new items right?
yes, based on vanilla ones but with new names and defenitions
eg:
module Base {
item ImprovisedSaw {
ConditionLowerChanceOneIn=1,
ConditionMax=2,
DisplayCategory=Improvised,
DisplayName=Improvised Saw,
Icon=Hacksaw,
MetalValue=35,
StaticModel=Hacksaw,
SurvivalGear=TRUE,
Tags=Saw,
Type=Normal,
Weight=0.7,
WorldStaticModel=HacksawGround
}
}
and the recipe to create it is:
module Base {
recipe Improvise Saw {
TreeBranch/MetalBar=1,
Twine=1,
Result:ImprovisedSaw,
Time:5000,
Sound:PutItemInBag,
Category:Improvised Tools,
OnCreate:ImprovisedTools.recipes.OnCreateTool,
OnGiveXP:ImprovisedTools.recipes.OnGiveEXPImprovise
}
}
i have some bespoke creation code which records what materials were used to create it, among other things, to later on be potentially recovered through a salvage recipe
actually after some more in depth testing it seems like this ISTimedActionQueue:onCompleted is def being triggered by all actions including dig graves (ISBuildAction) as well as the shovel ground and any crafting action... so i think i'm going to try to patch it and see if i can find a way to affect any of my new improvised tools used in the action
is it common to not namespace a module? I kind of figured Base was for the core game and we should name our mods something else
no idea i'me just learning how to do this
btw is it possible to have a recipe auto equip a tool on a character?
It's not necessary
a recipe ? Why ?
Oh I see what you're trying to do, like equip a tool that is used in the craft ?
I think so, something to do with prop
good practice doesn't mean common unfortunately
when using "Base.something" for your new items, you should ensure to give the "something" a very unique name (ideally containg your mod's name or a unique shorthand for it). With a generic name like "Base.LongShirt" you may run into the problem that another mod uses the same name for one of its items and you get mod compatibility issues.
But as long as you use very unique naming conventions with "Base." it should be somehow ok. (At least I hope so...)
but why do that?
there is at least one case where you're forced to use base but aside from that, the game provides modules as a solution to this problem
FenrisWolf writes in a modding guide that using smth different from Base. is a "minor" performance hit.
See here: https://github.com/FWolfe/Zomboid-Modding-Guide/blob/master/scripts/README.md
i have no idea how true that is as it doesn't point to any specific reason or source
i can imagine reasons why it might run ever so slightly slower but i can't think of a reason it'd be something worth thinking about
Is it possible to add another section to the F1 Help menu Would like to add Car Claim Info aswell as Safehouse Claim Info?
I am definitely no expert here. I just take FenrisWolf as a reliable source (I think FWolf is even a member of IndieStone now...)
But I am not saying using Base. is the best thing to do. It's just "If you use Base., then be very careful about naming conventions."
Hey would anyone know how to fix this issue with damage textures?
I know I fixed it in the past but I canโt remember how
The guide of FenrisWolf is probably the best starting point for getting into PZ modding you can find (in my opinion...). But the basics about lua coding are explained only very roughly and some prior knowledge about lua or other languages is still necessary.
I feel like the lua is pretty straight forward. the guide I am still looking for is modeling. every game I mod I fall short because I have not fancy graphics.
Considering that calling Java functions or rendering UI take so much performance already, I think it is OK to use modules other than Base, even if it did have a 2 FPS decrease.
Hi, I've just got a Project Zomboid poll here. I want to know what people want the most in the game. And no it's not a scam link or anything like that, I am not a bot lol
https://www.surveymonkey.com/r/NXSP3KR
THIS IS NOT SPAM I just wanted to post it in two channels for various reasons
Nor am I employed by TIS, I am a modder!!!
is there something im doing wrong with putting on the vinyl covers for the true music mod on solo? it keeps showing me the generic ones.
hi all, not touched a mod I made in ages, downloaded from the steam workshop and when i tried to host a server with it it kept aborting the launch, and in the logs was saying it was downloading mod 0/0 and it was failing to download. I copied the contents over to my C:/users/name/zomboid/mods folder and it works fine, just wondering if anything had changed on how to upload a mod to steam, and if not is there a guide anywhere in case I did something wrong
what version?
Morning yall, is it safe to assume the global getPlayer() always returns the active player? specially in scripts under the client folder?
it returns the latest added player local to the process calling it
so if you're not playing splitscreen yeah
hummmm
I mean that means it's not reliable guess i'll check if all actions handled by ISTimedActionQueue.onCompleted have the player property and use that instead
which seems to be the case to all 3 actions i'm curently focusing one, ISBuildAction, ISShovelAction and ISCraftAction
do you happen to know how I can use a "getPlayer()"-like command in client so that it also gives the actual player when playing in split screen?
i don't really get what you want to happen there, who is the 'actual player' in splitscreen?
Iโm not sure but I posted it 312 days ago, is there a more up to date guide on uploading it to the workshop, cause planning on reworking the mod anyway, so will reupload when that bit is done
I think you can manage the version from the ingame workshop menu right?
i mean when you publish it from the ingame workshop menu
also this should be on the mod.info file at the top of your mod file structure right?
Ok... so I am not 100% sure how split screen works in general so I don't know whether my question makes sense at all.
But if 2 people playing split screen, isn't it the case that each of them has their own client code? If not, how is the UI for each of the player managed?
For example, doesn't each player get their own health screen or their own inventory window?
(I never played split screen and therefore don't know how it looks like. But I know that at least one of my mod doesn't work in split screen...)
yes but they aren't separate lua environments, there's just multiple ui objects
maybe it's on the workshop.txt instead i cant recall
writing for splitscreen generally comes down to *not* using getPlayer() or any equivalent as it's generally unnecessary and makes your code weird
ok so i was hoping adding the prop1 and pop2 to my recipes would automagically make the game equip which ever items are used in the recipe unto the characters primary and secondary slots but such is not happening so is there anything else i need to do on the recipe for this to happen or does the actual prop1 and prop2 equip have to handled on a recipe by recipe basis through lua events?
as reference this the recipe i'm trying this on:
module Base {
recipe Salvage Improvised Tool {
keep [Recipe.GetItemTypes.Scissors]/[Recipe.GetItemTypes.SharpKnife],
ImprovisedAxe/ImprovisedHammer/ImprovisedKnife/ImprovisedNeedle/ImprovisedPickaxe/ImprovisedSaw/ImprovisedScissors/ImprovisedShovel/ImprovisedSledgehammer/ImprovisedTongs/=1,
Result:UnusableWood,
RemoveResultItem:true,
AllowDestroyedItem:true,
Time:120,
Sound:PutItemInBag,
Category:Improvised Tools,
OnTest:ImprovisedTools.recipes.OnTestIsImprovised,
OnCreate:ImprovisedTools.recipes.OnCreateSalvage,
OnGiveXP:ImprovisedTools.recipes.OnGiveEXPSalvage,
Prop1:Source=1,
Prop2:Source=2
}
}
in cases where you want to do things to all players in code that isn't already tied to a player (which is the most common necessary use of getPlayer()) then the snippet:```lua
for i = 0, getNumActivePlayers()-1 do
local player = getSpecificPlayer(i)
if player then -- must nil check as there can be 'gaps' in some situations
-- do stuff to the players
end
end
many thanks! that's probably what I need! I'll play a bit around with that code.
It looks like from going through the ISCraftAction code that props are only used for animation purposes :/
hey maybe soomone have or know mod that could make logs with actual date / time / weather on server in to logs ? so i can make bot for discord that will show it on channel?
did you try editing the OnCreate function?
I assume your OnCreateSalvage is custom. somewhere in that function you need something like
if not player:getPrimaryHandItem() then
player:setPrimaryHandItem(result);
end
player:setSecondaryHandItem(result);
end```
this checks if the player has something in there primary hand, if not equip.. otherwise equip to the secondary hand
OnCreate is invoked after the crafting action is completed i'm trying to force the props to be on the character hands while crafting
so at the moment i'm trying to pull it off by patching ISCraftAction:start
but i'm struggling to manage to figure out how to reference what items are actualy being used by the recipe
playing with RecipeManager.getAvailableItemsNeeded right now...
Craft recipe have a parameter for prop1/prop2.
you lost me ๐
You want the items being used in the recipe to appear in-hand during the crafting?
so you are trying to not craft from inventory. only from equipped? (at least for this recipe)
no I'm trying to force any prop item used on the recipe to be equiped during the crafting process so that i can check if any of those equiped items is one of my improvised tools so that when they are i can roll to break them
What happens in this case?
So you're trying to make it so the tools have a chance to break during crafting?
only the ones i introduced with my mod but yeh that's about it
There's another param called OnCanPerform
Either this, or OnTest should fire every tick during the recipe
I forget which
onTest is used to build contextual menus
OnCanPerform i havent played with yet i may have a go at it
๐ I just remember one fires every update() tick for the crafting
You could probably break your tools in there - and abort the crafting
nah i wana do it at the end but in any case it could be a good place to keep any used improvised tool equiped
so that at the end i can get any primary and secondary equiped tool and check if those are improvised and if so then roll to break them
Looking at the java - seems like canperform is only checked once - but no harm in testing it yourself
You could use OnCreate for that?
still trying to solve the "what items are currently being used in the recipe" problem though
-- When creating item in result box of crafting panel.
function Recipe.OnCreate.TorchBatteryRemoval(items, result, player)
for i=0, items:size()-1 do
local item = items:get(i)
-- we found the battery, we change his used delta according to the battery
if item:getType() == "Torch" or item:getType() == "HandTorch" or item:getType() == "Rubberducky2" then
result:setUsedDelta(item:getUsedDelta());
-- then we empty the torch used delta (his energy)
item:setUsedDelta(0);
end
end
end
The items param is an array
The order is the order in the recipe
so [1] and [2] would be your tools being used
again that's after the recipe completes
You just said after?
^
i want test after but i want to equip any keep indient of type improvised before
so unless the canperform event also receives the same items array i will keep persuing my current investigation using RecipeManager.getSourceItemsNeeded
Not really sure what you're asking for. You want to roll for breaks after, but what does "equip before" mean?
just use a function for the items
look at recipe Create Spear
you can create a function that declares what items it will use for the recipe
then use the function I mentioned early to only allow the items you want to allow
ok to recap, i want to when starting the crafting session look at the keep sources and check if it is using an improvised tool, one of my new items, if so i want it to be equiped while crafting. Then when it finishes i want to roll for a chance to break it
caviat: I want this to be applied on any recipe not just my mod recipes
'any recipe' will probably be higher in the code. not sure if that is lua exposed.
you can still use a function to check what you have in hand and only allow items if you are holding a specific item.
you can use Tags on items to tag each of your created items, then check if holding an item with that tag.
but this all still relies on changing each recipe you want to affect.
I know about tags already, which i'm in the process of implementing to my new tools already, giving them a new tag called "Improvised"
you should namespace your tags
as for the onTest i would rather not since that will hide the recipe away from the context menu making it hard to know why it can't be built
to reduce conflicts with other mods
You can overwrite the timed action for crafting - specifically the subevents. Although I'm assuming the equip item at the start is a preference thing? (In vanilla it's sort of visual only)
in any case i'm very close to want to achieve by patching ISCraftAction:start combined with RecipeManager.getSourceItemsNeeded
in vanilla it still requires the item equipped. I think cutting leather stips requires scissors
but that still hides the recipe, obscuring it
in fact right now i'm already able to check wich keep source is curently being used in any recipe, so i guess my next step is cross reference this with the prop1 and prop2 and when these match force the item to be on the character hands
for as far as i could tell prop1 and prop2 is really only a visual animation thing it never actualy equips the items
function ISCraftAction:getPropItemOrModel(propStr)
if not propStr then return nil end
if propStr == "" then return nil end
if not propStr:contains("Source=") then return propStr end
local sourceIndex = tonumber(propStr:sub(propStr:find("=") + 1))
if not sourceIndex or (sourceIndex < 1) or (sourceIndex > self.recipe:getSource():size()) then return nil end
local items = RecipeManager.getSourceItemsNeeded(self.recipe, sourceIndex - 1, self.character, self.containers, self.item, nil, nil)
if items:isEmpty() then return nil end
-- It would be best to use the item instead of the model, so any blood/etc appears as expected.
-- But things like flashlights have animation masks which break the "Dismantle Flashlight" animation, for example.
-- So return the model name instead of the item. Returning the item does work, though.
return items:get(0):getStaticModel()
end
There's this under craft action
But you mentioned start() already
Could just dump the vanilla start event in favor of your own - but it could create problems with other mods doing safer overwrites
Out of curiosity - why does it matter to equip the item?
why use prop1 or prop2 instead of player:getPrimaryHandItem() or player:getSecondaryHandItem() ?
exactly
i am patching start but i am only intercepting it to do my code and then continue on with the original implementation
not actually replacing it
Can't you get "onCreate" that would get items you made it with, take its tools and give zombRand to decrease condition?
Nik i have already answered this, onCreate happens after the recipe is done, i want to equip the items before the recipe completes
I know what you mean, but is that really necesarry if prop 1 and 2 can display items used with recipe?
but guys thank you a bunch for the discussions if nothing else it was an awesome rubber ducking session but i'm very close to what i want just need to nail down a few details
And you want the tools to lose condition and i don't think its needed for them to be "equiped"
it's hard to tell which of the items i want to decrease the condition from unless i cross reference it with the props, for example my salvage recipe both sources can have improved tools but only one of them is used as an actual 'tool'
Have you already tried to equip your improvised item when the vanilla function ISInventoryPaneContextMenu.OnCraft is called? That is actually the first function which is called when player chooses to craft smth from the inventory menu (right click on an ingredient -> craft recipe). This function is also the function which then calls the ISCraftAction TimedAction. Equipping stuff in your hand is in vanilla game in most cases also realized by a timed action.
thats a good point I'll have a go at it after i'm done with my current experiement
Even the vanilla game seems to use this particular function to equip tools to the player's hand in case players are crafting "MovableRecipe" objects. Not 100% sure but it will probably equip a hammer if you craft a wall or furniture where you need hammer for example.
i'll take a look at it later thanks @small topaz
nailed it ๐
my initial strategy paid of and i was able to equip the recipes prop1 at the ISCraftAction:start
local function getUsedSources(recipe, character, containers, item)
local sources = recipe:getSource();
local sourcesCount = sources:size();
local usedSources = {};
for i = 0, sourcesCount - 1 do
local source = sources:get(i);
local isKeep = source:isKeep();
local items = RecipeManager.getSourceItemsNeeded(recipe, i, character, containers, item, nil, nil);
usedSources[i] ={
sourceID = i,
items = items,
isKeep = isKeep
}
end
return usedSources;
end
local function getPropItem(usedSources, prop)
local getTableSize = ExtendableItemInventoryUtils.getTableSize;
if prop:contains('Source=') then
local sourceIndex = tonumber(prop:sub(prop:find('=') + 1)) - 1;
local source = usedSources[sourceIndex];
return source.items:get(0)
else
local sourcesCount = getTableSize(usedSources);
for i = 0, sourcesCount do
local source = usedSources[i];
local items = source.items;
local itemsCount = items.count;
for j = 0, itemsCount do
local item = items[j];
local name = item:getName();
if name == prop then return item; end
end
end
end
return nil;
end
local originalISCraftActionStart = ISCraftAction.start;
function ImprovisedTools.overrides.ISCraftAction:start()
local sources = getUsedSources(self.recipe, self.character, self.containers, self.item);
local prop1 = self.recipe:getProp1();
if prop1 then
local item = getPropItem(sources, prop1);
if item then self.character:setPrimaryHandItem(item); end
end
originalISCraftActionStart(self);
end
But there's already a prop1 option for the craftings ?
it wont actualy equip the item as far as i could tell only animate with the model in it's hands @bright fog
ah yeah
now i just need to unequip any currently equiped item first so I dont delete it he he he
Just equip the item
It won't delete the currently equiped item
oh yeh your right just needed to update my inventory it wasn't showing there, probebly need to mark it as dirty
Throw a container update after modifying the inventory
humm how do i do that again?
triggerEvent("OnContainerUpdate")
cool let me try that, but shouldn't i also mark the container inventory as dirty?
wdym as dirty ?
there is a dirty property for the inventory panels
typically to mark it as in need to be redrawn
ISInventoryPane:renderdetails
Just whenever you add or remove items, throw a OnContainerUpdate bcs if the player doesn't move it doesn't update the containers and thus he can actually still move/pick up items that were moved
if doDragged == false then
table.wipe(self.items)
if self.inventory:isDrawDirty() then
self:refreshContainer()
end
end```
i did mess with this code let's see how it goes he he he
yep that worked like a charm thanks @bright fog
๐
Is it possible to check the module of an item and use it as a condition?
Like "base" or "farming", etc
try item:getFullType()
item:getModule()
It's that simple? O_o
๐คท i'm just guessing to be honest
Doesn't hurt to try
Doesn't that return module.name? Like, Base.Apple? I can probably do a quick manip to get what's before the dot if nothing else works
albion just gave you a better answer i think @kindred dagger
hummm there isn't anything equivalent to AllowDestroyedItem just for a specific recipe source is there?
the best equivalent is enabling it and then filtering out the other items with an ontest
i am a bit lost about onTest item argument though, is this invoked for every possible item available for each source in the recipe or is the item the focused item to which the system checks which recipes apply to it?
every possible item availabe for each source, assuming it hasn't already been filtered by something else
hummm so what happens if the same item matches 2 sources but for one is fine to be broken but for the one is not?
and is there a way of knowing to wich source the ontest is being triggered to?
it'll fire twice (all sources are evalulated completely independently, which means there is no duplicate prevention, one item can fulfill any amount of sources), and i guess there isn't really a way of distinguishing it
hummm is it done on the squence as they declared on the recipe though?
nvm this wouldnt work if i have multiples of this item right?
Question: where would be an acceptable place to link the mod Iโve just finished re-working?
here
Oh sweet!!
I have finally finished the re-model and custom wheels for my cab over!!
There is so much more in store for this mod but I am going to go into the next thing for now!!!
https://steamcommunity.com/sharedfiles/filedetails/?id=3303231648
Hi, did you find a solution for this? I'm trying to get the closest zombie to the player but like you said those methods don't seem to work ๐
Hi! I ended up using the function getNearestVisibleZombie in Cell, which takes a player number as a parameter. So local zombie = getCell():getNearestVisibleZombie(player:getPlayerNum())
(That runs on the client side, BTW)
Thanks a lot! I'll check it out soon
does anyone know what i need to do to change the icon of a placed container?
The current image is NOT what the new models look like btw!!
They look far better then those things
congrats
Hi,
I am looking for a PNG in my files. I have searched everywhere without success, even though a path is indicated in my file. But it leads nowhere. If anyone has a solution, I would appreciate it.
It is the image of Spiffo in the survival guide. In my SurvivalGuide_FR, a line indicates the path to this PNG:
SurvivalGuide_entrie1txt = " <CENTER> "SIZE:large #1 - STAY CALM <LINE> IMAGECENTER:**media/ui/spiffo/control_yourself.png**<LINE> SIZE:medium You won't last long if you don't take some deep breaths and learn the basics."
"media/ui/spiffo/control_yourself.png"
Unable to find this PNG in my server files
yeah it is in texture packs i remember seeing it
if you install the project zomboid modding tools from the tools section of your steam library and then open tilezed and use this
it should be in ui or ui2 in media\texturepacks
then you can export images
ok I see I hadn't considered this possibility, I stupidly looked for a .png in my files, but now that you say it it's clearer, I thank you very much, the hope of finishing this damn guide comes back thanks to you two ๐ช๐ค
Thanks!!
Hey Iโm having some sort of issue with adding in a new vehicle, it shows up in the list but It wonโt load the model and Iโm not sure why
from what ive gathered, table.insert(ProceduralDistributions.list["ShelfGeneric"].items, "item"); table.insert(ProceduralDistributions.list["ShelfGeneric"].items, 1); is the way to make a modded item spawn in the world, in the examples' case, "shelf generic". would the following code work to randomly spawn set items in "ShelfGeneric", without having the copy and paste the line for each item added ```local "MusicSpawn" = MusicSpawn ={
rolls = 2,
items =
{
"CassetteVanHalenUnchained", 5,
"CassetteBornUnderABadSign", 5,
"CassetteTheRooster", 5,
"CassetteLeroyBrown", 5,
},
},
table.insert(ProceduralDistributions.list["ShelfGeneric"].items, "MusicSpawn");
table.insert(ProceduralDistributions.list["ShelfGeneric"].items, 1);```
Evening peeps
something more like this may do what you want:```lua
local items = {
"CassetteVanHalenUnchained", 5,
"CassetteBornUnderABadSign", 5,
"CassetteTheRooster", 5,
"CassetteLeroyBrown", 5,
}
for i = 1, #items do
table.insert(ProceduralDistributions.list["ShelfGeneric"].items, items[i])
end
My Improvised Tools mod is nearly ready only got 1 more detail i would like to learn how to do before i push out it's first version.... item inventory icons... what's the process to get my self some bespoke icons in them? i suspect it has something to do with the textures folder and the icon definition icon property but the files i see on the textures folder seems to be used for 3d models
the vanilla ones are in the texture packs, if you want to look at them spongie was showing how to extract them just a couple messages ago
though you can just download them from the wiki which is usually easier
but basically Icon = MyIcon will set the icon of the item to media/textures/Item_MyIcon.png
ok ok so prefixing them with 'Icon_' does the trick
and what are the restrictions on the files? size etc?
they should be 32x32, i think there's some weird issue with specific bit depths or something too...?
necessary!
i mean i'm not sure if it'll reject a non-transparent texture but it'll definitely look very weird if it isn't
Yep got it working using gimp to produce a 32x32 png with transparency, prefixed Item_ to it and bang worked like a charm thanks @bronze yoke
Very stupid question but how do you remove a specific item from an item container? This function doesn't work. I was running it as a test to see if I could get it to empty item containers before adding conditions.
`local function GalloViking_OnFillContainer(roomName, containerType, itemContainer)
local items = itemContainer:getItems()
for i = 0, items:size() -1 do
local item = items:get(i)
itemContainer:DoRemoveItem(item);
end
end
Events.OnFillContainer.Add(GalloViking_OnFillContainer)`
The way I see it item here is an inventoryitem, so DoRemoveItem should work?
It tells me this line is borked
itemContainer:DoRemoveItem(item);
this is the correct way to remove an item, the mistake is that you're deleting items while looping through it
I'm looping through the items in the container, or at least I think I am. I reused some code I wrote a while back
if you imagine there's two items in the array, then your code:
- gets item 0
- removes it
- array is now length 1
- gets item 1 - but wait, there is no item 1 because the array is only length 1 now, so an error is thrown
Mhmmmm
you should loop backwards if you want to remove items from an array you're looping over
for i = items:size() - 1, 0, -1
Aaaaaah I get it know. The array gets smaller each time so it breaks
If I add conditions later that could become a headache
just store the item during the iteration and remove it after it loops out
you can also break if you want to stop the iteration once you found the only item you need
I'll remove items at random to replace them with others
Wait so actually if I add an item every time I remove one, the array size wouldn't change
you're still messing with the next Item you get of the list, again if you only want to do this once to one item in the list you can either store a reference to it and do the switch after the loop is over or break the iteration once you find the item and act on it. if you want to manipulate the list as you iterate through it i would recomend use 2 lists instead, the original one which you iterate over and a buffer list to which you add items from the original one
alternatively just loop backwards
adding/removing items only modifies later parts of the list so looping backwards is safe
secondly.. looping backwards moves the count() method
first part of a for its the initial, second is the compare, third its increment.
looping forwards inplies you count on each iteration because the count is in the second clause.
looping backwards moves the count to the first clause, executing only at the start of the loop and not on each iteration.
no, the count is only executed once in either case
that's why looping forwards over an array while removing from it is an outright error rather than just causing unintended behaviour
the list gets shorter but the size was already evaluated at the start of the loop so you go out of range
because the control variables are local to the loop. lua is strange. other languages don't do that lol.
you see the same issue in other languages but instead of going out of bounds, you end up skipping parts of the array.
yeah that's what i was referencing with unintended behaviour
though it's not the standard i've honestly always thought this was the more intuitive implementation
standards are not always made because something is intuitive. some times standards are for readability. to help future proof code.
in this case i think it's more readable
the loop conditions are visually separated from the loop itself so it's misleading for them to actually be part of it
I'm glad I asked. All of this is rather informative
of course this only fits into lua because its for loops are strictly(*) numeric
lua actually specifies there are 2 types.. numeric and generic
yeah you can use an iterator too but they break that syntax entirely anyway
i assume you can technically use the numeric iterator with any types that have __add metatables defined but unless they're essentially numbers imo that's weird and you shouldn't do it
if you make a function that returns an iterator of the items you want instead of the actual items, then you can use a generic for on the second. and your iterator is reuseable else where
its because lua has a completely different for structure than other languages lol.
I agree with this being informative. that would have been annoying to stumble upon later.
a bit crude but but i think this will do for now :x
Heyo, I want to learn how to start tinkering with the superb survivors mod, does anyone have any tutorials / information regarding where to start with regards to coding / understanding how to alter the current mod?
Mainly adding capabilities to give them a bit more flavour when in the base, sitting down / reading / sleeping etc. at certain intervals so they seem a little less robotic
Question regarding changing the in-game icon for a modded item with or without ItemTweaker, whichever is most compatible with other mods.
Currently, trying to use ItemTweaker I have the following (with actual names etc. but for example's sake different): ```lua
if getActivatedMods():contains("ItemTweakerAPI") then
require("ItemTweaker_Core");
else return end
TweakItem("ModuleName.ItemNameOne","Icon", "TextureNameOne");
TweakItem("ModuleName.ItemNameTwo","Icon", "TextureNameTwo");
The items I want to change being from another mod, different file location, and the supposed replacement texturefiles being within the mod this `.lua` is in.
This does not seem to work however. Do note, I haven ever worked with ItemTweaker before, nor done trying to change an item's data this kinda way.
im trying that out now, item weight is 75 and i cant find any. i added multiple distributions lists that are being added to
do i have to just do it the standard way of adding each object to each container 1 by 1
Item_ is prefixed automatically, just pass e.g. TextureNameOne for the icon
Oh sorry, typed that wrong, I am doing that yeah, without the Item_
item tweaker is not hugely recommended as it's associated with some performance issues and compatibility issues
(and it doesn't really do anything so it's hard to recommend in general)
What is the better more compatible way?
local item = ScriptManager.instance:getItem("Module.Item")
if item then
item:DoParam("Icon = NewIcon")
end
```is equivalent to a TweakItem call
Awesome, thank you!
sorry for replying to an old message, but does anyone know where in the code this would be? Im struggling to find it, maybe itโs just me being stupid
Iโm trying to create my own global object (a container) that updated an item inside (and eventually replaces when the updated value gets high enough but thatโs a separate issue)
i don't believe freezers are global objects
i havent checked their code yet
i only assumed lol
they aren't simulated globally, that's why they can be buggy
they just simulate all the time since they were loaded when they load
that's probably the preferred method for anything using a container really, update it when the player checks the container
with freezers/fridges it causes a noticeable bug where it assumes the current power state was true for the entire time you spent away, so for example if you left your base for a week, and came back just a minute after the power goes out, it would assume the power was out for the entire week and all your food would be rotten
hmm, would that still be the recommended method then, on player check and update based on current state and time since last update
or is there a better way
and do you know of any mod/base game examples of anything similar I can view just to see how it works, as my last attempt worked single player but was incredibly buggy multiplayer
i don't think the game really implements anything like this in lua
fair enough, couldnโt find any mods that did anything similar when Iโve looked either, as a rough guess, do you think this is possible? just before I start going down this rabbit hole again
i don't know exactly what you're doing but what you've described sounds possible
long story short I was making a kiln, so functionally you put in a item with the โfirableโ tag, a fired property on the item ticks up while the item is in the kiln and the kiln is on, and after it reaches 100 it gets swapped out for a different item (a fired version of whatever was put in)
It basically works the same as cooking, but only for certain items
Does anyone know how to add additional parametres to a type? I.e having an shirt that has inventory space or a bag that provides insulation etc.
https://pzwiki.net/wiki/Scripts_guide/Item_Script_Parameters
I assume there's code somewhere that checks / allows for certain parametres to be included in certain "types" but I have zero idea where it is or how to go about finding it
Is there any way to automatically calculate the age of an item like the game does when spawning food in containers?
Nvm, looks like setAutoAge does exactly that
then loook at the campfire
Does anyone have a list of the skill codes used in VHS's?
skill codes?
Some VHS give stats
like boredom?
Yea, or fear, or XP I guess
He might want to know all the possibilities available
Good morning people, just pushed my mod into the wild :x hope i didn't mess it up too much!
https://steamcommunity.com/sharedfiles/filedetails/?id=3340325326
congrats
Congrats, there's some potential, too bad it uses the terrible crafting system
hi all, how do I go about making my new tile consume electricity, I can't see an option when setting the tile definition in tilezed, or is this handled just through the lua? if so does anyone know of an object that I can check the file of, as i'm clearly searching for the wrong thing
you as opposed to what's coming with the update?
Not sure what you mean
when you say it uses the terrible crafting system
Just the current b41 crafting system is the worst shit ever made. It's only benefit is its simplicity but I try to use it as less as possible
The B42 crafting system looks good
yeh that's what i meant
well who knows when that actualy get's pushed out of the door though
When b42 releases
exactly who knows when ๐
But yeah I would really see a more modulable system for your mod, which ignores the limited crafting system and allows you to either use context menu or a custom UI where you put the materials to improve your tool in and then craft a modulable item. Tho idk in detail what your mod does or tries to achieve
should be this year lol
that's a should(tm) right along side soon(tm)
the first half of this year without a doubt
it's just a shortcut to get key tools with very low condition, chance to injure you when constructed/salvaged, and have a chance to give back each of the materials used when salvaged
For sure 
in their defense they didin't say which planet year they were refering to, it could be this neptunian year
Hmm could you not have made such a system for any "Improvised" tool ?
I don't want to imagine in how many years that will be then lmao
i wanted to be able to recover the items used in the construction of the tool so anyone other tool will not have this information in them
perhaps a nibirubian year
Hmm actually you could have most likely done something for this in the case of weapons/tools that are crafted
i think that actualy more acurate... who knows when
Automatically too
if a vanilla recipe as optional source items does the resulting item keep record of which sources were used for it's construction out of the box?
Like:
- go through every recipe scripts
- check the ones with results as tools/weapons
- verify those are "Improvised" (weapon category)
- verify the craft doesn't use the same tool in the needed items (repairs for examples ?)
- access materials used to craft the tool/weapon
No
then my mod does that
But you can ignore parts that have multiple options and just do this
if a hammer can use a hard stick, metal bar or pipe to be built and you use a pipe, when salvaging you can get that pipe back
i could eventualy extend my mod to also try to guess other items materials.... but that was not my focus this time around
i don't really see why recipes wouldn't be appropriate for this
i mean i could even pull a random item from their recipes cource lists
But you've created new items ?
Or at least have made new crafts to make the same thing as other crafts
Such as making your improvised axe when there's already a vanilla one for that
Also your crafts are limited to a set of materials
i did but it is my mods version when created it adds data to it
You can't have:
- make an axe using metal scraps
- make an axe using rocks
with the same craft, or the display won't be great anyway
Hummm you lost me @bright fog
her's one of my recipes example:
module Darkhounds {
recipe Improvise Sledgehammer {
WoodenStick/MetalPipe/MetalBar=1,
Stone=2,
LeatherStrips=2,
Result:ImprovisedSledgehammer,
Time:5000,
Sound:PutItemInBag,
Category:Improvised Tools,
OnCreate:Darkhounds.ImprovisedTools.recipes.OnCreateTool,
OnGiveXP:Darkhounds.ImprovisedTools.recipes.OnGiveEXPImprovise,
Prop1:Source=1,
Prop2:Source=2
}
}```
I think I just don't have the same vision of what your mod was supposed to do
when building this if a MetalBar is used then the resulting Improvised Metal will keep that information
when salvaged only a MetalBar can be retrieved not the WoodenStick or MetalPipe
Yea I really feel like that could have been literally applied to any tool/weapon being created
Which is basically what I saw the mod would do, but you absolutely didn't go that way and just made new items, which use your salvage system
i would have to change every recipe even if programatically going through every loaded recipe sure
dude this was my first mod i have no idea if doing something like that wouldn't mess up all kinds of stuff
I mean it's an interesting concept, just I'm thinking if that can be applied to any tool/weapon craft and I feel like it could
i tried to keep it contained
yea np I'm not saying your mod is shit np
if anything i can use it as the foundation to try something bolder
you mean the idea of crafted items being able to be scrapped into their ingredients? yeah that's pretty universal but it's obviously just one part of what this mod is
Mostly me thinking about the technical aspects being it
Yeah
hell i already went out of my way rewriting the entire item inventory to make it more moddable
and i did tweek it so any recipe containing a prop1 and/or prop2 to force those to be actually equipped
I feel like you can probably run a lua function OnCreate for any tool/weapon creation recipe, if an OnCreate already exists, then decorate the original function with your method to access the result items and add mod data to them with their components. Then have either a craft or directly context menu to salvage the tool or weapon for some of the materials
though the item inventory reqwrite mod is not mandatory for this one
And add such a function OnCreate for any weapon/tool craft
Yeah you did some good job with it tbf. I've been following the development bit by bit whenever you asked for stuff here
i can see that happening for sure, again i just ddidn't feel confident enough to to do it as my first mod
yeh man you guys (and galls) have been invaluable! thanks a million!
it'd be simpler to just hook perform
I guess, I'm not too much familiar with the hooks
i mean what you call decorating
you can mass hook oncreate (i do this with ontest) but it's kind of just overcomplicating it
hooking the craft action's perform action does the same thing but has way less points of failure
Yes exactly
there are a few details that could make this be universally applied a bit tricky though, unless i drop one of the concepts
Hhhaaaaa yes
You are right actually
I keep forgeting it uses a timed action
Tho you need to access the recipe script
Is it sent to the craft action ?
originaly i had a single salvage recipe, that required a scissors or sharpKnife kind of tool but also accept broken items to be able to salvage broken tools, that however meant i could use broken scissors and knifes to salvage other tools
and i couldn;t figure out a away to use the onTest to verify if the evaluated item was coming form athe Keep source, where i dont want to allow broken items, or frrom my second source where i wanted to allow broken items
so in the end i ended up having to have individual salvage recipes for each of my new improvised tools
of corse if i remove the requirment to have a "sharp" tool to salvage the other ones this problem goes away
applying it universally does run into a few issues generally
some ingredient items aren't really 'in' the product item but are just used to create it, and some items just logically shouldn't be recoverable
so i feel at some point the hand crafted recipes become necessary regardless
the craft action keeps reference of the recipe as a property when using the new method
this is mostly true for consumables right?
like it doesnt make much sence to salvage a stew
you wouldn't expect to get glue back for instance
also regarding the onCreate vs perform i acntualy used the start method instead of the perform, since that one is called at the end of the process
fair enough this could probebly be fixed with some sort of black/white list filtering before storing the data
disregard what i just said about using start instead of onCreate, i did use perform, used start to force prop items to be equiped
is this the best channel to self promote a new mod? i mean this channel seems target mostly those developing mods not the player base in general ๐
Hmm
You can list items that can be retrieved
Do you have an example of weapon or tool craft which has materials which shouldn't be retrievable ?
playing with markers
Interesting
Nice, what kind UI marker is that ?
look for getWorldMarkers(). you can add various stuff
hey all, has anyone added custom spawnFunc's for custom forageables
despite matching how the vanilla ones work to the best of my knowledge the spawnFunc doesn't appear to be working
heres my definitions file and custom spawnFunc
that log isn't coming through on discover or collect item
neither am I getting a Log
You got a typo "Vegitation=4" make it "Vegetation=4"
in the base game files its "Vegitation"
yeah, its at the top of the first screenshot
but it doesn't seem to be running at all
hmm, try to uncomment -- if ZombRand(100) + 1 <= logChance then
will do, but had that first, commented it out to make sure it wasn't the check against random number than was broken, without that line it should add the item guaranteed right?
I'm far from very experienced in lua. I can refer you to the PZ modding discord, they are usually very good at helping
Yup 
I'm not familiar how the functions run tbf but everything looks good
Are you getting any errors ?
Also you are adding an item to an item
You need to add it to the inventory
not sure why this was the case, but removing the doGenericItemSpawn func allowed mine to work
ohh, I had only required forageSystem, not forageDefinitions, so the generic/existing functions don't exist, so i think it gives up, but didn't give me and error so might not be right
thanks, joined but my steam is refusing to connect to my discord, so can't post, but will try again later
requiring vanilla files doesn't do anything
i think it might just be because the function isn't exposed tbh, don't need it for mine so not an issue, but wonder if there is a way to use the vanilla spawnFunc's or if its better just to copy paste them into your own file
ok this is weird when i deployed my improvised tools mod to a dedicated server , there were no errors spinning the server up, there are no errors on my client when connecting but i get stuck on the loading screen after the this how you died message no ui no read sound but the cursor is rendered and the game in general does not look like it's frozen ๐
afaik, it'll display this message until everything's fully loaded and setup or something.
So give it some more time first.
pretty sure it's stuck... when i remove my mod it's almost instant
it happens every time? that's really weird
yeh
it's pretty difficult to cause a problem like that without outright freezing or crashing the game
this are the last lines on my server log
LOG : Network , 1729004234743> 2,292,497,682> [15-10-24 16:57:14.743] > ConnectionManager: [receive-packet] "login-queue-done" connection: guid=18014961009955052 ip=[REDACTED] steam-id=[REDACTED] access= username="[REDACTED]" connection-type="Steam"
LOG : Network , 1729004234743> 2,292,497,682> [15-10-24 16:57:14.743] > ConnectionManager: [send-packet] "checksum-packet-1" connection: null
and my client log:
LOG : General , 1729004234989> 0> game loading took 10 seconds
LOG : Network , 1729004234989> 0> [15-10-24 16:57:14.989] > ConnectionManager: [send-packet] "login-queue-done" connection: guid=1729004163327433 ip=[REDACTED] steam-id=[REDACTED] access="" username="[REDACTED]" connection-type="Steam"
LOG : Network , 1729004235022> 0> [15-10-24 16:57:15.022] > ConnectionManager: [receive-packet] "checksum-packet-1" connection: guid=1729004163327433 ip=[REDACTED] steam-id=[REDACTED] access="" username="[REDACTED]" connection-type="Steam"
For what its worth I found these going through the code in some other mods, I think there are a few more (like Short Blade is in one of the real tape in the game)
BOR-1 --boredom
ELC+1 --electric
MTL+1 --metalworking
TAI+1 --tailoring
MEC+1 --mechanics
DOC+1 --first aid
CRP+1 --carpentry
COO+1 --cooking
FRM+1 --farming
FIS+1 --fishing
TRA+1 --trapping
FOR+1 --foraging
PAN+1 --panic
UHP+1 --unhappy

