#mod_development
1 messages ยท Page 15 of 1
All of this in recipecode.lua
It works the way I expected, it just sets the item's useDelta and adjusts the battery that way
Probably for lighting-engine purposes.
Technically the more draw calls you have the less performant the render tick is.
The game uses a kind of macroed GL command API for both sprites and UI elements.
Not sure if these splits adds multiple calls to the frame.
Oh, and I'm not sure if file-size is a factor when slicing sprites.
well crap
the code worked
(also works on radios but semantics)
but the texture pack doesnt overwrite
Anybody know how to remove a vehicle in MP? I am doing vehicle:permanentlyRemove() server-side, but the vehicle disappears then reappears a few seconds later
i was going off a premade tv mod tho so i definetly could have gone wrong somewhere
how do you add a recipe via lua
new one
though i wouldn't mind knowing how to do the latter as well
that'll come up soon enough
im assuming editing one is something like editing an item script
at runtime
you don't use lua you write a new recipe definition
I believe new recipes are done via scripts, not lua, but I could be mistaken.
just like making a new item
yeah but no
i need to do it in lua
dynamically adding them depending on if diff mods are present
ohhh i see
i dont wanna have a crapton of submods
i was just messing with recipes here: #mod_development message
do you have the java decompiled? check out Recipe.java for how it all works
https://github.com/Konijima/PZ-Libraries makes it real ez
ive done it with rider before
my trial is prob over but i have another decompiler around
rider my beloved
whatever works best for you
anyway im not sure i need to decompile for this, i just was poking around looking for "recipe" and it's i guess in scriptmanager
I should prob decompile zomboid soon
yeah it is
best of luck
javadoc says that the Recipe() contructor is public, so maybe just try calling that?
public class Recipe extends BaseScriptObject yep
what is userdata anyway
userdata is just what kahlua calls the java objects
ohhhh that makes sense and it explains why my instanceof hasn't worked b4 lol
trying to print it to get its data but bleh
ah.
not gonna happen from what it looksl ike
y'all sound like u might be knowledgeable enough to help with another thing i was working on
its alot more complicated than that but thats practically what it always is with regards to PZ kahlua
do tostring(data) it generally works for me if it has a tostring
i want to store the builder of a tile in moddata for it
i hooked into ISBuildAction
but it seems to not have anything to put the data onto
oo that explains my problem
because it's not an IsoObject
I tried :ToString()

forgot lua funnies
I have a feeling it might still just
print the data location
performBuildAction_original = ISBuildAction.perform
function ISBuildAction:perform()
print("UDDTST: Perform firing..")
if self then
if (performBuildAction_original ~= nil) then
performBuildAction_original(self)
else
print("UDDTST: Original function backup is nil.")
end
if self.item then
self.item:getModData()['udderly:builder'] = getPlayer():getUsername()
self.item:transmitModData()
print("UDDTST: Reading back mod data.. builder: "..tostring(self.item:getModData()['udderly:builder']))
else
print("UDDTST: self.item is nil")
end
else
print("UDDTST: self is nil")
end
end```
this is what i was doing
but item isn't something that can store moddata
it's a table or smth
which confused me
can you show how you are building that tile?
i just did lol
oh
thru a build menu
any random construction
like stairs for instance
oh not like a specific tile, you want all tiles to store that stuff?
so that ppl can destroy their own shit but not anythign else
and admins can see who did what
but it doesn't work
you've got the actual type now at least lol
Is this something I consult the java docs for
sauce?
YES
YES
YES
Quick video on getting custom tiles in the project zomboid editors (buildinged, tiled and worlded)
If you like what im doing please consider donating to my Patreon.
https://www.patreon.com/DaddyDirkieDirk
YESSSSSS
am i allowed to post the mod link?
if I had to guess, I don't think self.item is the what ends up on the ground. you can see in the perform() at line 159, some constructor function is called on the self.item. so self.item already exists before it has been created and placed. and if it exists before it was even placed, it definitely isn't an isoobject and won't have a modData field. Im not exactly sure what type of object it is, probably some kind of reference object for creating the tile but it won't end up being the actual object there. you might need add checks at the very beginning of the perform call, a loop to gather all the objects on the tile using getObjects(), then do it again after the constructor. Then you can compare both lists and see which item on the world is the one that was newly placed. or maybe you can just do some comparisons with self.item and the isoobject after the constructor. not sure which would be easier.
yuh
Is there a way to associate a boolean with a specified instance?
I need to add a "hasBattery" bool to flashlights and the like somehow.
Because of how it's programmed, flashlights treat having no batteries and an empty battery as the same thing.
hey! anyone an idea why player:getLastPos() is not defined even tho player is? Is that related to kahlua?
local spawnHordeForEachPlayer = function()
local players = getOnlinePlayers()
if players then
for index = 0, players:size() -1 do
local player = players:get(index)
if player then
local playerPos = player:getLastPos()
createHordeInAreaTo(playerPos.x, playerPos.y, 100, 100, playerPos.x, playerPos.y, 100)
end
end
end
end
how can you set the modData for something? and how does modData work? I know it's just a KahluaTable but what's it for
I don't think the getlastpos function exists? i dont see it in the javadoc, nor in my decompile
you just use getmodData() to get the table for that object, then you can treat it like any other lua table. so
modData = object:getModData()
modData.field = value
local modData = torch:getModData()
modData.HasBattery = torch:getUsedDelta() > 0
Kinda sorta?
yeah

you're right...what did I think? -.-
you probably read it from some other code. I can't remember where, but I do remember lastpos being used as a variable name
anyways, thx! ๐
anyone ever spend like two hours editing the copy of a file in the workshop directory that's being superceded by an uploaded version, testing over and over, only to realize what you've done?
kinda weird that the local version doesn't take precedence
Is there a method for detecting when an item spawns?
Okay nevermind, I've figured out how to check containers with OnFillContainer and OnRefreshInventory (thank you creator that made Time Decreases Loot), but now I need to figure out how to identify what's a flashlight or not with mod support.
Doors placed in safehouses where there wasnt doors before produce no KeyID?
do you guys know if there's any way to draw a vector in PZ's engine? I wanna see a debug line so I can actually see them like in other game engines. im guessing not but it would be nice
Why does this c/c++ compiler keep saying that the stdio header file cant be found
Somethin brokey
client/ISUI/ISUIElement?
Think there should be line drawing in there.
Not 100% sure.
If not, check for public methods in zombie.ui.UIElement.
That's the self.javaObject referenced for all UI.
I think there's only 2 line drawing in there for the UI unfortunately. Could be wrong but that's what it looks like to me
I'm seeing stuff about drawing lines in LineDrawer.java as well but I don't know if that's debug or actually raycasting lol
If you draw null textures, it makes a solid colored rectangle.
I don't know about diagonal lines but I know about straight lines.
I recall seeing some line drawing stuff somewhere but too long ago to remember exactly.
Might've also been internal Java stuff.
Any idea how Iโd do that?
@cyan basalt ๐ I think that the ISUIElement.lua file shows that.
It expands on what you can feed into the Java methods.
Where it says tex or texture as a param, try passing nil.
Hmmm ok Iโll see thanks!
Is it possible to make modded "buff drinks"? For example, adding stress reduction to a hot drink via an ingredient? I know some vanilla items do it with 41.73
Not sure if I go here for help so I'm trying to run a modded MP server, but this one mod called "Mod Options" keeps crashing it. I tried looking for ways to fix it and some say I need to disable anti-cheat12 or something, but idk how to do that.. Any advice?
Currently there is no graphical interface to change it just yet, you will need to go to C:\Users\YourUserName\Zomboid\Server and edit the .ini file. There you should see your server settings and you can change the anticheat options at the bottom of the file.
via the internet
Would it be smart to seperate my mod into two?
I was originally wanting to make a "Hand Crank" mod for battery regeneration, but now I'm thinking I'll have to get an "API" (dunno if thats the right term) uploaded first for fixing the batteries.
The DeadBatteryAPI would just make it so Dead Batteries are properly added to the game and items have designated checks for whether or not they actually contain a battery, along with a provided table of what items are permitted in the TorchInsert / TorchRemove methods.
Im a bit slow with computers, how would I go to "C:\Users\YourUserName\Zomboid\Server "?
Open file explorer, go under "This PC", select drive C, then you can probably figure out the rest from there.
Or, alternatively, you can do it the copy-paste way which is a little faster.
Found it! Thank you
I've become genuinely concerned about credit. How should I do it?
I'm using "Time Decreases Loot" for a code reference of what I want to do, but I'm also editing a lot of the code for my own purposes.
Should I contact the original uplaoder for permission to upload, link his mod, what's the best plan of action?
All else fails I guess I could trial and error myself.
So I still have the issue for "mod options" when I try to load into the map, I always get this message
which I have firm belief that it's from this mod
https://steamcommunity.com/workshop/filedetails/?id=2169435993
but the weird thing is, if I do solo with these mods enabled, it works just fine
it's just MP thats all funky
Some mods can get wonky in Multiplayer, but personally I've had minimal issues with Mod Options.
yes it's possible, although I think there are a couple existing already
quick question how hard would it be to make a mod where if you press a keybind while holding a weapon a soundbyte plays?
I wouldn't imagine too difficult, there's an entire lua event for key presses iirc
good good, would there be any info or tutorial on how to make it
That much I dunno
if you're looking for general modding tutorials I recommend https://github.com/FWolfe/Zomboid-Modding-Guide and https://pzwiki.net/wiki/Modding
should be as simple as adding a function to OnKeyPressed
Thank you!
I've tried messing around with the idea, but it seems that an item with stresschange doesn't carry over into drinks.
can someone help me please
my game wont load because of certain mods i dont know what one making that happened
How does item distributions tables work? im trying to figure out why i cant find my items
How to start coop in debug mode with client and server consoles?
guys, can someone explain to me how I get exactly what I'm clicking with the right button with this function?
OnFillWorldObjectContextMenu
just saw this, congrats!
one of many mods to come
hoping i can make some more complex mods in the future
hoping with the help of my teachers at uni. i can find a way to add sound to the shout when q is pressed
that opens the door to a lot of memes
crap i never thought of testing my mods in mp
the sound on tv/radio will shuffle at random and will not play full lengths of sound clips
no idea if we can do anything with FMOD
basically you need to make a function that you add into OnFillWorldObjectContextMenu using ```lua
local foo = function(_player, _context, _worldObjects)
-- code stuff here
end
Events.OnFillWorldObjectContextMenu.Add(foo)
you can access the stuff in the world your mouse was over by looping through _worldObjects
What would be the most effective way to detect flashlights in containers?
I'm wanting to make it so I can apply modData when they're added, but I'm unsure how possible that is.
I'm testing OnFillContainer atm but I don't know if that applies to inventory or not.
Okay so it does not, it's only for the initial loading from the looks of it.
ok but, how do I get the name of the object I'm clicking on?
I wanted it to work for a specific object
you loop through the items and check them. names aren't always that easy, because some items don't have a nice name that easily identifies them. alot of the time you have to just settle with the tile name or sprite id.
for some simple stuff, ive just manually checked what the ID of a tile is, then you can do something like the following
does anyone know why an offset script would prevent the game from loading?
local objs = sq:getObjects()
if objs:size() > 0 then
if objs:get(0):getSprite() then
local id = objs:get(0):getSprite():getID()
if id >= 220032 and id <= 220079 then --220055 is the HC glass roof
if id >= 220032 and id <= 220047 then return 2 --slopes probably exist twice, but the 2nd one is hidden because of iso perspective
elseif id >= 220050 and id <= 220061 then return 1
elseif id == 220078 or id == 220079 then return 1
end
end
end
end
Does this mean it'd be better to try and use IDs for items rather than names for checking if an item is compatible with batteries or not?
so in the places im checking for the id, ive identifies that the id is associated for the tile im looking for. not very readible I understand, but can't be bothered to figure out a better way because it just works and cba
the IDs im talking about here are for tiles. I used IDs because they don't have nice names associated with them
Oooh oki
hmmmmm
like one type of wooden floor doesn't have a super readable name that says it is a wooden floor. but I found the ID with some testing, and then just continued to use that ID. maybe there is a better way to do it though
ok, i will try that. Thanks!
hmm weird just fixed it by re adjusting on of the numbers
can someone help me fix my evolved recipe? i have a problem so specific that i can't find anything on it
I want to code something, anyone need an UI for his mod ?
wanna try and help me figure out code for a mod i wanna make?
Mmm depend what kind of mod but I just want to code something of my own
Any idea of mod otherwise anyone ?
i wanna try and add sound to when q is pressed so an audio file can be played
Forget it, the last I tried to add sound, I went crazy
oof that bad?
You could try rewriting mods in Typescript.
Yep, I didn't even succeed, and I spent time
Too hard ๐
Huh? If you mean learning TS itself as a language that would make sense if it was a bit much for you.
@thin hornet has an environment that automagically sets things up otherwise. ๐
well yeah pzpw is not only restricted to typescript, it can also just contains lua
it will compile and do the work
2.0 should be released today
im hyped for that ^
CalcLightInfo() is it broken?
CalcLightInfo doesnt seem to even exist
Those docs are 2015 old.
Really?
I really wish that they'd either take it down or make a notice about it being that old. =/ You're not the first one to be confused.
This one is much better: https://zomboid-javadoc.com/41.65/
Javadoc Project Zomboid Modding API package index
It's not official however it's all but up-to-date.
Yeah i found new one thank u, but why they are not updating docs, even if it will not be updated it is not replaced by this?
I'm not sure myself. Hopefully this will be fixed in time.
I'm part of a project that is documenting as a third-party with other modders that involves stuff that I mentioned above.
Official docs, older than most people
Hahaha now I feel ancient. ๐
pzpw will be very useful for paid / commissioned mod work. ๐
PZPW?
@thin hornet 's environment for Typescript modding for PZ.
Ah i dont like Typescript modding i preffer lua
But idunno why but Lua not work fine for me
tbh I wouldnt mind using TypeScript, just another learning opportunity.
I've made a fair amount of progress on my battery upgrade mod, so that's always welcome.
Only thing is that one of my checks seems to be bugging out so I get to fix it (yay!)
Color of getting light source so hard why :(
Are walkies even considered drainable..?
(I dont know how can i explain sorry) How can i get variables like, getCurrentSquare() have .lighting gives a something but when i try with print always nil what i'm doing wrong?
I'm personally unsure, but I believe there's def a way
There's a mod that adds a fear of the dark trait so I know there's gotta be a way to detect light.
I need get color of light not darkness, darkness thing already done
Always getting nil
is there anything to make the minimap bigger?
what's up with recipes with a period in them not loading properly?
can i get away with it if i use a backslash as escape char or anything?
ex:
LOG : General , 1661366074869> [KitsuneMagazineCraftingVFE] Assigning Recipes To Magazine..
LOG : General , 1661366074869> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge .22 10-rd Magazine", skipping.
LOG : General , 1661366074869> [KitsuneMagazineCraftingVFE] Adding "Forge 9mm 15-rd Magazine" to magazine..
LOG : General , 1661366074869> [KitsuneMagazineCraftingVFE] Adding "Forge 9mm 17-rd Magazine" to magazine..
LOG : General , 1661366074869> [KitsuneMagazineCraftingVFE] Adding "Forge 9mm 20-rd Magazine" to magazine..
LOG : General , 1661366074869> [KitsuneMagazineCraftingVFE] Adding "Forge 9mm 30-rd Magazine" to magazine..
LOG : General , 1661366074869> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge .45 7-rd Magazine", skipping.
LOG : General , 1661366074870> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge .44 8-rd Magazine", skipping.
LOG : General , 1661366074870> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge .223 3-rd Magazine", skipping.
LOG : General , 1661366074870> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge .223 20-rd Magazine", skipping.
LOG : General , 1661366074870> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge .308 20-rd Magazine", skipping.
LOG : General , 1661366074870> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge .308 3-rd Magazine", skipping.
LOG : General , 1661366074870> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge 5.56mm 30-rd Magazine", skipping.
LOG : General , 1661366074870> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge 7.62mm 30-rd Magazine", skipping.```
all happy until it contains a period lol
local old_torchInsert = Recipe.OnCreate.TorchBatteryInsert
function Recipe.OnCreate.TorchBatteryInsert(items, result, player)
local modData = result:getModData()
for i=0, items:size()-1 do
-- we found the battery, we change his used delta according to the battery
if items:get(i):getType() == "Battery" then
result:setUsedDelta(items:get(i):getUsedDelta());
if modData.hasBattery == nil then BatteryFixes.applyBatteryFix(result) end
modData.hasBattery = true
end
end
end
Is there something wrong here?
a friend reminded me i could be using translation strings
and i will
that'll be a lot of work to redo
derp
Like, can you not overwrite vanilla methods or something? It's returning the correct data, it's just not.. using that data.
i can't tell u how many times ive run into that shit
lol
u definitely can overwrite vanilla methods
they have to be on the same folder path as the original script
hopefully that's all that it is, if not there might be other stuff to worry about
Same.. folder path..?
But how is that even possible with a mod
Am I just gonna have to overwrite the torches and stuff that use the method and make it into a new method or somethin?
who would be down to make a mod for me?
why someone would do that?
๐ต
I was thinking the HEV suit from half life would be an interesting addition ahaha
id be so down to make it if I was better at modding
Would be neat if it had the HEV UI and everything
And used batteries to increase protection
If you're looking for someone to do commissions work I run a market on a discord server. Feel free to DM me. I might even take on the task.
i would want to make that but i've burnt myself out on clothing modding really badly lmao
Dont know if this belongs in mapping or here; But how would I go about replacing the default game world textures? (More specifically the grass texture / color)
Is there a way, perhaps overwriting the used tilesheet by the world somehow?
use tilezed https://steamdb.info/app/380880/ and look for tutorial in #mapping
Tilezed will only allow me to create new buildings to use in worldzed. I'm looking for a way to replace the default textures used by the world in the vanilla map.
- Which no mapper I've asked knows how to do, so asking the coders here ๐
-- It might not be possible at all
I use tilezed to replace tv texture
Hmh.. I'll have to see if I can apply that on the ground aswell
Thanks for the tip
I assume you are looking to replace this
Correct
since items (at least books? which is what im doing) have DisplayName
how do i set up translation there
do i put the translatable string thing in DisplayName?
do i omit DisplayName? is it outdated?
hi, i have a question, i was looking for project zomboid folders to find how i can change the carpentry recipies, i then came across this. Was this npc folder always in the game?
and if so, what was it used for, cause npcs arent here yet
ItemName_EN = {
ItemName_Base.Your_Item = "Item Bag",
}
yeah and how does it work on the other end
module Base
{
item Your_Item
{
DisplayCategory = Container,
WeightReduction = 85,
Weight = 1.0,
Type = Container,
Capacity = 50,
DisplayName = Item Bag,
Icon = Bag_Item,
OpenSound = Bag_Item,
CloseSound = Bag_Item,
PutInSound = Bag_Item,
MetalValue = 15,
RunSpeedModifier = 0.95,
ReplaceInSecondHand = Bag_Item_LHand holdingbagleft,
ReplaceInPrimaryHand = Bag_Item_RHand holdingbagright,
WorldStaticModel = Bag_Item,
}
}
DisplayName = Item Bag, will be translated
wouldn't it only be seen if a translation file doesn't exist for a given language?
pardon?
well ur defining the name relative to the name of the item itself
Your_Item = "Whatever You Want"
if you then make it have
DisplayName = "Potato"
yes
it'll show up "Whatever You Want" in game
not "Potato"
unless there's no translation
yes?
k
not sure if I understand lol
DisplayName is what it will show in the game
while item Your_Item is item ID
@weak sierra I think it's overriding the functions correctly, I think there's something somewhere else just.. ignoring my changes..?

Are you trying to replace vanilla items?
No
I'm trying to rework how flashlights work
So instead of it just purely using :UsedDelta(), it uses a new modData boolean called "hasBattery"
So you can take out dead batteries instead of it just treating it like a flashlight with no battery.
What does it have to do with translation?
Nono they talked to me earlier about other things
Am just pinging them about that
Not the translations
I still need help though, I dunno why it's just ignoring my function returns.

Does zomboid just not use those lines or something?
It's running and everything so I don't understand why it's not..?
if you assign it by the item ID, and what you assign in the translation is in the translation file rather than DisplayName, it would seem that DisplayName only matters when there's no translation for the current language
im 99% sure im correct
and i dont know why u don't understand what im saying xD
why do you store the original in old_torchInsert if you don't call it
be sure that u wanna do that cuz if anyone else has to add code to that it'll ignore it
hmm
I was storing it just in case as a fallback, but now I don't really need it anymore.
runs a search for the function
it's def used
your code should be under the server folder
is it?
Lemme double check
Im p sure it is but ill check
oh my god
i may be an idiot
I left an old duplicate file in there without
ever
changing
it

require "recipeCode"
local old_veryTorchRemoval = Recipe.OnTest.TorchBatteryRemoval
function Recipe.OnTest:TorchBatteryRemoval(sourceItem, result)
local torches = getSpecificPlayer(0):getInventory():FindAll("Torch")
if torches:size() > 0 then
print(tostring(torches:get(0)))
end
return old_veryTorchRemoval(self, sourceItem, result)
end
this explains a lot
sorry, I'm sleepy ๐
What you just said should be correct. But I've never seen anyone change EN translation to be different from what they put in DisplayName.
So, I'm not sure if the EN translation will have priority over DisplayName in other languages or not.
I have like half of the logic working
It's the battery removal that's not working at this point
Insertion works, it won't let you insert a battery if one is already in its place.
But you can't remove the battery if it's empty, so the flashlight is just dead forever..?
function Recipe.OnCreate.TorchBatteryRemoval(items, result, player)
for i=0, items:size()-1 do
local item = items:get(i)
local modData = item:getModData()
-- we found the battery, we change his used delta according to the battery
if BatteryFixes.batteryItemWhitelist[item:getType()] then
result:setUsedDelta(item:getUsedDelta());
-- then we empty the torch used delta (his energy)
item:setUsedDelta(0);
if modData.hasBattery == nil then BatteryFixes.applyBatteryFix(item); end -- Apply patch if it isn't present.
modData.hasBattery = false
print("No longer has battery.")
end
end
end
Any idea why this may not work..?
function Recipe.OnTest.TorchBatteryRemoval(sourceItem, result) -- Patch of OnTest.Recipe.TorchBatteryRemoval to detect if a battery is present.
local sItem = sourceItem
local res = result
local modData = sourceItem:getModData()
if modData.hasBattery == nil then BatteryFixes.applyBatteryFix(sItem); end
return modData.hasBattery;
end
This code is functioning because it returns if it has a battery or not properly.
Dismantling works just fine which is the strangest thing.
I'm going insane because I don't know why this couldnt be working.
All this is doing is replacing some code in recipecode.lua
Is this just an engine limitation? Is something in java preventing this from working?
is it supposed to do this crusty shit when you use translatable recipe strings
reads book to find out
and the recipes aren't available
ugh
oh how fun it is to add translation strings to a previously working mod
is zomboid this consistently painful
agony
yes
every mod takes me about 36-50 hours of work
the actual work is more like 4-6 hours
the rest is bullshit
I've been working for the past 2 hours trying to figure out why it could possibly be that batteries simply can't be taken out specifically when their condition is 0
I've literally reprogrammed the functions to NOT DO THAT
AND THEY'RE STILL DOING THAT
make sure ur function is running
IM DYING
add print statements
mm
IT'S RETURNING THE RIGHT DATA TOO
No, I just can't take out the battery.
It's just perpetually stuck in there since the option to take it out ceases to be
did u override the OnTest method
for the removal recipe
it might check for a battery with >0
function Recipe.OnTest.TorchBatteryRemoval(sourceItem, result) -- Patch of OnTest.Recipe.TorchBatteryRemoval to detect if a battery is present.
local sItem = sourceItem
local res = result
local modData = sourceItem:getModData()
if modData.hasBattery == nil then BatteryFixes.applyBatteryFix(sItem); end
print("Has battery: "..tostring(modData.hasBattery))
return modData.hasBattery;
end
Man I just wanted to make it so batteries recharge
Literally EVERY FUNCTION WORKS but the ONTEST ONE!!
u know what pisses me off more than literally anything else?
if you have a mod on the workshop
the workshop version takes priority over the local one
so u see no changes unless u copy the code code to the workshop foldr
so i have constantly juggle files between two locations when working on existing mods
or unsub from my own shit
and delete it
That's horrible
it makes me so damn mad
the first few dozen hours
i spent like 16 hours trying to mod without changes taking effect
because i assumed it was sensible when it is not
:|
always assume everything is there to piss u off and u'll do better
works for me anyway
eventually u start to figure out the madness
and things start to make sense
but
then there's more layers of nonsense
MAn
i spent 2 hours adding translations and now the recipes dont exist ingame
mfw
and the book doesnt give me them
@quasi kernel what'd u name ur script file
the one that overrides the thing that isnt workin
it's usually good to name it the same as the original with something added to the end to ensure it loads after
like ISWhatever_Patch
"BatteryCheckUpdates"
I'm going to die
it loads on mod order
AND alphabetically
so prefix/postfix names to tweak when shit loads
I thought vanilla lua loaded before mod order

AAAAAAAAAGH
IM GOING TO CRY
the timeline of figuring that out by hand is pain
let me show u an override i did like
yesterday that owrks
local original = ISFixAction.perform
function ISFixAction:perform()
original(self)
--0-10% to not raise repair count based on maintenance level.
if (1 + ZombRand(100)) <= self.character:getPerkLevel(Perks.Maintenance) then
self.item:setHaveBeenRepaired(1)
end
end```
lua is a really fucking stupid language
so
there's two ways to call methods
and declare them
and one implicitly passes "self"
im saving it with the dot, which doesnt
: has self built-in
then since the original had the :
. doesn't have self
im overriding with that
and since there's a contradiction
im expressly passing self into the original
the one ur overriding doesn't have : tho
i cant get any method that i write and put in a table to run
so
u and me both
i hate lua
i've programmed for like 17 years
lol
so all my methods are local or global with prefixes to their names..
ive seen shit other ppl do not work for me due to file paths and folder structures
which is a headache of an extra layer to have matter
i had to do prefixes with numbers/letters to manipulate script run order
all kinds of nonsense
Recipes_EN = {
Recipe_ReconditionM9 = "Recondition M9",
Recipe_ReconditionTEC9 = "Recondition TEC-9",
Recipe_ReconditionM1911 = "Recondition M1911",
Recipe_ReconditionG17 = "Recondition G17",
Recipe_ReconditionDE = "Recondition D-E",
Recipe_ReconditionM105 = "Recondition M10-5",
Recipe_ReconditionMagnum = "Recondition Magnum",
Recipe_ReconditionM625 = "Recondition M625",
Recipe_ReconditionM500 = "Recondition M500",
Recipe_ReconditionM500Sawnoff = "Recondition Sawed-off M500",
Recipe_ReconditionM500SawnoffNoStock = "Recondition Sawed-off M500 (No Stock)",
Recipe_ReconditionDoubleBarrelShotgun = "Recondition Double Barrel Shotgun",
Recipe_ReconditionDoubleBarrelShotgunSawnoff = "Recondition Sawed-off Double Barrel Shotgun",
Recipe_ReconditionSP12 = "Recondition SP-12",
Recipe_ReconditionSP12F = "Recondition SP-12 (Folded)",
Recipe_ReconditionR700 = "Recondition R700",
Recipe_ReconditionW1866 = "Recondition W1866",
Recipe_ReconditionMSR788 = "Recondition MSR788",
Recipe_ReconditionR1022 = "Recondition R1022",
Recipe_ReconditionMR223 = "Recondition MR223",
Recipe_ReconditionMR223F = "Recondition MR223 (Folded)",
Recipe_ReconditionM14 = "Recondition M14",
Recipe_ReconditionSKS = "Recondition SKS",
Recipe_ReconditionAK47= "Recondition AK-47",
Recipe_ReconditionAK47F = "Recondition AK-47 (Folded)",
Recipe_ReconditionCAR15 = "Recondition CAR-15",
Recipe_ReconditionCAR15D = "Recondition CAR-15 Delta",
Recipe_ReconditionM16 = "Recondition M16",
Recipe_ReconditionMP5 = "Recondition MP5",
Recipe_ReconditionMP5SD = "Recondition MP5SD",
}
some of these recipes are assigned to magazine #3
in the game when i mouse over said magazine
and then i read the book and they do not show up in crafting at all
prior to adding this translation string set
and renaming the items
it worked fine
(PPSh is added dynamically by another mod and that shit all works do not worry about that)
the other two are at the bottom
u can see they have names defined..
Recipe_ReconditionMP5 = "Recondition MP5",
Recipe_ReconditionMP5SD = "Recondition MP5SD",```
this shit is in
UdderlyGunReconditioning/media/lua/shared/translate/EN/
and the file is named Recipes_EN.txt
which matches the zomboid translation crap i found here:
which is on TIS github
so it should be legit
(well not that file obviously, but that github)
e.g.
Recipes_EN = {
Recipe_Add_Crafted_Trigger = "Add Crafted Trigger",
Recipe_Add_Motion_Sensor_V1 = "Add Motion Sensor V1",```
and just to complete showing the info
here's one of the recipes
recipe Recipe_ReconditionMP5
{
MP5=1,
ScrapMetal=35,
SheetMetal=1,
Screws=10,
BlowTorch=8,
keep [Recipe.GetItemTypes.WeldingMask],
keep [Recipe.GetItemTypes.Screwdriver],
keep [Recipe.GetItemTypes.Hammer],
SkillRequired:MetalWelding=10;Aiming=8;Maintenance=6,
Sound:BlowTorch,
NeedToBeLearn:true,
Result:MP5,
Time:350.0,
Category:Firearm,
OnGiveXP:MetalWeldingAndMaintenance10,
OnCreate:ReconditionGun,
RemoveResultItem:true,
}```
they are in GunConditioningRecipes.txt
in
UdderlyGunReconditioning/media/scripts/
hm
now that i think of it i did move them out of a folder
and i did learn at some point that it seemed to use folders to determine category
regardless of it having "Category:Firearm"
so perhaps i need to shove it back in a Firearm folder.
mayb
ive had it with copying my shit to the workshop versions, time to unsub from myself
lol
im working on 3 mods
one has three submods
it's a headache
been planning to try to make rechargeable batteries at some point
i sense that will suck
eh?
Radios are hardcoded on the java end to only accept Base.Battery
that's fuckin stupid
Trust me, the entire point I started this mod was to add rechargables
So now I just have to make the regular ones rechargable
technically u can recharge alkaline batteries it's just dangerous and inconsistent
yea
thinking it might require an electrical skill or somethin
cuz i knew it might be hardcoded..
it's really no wonder so many modders are pissy and quit doing it
heh

oh i bet Translate has to be upper case
i bet that's what's fuckin me
im on linux after all
half the shit is lowercase half of it is capitalized
pretty irritating
I'm literally going to reprogram it to use a custom check for the OnTest
note to self: gun model has to be defined after the item otherwise it is invisible
:)
progress
it shows up now but the translation string is still not working
maybe i didnt fix that one tho
checks others
nope.
how the fuck
looks in her mods for another mod with Recipes_EN.txt to reference
mhm..
right
so im the only jackass trying to use this name format
oh weird i typed just recipes and see results with Recipes_EN.txt
whatever
Is that a SimTower theme for Windows?
Omg 95/98 brings back memories.
Haha
Delta, are you good with modding?
Im this close to breaking all of the bones in my body because I can't understand why my check doesn't work
I work on specific areas. What's up?
I'm trying to make a mod that modifies how BatteryRemoval and Insertion works, right?
you put underscores in the file
but u put spaces in the recipe?
this makes me wanna punch someone
-_-
takes a breath
require "recipecode"
BatteryFixes = {}
BatteryFixes.batteryItemWhitelist = { -- Whitelist of "torches" and other items that can have their batteries added and removed. Uses dictionary for efficiency.
["Torch"] = true;
["HandTorch"] = true;
["Rubberducky2"] = true;
}
function BatteryFixes.applyBatteryFix(item) -- Applies the battery patch included with the mod.
local modData = item:getModData()
print("Checking if patch has already been applied..")
print("Patch applied: "..tostring(modData.hasBattery ~= nil))
if modData.hasBattery == nil then
print("Patched.")
modData.hasBattery = item:getUsedDelta() > 0
print(modData.hasBattery)
end
end
function BatteryFixes.OnTest.TorchBatteryRemoval (sourceItem, result)
local modData = sourceItem:getModData()
if modData.hasBattery == nil then BatteryFixes.applyBatteryFix(sourceItem) end
print("Can remove battery: "..tostring(modData.hasBattery))
return modData.hasBattery
end
function Recipe.OnCreate.TorchBatteryRemoval(items, result, player)
print("Firing.")
for i=0, items:size()-1 do
local item = items:get(i)
local modData = item:getModData()
-- we found the battery, we change his used delta according to the battery
print("Is valid item: "..tostring(BatteryFixes.batteryItemWhitelist[item:getType()]))
if BatteryFixes.batteryItemWhitelist[item:getType()] then
result:setUsedDelta(item:getUsedDelta());
-- then we empty the torch used delta (his energy)
item:setUsedDelta(0);
if modData.hasBattery == nil then BatteryFixes.applyBatteryFix(item); end -- Apply patch if it isn't present.
modData.hasBattery = false
print("No longer has battery.")
end
end
end
function Recipe.OnTest.TorchBatteryInsert(sourceItem, result)
local sourceItem = sourceItem
local res = result
local modData = sourceItem:getModData()
if BatteryFixes.batteryItemWhitelist[sourceItem:getType()] then
if modData.hasBattery == nil then BatteryFixes.applyBatteryFix(sourceItem); end
--local returnData = (not modData.hasBattery)
--print("Item lacks battery: "..tostring(returnData))
return (not modData.hasBattery)
end
return true -- the battery
end
function Recipe.OnCreate.TorchBatteryInsert(items, result, player)
local modData = result:getModData()
for i=0, items:size()-1 do
-- we found the battery, we change his used delta according to the battery
if items:get(i):getType() == "Battery" then
result:setUsedDelta(items:get(i):getUsedDelta());
if modData.hasBattery == nil then BatteryFixes.applyBatteryFix(result) end
modData.hasBattery = true
end
end
end
function Recipe.OnCreate.DismantleFlashlight(items, result, player)
for i=1,items:size() do
local item = items:get(i-1)
if BatteryFixes.batteryItemWhitelist[item:getType()] then
if Recipe.OnTest.TorchBatteryRemoval(item) then -- Updated to use Recipe.OnTest.TorchBatteryRemoval to use the same logic for checking if a battery can be taken out upon destruction.
local battery = player:getInventory():AddItem("Base.Battery")
if battery then
battery:setUsedDelta(item:getUsedDelta())
end
end
break
end
end
end
seriously, this sort of thing is super unintuitive
This is literally
my entire file
And I don't possibly understand
Why it's not working
Does it error?
No
of course not
then it'd be easy to fix
haha
it's the quiet shit due to subtle inner workings of PZ that fuck you
Mmmm well I haven't touched this area of the API. I'll take a read.
IT STILL ACTS LIKE IT'S USING THE :GETDELTA() CHECK
c a l m ๐
-- Return true if recipe is valid, false otherwise
function Recipe.OnTest.TorchBatteryRemoval (sourceItem, result)
return sourceItem:getUsedDelta() > 0;
end
i have to go rename all of my recipes now
Yes, the space is there.
because someone decided '_' == ' '
all in recipecode.lua
OnTest is somehow failing.
I'm using a require for a safeguard, I have it named in a such a way that it should always load afterwards, it prints everything I want, I don't understand
Yeah that API is very confusing.
anyone who has ever done the thing i just did could have seen my mistake so easily
now that i know what it was
it's sad nobody read it
Hey @thin hornet Do you know battery stuff?
cudda saved me 3 hours
mate
u hav wrong arg count
in ur code
wat
OnTest doesn't have player
look at original
that's borkin it
now naturally it doesn't tell you this
In Typescript it does. >=)
im dying of frustration and misread
its oki
am i late to the party?
Nono you're on time
the party is on fire
I'm in agony
XD
pls to bring extinguisher
I think we just need to flood the building
whatsup
i just figured my problem out, and it's that the translation string system has a bunch of dumb not clear things that are done quietly like replacing bits of strings
but pwrcosmic still needs help
The Recipe.OnTest.TorchBatteryRemoval replacement is running but not doing what I need it to do despite it returning the correct value.
I don't know if this is just zomboid being weird or what, every other function replacement has worked just fine.
The only difference I see in this stupid function is that there's a single space between the function name and the ()
what are you trying to do in OnTest?
Check if the flashlight has a battery, and if it does, remove it.
It's replacing the :GetDelta() checks of the original and adds a boolean modData of "hasBattery" to flashlights
So players are SUPPOSED to be able to remove and add dead batteries.
ahh
(idk about add, but removing is needed for my mod concept)
If I can get this working, I can finally start implementing the Hand Crank.
i yeah cause vanilla flashlight doesnt remove depleted battery right
It treats a depleted battery as a noenxistent battery
Hence why I converted it to a boolean
So you can't just remove dead batteries from flashlights.. forever.
Problem is, when a battery dies, it's just perpetually stuck in the flashlight and can't be taken out.
Despite the custom check making no reference to :getdelta()
It works perfectly fine on every other charge.
function BatteryFixes.OnTest.TestTorchMustHaveBattery(sourceItem, result)
local modData = sourceItem:getModData()
return modData.hasBattery || sourceItem:getUsedDelta() > 0;
--- true if hasBattery is set or if it has used delta left
end
function BatteryFixes.OnTest.TestTorchMustNotHaveBattery(sourceItem, result)
local modData = sourceItem:getModData()
return not modData.hasBattery && sourceItem:getUsedDelta() <= 0;
--- false if hasBattery not set and used delta is zero
end
when inserting just set has battery
when removing unset it
But I do that though-
while ur here and knowing things, is it really hardcoded in java that radios accept only Base.Battery?
If it actually isnt im totally making rechargables
then i wont have to
that'd be nice
lol
i dont have a decompile on this machine yet
Also do || and && work in lua?
or id look
for and u type "and"
for or you type "or"
but it doesnt work bitwise
I know that but Im just asking cuz of the funny
at all
Didnt figure
probably works in other languages like i do and just did it by habit
probs
i dont think you need to apply any patch
on the recipe to remove battery use OnTest:BatteryFixes.OnTest.TorchHaveBattery
on the recipe to insert battery use BatteryFixes.OnTest.TorchDontHaveBattery
So you're saying I have to change vanilla recipe definitions
To use the new functions
u can override those if u want yeah
in this case i would have tried to override the function too tho
cuz.. mod support!
you can do it in a mod still tho
u have to loop thru all recipes that seem to conform to what u want
and modify them in code
if it can't be done by patching the original function
I have no idea how to do that
copy the original recipe and add Override:true,
Am I able to just leave everything else out?
recipe Remove Battery
{
keep Torch/HandTorch/Rubberducky2,
Result:Battery,
Time:30,
OnTest:Recipe.OnTest.TorchBatteryRemoval,
OnCreate:Recipe.OnCreate.TorchBatteryRemoval,
StopOnWalk:false,
}
ugh so i fixed the translations showing up but broke the recipe showing up
i fucking hate this
But then have another script that's just..
recipe Remove Battery
{
OnTest:BatteryFixes.OnTest.TestTorchMustHaveBattery,
Override:true
}
?
nope
agony
Won't that cause mod incompatibilities?
i will
everything about this is agonizing
if u need to
How do I mdoify it dynamically
by retrieving the recipe on startup and tweaking the value
I see
local recipe = ScriptManager.instance:getRecipe("Remove Battery")
to get the recipe
iirc
then
well for items it'd be DoParam idr for recipe
Did I do anything wrong or is it just zomboid jank-
zomboid jank and u probably did something wrong too
xd
but figuring out what u did wrong
is made very hard by zomboid's lack of feedback
about many issues
I gotta figure out how to have compatibility with Better Flashlights-
ok i was eating sorry
this translation system is a fuck
They override.
two mod that override the same recipe are probably not meant to be compatible
u can make it do it anyway.. it just sucks :)
sometimes mods do it when they dont need to
๐
thats it?
And they did add an OnTest of their own, but it doesn't override.
It functions on it's own accord.
For the vanilla modification?
for better flashlight
recipe Remove Battery
{
keep BF_HeadLight/HandTorch_Army1/HandTorch_Army2/HandTorch_ManLite/HandTorch_CK_LED/Torch1/Torch2/Torch3/Torch4/Torch5/Torch6/Torch7/TorchArmy1/TorchArmy2/BF_SpiffoLite/BF_EgenerexLite/BF_OldFlashlight,
Result:Battery,
Time:30,
OnTest:Recipe.OnTest.TorchBatteryRemoval,
OnCreate:Recipe.OnCreate.BF_TorchBatteryRemoval,
StopOnWalk:false,
}
What fun
Seems they still use the default and just use a custom for create
I dont think any of their lua modifies Recipe.OnTest though
Only "copies" it
then we can easily make it compatible
How do you figure if Recipe.OnTest.TorchBatteryRemoval isn't functioning correctly?
Would I just force them to use my method?
I puposely made my item lookup a dictionary specifically for compatibility so
two things you can do:
If the mod exists, to add their items, I can simply just add all of the item names to the dictionary.
you can either make your stuff have their stuff in it for compat and override their method as necessary depending on what it does
making sure ur mod loads later
OR
u can edit the existing recipe to tweak the one OnTest setting
which is more complex but shorter once you know how - that said i've never edited a recipe before, just items
OnTest isn't modified.
OnCreate is.
Ohh
instead of also overriding the recipe
So like, make the OnTest convert over to mine..?
I wish the OnTest override worked-
It'd make mod compatibility so much better
or if you like the kludgey way (very simple tho), make a second branch of your mod that uses their OnCreate and requires their mod
but has ur OnTest
as a submod
Would rather have it in the main mod so people don't gotta do that
of course
:p
me too that's why i suffer
:)
i make all my mods dynamically intercompatible and allow others to use them as frameworks
ugh
modular everything
i dont understand why the recipe is gone now
fix translation -> recipe disappear
I just don't understand why specifically TorchBatteryRemoval doesn't work
me either
a normal language would tell u something went wrong
but KahLua? nah
im really salty excuse my sassiness
so much frustration at this translation system
Are you talking about type safety or something like assignment errors?
well ur overriding an existing function
in, e.g., C#, it'd require an override keyword
and it'd only let it happen if the something existed
in lua it's just defining a fresh function quietly if it is mistargeted
and u never know
For some stupid reason I have a hunch that the space is part of it
@weak sierra I mentioned this already, but Typescript modding is a thing now in PZ.
Since you were talking about error reporting, I thought I'd mention it.
Ok.
I guess im just irritated, I was doing so well then this just inexplicably decides to not do its only job
not sure if it being in typescript would help with that anyway tho
cuz.. in the end the typescript is being translated to lua
for runtime
so runtime errors will still be runtime errors unless ur introducing a lua-based typescript VM
in which case ur introducing lag
cuz more overhead
im pretty sure it's just a translator tho
the log is outputting it and everything
have u read the actual log?
the debug log only shows some stuff that comes out in my experience
like loading errors won't be in there
syntax errors
etc
my understanding was that it just always had a battery
and 0 was treated as "no battery"
the battery being just the flashlights fullness
if the battery is dead it still in it
That's how it is in vanilla
as a concept
In the mod, I want dead batteries to be a thing so you can recharge them
yeah i know
I don't want your batteries to just be magically eaten by hungry flashlight monster
but.. the test for having a battery is always gonna be true? idk i didnt read all ur code
u storing it in moddata or smth?
yes
nod
after taking it out
lots of things should have lots of things
but PZ seems like it was written originally by an inexperienced team at game design
(no offense intended)
and then retrofitted to have better systems as they learned
which is unfortunately true of many indie titles
It's just specifcally when the battery is dead when the menu wont come up to remove it
i mean the betterflashlight mod check for each item types
if sourceItem:getType() == "BF_HeadLight" or sourceItem:getType() == "HandTorch_Army1" or sourceItem:getType() == "HandTorch_Army2" or sourceItem:getType() == "HandTorch_ManLite" or sourceItem:getType() == "HandTorch_CK_LED" or sourceItem:getType() == "Torch1" or sourceItem:getType() == "Torch2" or sourceItem:getType() == "Torch3" or sourceItem:getType() == "Torch4" or sourceItem:getType() == "Torch5" or sourceItem:getType() == "Torch6" or sourceItem:getType() == "Torch7" or sourceItem:getType() == "TorchArmy1" or sourceItem:getType() == "TorchArmy2" or sourceItem:getType() == "BF_EgenerexLite" or sourceItem:getType() == "BF_SpiffoLite" or sourceItem:getType() == "BF_OldFlashlight"then
That's why I made a dictionary to optimize that a bit LOL
I wanted support to be seamless for that mod
yeah
ew gross
fuckin
they're also doing getType over and over
do it once
jesus
overrides the recipe
Mine just does a ["Torch"] = true
and add this
BatteryFixes.batteryItemWhitelist = { -- Whitelist of "torches" and other items that can have their batteries added and removed. Uses dictionary for efficiency.
["Torch"] = true,
["HandTorch"] = true,
["Rubberducky2"] = true,
["BF_HeadLight"] = true,
["HandTorch_Army1"] = true,
["HandTorch_Army2"] = true,
["HandTorch_ManLite"] = true,
["HandTorch_CK_LED"] = true,
["Torch1"] = true,
["Torch2"] = true,
["Torch3"] = true,
["Torch4"] = true,
["Torch5"] = true,
["Torch6"] = true,
["Torch7"] = true,
["TorchArmy1"] = true,
["TorchArmy2"] = true,
["BF_EgenerexLite"] = true,
["BF_SpiffoLite"] = true,
["BF_OldFlashlight"] = true,
}
Should I override the dynamic way?
his function only do vanilla stuff but checks for his items
so all you need to do is override recipe script txt and check for his types
Alright, I can look into that.
do u know how recipe name translation works Konijima?
Would it be better to dynamically add those items or is there no way of checking?
i've been fighting with it for 4 hours now
you can look for "Torch", "Lite", "Light", "Lantern", "Lamp" etc
It'd be nice for it to still be "up to date" with Better Flashlights if they ever add a new one.
in the names
kludgey but will probably work fine
u'd have to loop thru all items tho
heheh
Recipe_Attach_Hunting_Knife_to_Spear = ""
you take the name and replace space with _
yeah and apparently u dont put Recipe_ in ur recipe name
so, let's say u have no space
or underscores
the translation is working but now my recipes dont show up in the game
I'd have to hook the override to an event, what event should I hook to?
why no Recipe_?
cuz it automatically strips it
and then doesnt find the translation
lmao
anyway
it seems it magically decided to work now
musta forgot to restart the game last test
so
the fact that entries in Recipes_EN.txt have Recipe_ added
and that u can't have underscores in ur recipe names
because it confuses the stupid thing
both made me get so lost
cuz i had both going on
i had recipes named like
Should I just rely on the Better Flashlights dude to update his mod to be compatible with mine or-
you may have to add the module name
Recipe_Forge762_71Drum
on the actual recipe
thinking it'd work if i then did Recipe_Forge762_71Drum = "Forge 7.62mm 71-rd Drum"
and it's over there lookin for
"Forge762 71Drum"
-_-
How do you show the full log btw
user folder/zomboid/console.txt
if it's an old one u find them in logs folder in zomboid folder
if (var3.contains("=") && var3.contains("\"")) {
if (var3.trim().startsWith("Recipe_")) {
var8 = var3.split("=")[0].replaceAll("Recipe_", "").replaceAll("_", " ").trim();
var9 = var3.split("=")[1];
var9 = var9.substring(var9.indexOf("\"") + 1, var9.lastIndexOf("\""));
} else {
ima stick that in my notes in case this fucks with me again lol
clearly remove the Recipe_
yeah i did
but you need it in your text file
just the translation one yes


