#mod_development
1 messages ยท Page 16 of 1
i have it all sorted now
but i swear - 4 hours
:|
i need to make time to do the decompile
i cudda just looked at that
lmfao
i keep trying to avoid it cuz im busy and it keeps biting me in the ass making me waste more time
ill do it tomorrow before i do any more work
if ur still fighting this tomorrow hmu when im less burned out
function Recipe.OnTest.TorchBatteryRemoval(sourceItem, result)
--[[local modData = sourceItem:getModData()
print(tostring(modData.hasBattery))
if modData.hasBattery == nil then BetterBatteries.applyBatteryFix(sourceItem) end
print(tostring(modData.hasBattery))
return modData.hasBattery;]]
return true;
end
Literally doing this crap
If it doesn't work, something is interfering.

yup
good debugging technique that is
tbh
called uh.. what's the name
sanity check
yeah
Danggg, you guys are like the smart people right? With all the fancy coding and numbers and stuff. I feel like an idiot compared to yall.
ive programmed since 1999 technically, but in seriousness since 2005
i still call myself stupid on a daily basis
for making dumb mistakes
I only started tampering with any sort of scripting / programming in like 2015
it's like if u had to explain everything to a 5 year old very clearly and bluntly
That's pretty impressive right?
RecipeManager in the java scripts is what manages recipes I'd assume
Would hope to god it does anyways
I once spelt my name wrong on an Exam. I'm not that smart
most of the stuff u want is in ScriptManager
generally speaking and in this case
i dont remember what RecipeManager does
but i looked at it the other day and my conclusion was to forget about it
for the time being
eats dinner
Im in bed right now. All cozy...
So ima just eevesdrop on you guys
So talk about code stuff as I observe...and stuff
@cosmic condor do you know if its possible to change the output text from the televisions?
@iron salmon is it possible to know at all where the script text for the televisions are stored in files?
Possibly here
C:\Program Files (x86)\Steam\steamapps\common\ProjectZomboid\media\radio
@thin hornet Bad news, I don't think the TorchBatteryRemoval function works on it's own.
I set it (both in the raw lua files and in my modification) to only return true
And it still denies me the ability to take out a battery when :getUsedDelta() is zero.
There isn't anything wrong with my code, it's another problem entirely.
Even if I did the custom functions it wouldn't work the way I wanted to
that possibly looks right...
ah yes it is
its just the english is saved as xml
Interesting
For the curious, we've managed to pull the 41.73->41.74 changes. It's typescript definition files but hopefully you can mentally map it to lua!
https://github.com/asledgehammer/PipeWrench/pull/13/files

We have automation going now so should pick up any changes the moment TIS pushes them
might sort out a github pages site or something that gets automatically updated with these 'patches', if there's interest
Any clue why I could be getting this nil?
function: perform -- file: DTByMovingObjects.lua line # 163 | MOD: Dynamic Traits
ERROR: General , 1661383062536> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: Object tried to call nil in perform at KahluaUtil.fail line:82.
ERROR: General , 1661383062537> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: Object tried to call nil in perform
This is the function, it only fails if I use the "Grab" option from the context menu, grabbing items from floor is all okay
i
i just wanna make funny meme mod

look at mods that add tv channels
@thin hornet does it matter whats typed up for the id?
cause it just looks like random strings
GAMING
wait what
i was about to illustrate it not working
cuz i searched for the recipes a min ago
and didnt see them there in the search
but then..
It worked..?
Amazing
I feel like this is a lead but idk
sounds like that'd only affect things in the radial menu
Yeaaa
i think ur barking up the wrong tree there
use a random GUID generator
that's the same.. thing
wait is it
i mean i can see hardcoding to Base.Battery there
but again this is just the radial
im so sorry LOL
lol
Im literally going in circles
Maybe I can find it by looking into UI
Dunno which UI, but a UI
The colors look cool
Well
I've gotten absolutely nowhere
Over the course of..
Nearly an hour now.
I managed to find a function called "getLuaTest" in java that can be accessed by lua
by neither Java nor Lua actually access it
wait, found a new lead
getLuaTest isn't used as a get ironically, they just go straight for LuaTest
can you do fractional units of something in a recipe
e.g.
GunPowder;.25,
gonna find out :p
Hey folks! Quick question because I'm too dumb to figure it out - Any server I join downloads all the mods, then close it, try to connect again and it always says Im missing XXXXX mod.
u want #mod_support
my bad
I've looked through both the lua and java ends for
hours now
and i still can't get anything
@thin hornet if you find anything can you let me know
I'm not expecting you to go out of your way to find anything, I just mean if you happen to stumble upon something.
please refresh me what exactly you are trying to do now?
I found out that there's some sort of secondary check to Test.TorchBatteryRemoval
I set the function to only return true and it still had the same behaviour
I don't exactly know where the secondary check could be, but it'd have to do with recipe test links
Likely in combination with a getUsedDelta() or similar
RecipeManager and IsoThumpable have been my greatest leads so far (on the java side)
Not sure about Thumpable but it has some fuel refs
ISInventoryPaneContextMenu is my only lead on the lua end of things

im so DEAD
i do not find anything in code that could prevent it
genuine agony
ill take a crack at it tomorrow
actually, ill just flip over to the other method and see if it just magically works
Even with the edits you made, it still doesn't quite work. @thin hornet
Sorry if I'm bothering you by the way, if you'd like some peace let me know.
I converted it to use the method you created, and still nothing shows up when a battery is depleted.
does anyone know why my recipe is not working to craft this fanny pack? am i missing something here? it works for my alice packs..
{
DisplayCategory = Bag,
WeightReduction = 50,
ClothingItemExtra = Bag_FannyPackBack,
ClothingItemExtraOption = FannyPack_WearBack,
clothingExtraSubmenu = FannyPack_WearFront,
Weight = 0.2,
Type = Container,
Capacity = 2,
DisplayName = Bigger Fanny Pack (Front),
Icon = PurpleFannyPack,
OpenSound = OpenBag,
CloseSound = CloseBag,
PutInSound = PutItemInBag,
BodyLocation = FannyPackFront,
ClothingItem = Bag_FannyPack,
CanBeEquipped = FannyPackFront,
RunSpeedModifier = 0.98,
WorldStaticModel = FannyPack_Ground,
}
recipe Craft Bigger Fanny Pack
{
keep [Recipe.GetItemTypes.SewingNeedle],
Thread = 5,
Sheet = 2,
Result : Bag_Fanny_Pack,
Time : 400.0,
Category : Survivalist,
}```
no worry im just very busy atm i will look at it soon, just @frail spire tomorrow if you still have an issue with this
Can I make a /server/ file to trigger a player to say something?
Or do I need to pass it to the client?
Not 100% sure. I'd go with OnServerCommand to the Client.
I am running off of only adrenaline and rage right now
After updating some translation files of my mod, suddenly things that get cooked disappear. Is this a known issue?
Hehe, Evelyn was having some problems with that type of stuff earlier.
@weak sierra share your knowledge!!
What's getting me is it was working fine until I changed some item name values in the Translate folder.
I've been trying to fix it for half an hour, I think I'll just try some stuff later.
Best of luck my friend!
Time to take a break!
I just realized that what I'm doing hits the java side of things

I don't think I can patch it.
With getDelta() being a non-zero value, it successfully retrieves the recipe via Recipemanager.getUniqueRecipeItems()
With getDelta() being a zero value, it returns []
An empty table.
After further investigation, there is indeed some sort of secondary check.
I set it to always return true, and I was able to remove batteries from flashlights when their delta was above 1.
But when I set it to my old method, I couldn't do that.
It's a combination of my own check and some undesired check located god knows where
Probably on the java side if Im unlucky (which is probably is)
Figure it out?
Sleep on it. Might come to you then.
I guess it might, worth a shot.
If you try anything crazy, make sure to git or archive your stable code.
Will save you from grief.
I'm not gonna be touching the java end of things since I know we're not really supposed to so

Oh no no I mean't your Lua.
Also you're fine to mod the Java side. The problem is distribution.
Distribution as in like, giving it to other people?
Yeah. You can't upload this sort of thing to the Workshop.
Fun
It's both against the devs and Steam's ToS for Workshop.
Very much noted
To link it though from another host is fine, just make sure you say exactly what it does and people will decide whether or not to trust it.
All good.

man I just wish it'd be easier
like, the function works and everything
it's something to do with that stupid check somewhere
and I can't freaking find it
Sounds lovely
There's a market for it. xD
I wouldnt doubt it hehe
Welp, suppose all I can do is sleep.
See ya in the morning I supposeeee

Heh. Have a good night. Hope you find your fix.
hello everyone and welcome to my basic tutorial on using wordzed!
Here's the link to download the program -- https://drive.google.com/file/d/1vY-08QJBIzh8gxzIzhGuyLs-RP-CV2T3/view?usp=sharing
did u try putting the recipe above the item? i know it makes no sense but the opposite works with models and guns.. 
u have to be more specific about what "not working" means tho
Is there a way in WorldEd to make a 3 cell lay out in an L shape
I could try that but not sure as my bags work fine going first and having the recipe after. not working as in the recipe to craft it is not appearing when i have the required items
need to see the actual file the error is from, or the correct error atleast. the file you sent doesn't have anything at line 82, and the error is pointing at a file line 163, so definitely not in this file.
Fixed it! I just needed to tweak the ReplacedOnCooked value of the items. No clue why the issue happened until after changing translation files, though
hmm, im wondering, are you sure that it is even replacing the function associated with the recipe? There might be some funky stuff with the function being saved, rather than being a reference to the original functionname. Some stuff behaves like that. for example, functions that are pushed into a event, can't be overwritten normally. The global function will be changed by the overwrite, but the function that was already added to the event, will be unchanged. Try putting a print statement into the ontest, and see if it outputs it. You can also get the ontest function from the recipe manager and manually run it, if you don't see the print statement just incase the game isn't running it due to some other check, then for some reason the function isn't being replaced properly. Also how are you doing the override atm. you said before that you were hooking the override to an event? you shouldn't need to do that tmk. maybe that is doing some weird stuff
basically I think the problem you think is caused by some secondary check could also just be explained by the Ontest not actually being replaced I think. although I may have also gotten a bit lost in all the messages
Does anyone know if I can tweak the offset of a sword on the belt but just the belt like changing the angle its holstered on
is it knife_belt_front?
Anyone knows how to get a specific cell?
I know its getSpecificPlayer(0):getCell()
But how do I call that in a function if I want to check a specific cell?
getSpecificPlayer(0):getCell() == 11,19 doesnt work
getSpecificPlayer(0):getCell(11,19) doesnt either, so I'm at a loss how to check if the player is at cell 11,19
I've wanted a more "survival horror" style map and I think I'm going to try my hand at it. I have a bit of experience modding other games and with 3d modeling/lua code but wanted to check as I'm newish to project zomboid. Would there be any interest in a 4x4 cell map that spawns the player in an enclosed underground city? Thinking the feel could be achieved via a series of interconnected massive multilevel building complexs without windows. Want to make a constantly dark enclosed survival map where scavenging is both incredibly dangerous because of narrow alleys/blind corners/darkness but also necessary as fishing/farming wouldn't be feasible. Any thoughts?
How often does action :update() happen?
The same as OnTick?
It fails on every line (based on the conditions given by the if's) like this:
player:getModData().DTdoTraits = player:getModData().DTdoTraits + (item:getActualWeight() * 3);
I'm not sure why would it be a nil, I'm storing both the player and the item above
local player = self.character;
local item = self.item;
This is the entire file
Anyone got a dumbed down how to use OnClientCommand and OnServerCommand?
I want to make a player say something by a server thing, but I dont understand how to
It seems I need to pass something like a module
and somewhere on the way I pass the player info
well if the error is repeatable, i'd temporarily break down the lines to figure out exactly which call is breaking ie
local traits = player:getModData().DTdoTraits
local weight = item:getActualWeight()
player:getModData().DTdoTraits = traits + weight*3
either player or item is nil. If I had to guess, I think it is that self.item from the ISGrabItemAction is nil. maybe some issue with the queuelist
here is an example
in the server
local function OnClientCommand(module, command, player, args)
if module ~= 'Beehive' then return end
--print('Beehive OnClientCommand received command '..command)
if SBeehiveSystemCommands[command] then
local argStr = ''
for k,v in pairs(args) do argStr = argStr..' '..k..'='..v end
SBeehiveSystem:noise('OnClientCommand '..module..' '..command..argStr)
SBeehiveSystemCommands[command](player, args)
end
end
Events.OnClientCommand.Add(OnClientCommand)
in the client
local args = { x = self.beehive.x, y = self.beehive.y, z = self.beehive.z}
sendClientCommand(self.character, 'Beehive','harvest', args)
This sends a command from the server to the client?
basically, the module is usually just a way to figure out what category the command is related to. So in this example, Ive gathered all my beehive related code into SBeehiveSystemCommands table, and so I just use the 'Beehive' to tell which one it goes to. because technically, when a command is sent with sendClientCommand(this sends command from the client to the server), the command is given to all functions inside Events.OnClientCommand. so you need to use the module to filter out which one it is meant to go to
Yeap, you were right, the nil comes from the item, not the player
yes. sendServerCommand and OnServerCommand, is the opposite mechanism. I haven't used it so I don't have an example at hand, but Im pretty sure it works the exact same way except a slightly different order of arguments
Hello was wondering if anyone could advise?
Poked around a little with a mod script
And I was just wandering how Id go about compiling it?
Its a single .txt file Ive edited, and god knows how I build it from VS without making something much larger than the original .exe
Which also doesnt work
what kind of mod is this?
Its TrueMusic one
Its one little edit ive made
Pretty sure it works but this would be the final test to see if so
you don't need to compile anything for normal modding. You just need to put it into a mod folder in the correct structure. There is an example mod in your c drive here "C:\Users\youruser\Zomboid\Workshop\ModTemplate"
Yea this isnt a normal one
You have to run an exe file in the mod to get it to what you want
ie adding your music
And its that exe file im looking at changing
oh i see. You won't be able to modify the exe in another mod, but you can just provide your own.
?
THey provide the code for the exe so I dont see why not
Even say in the notes you can compile that code to create that exe
But all they recommend is VS
not how
hmm, oh are you just doing this for personal use?
Yea yea
Ive got the code
ive got the edit ive made
Im just trying to compile it now into an exe
ah, ok then I suggest you go to their mod page to ask for help
You have to pay and im not doing that for this
or maybe mod_support channel, maybe someone there knows
Just want to know how to build cs on a txt doc
Yea i thought this channel was more appropriate tbh
not really, this channel is about making mods for zomboid. Your issue isn't about creating a mod, its about using an existing mod
... well, modding an existing mod
compiling isnt the average thing you do when you need support for a mod
it isn't really something you need to do for modding in zomboid
look we can argue semantics for however you want, Im just trying to tell you where you have a better chance getting help
Will investigate
I doubt I can in that channel but thanks if you cant help
Also robot, the override is just redefining the OnTest event.
What's strange is all the prints are firing, but you could be right in it somehow not being associated correctly.
oh nevermind then
I think I maybe misread something
I thought the prints in the Ontest weren't printing. Thats why I suspected the Ontest wasn't being replaced in the actual recipe
They printing alright, and the result is correct, it just seems that the result is only being partially used with a other check.
I know it's being used to some degree, as when I set the function to always return true, I can remove batteries from flashlights with the "hasBattery" mod data being false.
However when I do my solution, I can only remove batteries when the modData aligns.
Both however won't let me remove batteries from a dead flashlight.
Hence why I suspect there's some sort of secondary check somewhere, and assuming I'm as lucky as I am it's probably on the java side.
Callframe at: se.krka.kahlua.integration.expose.MultiLuaJavaInvoker@c84d90e1
function: createMenu -- file: ISWorldObjectContextMenu.lua line # 1532 | Vanilla
function: createMenu -- file: ISMenuContextWorld.lua line # 50 | Vanilla
function: createWorldMenu -- file: ISContextManager.lua line # 28 | Vanilla
function: doRClick -- file: ISObjectClickHandler.lua line # 60 | Vanilla
function: onObjectRightMouseButtonUp -- file: ISObjectClickHandler.lua line # 369 | Vanilla```
any idea whats causing this error
caused by matches
this is my mod
{
Base
}
recipe Scrap Matches into Small Primers
{
Matches=2,
Result:PrimerSM=6,
CanBeDoneFromFloor:true,
NeedToBeLearn:false,
Category:Survivalist,
Time:300,
}
recipe Scrap Matches into Large Primers
{
Matches=2,
Result:PrimerLG=6,
CanBeDoneFromFloor:true,
NeedToBeLearn:false,
Category:Survivalist,
Time:300,
}
recipe Scrap Matches into Shotgun Primers
{
Matches=2,
Result:PrimerSG=4,
CanBeDoneFromFloor:true,
NeedToBeLearn:false,
Category:Survivalist,
Time:300,
}```
Back into the madness of checking these functions I go
sorry, do you mind linking to which one was your solution again? I would like to take a look to see if I can spot any, but there are so many mesages now, idk which is which
function Recipe.OnTest.TorchBatteryRemoval(sourceItem, result)
local modData = sourceItem:getModData()
if modData.hasBattery == nil then BetterBatteries.applyBatteryFix(sourceItem) end
return modData.hasBattery
end
Simply tries to retrive the mod data of the item, if hasBattery isn't valid it applies the patch, then returns the value of hasBattery.
function BetterBatteries.applyBatteryFix(item) -- Applies the battery patch included with the mod.
local modData = item:getModData()
if modData.hasBattery == nil then
modData.hasBattery = item:getUsedDelta() > 0
end
end
The actual patch for ref
huh
table.sort(startFireList, function(a,b) return not string.sort(a:getDisplayName(), b:getDisplayName()) end)
this is the error line referenced
its just a lua check if your character is camping
no idea whats causing it
there should be a couple lines above this that say the actual error. do you still have it?
one second
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64```
ahh
this seems to be the issue
what the hell is stdlib
Clearly the library of stds
function: @stdlib.lua -- file: null line # 52
function: @stdlib.lua -- file: null line # 63
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64
function: @stdlib.lua -- file: null line # 64```
yea but what mod uses it
lol
@shadow geyser
this still remains my main lead, and it's horrifying
ah hah
i think its a map issue
wait no it isnt
if i start a new game and spawn in matches i dont get the error
but in an old save i do get the error
weird
yeah, the only thing I can think of, doesn't really make any sense. can you try putting a print statement of what modData.Battery is just before the return line to check that it is. Only thing I can think of is that modifying the table in the nested functions isn't being reflected in the modData variable in the OnTest, but that doesn't really make sense either
(with charge)
oh wtf, thats hmm. I just was checking how lua treats values as boolean, and it is weird. 0 is equivalent to true. Only nil and false are false, everything else is true
still recognizes the battery as existing without a charge, however the recipe to remove the battery no longer exists.
the second charge goes up
hence why im p sure there's a check somehwere screwing with it
having to do with RecipeManager.doUniqueRecipeItems somewhere in it's code
Likely here
Problem? It's java side.
hmm, the torch itself is drainable when empty I think, not just the battery inside the torch. Maybe it doesn't work because you don't have a torch (because it is empty). Try changing the recipe to destroy the torch, but then ofc you can make the recipe give you back the torch
cuz obviously a drainable with 0 uses, can't be used for a recipe, but for destroy tag instead of keep, I think it does work
What's the best way to go about adjusting the recipe with mod compatibility?
One of the core reasons I made this mod was for compatibility with BetterFlashlights for a friend in our server
ok i found the weird issue
if you have more than 400 matches
for whatever reason
the game derps out
The only other possible solution I can think of is implementing a "dead" version of everything and being able to use that as a sep recipe
But that would have mod compatibility problems
Holy crap you were right
However, what would the better solution at this point..
@shadow geyser Is there a "cleaner" way of doing it without the recipes?
If not, that's fine, I just think it'd confuse players if it said it destroyed the flashlight / other item when removing the battery
Hey i don't suppose anyone has an example of creating a recipe with a unit of gas or liquid as apart of it?
What is the simplest way to add a new keybind in the game?
This is my current recipe, i also want to create the item with 0 gas so we can refil it or create it with needing 1 unit of gas
imports {
Base
}
recipe Craft Lighter
{
Aluminum=1,
Battery,
Result:Lighter,
Sound:PutItemInBag,
Time:30.0,
}
you need to use an OnCreate function, which then takes the result item, and sets it's usedDelta to 0
Thank you @shadow geyser i have one more question, either sapphs better cooking mod or my new one stops me being able to opened canned food, is anything wrong with the full script/structure here?
module ISSRecipesMod {
imports {
Base
}
recipe Craft Lighter
{
Aluminum=1,
Battery,
Result:Lighter,
Sound:PutItemInBag,
Time:30.0,
}
}
Anyone know why I get an error when I try to add a recipe to a custom trait?
works completely fine without the recipe
I fixed it, all good. I named it recipes.txt, bad idea ๐
@shadow geyser Would it be better for me to request other mod authors to add support for my mod for flashlights or would it be better if I did it myself?
If other mod authors do it, they can add empty variants of their flashlights and the necessary modifications as necessary
Doing it myself isn't impossible, but I'd have to update the mod every time they update theirs to keep them in sync
Can someone give me an example of how to get the ID of an object you are clicking on?
you can try. sometimes they are open to doing it
because its usually better just for the code to be added to the mod, rather than overwriting
Ah yes but, this "local objs = sq:getObjects()" I put inside this function? or create a new one?
And where is that "sq" from?
I assume the sq stands for square or something
yes, an instance of an IsoGridSquare
also, in that example, I would suggest you only use an if/else when dealing with just a few desired IDs - if you have a whole load of tiles you want to match on, use a table
๐ค type:
local function IsoGrindSquare(square)
end
?
no
based on your question, it sounded like you already had obtained the grid square you wanted to inspect
were you referring to left or right clicking on the screen? if you're right clicking, there is code that already brings up a context menu that obtains grid square(s) to inspect in the vicinity of the mouse cursor
yes, but I wanted to create a context menu for a specific object
only I don't know information about this object
huh?
then look it up
like, from the tilesheets, or I suppose just dumping the id from a known-good square if you prefer that route
Now, this is a caveat in that this isn't broadly applicable, but for some circumstances is useful.
There actually are a fair amount of temporary global variables that are useful for some context menu event stuff.
I'm not good at explaining stuff, and am distracted by dealing with a bunch of dev stuff with my two brain cells,
and the examples from my mods are too big to upload to discord as posts.
But here's a stripped down example THAT WON'T WORK as I just provided as an example of using those variables
function PA_NinjaGrapple (player, context, worldobjects, test)
if not window then return end
if invincibleWindow or window:haveSheetRope() then return end
local playerObj = getSpecificPlayer(player)
context:addOption(getText("ContextMenu_Throw_ninja_grappling_hook"), worldobjects, PA_Grapple_Action, window, player, maxDistance);
return
end
Events.OnPreFillWorldObjectContextMenu.Add(PA_NinjaGrapple)
In this case window is a temporary global variable that was defined previously to OnPreFillWorldObjectContextMenu
Again, this isn't broadly applicable, but a lot of those temporary variables in the context menu can be very useful for mods.
"temporary global" - I'm so triggered right now
Sorry, I'm a former construction worker who just ended up being a coder by lucky accident ๐คช
I don't even know what a github is really? Isn't that a monster from Dungeons and Dragons?
These two files contain the temporary variables that are defined for ISInventoryPaneContextMenu.lua and ISWorldObjectContextMenu.lua
These variables by defined by cycling through the inventory/world context; for world stuff should be all the tiles and objects under the mouse cursor.
no no, a github is an English slang word for a pub in an old peoples' community
Hold on, isn't that one of those new fancy technical keyboard switches?
ah yes, I've been meaning to upgrade my mechanical keyboard to a technical one ๐
Ugh, I'm still learning how to use my fancy new 3c resolution monitor.
Still haven't figured out how to get my new technical keyboard to connect through bluemouth either. I don't think this new 5G wifi is working?
you need to mesh those together. The first one shows making a function and adding it to the event. You can see one of the variables given to you is worldobjects. make a loop that will go through lal the world objects one by one, then you can utilise the getsprite to get some identifies for it
bluemouth? you should ask Tobias Funke about that
It's very naughty of me to practice my comedy routines with this channel and I apologize ๐คช
Re-asking this. Anyone has any idea how to check a specific cell?
Hey Ive updated a Workshop item, all seemed to be good. But when I download that workshop item its still displaying the old update
Any idea why this would happen?
don't subscribe to your mod
Where is the code preventing players not part of a safe zone to not be able to right-click context in a safe zone?
testing it out
otherwise I wouldnt know it was broken
maybe temporarily move your local mod folder to somewhere else
then resub to your mod to see if the online contents match your expectation
I may require some assistance trying to map out some code in my head, y'all dont mind if I ramble a bit do you?
I'm trying to determine the best way to create new items and set up proper recipes for them dynamically via lua
Because of a limitation on Drainables in crafting
I don't mind, but I have no capability to help
That's quite alright.
Hm..
Right now im just trying to make sudo-code before trying to implement
So I suppose I should map out my goal first
I need to take all current flashlights / similar objects, make it so they turn into an empty equivalent upon running out of battery, and give the empty equivalents their own recipe, plus add a new "Replace Battery" method if possible.
- Loop through items
- If item is in BetterBatteries.batteryWhitelist, check for an empty equivalent.
- If an empty equivalent doesn't exist, create it as a "Normal" item with a custom "Insert Battery" recipe, as well as a custom "Remove Battery" recipe that checks for new ModData that dictates whether or not the empty item as a battery (all empty items by default will have a battery until it is removed.)
- Get recipes of original item
- If recipe's result is a Battery and it keeps the original item, assume "Remove Battery" and remove the item from the keep.
- If recipe's result is a Battery and it does NOT keep the original item, assume "Replace Battery" and dont do anything (?)
- If recipe's result is an item in the BetterBatteries.batteryWhitelist and is in destroy, remove the item from destroy and instead make it a use.
- If item is in BetterBatteries.batteryWhitelist, check for an empty equivalent.
I think that logic checks out (?)
Only thing that doesn't quite line up is checking for "Replace Battery", since I need to add the method if it doesn't exist.
Better Batteries and Vanilla don't have "Replace Battery" by default, but "Sleeping Bags and Attachments" Military Flashlights do have it by default.
@weak sierra What is your wisdom in dynamic recipes
Ok does anyone usually have issues uploading/updating Workshop Items?
Its uploading a 2GB workshop item in a microsecond and displaying a previous workshop item I already deleted, even though I uploaded them under new Item IDs?
Does anyone know a method to get all of the recipes associated with an item that doesn't involve looping through every single recipe in the game
sadly not. However, this is an operation you can do exactly once, at load time
technically this will be problematic if you care about people who dynamically define recipes in their mods - but that is solvable with a bit of function call wrapping
(I say "technically" because even if someone is defining them dynamically, I doubt it's very common to be doing so in the middle of the game, though not implausible)
So you mean OnGameStart?
for example, yes
Would it be smart for me to set up a dictionary that just links all the recipe sources to any item so I don't have a loop in a loop?
before I answer, what's your goal exactly?
This madness
Effectively trying to dynamically create improved flashlight recipes
Since by default, I can't remove an empty battery from a flashlight.
that's your proposed logic, I mean, in plain english, what do you want to change
I want to be able to (with mod support) remove batteries from flashlights, conver batteries into an empty counterpart so I can do so, and also have a "Replace Battery" option like in one of the mods I have.
Hence why I want to do a dynamic route for maximum possible mod support.
so, removing batteries seems simple to me; you just define your own recipe which runs a lua function
and your lua function inspects the flashlight item to determine the energy level, then add a battery item with matching energy to player inventory
Flashlight has to be a seperate, empty equivalent.
If it's the base flashlight, it wont work because of Drainable limitations in recipes.

but why? what's the problem with zeroing its energy?
in terms of your code, you can always check for "is drainable state at zero"
Nono it's a java thing
I have a "hasBattery" check atm to determine if a flashlight has a battery or not
I'm wanting to convert that over to an empty/full item system for a number of reasons
right, but I'm asking why are you doing that, why not just consider no energy to be "doesn't have a battery"
Because "doesn't have a battery" also means "has a battery but it's dead"
I specifically want dead batteries to be removable so I can use them in a battery charger item
ah, true, but then you could just set a moddata value on the item to indicate whether it "has a battery" or not
which then saves you from having to create a new item for every flashlight
what do you mean that java prevents it functioning?
Drainables with 0 usedDelta aren't considered n recipes
So "Remove Battery" is no longer considered to be a valid recipe.
Trust me, I already tried the easy way LOL
function Recipe.OnTest.TorchBatteryRemoval(sourceItem, result)
local modData = sourceItem:getModData()
if modData.hasBattery == nil then BetterBatteries.applyBatteryFix(sourceItem) end
print("Item has battery: "..tostring(modData.hasBattery))
return modData.hasBattery
end
and have your own logic for determining whether the operation is legit
We determined it was a java problem a while ago because "Destroy" or "Use" in a recipe works, but "Keep" doesn't.
So you can remove a battery from a flashlight, but only if it destroys the flashlight in the process.
Yeah but that has it's own weirdness
bleh
I'd rather the Drainable bar also just not be there if the flashlight is dead / empty
Which is only possible with a Normal item type instead
then also alter the GUI to suppress it if the moddata indicates no battery
what you're griping about is a frontend problem ๐
So what you're saying is
- Change recipe to instead destroy the flashlight, bring the flashlight back after use.
- Suppress drainable UI if it's at 0
yes, instead of using keep, it's a destroy & give
the other benefit here is of course that you don't need to do anything special to handle new flashlights added to the game
How do I use tooltip in contextmenu?
actually, did TIS tag flashlights? that would be an even cleaner way of doing identification
anyone have a good mod collection they like running?
I just optimized it to use a dictionary for improved performance with larger item quantities
hm, there is DisplayCategory = LightSource
That might cause other problems, like being able to remove the batteries from Rubber Ducks
(Well, not being able to rather)
Yes rubber ducks can contain batteries
ah, but that includes candles
Better to just use types for now
so, what exactly do you mean with regard to this dictionary?
BetterBatteries.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;
}
Rather than tens of twenties of if checks with mods lol
Better than going if item:getType() == "Torch" over and over
Instead we can just do if BetterBatteries.batteryItemWhitelist[item:getType()]
but why do you need this?
Helps with mod support, can just add modded flashlights into the table.
the battery removal can just be a recipe that only allows one of any flashlight
ditto for insertion
This was for my old method before I figured out it no workie
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(BetterBatteries.batteryItemWhitelist[item:getType()]))
if BetterBatteries.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 BetterBatteries.applyBatteryFix(item); end -- Apply patch if it isn't present.
modData.hasBattery = false
print("No longer has battery.")
end
end
end
Looked like this
It replaced some vanilla flashlight code
huh? presumably your recipe for battery removal only has one input item (the flashlight)
which means items will only ever have a size of 1
It has three
what are the input items?
Oh wait
nvm, this was just how it was set up originally
I just re-used and modified some of the code
This was the original method
function Recipe.OnCreate.TorchBatteryRemoval(items, result, player)
for i=0, items:size()-1 do
local item = items:get(i)
-- we found the battery, we change his used delta according to the battery
if item:getType() == "Torch" or item:getType() == "HandTorch" or item:getType() == "Rubberducky2" then
result:setUsedDelta(item:getUsedDelta());
-- then we empty the torch used delta (his energy)
item:setUsedDelta(0);
end
end
end
Not entirely sure why it uses items plural either but whatever
because when you define a recipe, it could have multiple inputs
if it doesn't, you just end up with an array of one
in any case, you are guaranteed that your function will ONLY be called with whatever your recipe allows
My brain hurtss
so, since you have defined what is allowed, you don't need to check what the input is
because it's impossible for your recipe to execute with anything other than what you have put in the script
Apologies, I'm lost
This is old stuff that's being superseded
Since we're going more a recipe route
Well, proper recipe route anyways.
If i add a car mod to my multiplayer save would i need to soft or hard restart the server
hard. and use #mod_support please
Hope I'm not being too bothersome, I'm still new to all this.
it's fine
I am worried about overriding the GUI libs because of how those are generally more likely to be modified by anyone interested in that stuff
I'd like to keep the number of overrides to a minimum to get maximum compatibility in there
well, it's basically just a cosmetic thing anyway, but as long as you're doing a clean job on the interception, I don't consider it that big of a deal
This is intended to work alongside two other mods so I'm unsure what I need to do
One has a "Replace Battery" method that I'd like to replicate, with that same mod also having the "empty" approach hence why I thought it'd be better compatbility-wise to do it that way
get it working on its own, git commit it and then investigate any integration issues
The other is more similar, just using near-default methods with just custom :getTypes() for their items.
I need to set up git-
Pleh, I'm really newbie to git
I do have github desktop so there's that at least
I have it from ages ago, haven't used it much but it's there.
for your purposes you can just use it locally as a Git GUI
there is no requirement to ever upload it to GitHub
So create a new repository on my hard drive?
git existed long before github did
git is just content versioning with a built-in upload/download system. services like GitHub were built around it later
Am I still clear to use github-
what do you mean?
aaA
Im all jumbled up
Like am I able to just store a local copy of everything in a harddrive github repo and use that?
Use GitHub plug in on VS Code
oh ok
if you're using VSCode, you can just use the Git plugin
You don't need to learn git of you use that plug in
the GitHub plugin is only needed if you want to upload/download with GitHub's service
actually, these days, doesn't VSCode have Git support by default?

Does anyone happen to know the WetCooldown value interval? Does 800 mean 800 in-game minutes?
So what am I supposed to do- use GitHub desktop or use the low rated Github extension on VSCode
I just wanna make my funny battery mod
whatever floats your boat, I'd suggest GitHub desktop will be perfectly fine
Guys, how do I put color in a subcontextmenu? can someone give me an example?
Hi, i'm trying to change some UI elements from the UI.pack. I have exported the images I want to edit from the game files to a folder and edited them. Then I used TileZed to pack the edited images back together. These are the settings I used, but I get the following error when using the file. Can someone help me?
@calm depot is it unreasonable to go the "EmptyFlashlight" route?
I have the github repo set up btw
I would consider it sub-par - there's plenty of mods that let you do things with flashlights (such as makeshift silencers) and creating a new item is going to break them
Oh crap, you're right-
Then again, couldn't I also just dynamically edit those to accept empties?
unless you go the route of what you were originally thinking by trying to patch their recipes, but that's the greater evil
handling the case in the vanilla game where the drainable is empty is much less hacky than attempting an intrusive patch on everyone else's mod that happens to use flashlights
I see
Is it bad to add dynamic recipes to some of the mods to accept the new "Insert Battery" logic tho?
Actually thats a stupid question-

yeah, why would you need to do that?
It's the remove battery that's the part I need to worry about
hm?
right, so make it destroy, and in your OnCreate, give them back the item
I assume your OnTest currently just checks that its drainable value is > 0
ah right, an "empty battery" is of course valid
Would it be ok to dynamically change the other remove battery methods since other mods have their own?
I don't see why it would cause incompatibilities there.
why would you need to?
Otherwise BetterFlashlight Remove Battery behaviour will use the old method.
It'll be keeping the flashlight, which prevents my fix.
Same goes for the Military Flashlight in the Backpacks and Attachments mod
you mean another mod is removing the battery, but simply sets the drainable state of the flashlight to 0 without any additional data?
gets not sets but yes
It won't check if it has the "hasBattery" mod Data, nor will it follow the new destroy + add back behaviour
if other mods have their own unique items with their own accompanying recipes for dealing with battery removal - what's there to do?
Just change the keep to destroy and change the method they use to mine.
sounds to me like it would be a better situation for those mods to consider using your mod if it's active
They both just use forks of the original method to account for their own item's types, which mine can already do with a dictionary-
does anyone know when you use IconsForTexture, is there a way when crafting an item for the actual image of the texture to appear, ex: i have two skins for my fanny pack but when i try to craft the pictured one, it creates the other texture ex:
I don't like coercing other peoples' mods to play ball with mine unless they went AWOL or something and everyone's crying for it
I figured, but I also wanna make compatibility easy for them
otherwise, you'll probably end up breaking shit when they change things, and then you've pissed them off because they get complaints from users that are your fault ๐
What I was thinking was like
They can have their default behaviour, but all they have to do to add compatibility with my mod is add their flashlight / battery storage to BetterBatteries.batteryItemWhitelist
Then the system just loops through the recipes, checks to see if the recipe's sourceitem is their whitelist item, and do some snazzy stuff
They wouldnt have to flip to use my method on their end, and it wouldn't be compatible unless they chose to opt into it
actually, I have a better suggestion
So it's an "optional compatibility" type thing
none, but that's not the point
just because the vanilla game doesn't have any tags doesn't mean you can't define one for modders to use
ooo
So then they can just apply the tag to their item if my mod is active and done?
precisely
And I just apply the tag to the vanilla items?
Smart.
Just gotta figure out how tags work lol
no, don't tag the vanilla items
process them as you do now. if TIS ever tag them in future, which they may well do, update your mod
have a look at pens, they're a decent example
So.. keep the whitelist dictionary..?
you still don't need the whitelist because your recipe only calls OnCreate if the input item matches one of the destroy elements
as in, the game has already taken care of filtering out non-matching shit
ah, you do have a slight caveat in that since that recipe matches on the items you listed, you can't generically permit based on tag.
Solution: define a second recipe with an OnTest that only checks for the tag and calls the same OnCreate
and of course, that recipe doesn't have any input filters at all
you create two separate remove battery recipes: the first one is what you already have, which has the destroy defining the various vanilla flashlights
the second one does not have any destroy, basically just the OnTest and OnCreate
the OnTest for the second recipe checks if the input item is tagged as FlashLight, or whatever you choose to be the tag string
actually, rather than tags, it would appear Recipe.GetItemTypes is the way to go
so modders define an item type, not a tag
actually this is even easier
your destroy can just be destroy FlashLight/OtherThing/[Recipe.GetItemTypes.FlashLight]
Oo, that'll register in the recipe?
yeah, the game does this too
and, now that I think about it, you can probably just define the vanilla items as item types
yeah
Lovely! That works out nicely.
Thank you for sticking with me by the way, I know it can get irritating sometimes hehe
I appreciate it.
Only thing I'm even partially worried about is what order it'll load in, but I have a feeling that'll be a non-issue.
yeah, btw, from looking, I think GetItemType might be synonymous with Tags
as in, you define it using Tags = on the item, and it'll show up for GetItemType
Oo
I base this on the fact that the game does Recipes.GetItemTypes.Milk but I note that Milk/CannedMilk share their commonality through Tags
(for making the pesticide)
So to assign a tag, I assume it's a table I insert into that I access via item.GetItemTypes..?
no no
it goes in your item script
look at the vanilla game scripts that define say, the blue pen, or milk
Oh I think I understand
Okay
Everything else should be a piece of cake from there.
Then I can start working on my hand crank thingy
hand-powered torch?
Nono, hand-powered battery charger
More compatible and useful with other battery items
Plus a mechanical flashlight is already on the workshop
you'd have to do a lot of winding to charge up an AA battery ๐
That's the idea!
Would prob charge faster with higher strength
Or would it be fitness..?
Maybe both.
then again, given the amount of IRL time it takes for an in-game hour to pass... not that unrealistic
I would suggest strength for determining the charge per second, and just use fatigue level as a penalty
and of course, the action causes fatigue
Yeye
I forget if it's called fatigue, that might be sleepiness, but you get what I mean
the game will already account for how worn out the player gets when you define the exertion amount; the fitter they are, the less of a penalty it will incur, so that's already handled for you in the vanilla game
Exertion and Fatigue should both be accounted for
Would encourage people to sleep more lol
I think fitness would be a better fit since this is a repetitive, fast action rather than a strength-intensive one.
I think if you're sleepy, you already lose stamina faster, no?
what I'm saying is, you don't need to care about their fitness level; your code just tells the game that it costs X amount of exertion per second and you check what their current stamina value is
No I know that, I mean Fitness should be used instead of Strength for the charge per second
if you want to be consistent with the game, rather than using the exact ratio, which goes from 0 to 1, just use the "tiers" like the game does for your running speed
Wait nvm I see what you're saying
Since fitness already dictates how much fatigue is gained-
yes
Mfw I'm an idiot LOL
so all you care about is if they're at stamina level "full/mild/moderate/severe"
Then if it's severe, it's either stupid slow or just not usable.
Probably just not usable at that point.
Gamingg
Alright, this seems like it'll work nicely. Thank you!
I'll get it into code n stuff when I get home
see, the code is just a detail, coding it properly with the right approach is the real challenge ๐
Yeye
I was trying to get a good approach from the start, but I'm unfamiliar with Zomboid's options and general mod setup.
Didn't even know half of this was possible

there's a junior vs senior developer meme in here somewhere
but, memes aside, investing the time to poke through what can be done can save you so much more time in the long run than trying to hack something into existence with what you already know
Valid
have grep, can research ๐
it's a command-line tool
Ohh I see
you can get by just fine on GUI tools of course, but personally, I wouldn't be nearly as productive without a shell
search function in vscode goes hard though
Does anyone know where being able to open a right-click context menu is being checked - specifically within safehouses? Its at least checking admin, or if you are the safe house owner/on the safe house perm list. If you fit either of these then you can open a right-click context as usual. If not, it will not open at all.
Wherever this check is, my guess is that it may rely on some of the server options variables as well.
Does anyone know of a mod that allows difficulty zoning? So different parts of the map have different difficulties
anyone know? or should i make different bags with the same name and different recipes to make each of them?
Where can I see which error is occuring when that red box pops up on the bottom right?
console.txt
Is it possible to express multiple 'any of' ingredients when working with drainable items on recipes, i tried the below and got an error this was just me guessing based on the types in list viewer, PetrolCan=1 on its own is fine, trying to expand the ligher refils mod to allow use more than one type of gas container
PetrolCan=1/PetrolPopBottle=1/WhiskeyPetrol=1/WinePetrol=1/WaterBottlePetrol=1
remove the =1 and have it at the end
only at the end
ex: WaterBottleFull/WhiskeyWaterFull/WaterPopBottle/RemouladeWaterFull/WineWaterFull/BeerWaterFull = 5,
think it might also pop up if you push f11 if you have debug open
Thanks ๐ ill try it out now
fsho
Worked like a charm once again thanks for the help, this is my first time getting into game modding xD
Oh, I'll try that next time
no prob, me too i spent hours trying to figure most things out lol.
Oh? You were the one that made the Refill Lighters mod?
No i didnt make the lighter refill mod, but ive made a new one where you can can craft an empty lighter and refil it with bottles and other types of containers, noticed that one only allows gas can
https://www.youtube.com/watch?v=wBm4C0c2pLk
Check out his mod when you have the time. It's really good and supports multiplayer for those more "MMO" type oriented servers.
Please download his fucking mod, he's worked really hard on it.
Check it out here: https://steamcommunity.com/sharedfiles/filedetails/?id=2793385743
Music used in the video is owned by Indie Stone.
Recipe is questionable as it needs a battery, was a suggestion from someone on the server
i know that u can get all recipes or one by name from ScriptManager and then manipulate the recipe objects - what i don't know is what the limitations are on what can be messed with. i have been trying to use Recipe.Load but i can't figure it out, which if you can do you could load an override recipe and change whatever you want.
Except, don't do this if you just want to use up some water. Simply Water=1 in your recipe is what you want
unless you have some particularly sensible reason for restricting it to only specific containers of water
In my case it worked, It uses 1 unit of gas to refil the lighter, and all the other bottles work too
Interesting ill try that out though, so essentially just Gas=1 ?
anyone know a way to use fractional units of liquids/etc.?
or is that not a thing we can do
i know to use units we use a semicolon
e.g., per the current convo, Water;1
no, unfortunately Gas=1 doesn't exist. BlowTorch=1 does, but unlikely to be what you want
That would be ideal if Gas worked the same
i thought it did
particularly after 41.73's updates to allow it in many containers
but i havent tried
if not there is FuelAPI
Thought of that as well. Seems like a lot of work and mod compatibility seems like a lot more work.
zombie heatmap is one way

but that's only one sort of difficulty
Drainables are still just drainables, but they added tagging
so bottles with petrol, whilst still their own item, are now identified via their tag
well if drainables are drainables then why can i do Salt;1 but not Gas;1 :p
because those are "special" drainables
๐คจ
as in, they have their own dedicated key within recipes
should look into how that works sometime.
hopefully they'll move everything over to the tagging mechanism and do away with the legacy mess
unfortunately, until that happens, working with Propane kinda sucks - though not that badly since unless someone installed additional mods, there's basically only the propane tank to care about
Not sure, I know how to program, but I don't know modding very much.
The way I think about it is just adjusting modifiers when the zombie wanders in a zone.
But then again, I don't know if all zombies are connected to 1 set of information, or if zombie stats are individual.
each zombie is an instance of IsoZombie
yep
For the vanilla items, I should modify their recipes through Lua, yea?
That way it ensures more compatibility with items that may adjust the flashlights one way or another.
huh? why would you need to modify their recipes?
Wait
I'm a dunce nvm

I'm half asleep I swear
Wait, I remember now.
You said I had to add the tags to the items.
And that's done via recipe, correct?
Well not recipe but
The item def
no, via item definition. You don't need to add any tags unless you intend to also introduce your own custom flashlight with this mod
otherwise, that's just a feature you're supporting for other modders to use
I don't plan on adding my own flashlight, I want that feature for- yeah
I'd have to modify the item def without overriding the other values to ensure max compatibility
That's possible right?
in your recipe, you're just going to include Recipes.GetItemTypes.BatteryLight or whatever the heck you wanna call it
if someone decides to then make a mod that uses it, they just have to put the BatteryLight tag on their item
Cuz if someone wanted to have a "reduced flashlight weight" mod or "brighter flashlights" or god knows what, I can't just override the entire item def or their mod won't work
Oh wait im
Still dumb
I just leave the vanilla recipes in there and just-
Add on the tags

you don't add the tags, someone who wants to benefit from your mod does
well, that will be in the destroy clause
destroy FlashLight/Rubberduck/Recipes.Blahblah
Yeye
But that's what I mean
Sorry I'm not very good at articulating things
I always have a really weird way of explaining things

In the vanilla recipes
recipe Make Molotov Cocktail
{
WineEmpty/WineEmpty2/WhiskeyEmpty,
RippedSheets/RippedSheetsDirty/DenimStrips/DenimStripsDirty,
[Recipe.GetItemTypes.Petrol]=1,
Result:Molotov,
Time:50.0,
}
yeah, Petrol is fine, it's Propane that doesn't have the tags system
yet, I'm sure ๐
I've been looking both lua & java source. It's either subliminal or right under my nose.
client/ISUI/ISWorldObjectContextMenu.lua
I'll hazard a guess that line 1438 answers your question
I've been messing with that for sometime. Hrrmmm, maybe I'm looking at it the wrong way.
what are you trying to achieve
I want player not on the safehouse perm list to be able to open the right-cick context menu within a safe house zone.
for what purpose?
So they can interact with items. For example, turn on TV, drink water from sink, flick light switch, etc.
I see
well, playerAllowed is implemented in java, you could wrap SafeHouse.getSafeHouse so that it returns a lua table with a metatable that wraps it in order to fake the permission
although I wasn't aware that you couldn't interact with movables if you're allowed into a safehouse
recipe Remove Battery
{
Torch/HandTorch/Rubberducky2/[Recipe.GetItemTypes.BatteryItem],
Result:Battery,
Time:30,
OnTest:Recipe.OnTest.TorchBatteryRemoval,
OnCreate:Recipe.OnCreate.TorchBatteryRemoval,
StopOnWalk:false,
}
Something like this for the funny?
The context menu won't even open. So an interact check doesnt even seem to be takign palce.
yep
Perfect.
Do I just plug this into a file of it's own to override or will it just "add onto" it?
Last time I did something like this, it just used both as seperate recipes instead of overriding-
stick in a txt file of your choice under media/scripts in your mod
I would suggest recipes.txt but the game doesn't care
Do I keep the module base and everything?
I assume dont extend to base
just add imports { Base } and you're good to go
Now I just edit the TorchBatteryRemoval OnCreate to give you back the used item and we're golden
--safehouse
if safehouse and safehouse:playerAllowed(playerObj) then
--if test == true then return true; end
context:addOption(getText("ContextMenu_ViewSafehouse"), worldobjects, ISWorldObjectContextMenu.onViewSafeHouse, safehouse, playerObj);
end```
This seems to only impact whether the "View Safehouse" option appears as a context menu option. Doesn't prevent the context menu from being opened at all?
hold on, you're saying that the right click menu totally doesn't appear at all?!?
there are more actions in that menu than just stuff related to the safehouse - like "walk here" for example
exactly, IF you are not on the permission list, owner or admin, it does not open at all.
I'll wait until yall finish your thing hehe
np
a
and what safehouse options are configured on the server?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
yes. you'll probably need to set its drainable state to 0, I believe it defaults to 1
jesus christ, use pastebin in future
or a snippet
muh bad
so uh, you have both trespassing and looting allowed, that definitely doesn't make sense. sounds more likely to me that you've got a mod installed that's breaking stuff
yeah, the item will get removed by the game
Ok, so better question
How do I get it to have it's module extention
Do I just do like, item:GetModule() or do I have to piece a string together
Because I gotta add the orig item back into the inv
I assume it require a string to be passed through, so I gotta get the original item's full name
It may not make sense at first, but if you want to use safe houses as a defense against players not on the safe house perm list using sledge hammers it works out. I tested without any mods.
Sweet
They have to axe their way into the base instead of single shotting walls with a sledge.
I don't follow. With the server options you sent, anyone can sledgehammer and steal from someone else's safehouse
The context menu will not come up when they click on the safe zone. The only thing they could do was select the 'destruction' option outside of the safehouse then walk back in with the red highlight cursor then start smashing. I put a check in to counter this though; they can no longer highlight thumpables in safehouses, only non player built objects.
Stealing is intended.
well, I'm not aware of any outstanding bug in the game where the right-click menu is broken if you're in someone else's safehouse
because what you're describing would be a bug
maybe the bug is real, but I personally haven't heard of it. if what you're claiming is true, go file a bug on the PZ forums
Hrmm, if i knew where that check actually took place, I'd be able to describe the bug better.
that is, if you can reproduce it with no mods enabled at all
there is no check in the code to disable the menu just because you're in a safehouse
I hope your right
Itll save a bit of my sanity
I swear there isnt either, i looked everywhere
have you checked your client's log to see if a lua error is being thrown
mmm, well nobody else has filed a bug report for this, and it's pretty broken
so I find it difficult to believe that you're the only person who has noticed this
I think something went wrong
lol
Infinite flashlight generator
time to P O S T D A T C O D E
Yeh, I would too, but then again, who the hell uses a combination of server options like this?
looks perfectly reasonable to me
function Recipe.OnCreate.TorchBatteryRemoval(items, result, player)
print("Firing.")
for i=0, items:size()-1 do
local item = items:get(i)
-- we found the battery, we change his used delta according to the battery
--print("Is valid item: "..tostring(BetterBatteries.batteryItemWhitelist[item:getType()]))
--if BetterBatteries.batteryItemWhitelist[item:getType()] then
local newItem = player:getInventory():AddItem(item:getFullType())
newItem:setUsedDelta(0)
result:setUsedDelta(item:getUsedDelta());
local modData = newItem:getModData()
modData.hasBattery = false -- Patch won't be present, so automatically apply it.
print("No longer has battery.. sad!")
--end
end
end
Lots of stuff commented out, dont mind that
I've been on servers where you're allowed to enter owned ones, haven't had issues
why do you iterate over every item in items
like, you don't even need that for loop at all
Not my choice, we've been over this
bleh
It was like this in the original code
I can just make it items[1] if that'd make you happy tho
I just commented it out cuz why not
print out the name of every item in the array

I'm curious to see what you get
And thaaaat's it
Actually, maybe it's making infinite torches since I didn't explicitly type "destroy"
might just destroy the old one via code
I prefer it say "use" in recipe over "destroy" anyways
well, if use is fine, that makes the code even simpler
just take the first element of items and set its drain to 0
oh, so I dont have to make a new torch?
That's nice.
Does use work similarly to keep or something?
I thought you'd said originally that use doesn't allow the recipe if it's empty
if that's not the case, then no, you can just drain it instead
I see, probably not, try it
I dont think they're treated the same
sounds like you have it even easier
I dont even have it set to use, well, "use", I think it just defaults to it
recipe Remove Battery
{
Torch/HandTorch/Rubberducky2/[Recipe.GetItemTypes.BatteryItem],
Result:Battery,
Time:30,
OnTest:Recipe.OnTest.TorchBatteryRemoval,
OnCreate:Recipe.OnCreate.TorchBatteryRemoval,
StopOnWalk:false,
}
Cuz here I never specified destroy
And it's not destroying the torch
But that may be a good thing
yeah, that won't do, perfect
Cleaned up some unnecessary function firing for the setters of the modData
Doesn't matter if the modData exists if I'm setting hasBattery to true/false anyways lol
Well yeah since that'd be either a nil or not value
if true, then someone must have removed the battery, otherwise, it can be nil
the only state your mod introduces is that the battery was removed
so there is no other state that needs to be noted
it also saves wasting a few bytes on items in the default state
setting a key to nil is the same as removing it
speaking of which, in your whitelist, I wanted to mention that the [""] syntax is unnecessary. if the keys are A-z and _, you don't need it
Torch battery insertion seems to have borked tho
res can be tossed in cleanup yes
and the reason im setting a value to itself is because local go brrr
lua moment
I think because of this, we may actually need to apply the tag (?)
change your logic, don't use hasBattery, use batteryRemoved
Because this is what diferrentiates between the battery and the item apparently
the state machine is thus:
- virgin item, has no mod data
- player removes battery, set mod data to indicate
batteryRemoved - when attempting to insert battery, return
batteryRemoved
I'm still worried about the "the battery" comment left behind the devs
if they did remove it, the mod data will be set, if they didn't it will be nil and it won't let them
what do you mean?
Up in that function up there
-- return true -- the battery
Before there were some type checks
Hence why I converted it over to a dictionary originally to optimize it a bit
oh, I see what you're doing
Might be better to just check if the item has the tag at that point
And apply the tags to the vanilla items
but idk
nah, just wrap their function


