#mod_development
1 messages · Page 334 of 1
I dropped a lite version of the bike that doesn't have the attachment system so it should be compatible with everything, that'll just have to do if people are having conflicts
well crap.... realized I need to use the GenericCraftingSurface flag in TileZed and my version doesn't have that field, (at least I can't find it). The newest unofficial build steps start with
QTDIR=~/Qt/5.15.2/gcc_64
SRC=~/Programming/pzworlded
which is never a good sign; hard coded paths to atypical files.
quick Q for anyone who may know - seems like when wearing a jacket the game completely hides neck jewelry/chokers etc. im not seeing anything relevant to this in the xmls or scripts aka masks etc. is this a hard coded behavior that a mod cant get around? short of not using the jacket location.
valid properties are defined in a .txt file, you don't need to recompile to change them
I just noticed that; happen to know if there's a current list of properties?
answered my own question. https://github.com/timbaker/tiled/blob/basements/TileProperties.txt
(eventually)
beautiful.
Can I use this function to half weight of all liquids?
Or use any multiplier, at this point
That's like N1 thing I want to do rn
Damn, realized there's a PegBoard in the game already, now I'm thinking I should modify the existing item vs creating new, which seems far more complex :/
Having issues with recipes..
recipe Make Ice Cream
{
[Recipe.GetItemTypes.SapphCookingMilk];10,
[Recipe.GetItemTypes.SapphCookingSugar];10,
[Recipe.GetItemTypes.BakingFat];1,
[Recipe.GetItemTypes.SapphCookingEgg]=2,
keep Spatula/[Recipe.GetItemTypes.Spoon]/[Recipe.GetItemTypes.Fork],
Result:Icecream,
Category:Cooking,
Time:500,
Category:Cooking,
OnGiveXP:Recipe.OnGiveXP.Cooking10,
SkillRequired:Cooking=6,
}
recipe Make Caramel Syrup
{
keep Spatula/[Recipe.GetItemTypes.Spoon]/[Recipe.GetItemTypes.Fork],
[Recipe.GetItemTypes.SapphCookingSugar];10,
keep Saucepan,
Butter;1,
result:Syrup_Caramel,
Time:400,
Category:Cooking,
OnGiveXP:Recipe.OnGiveXP.Cooking10,
SkillRequired:Cooking=5,
CanBeDoneFromFloor:true,
}
The ice cream recipe is working ingame, but the caramel just isnt showing up. Does anyone know why?
result in the second recipe should probably be capitalised
Result yea
AAAAAAAAAAAAAAA
Thx god that can't be an issue in B42 recipes lol
Check the javadocs to see if fluids have DoParam or an equivalent. I can't remember what that class inherits from.
Also, I got the modified function that would multiply weight of listed items automatically, but I need to figure how to get original item weight into variable
I need to get original weight into variable
Check InventoryItem on javadocs
Thanks, I'll look it up
There's a get weight() or getActualWeight() function
You'll need to convert from the item name to an actual item or an item script though
I'll try to run this and hope it'll work 
A lot of this code does nothing
the if originalWeight is useless, bcs you will always get a weight
That won't work; item is just a string
It just checks that originalweight isn't nil
Typical thing for lua, isn't it?
Also you can move that items table outside the function, doesn't change much but you won't redefine it everytime you run the function
No
Not everything can give nil
And in this case, an item without weight shouldn't be possible
Smart, I'll note this, thanks
I'm starting to understand it
And last point, when iterating over arrays (lists with only array entries and not key tables), use the method explained here:
https://pzwiki.net/wiki/Lua_(language)#Table_Iteration
It's better to get used to use this method for this specific kind of table (usually called arrays) because it tends to be faster than ipairs and pairs
I think in this case it is not that bad, since this function is triggered upon reloading lua
Yea
But I'll note this too
But like I said, it's mostly of getting used to using this method
That way you never have to think about it later down the line
Also feel like it teaches you better the difference between iterating over a key table and an array
Dammit
the wiki should probably note how galactically expensive ipairs is
I thought I had explained it in the mod optimization page
it's not just slower than a numeric loop but exponentially more expensive than pairs
which is something that takes people who are used to other lua implementations off guard
But it turns out I didn't do it (or didn't find it)
I thought it was pairs that was the worst one ?
no, pairs is massively better
pairs is implemented in java so it's fast
ipairs is implemented in lua so it's slow as shit
pairs pays function overhead 1 time, ipairs pays function overhead N times
Could you detail it ? Wdym ?
Is that correct implementation?
If we ignore the fact that you can't get weight from item string
Yes, but like I said the if check for the weight is useless
an item is never going to not have a weight
Yes-yes
Pretend it is not here
Also, you shouldn't implement this kind of prints that shows debug stuff if a scenario doesn't happen
This will explain why
Good to know
for i = 1, #tile_tags do
MapObjects.OnLoadWithSprite(tile_tags[i], VNGarage.Workbench.SetupPlacedTile, 5)
end
I'm still foggy on the difference, and why sometimes an array is an ArrayList and sometimes it's some Java object...
yea fixed it
Ok
it's fine to print in the case of an unrecoverable error like this
I'll keep it for testing tho
I'd rather teach people to NOT do it because they won't know when their print won't even trigger
And that's how we end up with ItemTweaker 2.0
Overall terrible reflex to have in your codes
item tweaker's problem is that it prints when everything is working, printing errors is standard practice
No no I don't agree with that, because let's take the case of his code actually having the possibility of a nil, in a situation where it's likely that in some cases this if check doesn't pass, then you end up with people not being able to make the difference with "is it normal that the if doesn't pass" and "the if here should always pass" (tho for that last one you shouldn't ever need the if anyway)
So I will keep my position that I will not teach people to put such prints in their code, because dear god I KNOW FOR A FACT people will then get used to put them at places they don't understand why they shouldn't put it. Also taking into account here that Serenity here thought that "checking for a nil is normal pratice in Lua" .... which means they considered that this nil check could likely not pass
Also that error print is in freaking russian so no one gives a shit about it but the mod author !!!! like I stated in the mod optimization page: literally the entire population of this galaxy doesn't care about your prints but mostly yourself and a few random nerds that can ACTUALLY read console logs AND understand that this error print is not some bullshit that the game prints thinking the information is useful but it's actually bloating the console, and that how you get constant cases of people asking if these random weird ass vanilla errors are the source of their problems when in fact these are literally nothing and just present anyway
You really don't like print, aren't you?
No
so how the hell are you supposed to debug other people's errors without prints? 😭
I added it for myself so I can easily read it
breakpoints
other people's errors!!
breakpoints.
By not teaching people TO PUT PRINTS FUCKING EVERYWHERE
I had to deal with making an addon for a mod that LITERALLY PUT PRINTS FUCKING EVERYWHERE because they do not understand that their prints are BLOATS to EVERYONE and DO NOT GIVE INFORMATIONS THAT ANYONE ASKED FOR
I almost had to go in all their mother fucking files to comments out every fucking prints
"Break on Error" is enabled by default.
doggy also HATES the debugger so he's not doing that either 😭
Yea >:(
It is a pretty rubbish debugger, but at least it's better than nothing.
i use the debugger heavily for my local testing but i need someone else's error log to say what the error is before i can start locally debugging it
I personally do not care for prints for errors from modders that ACTUALLY understand the shit they are making AND the informations that they should ACTUALLY give to people
Might write my own debugger lol
Currently occupied with writing a strict class framework in Lua.
Waiting for Doggy to write a mod that globally disables print()
Easy to do
__G.print = function() end
did anyone ever actually release a mod that buffers prints? i know a few people did that locally and it worked really well
iirc it massively improved performance with mods that were spammy
I usually string.format / string concat then print but a buffer wouldn't be hard to write.
Overrides?
yeah, the benefit was for other mods that already had spammy prints
No I won't, because I use prints when developping, but I will not teach people to leave prints everywhere because they are the source of way more problems than they actually help fixing
I think it should push mods to write better debugging code but hey that's not happening.
Also didn't Chuck want to add that in error fixifier lol ?
Exactly
anyway, the biggest benefit to logging error info is that things don't break silently
i design my code to break as soon and loudly as possible when there's an issue so that mistakes and bugs don't make it out to public release in the first place
Yea but you know your shit and you know when something's actually not meant to break
If you can get the stack of a call then you can catch this in your overrided print function and then mute or buffer-stack prints.
That's probably what that local code did.
nah, it literally just replaced print with a buffered version
it wasn't anything fancy
@sour island did you implement the disabling of prints in error fixifier ?
Wasn't possible afaik
So what Jab shared isn't possible ?
Oh disabling print like that is possible, sorry misread/misremembered what I was trying to do was to disable console errors
Which isn't possible
Write code in a way that validates or returns code flags / status.
I had to write a json validator that doesn't stacktrace.
The stuff for logs isn't exposed, and filesystem isn't exposed to let one touch stuff where console is
You can use DebugLogger
mute print and use DebugLogger
The farthest I got was to break the debug console a bit- which broke the game
lmao
This was to further my joke-mod to hide errors
Oh ok.
Right now it stencils the error area incompletely
here's a pretty legitimate example of a debug print:```lua
local traitMetatable
if Trait and Trait.class then
---@type Trait
traitMetatable = __classmetatables[Trait.class].__index
else
log("Another mod has corrupted the global environment (replaced global Trait).", "warn")
if instanceof(Trait, "TraitFactory$Trait") then
log("The mod that adds the trait %s is probably to blame.", "info", Trait:getType())
traitMetatable = getmetatable(Trait).__index
log("Workaround succeeded.", "info")
end
end
if not traitMetatable then
log("Unable to get trait metatable. Sandbox options affecting traits will not work. See previous messages for info.", "error")
return
end
So that whole area skips the UI rendering 😅
(ignore the gross logging api that i'm not really very happy with anymore 😅)
Hmm can't I replace log() to any useful effect for what I need?
Yea but again, you know your shit
I assume stack traces are directly from java
BTW, error fixifier basically hides error popups?
Yeah
Unironically, useful sometimes. I get quite a bunch of harmful errors, but popups annoy a little
People have gotten GBs of console logs cause they can't see errors in game
My SSD is so cooked with this one
When I'm evaluating which mods to install on my servers, I run them through the local game with -debug and refuse to include any that throw errors.
Actually
I think there's case where it can throw nil
Some errors can be ignored tbh
If I'll list modded item, but don't have the mod itself
The function will just not run
Damn that's harsh
You will error on trying to get the weight
I thought this kind of errors could be ignored and skipped to the next entry
any error will end the current function
You just straight up shouldn't leave errors in your mod
it's a lot more lenient than is normal 😅
So, if I want to add optional mod support, I have to create function like this, but with mod check
Right?
Speaking of errors, I'm writing error handling code that's verbose AF but professionally.
lua: ...coding\zomboid\CSSBoxLua\cssbox\layout\Dimension.lua:228: Lua Class (Dimension): Attempted to assign field "width" with type "string". Expected type(s): [
number
]
Strict Lua class framework in-development.
Gonna make this strict class framework make class objects act like Java objects.
it would also be valid to nil check the item
Probably the best way
I want to explore modding Project Zomboid/modding in general and potentially one day making a game from a mod, my question is how much Indie Stone is ok with it?
As long as you don't reuse their assets, you're fine
I plan on creating my own (hopefully)
i mean, if you're not planning to reuse their work or ip, i'm not sure why you're even worrying about TIS, they have nothing to do with your game
I’m completely new to this kind of thing
so I’m trying to learn what the, boundaries? are with this kind of thing
Gotta start somewhere
Let's look if I can apply patch to this using lua
that's not what that code is doing
Oh, what does Petrol:1.0 stands for?
the fluids block defines the amount of that fluid the container should spawn with, as a fraction of the total capacity
Oh, got it
You've created the javadocs, have you found anything about fluid weight?
It's fixed to 1 weight per 1L, I want to start from changing it to 0.5, and then attach sandbox setting
i haven't looked at fluids in particular but a lot of the new script types in b42 aren't very flexible in the way the older ones are
I have a really bad idea
In theory, it is possible to dynamically change the weight of an object with liquid with each liquid update
Considering the weight of the empty container
So basically, I have a bucket of 1 weight, being able to hold 10L with total encumbrance of 11 weight. I run a function to get liquid amount and original weight of empty container, then I assign to this item the weight of liquid divided by two + empty container weight
And this function happens each time amount of liquid in the container updates
Rate how horrible this idea from 0 to 10

It's this because you can't change the weight of the fluid itself?
Coudn't find anything about it in javadocs
So I came up with this yanderedev ahhh solution
The only missing component of this scheme is the event onFluidUpdate or smth like this
Setting container weight probably won't work
It will set the container weight, ignoring the liquid
Then you ask for weight, it gives you that plus the weight of the contents
Anyway it's joever, I can't update it dynamically since I can't really hook this function to any event
I think setactualweight will change total weight of this item, but i'm unsure
Currently looking at ProceduralDistributions.
I get what roll means, it is amount of times games "drops a dice" to spawn something from a list
But I don't understand: what those chances actually mean (if it is not percentage or weight), and where is the chance that roll spawns nothing?
Tbf it's not that bad
Read the wiki page
that's not what a roll is
the game rolls *every single entry in that distribution table* that many times
Yea
in other words they aren't weighted
I'm literally reading it
The wiki page explains all of these
the meaning of the chance value is more or less arbitrary
there are too many factors involved to be able to reliably say what the actual chance ends up being
It varies on a bunch of factors
So there's 4 rolls for each entry if set so
Depends which distribution
So what are those chances? How do i read them?
in that example distribution, Item1 is rolled with a chance of 10 out of (SOMETHING, WHO KNOWS) three times, then Item2 with a chance of 5 three times
You don't really read them
You just feel them?
you just feel them
lmfao
look at vanilla stuff that has a similar spawn rate to what you want
in the case of rolls for each item, they could've implemented percentages
it's not accidental that it's like this
the chance of loot spawning is mostly scaled by the zombie population of the area
that's why it's not easy to know the effective chance, because even in the same kind of container it will be different in difference places
So, rolls is the amount of attempts to spawn item, it goes through every item in the list. And the spawn chance is just something
You compare to what the vanilla items have in that distribution
And apply your distribution based on that
There's also an API which allows you to set the same distribution for your item as other items
Yeah, I know it, but it's not suitable in my case
👌
Can I see distribution category in-game via debug mode?
For loot generation?
Cheats -> lootzed
right click container
lootzed
lets you see what objects can spawn in there
Wrapping distro changes is a good handrail for newer modders- but if you understand how Lua tables work it's generally fine to do anything you want with it.
note the scientific notation (if that's what you mean)
It's kind of silly it does that when its just 1 more 0 than the other stuff 😅
Welcome to floating point numbers in a debug UI that was never configured to be easy to read for humans.
Mod isn't showing on the modlist, i think i replicated mod structure correctly
what could be the issue?
tree -d is the command to tree a folder
Should help us have a fixed image of it bcs rn it hurts my eyes
Tho I can't look at it now
Got to go
Wrong folder
You're inside the game files
Not in the cache folder
That Workshop folder you're in is wrong
It's unused
Read the part about the cache folder on the wiki page
In Game files if I remember right
@late hound (and anyone else wanting to see something funny) - this is what enabling ragdoll on the player part of the "player drags a corpse" animation looks like.
The moment I stopped moving, full ragdoll.
I'm more surprised that player can ragdoll
The animation system is the same for players and zombies, just with different sets of animations
The real challenge is setting up animations to use ragdoll properly and not just make a huge mess or curl up into a little ball
Solar power mod replaces several container distribution types across the map, like carton box with solar inc stuff
I want to apply the same treatment to lectromax factory in scenic grove
Is that mod changing the loot type of containers
Or replacing a tile with a different tile
It replaces some crates on the map with its own container with special loot table
Personally I don't like mods that replace tiles on load, I've had performance issues with that start of thing in the past since the game already struggles to load when driving and having to also go though every object on every time as well is not ideal.
I want to do this to lectromax factory
So it has loot table that actually makes sense
Do you need to replace tiles, or do you need to change the loot in containers?
And do you know what loot tables it uses... If you're lucky there's a lectromax table that just needs the proper stuff put into it
It uses default factory loot table that has handles and saw heads
very fitting for company that produces electrical appliances 👍
I want to replace containers with default factory loot to containers with my new lectromax loot table
I think I need to do it same way solar power mod does it
Does anyone know of an event triggered when a players injury heals?
(or otherwise a way to detect when a player's injury has been healed)
Hey @terse delta you manage to understand distributions? bc im facing the same problem now
just finished combing through events.md and didn't find anything but I imagine you could theoretically check each body segment for each injury type each frame and keep a running status that you check for change in
and chatgpt isnt chatgpting
I had a success with adding exactly one item to one distro
What's your problem?
amazing
I dont understand how to write it to make it work
Basically i just modify the texture and properties of a cereal box, and i want to make it spawn naturally at the same points of cereal, without overwritting the base lua distribution
if that makes sence
Oh, you're better to use Easy Distribution API for this
I've added my entry to base distribution list
That work like a dependency for the mod? or i can just use one time?
It is a dependency
There's no meaning to inject lua script into global lua distribution for a cereal copy
You could do that the same way solar panels does, and start with a quick check if you're near the factory for performance reasons (almost no impact for the rest of the map)
yeah i got you, i just want to evade dependencies for the future projects and manage how to do it fully by myself
Thanks Sere i know the existence of this api (im gonna take a look on it if i get stuck)
You can have a look at the code in easy distro, then do your own version of that. Or just do the loot all by hand
The code is a bit ugly, but not complicated
Haha i just imagine myself, enter to debug mode to add all the houses scooby snacks and then just starting to play normal
Yeah, im for sure doing that (taking a look on it)
I feel is a little empty on resources to make mods
You can just copy the API into your mod folder like Better Sorting did for item tweaker
If you really hate dependencies that much


The worst case scenario to using a dependency is that one that it might be outdated and you may need to fix it yourself. By sticking in a copy, you're kind of starting off on that worst case.
steal is bad
but i got the general idea i let you know how it was when i finish if you want to
Not even about stealing- you can ask permission and chances are most API writers would love for someone to use their work even if you're including a version of it. 😅
Yeah that's one of the reasons, my main reason is to make a fully functional mod without lack of performance due dependencies (im not saying this particular one has bad performance) but as you said my mod version gonna be attach to the dependency version
avoiding dependencies for performance reasons is a little silly
u had all the reason here
dependencies don't inherently cause any performance difference whatsoever, it is exactly the same as if you had copied it into your mod, and you're banking on your own version being better than a mod specifically designed to do that one thing
in this case, this mod doesn't do anything outside of load time so performance shouldn't really matter either way, it won't affect performance during actual gameplay
i see, maybe i was comparing pz modding with MC modding a little
For better or for worse most APIs/Libraries (Not even sure what the actual industry term is) in PZ are 1-2 features a piece, and I don't think it would work the same way where you'd be loading a bunch of stuff you wouldn't actually be using(?)
should be 'library', the usage in this community of 'api' is a little off 😅
I feel like all the terms are to an extent
yeah, that's just what happens in amateur scenes really
there's a bunch of computer science terms we've all heard informally and think we know what they mean
I've done it myself, but I think this actually counts cause I modified the vanilla API to simply have more pages to itself. 🤷♂️
https://steamcommunity.com/sharedfiles/filedetails/?id=3155647374
i've got a 'stats api' too 😅
facts
😅
it's not far off anyway, a library has an api, and the intention of the mod is probably exclusively to implement that api so it's not really wrong to name the mod after the api
My brain status rn


but i think 'library' sounds a little better 😅
I guess it's a glass half full/empty in terms of how much of the lifting the api/library is doing
Correct me if im wrong, Distributions.lua is for the actions of spawn items and the ProceduralDistribution.lua is for the tables, like the items that could appear?
(in a general way)
Distributions maps containers to specific spawn tables, ProceduralDistributions is the actual spawn tables they're being mapped to
Dist has some containerIDs too though
I was trying to word it cleanly, but distributions is kind of a nest lol
yeah, some types of containers aren't procedural (just bags and zombie outfits i think?) so they're defined directly in Distributions
and there's some random bonus files in b42 too
Some of the stuff is confusing at first glance, like everything being shoved into another table
table.insert(Distributions, 1, distributionTable);
Also the .list thing threw me off for the longest, but I think that was to keep the option open to include functions to the main table
i see
i put metal shelves to see if that actually works and then i gonna change it to another container
bruh
Becareful naming files exactly the same, the game will override vanilla files, it's path sensitive, so you could include an extra folder or rename the files with a prefix.
Gotcha thanks for the advice
I offered to call it an easy distribution application API interface library
And everyone yelled at ne
🤣
I'd rather do this
It just injects new entry into distrolist, extremely compatible and has 0 issues possible
Yeah, I forgot to mention that -- by defining the table again you're wiping it out as well 😅
no loot experience
But now you have to do that for every distribution list you want your item in.
👀 im gonna save this for later
If I was eloy i'd just use easy distro
I wanted to add propane tank specifically to gas stations and that's all
I made easy distribution because I wanted it to be a thing, and figured it would actually be useful elsewhere
Note: this code make all the loot dissapear
I feel like a dozen people including myself have written a distribution function that inserts stuff into a pool of entries
In that case, what you did is perfect
amazing for sure a expendid work
Loot Rarity: hyper extrem
non-existent
You can upload this as challenge mod
only scooby snacks can spawn
Scooby snacks neither available
Challenge: all loot replaced by tins of beans.
the real "schizophrenia" mod
So youre limited to foraging and what you can recover from zombies lol
And vehicles probably since they have a seperate set of loot tables
The issue is you're overriding the entire table, using table insert or defining new keys is the only way to modify the loot
Change ProceduralDistributions.list = { to
ProceduralDistributions.list.sSnack = { ditch the ending }
yesterday i just learn how to make an actual item, most of my focus where to understand how to make a new mesh
Gotcha, thanks
let me test it
Oh, I know what next distro-magic i'm going to do
I'll add reloading, long blade and aiming books into libraries with a lowered chance
So.. if I want a script to add players to a safehouse with addPlayer(String player) How do I know what the string is for the safehouse in question?
Sometimes the real lesson is finding a bunch of things that don't work
What's the object you're calling addPlayer on? If it's Lua, you can just look at the Lua to see what it expects. If it's java, that's where having a local decompiled copy of the java is really handy.
declaration: package: zombie.iso.areas, class: SafeHouse
I want to add players (safehouse members) back to the house after a resize.
Other tricks are seeing how something is used in vanilla Lua code
yeah, I do that a lot. For this I have no idea what the add member does when a player accepts an invite.
I'm guessing it's a multiplayer thing, since for single player I can't think of any way a string would identify a player (also, no need for a safehouse)
if you mean what string the method is expecting, it's a username, player:getUsername()
I was just searching through the safehouse inputs for a way to add someone directly as a member at that looked like the way. Its under the safehouse heading in the modding doc
my safehouse resize tool is pulling the member list from the safehouse data before it resizes the zone by dropping and replacing the zone but doing so removes any members. I wanted my players to do less work.
I'm waiting for B42 to learn multiplayer modding quirks so I don't need to relearn everything.
You have a few years to study I would say lol.
Also lets me put off multiplayer stuff for ... Probably another year.
Absolute minimum six months, but only if they leave a lot of stuff broken and just go ahead with multiplayer.
@silent zealot Got it to work!
now does anyone know of a "reset" function for the player animation skeleton? I've gotten the character stuck sometimes when adding/subtracting conditions and whatnot to the AnimSet xmls
What that "stuck" state looks like, take notice to whats happening in the anim monitor when I try to move around
Whats that UI 😮
the anim monitor
i don't remember if it's in the main debug menu or if it's one of the ones you need to right click a character to open
perfect!
New B42 debug stuff - hit debug icon, second tab, anim monior.
it was definitely in b41 too
I thought it was new - the debug menu in B41 looks so lacking when I run that to check something after B42
I haven't figured out how to use half the tool lol
so looks like I either have to reset or clear the anim layer
Does mashing the ESC key a bunch fix it?
Quit/load will fix it
well yeah, but I am trying to find an in-game fix to it
nope
fix what exactly?
your player cant move?
yes
local pl = getPlayer()
pl:setBumpType("stagger");
pl:setBumpFall(true);
pl:setVariable("BumpFallType", "pushedFront"); --pushedFront --pushedbehind
pl:setBumpDone(true);
pl:reportEvent("wasBumped");
try that paste it on the lua console and hit enter
thats what i use whenever my char ggets stuck cuz of animation
i have this ready with chat command so i just /stag and it will unstuck
weird it might be doing that on a loop or something
huh ok, will work with it some more
You killed him 
I'm following https://pzwiki.net/wiki/Adding_new_tiles to make a tile for my mod
so in tilezed when i create the .pack, I also have the option to add .tiles files, but the tutorial doesnt mention doing that. Am I supposed to add my .tiles here to make the .pack? If so why do i also need the .tiles in the mod folder
Edit: seems optional based on posts ive found in this channel
Your character gets stuck if you update the current anim or animsets while the animation is running
Idk what the tutorial is worth but I suggest asking in the mapping Discord (pinned messages)
ok I knew that already though
You fix one balaclava and suddenly everyone wants you to let them wear watches and vambraces, or shoulderpad and a backpack, or an eyepach under their gasmask...
Wait that's amazing
What did you use to do it ?
Is there an driving event similar to OnPlayerMove?
A can of Aldi imitation redbull and some decompiled java.
-- This runs after Bodylocations.lua, so we need to clear all exclusives in
-- all bodylocations since it's too late to prevent them in the first place
--
-- That's BodyLocations(plural of BodyLocation), not to be confused with BodyLocations
local group = BodyLocations.getGroup("Human")
local locsUpdated = 0
local exCount=0
for i=0,group.locations:size()-1 do
exCount=exCount+group.locations:get(i).exclusive:size()
group.locations:get(i).exclusive:clear()
locsUpdated=locsUpdated+1
end
print("WAWA: "..locsUpdated.." locations updated, "..exCount.." exclusions removed.")
that's the entire mod. BodyLocations-> Human BodyLocationGroup -> ArrayList of BodyLocation -> ArrayList of Exclusions
Iterate through and clear all the exclusions ArrayLists.
Can you do a quick test of it? First comment is "doesn't work" but I don't trust bug reports like that.
Works for me in debug and normal mode, without other mods running, and now I'll verify on my full modlist.
amazing
My first plan was to block lua from using setExclusive(), but... too late to do that.
wouldnt this cause problems if mods use the function to attach the item
like "back" or something
Only if the mod somehow relies on exclusions for... I don't know what it would rely on them for other than the intended purpose.
All the body locations are intact, other than the stuff that gets set like this:
works with all my mods. two eyepatches under glasses under a football hetmet with a bunny ears hat, which was impossible before I added the mod.
Hey I just joined and was wondering if anyone could tell me what it takes to edit the vision cone angle during night. I'm just kind of interested in removing the vision cone reduction during night so I can enjoy nighttime a little more (it also seems like kind of a stupid mechanic tbh) I'm not a modder or anything, so I looked around on the workshop and didn't find anything, but If it's as easy as editing some values I can probably just make my own mod that does it, but I don't really have any idea what I'm doing so I figured I'd ask in here and see what happens.
i dont think thats possible
That's unfortunate, also explains why there's no mods for it, I'm sure I'm not the first to have this idea
Could someone tell me what the cause is when, for example, for a mod that has a speech popup for an event that happens with the player, instead of displaying the text of the speech, it displays "IGUI_whatever"?
I'd like to know what to look for in my mod list to try and figure out which mod is causing it
There's a java mod that makes it 360 degrees.
From memory If you make an piece of clothing with a -100 vision penalty it will give you a max vision cone even at night
Missing entry in the translation files, or coding error where they forgot to use the translate function and just displays the key instead.
The "whatever" should give you a hint what mod is from, subs people normally name the translation key something related to the way it is used.
Thank you.
Or use PowerShell or another tool to check every Lua file in your mod download folder for IGUI_whatever
I know which mod is causing manifesting the most egregious case of it for me, so I'll check that one first, but I appreciate the advice very much
Interesting, tho it means you can't wear stuff with the same clothing location right ?
It doesn't change that, you're still limited to one item per slot.
I don't think that can be changed, but I'll have a look later in case it can be.
My feeling is the data structure would support it, but it would be an issue with anything that does getClothingByLocation() or whatever that function is called
And the code the un-equips the existing item may be in the java. Or it may be in 15 different places in the lua.
If you have a personal tweaks mod, you can add a translation files to it with the missing entries.
Or make a dedicated "English translation" mod lol
Yeah I used to make my own patches for Bethesda games but it was a bit easier with the tools there lol. I will learn how to do that for PZ sooner or later
I think the only way to change liquid weight is replacing whole Java class
I'll try to locate it
Hey, anyone able to help me out on this one?
I think this is #mapping question
really? sure thing then
How did you replace the spawn points? I've added spawn points (make a map mod with no map, just spawn points) but never removed them
The extra "maps" in the base game like like ProjectZomboid\media\maps\Echo Creek, KY still show the Mauldraugh, KY world map... but they don't do anything to disable the Mauldraugh, KY map.
I really want to tinker a bit with ki5 vehicles
I can make loot and vehicle categories not so obnoxious
AI suggested me to shorten my table.insert. Don't have time rn to check it, does it works that way?
no
welp that was expected
Also, does this work if I want to completely remove entry from the table?
no

you need to pass the index of the value that you want to remove, not the value
you can simplify your while loop to for i = 1, #items, 2 do
So this way I can get rid of else block
yeah
In summary, will this script work?
i think so
OnInitGlobalModData
assuming all you need is to run this code, no event is needed, you can just call it
if you need sandbox options then you will need to wait for that event
and you will also need to re-parse the loot tables afterwards
In summary, it will look like this
- Creating function
- Calling it
You don't need a function
Remove the function entirely
it's fine to use a function, personal preference
Yea
But here it sounds more like a common missunderstanding of how it works
This is a common misconception that new coders have I feel like, that to run your code it needs a function or something like that
in most programming languages you need to define a function and then call it, in lua files *are* functions so there is no need to do that
stylistically it is still preferable to mostly stick to functions though
gtk
Thanks
I see having a single defined entrypoint as being part of the distinction between a programming language and a scripting language
But there's no much crossover it's an academic argument, not a useful one.
Final version of cycle, now I gotta test it
Albion, you probably know this: I'm trying to access a public ArrayList. I can get... something. When I use print to try to get a clue what it is, it prints []
So it's not nil
but.. I can't figure out exactly what it it or how to use it.
in the java
that just means the arraylist is empty
they have a custom tostring so they don't show the type there
oh, that's disappointing lol
I thought I've just saved myself a big pile of work by getting access to the list of all zones along with some helpful functions that the Zone class has.
Albion, there's no way to change global fuel generators properties, right? Coudn't find info on javadocs
nope, all hardcoded
Some are in in sandbox settings
I swear I'm going to use leaf someday 
including range now
I wanted to access noise and fuelcapacity at the very least
Road blocks are everywhere 😔
That's why I prefer when game allows to code in its source language
C# compiled using Mono == so nice to mod.
well writing in java wouldn't let you change this either
it's not lack of access from lua, it's just not dynamic to start with
I'm not that deep in Java, but can't I meddle in Class and overwrite values?
Or at least change the class and recompile it
you could recompile it but that's a different scope entirely
Java mods are possible, but they are not something you want to undertake lightly
And a lot of people won't install them because it means manually overwriting .class files
You'll need to be ready to redo the java code and recomile with every update
Better if you can come up with a workaround.
For example, what if you made something using a fuel drum you placed next to a generator that would automatically top up the generator with periodic setFuel() calls?
That's what UsefulBarrels is trying to do, but it's taking him a long time
Perhaps he met another road block?
Figuring out how to handle things when it's not loaded maybe?
the gobalobjects system is really confusing
And a lot of generator stuff is in java
generators aren't actually global objects at all
the generator global object code i suspect you're looking at is unused
I had a concept for upgrading the generators in the list, but it looks like this will require not only changing the Java Class, but also installing a bridge between this class and Lua
I can imagine that it is extremely difficult.
Would require a patch but from my understanding lf it, Leaf should allow that ?
leaf would yeah
but it's nothing trivial, you'd basically just have to rewrite all the logic
generators use static final fields, accesses to which are optimised to literals at compile time so even with reflection changing the values of the field it doesn't actually change anything
so it's not something standard reflection would help with, nor prefix or postfix patches
Tis would optimise anything but lighting 
That's more of a Java compiler optimization
That explains why it didn;t seem to do anything 🙂
When I changed the generator range to avoid needing two in my base I had to change it in I think 12 places
it's all compiled to literals, both for tiles and chunks.
(since it keeps track of which chunks are affected by which generators)
Hello, I'm developing a mod. I'm still in the early stages, but I'd like some help.
The first issue is that I want the character to have only one cloth bag when he starts the game, and it turns out that he always spawns with an ID card, 9mm pistol, box of bullets, belt, 9mm magazine and keychain. Could someone help me remove these items and add only the cloth bag via codes in the mod?
Thank you very much
I think, you can modify and implement code from mod that removes starter pistol
how can i do that? can you help me? i can send my actual codes
First idea when I want to implement something, I try to remember a mod that does something similar
You should check out the code for existing mods that change starting items
Iirc theres a mod for b42 that removes the pistol, and for b41 the more traits mods has a perk called deprived that makes you start with nothing, and a perk called burn ward victim that makes you start covered in burns and wearing bandages
Do yall know of any movables that call scripts on placing them?
All i can think of are generators and rain barrels, but generators are unique and rain barrels are crafted
Wdym by calling a script ?
Like triggering an event ?
It's probably an event that triggers and they identify the object and run code based on that
yeah, i need a lua file that runs when placing a movable
I see the functions onNewWithSprite and onLoadWithSprite
those should work i think
i'm not really familiar with anything using onNew but onLoad definitely works reliably
do you know when onLoad is called?
when you load a chunk for the first time (since you created the save) with an object of that sprite
it's mostly used to convert map objects to global objects but you can run whatever script you want
thats what im trying to do
but that doesnt cover if its placed in a already loaded chunk
I assume thats what onNew is for?
i'd guess from the name onNew is to do with the player placing/crafting objects
oh yeah, i didn't pick up on that, but this is something i've had trouble with before: basically, don't trust any .instance, or any static field in general
ScriptManager.instance is reliable, GameTime.instance is not
when kahlua exposes static fields there's no link to the actual field, it just copies the value at the time of exposure
so if it changes, the field will point to the old instance, only the getter will return the real instance
Pls check your inbox msg on discord
Good progress for tonight.
Mod goal: start knowing all the major roads on the map.
By reading from the foraging zone data
Hello guys!
I have over a thousand hours of PZ playing time and I would like to create a mod that is not extremely complex but that seems quite interesting to me. I managed to complete some steps, but others are beyond my knowledge. Would anyone with more experience in creating mods like to join me in this project? I can explain more about it if you accept. Let's go? Please...DM
Heck yeah!
Welcome! What's your mod idea? Just ask in this channel, the first step is figuring how to approach it/if there are similar mods that can be used as a basis/if there are likely to be some bits that are locked away in java etc.
just send it a DM for you
I'm not getting involved in a one-on-one conversation with no details
Good day. I have a consultation. Why is Windows-1252 used in the language (ES and AR)? Within a mod, I added a file called Language.txt, using UTF-8 (which is the one that all other languages use) and I had no problems with the accents. Excuse me for using this channel, but it doesn't let me write on the #translations channel.
Also, it's 2:30am and I was going to go to bed 3 hours ago when I noticed the forage zones might be the solution to my "start knowing roads" idea... oops.
Hello DrStalker. I'm trying to develop a mod that simulates the TV show Naked and Afraid. I got some steps, I know of other mods that have the other steps I need but I'm not able to implement them. Do you think we can do it together?
I don't know that show.
I'm guessing the player starts naked (easy to do)
Do you have a list of specific game effects that you want?
Then you work through them all one by one
I've got too many things I want to make myself to do team ups, but this channel is an excellent resource that can help you work through what you need piece by piece.
Have you done any programming/scripting before? (any language, just enough to the basic of variables/functions/conditionals... if you have that lua is an easy language to pick up)
It's not just about being born without items. In addition to being born naked, I managed to implement a day count that goes up to 21 days of survival. This is the time it takes for the player to reach a specific location for an extraction, which can also be the destruction of an item to end the game (as occurs in the Zring mod). That would be the basics. Later, I would like to add some extras, but they could be in a next stage, such as animals damaging the player, failure in crafting attempts, and finally a specific forest or island map, but for now we can use a map that has already been created, such as "the forest".
The game already keeps track of time, so it's easy to tell how many days have passed.
What would "extraction" look like in the game? And what would not getting to the extraction point look like?
I achieved this, every day at 6 am a message appears on the screen saying x/21 days survived
death 
i'd assume
Stalker, are you nepentho?
Ah, but what sort of death? Just falling over dead isn't very saisfying, but it easy.
No DM
I am.
Just ask
Used your library for new book distro 😎
👍
reach a specific location where the game ends. as in the Zring mod where you need to destroy the ring on top of a specific building in Louisville or maybe a helicopter and a message that you won and the game ends.
Now I want to make a system of "Hidden Sprinters". These are zombies that initially spawn with this hidden property. When a certain condition is met, with a certain chance, they become sprinters. Where I should start from?
What's the condition ?
Bcs that fully depends on that
A number of things
Getting hit
Hearing Loud Sound
Another zombie died in close proximity
Standing up
Seeing player
whats the mod gonna be?
and else
I would suggest going with a base chance instead
Could you elaborate?
can someone review some code snippets for me?
When any of these actions happen, have a random chance that the zombie becomes a sprinter
Yep, that's the concept
My "minimum naked survival mod" plan would be:
Character spawns in a pre-chosen forest location
All items are removed from the player.
The area around the pre-chosen extraction zone is revealed on the map so they know where to go.
The expected path is a low zombie count area with some water source
The helicoptor event spawns every day.
On Day 21 if they have not extracted they catch fire, everything around them explodes, and if they are still alive they die anyway.
At the extraction point is something they can right click -> win game, and a "you won a prize!" noise plays/a message is displayed.
Each condition has a tied chance
No, just send it and explain it
You were talking about zombies having a hidden condition
Which you shouldn't do
Obviously adjust the list because it's yoru mod and I've never seen the show
Oh, so you mean every zombie w/o any hidden properties
That would basically be the same thing
Start the game with map knowledge of major roads.
The question is: why would you need a hidden property ?
Only certain zombies can turn into sprinters, not any
Or all roads if the player wants, via a "minimum road width" option.
I figured it was worth asking but I expected the answer would be no.
Imo that would kind of be the same thing at the end of the day bcs it's not like players can know that zombie has a hidden property
is road width tracked somehow in vanilla? im curious how you plan on implementing that
Also don't associate a hidden property to every zombies, use a predeterministic random using the trueID of a zombie
why so hostile doggy? if you want feedback on your code you can send it
nope. But! Forage zones can be a rectangle (so min(width,height) == thinckness)
I said no he can send it
something like that. how can i do the pre-chosen extraction zone on the map?
or a polyline, which has a specified thickness
or a polygon, which I will deal with when I get to them.
cool approach. should be compatible with map mods then too no?
idk why you associated my remark with being hostile seriously. The person wants help with modding, they can just send their question with their code
you look at the map, you pick a point, find the co-ordinates and say "extraction is x:10900, y:875"
could also have a list you hardcode, but randomly choose 1 and mark it on a map
Yes, provided they have properly set up forage zones. Which a lot don't, but oh well.
ok, but how can i do that in codes? it is a possibility for this place be variable each start?
you absolutely can make it variable
With whatever logic you come up with
look at https://b42map.com/
The reason I suggest picking pre-chosen spots is for this to work won't the player need a path with appropriate resources? e.g.: water, but no urban areas full of loot
Or maybe you intend loot rarity to be insanely low... it's all up to you, but the key thing is to have a list of specic and implementable things to work through to get the mod going, and you can build that list out as you come up with new idea/have time tom implemt more complex ones.
Yeah I agree, it's not hostile and I reached out to see if someone was willing to review what I got; clearly only expecting those interested to comment.
i guess leading your answer with 'no' was misleading when you meant 'yes' 😅
It's all good, figured it was worth a shot.
Excuse my ignorance, but I have no idea how to create this function. A *.lua file? How will the game identify that the match should end when it reaches the region? My goal is to use a map without urban areas like "the forest" map. I also intend to reduce the loot to insanely rare, but for now my sandbox modification file is still not working in the mod and I don't know why.
I don't think anyone had hostile intent, we just want questions asked here instead of dragging people away to ask one-on-one
yup, lua.
sorry, i dont speak english and using the google translator, is not my intention to be rude
i created a SandBoxOptions.lua on lua folder thats de description, but isnt works...
SandboxVars = {
Zombies = 1, -- None
Distribution = 1,
WaterShutModifier = 0,
ElecShutModifier = 0,
DayLength = 2, -- 2 = 1h = 1 dia
StartMonth = 7,
StartDay = 9,
StartYear = 1993,
Temperature = 3,
Rain = 3,
ErosionSpeed = 5,
FoodLoot = 1, -- Insanely Rare
WeaponLoot = 1,
OtherLoot = 1,
NatureAbundance = 1, -- Very Low
Alarm = 6,
LockedHouses = 6,
StarterKit = false,
Nutrition = true,
Helicopter = 1, -- Never
StatsDecrease = 3,
ClothingDegradation = 2,
InjurySeverity = 3,
BoneFracture = true,
InfectionMortality = 1,
LootRespawn = 1, -- None
SeenHoursPreventLootRespawn = 0,
}
A lot of this is stuff you want to do once when the game starts. So in your lua file, you make a function and attach it to the event OnNewGame. Then it runs the first time a player enters the world,
Typically you let the player choose their sandbox settings
And you recommend what they should be.
For a fixed scenario, you'd have to look at how the pre-made scenarios do it.
So, where I should start? I think I might need some zombie AI functions and onZombieUpdate event to hook functions
You said you had the day being announced every day, so I assume you've already got a mod that loads properly and does something?
Also, I wanna know if this is worthwhile. I won't do this if checks like this are too bad for performance
Have a look at available events:
You can attach a function to those events, and it will run your code when the event happens.
eg: OnHitZombie triggers when the player hits a zombie with an attack.
I need SetZombieState or smth to change him
So, about predetermined random based on zombie ID...
Yes, I can currently run the mod already born naked, without the initial items (except for the belt that I haven't been able to remove yet) and with a cloth bag. Every day an announcement of how many days have passed, but I still can't get the other sandbox functions or the extraction issue.
Let's say I want every fifth zombie to be hidden sprinter
then you set sprinter percentage to 20 in sandbox options
(in B42)
(there's a mod for that in B41)
now i managed how to not have belt!
No, not in this way. You know what I mean by hidden sprinter?
I think your challenge will be turning a walker into a sprinter, not finding ways to trigger that
What exactly do you want to happen at the extraction point? You need to coem up with a very specific plan, because theres no makeExtractionPoint() function - instead you'd be using the stuff the game can already do to... well I don't know what it looks like.
Nope.
But all sprinters are hidden until they start to charge at you.
Or you see them running around in the distance
Hidden sprinter is the zombie that behaves like normal walker until the condition is triggered. You fight zombie, smack him, bam, he is a sprinter now
Suggestion: you don't need to actually decide which zombies are sprinters
You need to trigger then to being sprinters at the appropriate time/with the appropriate chance.
Then player has no idea of the difference between "those three zombies sprinted at me because they were pre-chosesn to do so" and "those three zombies sprinted at me because of random numbers"
There is a mod called zring where the player needs to destroy the ring in a certain location. So this could be an alternative (destroying a necklace) and this ends the game or what I would like most is that when arriving at the pre-established location on the 21st, a helicopter appears and it is possible, as you said, to click to end the game with a message "you won"
And if you want persistant zombies... do a search, there have been a few big discussions on it recently
So what does "destroy a necklace" mean?
Having a helicoptor appear as in actually see it will need something like a a helicopter vehicle mod or custom tiles, just playing the sound is easy though
like in this mod, where you need to destroy the ring to end the game:: https://steamcommunity.com/sharedfiles/filedetails/?id=3453050525&searchtext=ring
It could be the game's event helicopter, just sound and shadow...
I thought about performance also. If only 20% of zombies are ticking to check conditions, wouldn't that mean better performance?
Cause if all zombies are going to check condition every update tick, I expect peformance getting worse exponentially with increasing amount of zombies
you can't really tick 20% of zombies though
either way you're going to need some amount of code on tick for every zombie
You can set a max number of allowed processed zombies, but then you'd need a way to handle skipping previously processed ones to avoid reprocessing the same few
But there's always going to be overhead costs - and in most cases the code you're doing shouldn't be killing your computer
You don't check every zombie every tick
To start I'd need a function that rolls some number on zombie getting hit, and attach a function that would change zombie speed
You wish out a sneaky way to check for the conditions you want with other events, and do the becomeSpinter stuff then
Yup
Yeah, keep the footprint of the thinking elsewhere -- the ontick should just be if X true then do thing
Update of the code: im cooked 
Yes,and you can do that every time a zombie is hit because that doesn't happen every tick and when it does happen you only have to look at one zombie
Oh wait, yeah that's true - if the condition is combat
Something to note though -- zombies are a bit finicky when it comes to storing data, and you have to be careful. Unless you're ok with it resetting when unloaded due to exploration.
It's not recommended to use zombie modData (at least in b41) as it's not cleared when recycled -- same for using the object directly
You could also do things like a function that goes off every minutes, rolls a random number, if that pssses it picks a random nearby zombie and sprintifues it.
We've figured out you can use the unique outfit ID (with some trickery regarding hats dropped) but it depends how much depth you want in this feature
if you want persistence
Personally I think it's fine if it's not persistent; it's not about knowing which zombies are sprinters, it's about dealing with them when they sprint at you. If you escape and return, that exact same zombie doesn't need to sprint again
Id honestly not even worry about players quitting and reloading to reset sprinters, let people do that if they really want.
seems like IsoZombie has a getter but no setter for canSprint
those players wouldnt even get the mod tbh
That might be a function to day "can they sprint right now" not "are they a sprinter"
Eg: cant sprint when sitting, falling over, attacking etc
ah true
I had an idea of zombies having random set of conditions, like 3 out of 10. But knowing the persistence now, it would require some serious trickery
That why you fake it; when the condition happens, random chance to make a sprinter.
Story generator, not accurate simulator.
#mapping would know more, but I expect the effort needed depends a lot on the quality you want.
Ways to find out:
in IsoZombie.java:
Find some code that changes zombie speed using Lua. Look for the B41 mod that let you have random speeds
Check the java
In this case, you now need to look at what walk type does
It is the animation thingie
And also see if there is a field in there that holds the speed, probably as a enum slowsshambler shambler sprinter crawler
Naked and Afraid mod:
Steps completed:
-
Player is born naked with only a cloth bag - OK (problem: being born without a belt in the inventory but the right and left belt options still appear in the shortcut bar)
-
At 6 am every day the message x/21 days of survival appears - OK
Steps that I am not able to complete
-
Create a designated extraction point on the map at the beginning of the game so that being in that location on day 21 it is possible to "win the game" (this could be the appearance of the helicopter event and a message "you won Naked and Afraid")
-
Set the sandbox conditions such as lack of loot, amount of zombies, etc.
Could someone help me with steps 3 and 4?
For sandbox you can either use a preset, which will be much easier
declaration: package: zombie, class: SandboxOptions
There, you have coordinates
Force settings through a functions
(but use better numbers)
but what i need to do? create a *.lua file, a *.txt file? with wich parameters more? and where i place the file? and how to name it?
you should look at existing mods
its like greek to me kkk
"set an extraction point" is just deciding where it will be
If you're thinking "but that doesn't actually do anything" you're right
lots of lua files like survivaldaycountee.lua, nakedstart.lua, nostarterbelt.lua, no starter pistol.lua...
Why are those all in separate files?
...you didn't ask AI to write them, one by one, did you?
i just really dont know how it works lua files...
i tooked from other mods as you said me on the nostarterpistol condition and copied the file
You can separate things into multiple files to make it easier to manage, but removing the starter gun and removing the starter belt...
Oh
No, sorry if that was not clear
Look at other mods, see how they do things, use that to help you write code
Don't just copy whole files over
when i tried to remove the starter pistol and bel on the same file doesnt works... i dont know hoe to mange the commands like end..onevent etc
the gun and the belt are different files because his script is based on ready solution
You're not going to be able to do this without some basic Lua skills
I think I know why
You didn't hooked belt removal to an event
and the belt is bugged because it keeps appearing in the shortcut bar even though it's not in the inventory...
Arent' you?
It's easy to pick up if you have done programming if scripting before
I have a hunch he's very new to programming
which is definitely okay, you just need to learn some basics
i dont know, im really noob in programming, its my 1st atempt
But if you are completely lost, which I suspect you are, you're going to need to start with learning a bit about Lua in general
Ask AI to analyze code and explain each line to you
It really makes things clear when you start
Don't ask AI to write code though
My item remover from lua distributions prototype is generated by AI
Ask it how to do very specific lua things, then do then yourself
exactly, that's why I'm looking for a partner to develop this mod that could be really interesting
Don't ask to write code without context I'd say
when you provide enough of context, it starts to orient good enough
When you say "partner" I hear "someone to do all the work"
ok
that's tad rude
He already made a few scripts
Did we not just establish those were from other mods?
We all rip apart mods to get the functions prototypes 
No friend, I'm trying hard and I've already achieved some steps with your help and a lot of tutorials, but I realize that I have limitations in programming that I intend to learn with someone together.
I am very grateful for the help I have received here
I suggest stepping back and doing some lua tutorials if you have not programmed at all before
You don't need to be good at it, but you need to be able to understand the basic structure of the code
Furthermore, English is not my native language so it is more difficult to find content or interpret tutorials in English for me, but even so I am trying very hard.
few but I'm already looking here.
I'm using Google Translate to talk to you
Ah, that explains some of the confusion/lost meaning
Learning programming without tutorials is like jumping into foreign language environment without any preparation. You don't know anything, but your brain starts to understand things REALLY quickly
It is possible
By ripping apart already made mods
It became really easy when there's AI that can explain things to you
to be honest i feel like the majority of lua issues i help with are caused by people jumping in without tutorials and not actually knowing how anything works 😅
It seems to me that it will take me hours to resolve issues that if I had a partner could be done in minutes.
Furthermore, I have no intention of being a modder, so this partner can take all the credit. It's not a problem for me, I just want to do the mod and I think it would be very interesting.
sorry...kkk
I started last night and managed to create the mod and implement some steps with help, I'm hard working 🙂
Look up this
(Open it in browser or download, you won't see it in discord)
You can question AI to describe you code, as I said, this is very effective
i tried but still cant read because the resolution... 😦
what is it called?
Use this link
ok ill try it
It was an invention for me
thanks
AI catches up context really good
And elaborates syntaxis for you
That's not even AI for coding, just language model
One might think that they will save time by skipping tutorials and jumping straight to the fun part, but in reality, without a solid understanding of the basic principles, they will end up spending much more time debugging issues in their code. They might even become so frustrated that they abandon the idea altogether
And AI is only helpful up to a certain point
I personally spent a lot of time banging my head against the wall over the code produced by the likes of ChatGPT, and I have a CS degree
im almost abandoning.....its so hard to me, im a musician dont know nothing about programming, just have more than 1000 hours playing zomboid
Digging through existing mods is a good idea tbf
It depends which mod
But if you find some decent mod, you can check how it works and reverse engineer the important bits
im still trying but its hard to identify the parameters for me...
What parameters ?
all of them, im not used with programming
That's why you can ask questions here
Go through code, and ask about the bits you don't understand
I don't understand anything and even so I managed to solve some steps of the mod I'm trying to make, but it seems that these next steps are more difficult without knowledge. I'm using other mods as a reference but they have so many folders and files that sometimes I don't even know where to start...
Did you read the various wiki pages ?
a lot, and also videos...but still so hard..
Did you read the Lua (language) page ?
i think so, but if you want to send me a link i aprecciate
Thank you. I had read it, but it is very difficult to apply. Of the four basic functions of the mod, I managed to implement 2, but the other 2 are very complicated for me.
What are the other 2 functions ?
This mod has the extraction function that I would like to implement. In my case, it would be much simpler than this, but when I look at the files, I don't even know where to start.
I would like to implement an extraction function that shows the map a location for the extraction of the player who finishes the game.
The conditions would be: be on day 21 of survival and light a fire. Then the helicopter event happens (the same one that already exists in the game) accompanied by a message that you have won.
https://steamcommunity.com/sharedfiles/filedetails/?id=2987772693&searchtext=extraction
the other function would be to be able to have a fixed sandbox configuration for all players who use the mod, defining the number of zombies, loot and all other parameters that exist in the sandbox
But those settings are already vanilla settings
I suggest breaking it down into steps
- detect day 21
- detect the player is next to a fire on day 21
- define a fixed coordinate valid for the campfire
- define a random coordinate valid for the campfire (or multiple possible coordinates)
Go step by step
Start simple first
Break down what you're trying to achieve into numerous tiny tasks which sound less challenging than every bits together
Yes, these are functions that already exist in the game, but I would like to fix them without the player needing to configure them.
The question is why do you want to fix them ? Do you think removing the ability for players to configure it should be part of the mod ? Removing the sandbox-ability of the game from the players ?
anybody know the api calls for integrating custom shaders in b42?
Wdym by custom shaders ?
I managed to make a count of days with a message printed on the screen of x/21 days of survival, but making the extraction point and its conditions is impossible for me, I have no knowledge of the moon.... I managed to make them spawn without an item and without clothes, which was one of the objectives, but it seems that I can't advance any further.
like tree shadows moving in sync with the sun
Ok you did these small tasks, great ! Now ask yourself: what's the next small task ?
The ones I gave you I think are a good start
Meu My goal is to make a mod simulating the TV show Naked and Afraid, do you know it?
No
I don't think so
Naked and Afraid is an extreme survival reality show in which two people (a man and a woman) are left naked in a hostile, wild environment — such as forests, deserts, or swamps — and must survive for 21 days.
They are given no food, water, or clothing, and are only allowed to choose one survival item each (such as a knife or flint). The goal is to reach an extraction point after 21 days, facing hunger, thirst, extreme weather, predators, and disease.
detect day 21
detect the player is next to a fire on day 21
define a fixed coordinate valid for the campfire
define a random coordinate valid for the campfire (or multiple possible coordinates)
good goals, but i dont know how to do it....im never programmed before...
can i send you my mod Can I send you my mod so you can take a look at the structure of how I'm doing it?
taking into account that I did practically everything using AI or copying from other mods.
sry about my english, im using google translator
No
I'll personally don't look at it
oh ok...
And overall you can't expect people here to completely study your mod, that's usually way too much work that you are asking most people for
i understand...
Ok so, take the detecting a campfire problem
First off, what's the range ?
Is it a radius ? A square area around the player ?
The player needs to make and light the bonfire within the specified location for extraction and stay very close to it
No no
Keep it simple
Does the player need to place the campfire at EXACT coordinates, or in an area ?
If it's at exact coordinates, that makes it easier bcs you just have to check that the square has the campfire (tho this brings the problem of making sure the player actually knows where to build the fire EXACTLY)
If it's an area, you got different ways to go about it
Depends on what you want as an "area"
a specific area of approximately 10x10 squares but it can be a specific square as long as it is marked
This is an interesting area, because you could use something that exists in the game
The map is divided in cells, which are divided in chunks
If you're on B41, a cell is 300x300 and a chunk is 10x10
In B42, it's 256x256 and chunks 8x8
So you could set a specific chunk as the one which should have a campfire in
The issue is that this fixes the borders of the area, so if you wanted to chose a specific border, you can't use chunks then
This, ideally, should be random each time the player starts a game.
I understand what you're saying but I have no idea how to program this
So you could chose a random chunk every new saves as the area to place a campfire in
Which is simple, because it involves generating two random numbers on creating a new save
Yes, but it is important that the player sees the position on the map even if the map is not yet fully open.
Where would I start?
and how do I do that?
I know less than that, for example, should I create a .txt file? a .lua file? What should I write in the file besides those random parameters that you sent me?
ok, i created it
Where ?
Client folder
That's good for now
🙂
So your objective rn, is to use Random to generate 2 numbers when loading the Lua file
Try to do that
And print the numbers in the console to read what the output is
I've never programmed before, so I don't know how to print the numbers on the console...
I don't even know where to start the text of the file, you know? Excuse my ignorance
Look it up
something like this:?
local random_instance = newrandom()
local coinFlip = function()
return random_instance:random(0,1) == 1
local randominstance = 10
print(randominstance)
end
Yes !
And you can call this function
Tho
Kind of
there's mistakes
But that's a good start !
local random_instance = newrandom()
local coinFlip = function() -- creates a new function
return random_instance:random(0,1) == 1 -- generate a 0 or 1, and if 1 then returns true, else false
end
print(coinFlip()) -- run the function, and print the result (return)
This will randomly give you True or False
So that's one usage of generating a random number
With comments
local random_instance = newrandom()
local extrationarea = function()
return random_instance:random(0,1) == 1
end
print(extractionarea())
so, now i put this file in client folder?
Yes
Since you are calling the function in root, this will call the function when loading Lua
You probably won't see the print in the console because it'll be lost in-between lots of other stuff
How do I call the function at the root? What is the root?
The core of your file
where i can found it?
It's basically your file
For example
print("Hello World") -- this is in the core, and will run when your file gets loaded
local function OnPlayerUpdate(player)
-- this will run every OnPlayerUpdate trigger
end
Events.OnPlayerUpdate.Add(OnPlayerUpdate)
Usually, you don't run stuff in the core, most of the time
In your case, you will have to do it in an event
An event which triggers when a new game is created
This is the one that will interest you
https://pzwiki.net/wiki/OnNewGame
but the root is a file?
I probably shouldn't have used these terms, this seems to confuse you a lot
core == root here
Tho you could argue technically the two words describe two different things
ok. it is a file?
Remove this from your head
Just you have your lua file, and when the game loads it will run this file
i did this for my counter and it works
local lastNotifiedDay = -1
local function showDayMessage(day)
local text = "Dia de sobrevivencia: " .. day .. " de 21"
local panel = ISPanel:new(0, 0, 300, 50)
panel:initialise()
panel:addToUIManager()
panel:setVisible(true)
panel.render = function(self)
local screenWidth = getCore():getScreenWidth()
local screenHeight = getCore():getScreenHeight()
local x = (screenWidth - self.width) / 2
local y = screenHeight * 0.2
self:setX(x)
self:setY(y)
self:drawTextCentre(text, self.width / 2, 15, 1, 1, 1, 1)
end
-- Remove após 5 segundos
panel.removeTime = getTimestamp() + 5
Events.OnTick.Add(function()
if getTimestamp() > panel.removeTime then
panel:removeFromUIManager()
end
end)
end
Events.EveryTenMinutes.Add(function()
local player = getSpecificPlayer(0)
if not player then return end
local gametime = getGameTime()
local day = gametime:getDaysSurvived() + 1
local hour = gametime:getHour()
if day <= 21 and hour == 6 and lastNotifiedDay ~= day then
showDayMessage(day)
lastNotifiedDay = day
end
end)
So anything which isn't in a function, will trigger instantly
but i have lots of lua files, one for each goal...
Where did you find this ?
Bcs you're telling me you don't know shit about programming so you didn't make this yourself ?
also did this and works too
Events.OnCreateLivingCharacter.Add(function(player)
if not player or not instanceof(player, "IsoPlayer") then return end
-- Remove todas as roupas
local inv = player:getInventory()
local wornItems = player:getWornItems()
for i = wornItems:size() - 1, 0, -1 do
local item = wornItems:get(i):getItem()
if item then
inv:Remove(item)
end
end
player:getWornItems():clear()
player:resetModel()
-- Adiciona uma bolsa improvisada (SheetSling bag)
local bag = inv:AddItem("Base.Bag_SheetSlingBag")
if bag then
bag:setActualWeight(1.0)
bag:setMaxWeight(8)
bag:setName("Bolsa Improvisada")
bag:setCustomColor(true)
player:setClothingItem_Back(bag)
end
end)
reading, copying for other mods and usin IA
Then I invite you to read your codes, and figure out what's going on here
Try understanding this one
Events.EveryTenMinutes.Add(function()
local player = getSpecificPlayer(0)
if not player then return end
local gametime = getGameTime()
local day = gametime:getDaysSurvived() + 1
local hour = gametime:getHour()
if day <= 21 and hour == 6 and lastNotifiedDay ~= day then
showDayMessage(day)
lastNotifiedDay = day
end
end)
I did it but I have no idea what I'm doing. At the moment I've managed to make my player born naked, just with a cloth bag and that every day at 6 am the counter appears on the screen
Stop rn making random ass codes if you don't know they do
Read your codes
Figure out how these works
let's go
an event that every ten minutes adds a function. the function selects a specific player, if it is not a player it returns to the end (which end?)
it looks at the game time, how many days the player survived, the time.
if it is the 21st and the time is 6 and there is no notification yet it notifies the day.
is that it?
Absolutely not
I mean
Sort of
Some parts yes
Well, how do I call the function at the root?
The “root” is just the top-level scope, if I've read the context correctly. Each function and block is a new scope, including the file-level. So, you'd just call a function in the main scope, rather than within a different function
I'd advise listening to Jvla's advice to become familiar with what the code is actually doing. A pretty good resource for that is Programming in Lua, for Lua 5.1—you can find this online. There are some things that don't apply to Kahlua (the version of Lua that PZ uses), but for the language itself it should teach you what you need to know
If you prefer to learn from videos rather than reading, there are plenty of those too & if anything is unclear you should feel free to ask general Lua questions here as well
ty so much
What is the correct command for accessing fluids? (b42)
item = ScriptManager.instance:getItem(name) -- for items
recipe = getScriptManager():getCraftRecipe(name) -- for recipes
-- ??? for fluids
Fluid.Get(fluidID) I think
declaration: package: zombie.entity.components.fluids, class: Fluid
yes getFluid() is correct