#mod_development

1 messages ยท Page 16 of 1

thin hornet
#

yeah

weak sierra
#

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

quasi kernel
#

Im starting to wonder if

#

another part of lua or even java

#

is interfering

weak sierra
#

if ur still fighting this tomorrow hmu when im less burned out

quasi kernel
#

Oki

#

I just have a hunch that

#

hm..

#

lemme try something dumb

weak sierra
#

i find that works a lot of the time

#

:p

quasi kernel
#
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.

weak sierra
#

yup

#

good debugging technique that is

#

tbh

#

called uh.. what's the name

#

sanity check

#

yeah

quasi kernel
#

option didnt show up

#

This basically confirms it

plush wagon
#

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.

quasi kernel
#

oh trust me im not that smart

#

im basically banging my head against a brick wall

weak sierra
#

ive programmed since 1999 technically, but in seriousness since 2005

#

i still call myself stupid on a daily basis

#

for making dumb mistakes

quasi kernel
#

I only started tampering with any sort of scripting / programming in like 2015

weak sierra
#

lol

#

but yes i have a lot of experience

plush wagon
#

I don't know anything about code.

#

But I can make noodles

weak sierra
#

it's like if u had to explain everything to a 5 year old very clearly and bluntly

plush wagon
#

That's pretty impressive right?

weak sierra
#

making noodles is good

#

noodles are good.

#

๐Ÿœ

plush wagon
#

Sometimes I cook them for too long....

#

But noodles are noodles

#

๐Ÿœ

weak sierra
#

oh i thought u meant u literally make them

#

like from scratch

quasi kernel
#

RecipeManager in the java scripts is what manages recipes I'd assume

#

Would hope to god it does anyways

weak sierra
#

u assume wrong

#

:)

plush wagon
#

I once spelt my name wrong on an Exam. I'm not that smart

weak sierra
#

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

plush wagon
#

Im in bed right now. All cozy...

So ima just eevesdrop on you guys

#

So talk about code stuff as I observe...and stuff

steady herald
#

@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?

thin hornet
quasi kernel
#

@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

steady herald
#

ah yes it is

#

its just the english is saved as xml

plush wagon
#

Interesting

steady herald
#

oh god

#

im gonna have to seperate all the television scripts from the radio

bold oriole
steady herald
bold oriole
#

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

worldly olive
#

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

steady herald
#

i

#

i just wanna make funny meme mod

thin hornet
#

look at mods that add tv channels

steady herald
#

you genius

steady herald
#

@thin hornet does it matter whats typed up for the id?

#

cause it just looks like random strings

weak sierra
quasi kernel
#

GAMING

weak sierra
#

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..

quasi kernel
#

It worked..?

weak sierra
#

i tabbed out and

#

back in

#

and now it works

#

yes

#

:|

quasi kernel
#

Amazing

weak sierra
#

i changed a file maybe.. maybe some things do update live?

#

idk thoroughly confused

quasi kernel
#

I feel like this is a lead but idk

weak sierra
#

sounds like that'd only affect things in the radial menu

quasi kernel
#

Yeaaa

weak sierra
#

i think ur barking up the wrong tree there

thin hornet
steady herald
#

oh ok

#

what is advert cat and is segment false

quasi kernel
#

@weak sierra thoughts?

#

This feels closer

weak sierra
#

that's the same.. thing

quasi kernel
#

wait is it

weak sierra
#

i mean i can see hardcoding to Base.Battery there

quasi kernel
#

oh im

#

insane

weak sierra
#

but again this is just the radial

quasi kernel
#

im so sorry LOL

weak sierra
#

lol

quasi kernel
#

Im literally going in circles

#

Maybe I can find it by looking into UI

#

Dunno which UI, but a UI

plush wagon
#

The colors look cool

quasi kernel
#

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

weak sierra
#

can you do fractional units of something in a recipe

#

e.g.

#

GunPowder;.25,

#

gonna find out :p

gray glen
#

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.

weak sierra
gray glen
#

my bad

quasi kernel
#

im still so lost

weak sierra
#

the answer is no

#

cannot use fractional units

quasi kernel
#

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.

thin hornet
quasi kernel
#

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

thin hornet
#

i do not find anything in code that could prevent it

quasi kernel
#

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.

glad ridge
#

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,
    }```
thin hornet
quasi kernel
#

Alright, I'll leave ya be for now. Thank you for your help!

alpine scroll
#

Can I make a /server/ file to trigger a player to say something?

#

Or do I need to pass it to the client?

jagged ingot
quasi kernel
#

I am running off of only adrenaline and rage right now

pine gulch
#

After updating some translation files of my mod, suddenly things that get cooked disappear. Is this a known issue?

quasi kernel
#

Hehe, Evelyn was having some problems with that type of stuff earlier.

#

@weak sierra share your knowledge!!

pine gulch
#

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.

quasi kernel
#

Best of luck my friend!

pine gulch
#

Time to take a break!

quasi kernel
#

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)

quasi kernel
#

Nnnope

#

Im dead tired and have 0 clue

jagged ingot
#

Sleep on it. Might come to you then.

quasi kernel
#

I guess it might, worth a shot.

jagged ingot
#

If you try anything crazy, make sure to git or archive your stable code.

#

Will save you from grief.

quasi kernel
#

I'm not gonna be touching the java end of things since I know we're not really supposed to so

jagged ingot
#

Oh no no I mean't your Lua.

#

Also you're fine to mod the Java side. The problem is distribution.

quasi kernel
#

Distribution as in like, giving it to other people?

jagged ingot
#

Yeah. You can't upload this sort of thing to the Workshop.

quasi kernel
#

Fun

jagged ingot
#

It's both against the devs and Steam's ToS for Workshop.

quasi kernel
#

Very much noted

jagged ingot
#

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.

quasi kernel
#

Ehh, safer to just go lua

#

Though more limiting

jagged ingot
#

All good.

quasi kernel
#

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

jagged ingot
#

I core mod for private clients and commissioners.

#

๐Ÿ™‚

#

I agree, basically.

quasi kernel
#

Sounds lovely

jagged ingot
#

There's a market for it. xD

quasi kernel
#

I wouldnt doubt it hehe

#

Welp, suppose all I can do is sleep.

#

See ya in the morning I supposeeee

jagged ingot
#

Heh. Have a good night. Hope you find your fix.

weak sierra
#

u have to be more specific about what "not working" means tho

warped night
#

Is there a way in WorldEd to make a 3 cell lay out in an L shape

glad ridge
shadow geyser
pine gulch
shadow geyser
# quasi kernel I set it to always return true, and I was able to remove batteries from flashlig...

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

alpine rune
#

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?

little vessel
#

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

outer wolf
#

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?

undone elbow
#

How often does action :update() happen?
The same as OnTick?

worldly olive
alpine scroll
#

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

shadow geyser
# worldly olive It fails on every line (based on the conditions given by the if's) like this: p...

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

shadow geyser
# alpine scroll Anyone got a dumbed down how to use OnClientCommand and OnServerCommand?

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)
alpine scroll
shadow geyser
#

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

worldly olive
shadow geyser
alpine scroll
#

Hmm

#

I'll try to make it work then

#

Thank you

#

Brb

exotic ember
#

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

shadow geyser
#

what kind of mod is this?

exotic ember
#

Its TrueMusic one

#

Its one little edit ive made

#

Pretty sure it works but this would be the final test to see if so

shadow geyser
#

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"

exotic ember
#

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

shadow geyser
#

oh i see. You won't be able to modify the exe in another mod, but you can just provide your own.

exotic ember
#

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

shadow geyser
#

hmm, oh are you just doing this for personal use?

exotic ember
#

Yea yea

#

Ive got the code

#

ive got the edit ive made

#

Im just trying to compile it now into an exe

shadow geyser
#

ah, ok then I suggest you go to their mod page to ask for help

exotic ember
shadow geyser
#

or maybe mod_support channel, maybe someone there knows

exotic ember
#

Just want to know how to build cs on a txt doc

exotic ember
shadow geyser
#

not really, this channel is about making mods for zomboid. Your issue isn't about creating a mod, its about using an existing mod

exotic ember
#

compiling isnt the average thing you do when you need support for a mod

shadow geyser
#

it isn't really something you need to do for modding in zomboid

exotic ember
#

exactly

#

but in this specific scenario it is

shadow geyser
#

look we can argue semantics for however you want, Im just trying to tell you where you have a better chance getting help

exotic ember
#

I doubt I can in that channel but thanks if you cant help

quasi kernel
#

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.

shadow geyser
#

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

quasi kernel
#

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.

drifting ore
#
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,
    }```
quasi kernel
#

Back into the madness of checking these functions I go

drifting ore
#

ok nvm its not my mod

#

not sure whats causing it

#

derperino

shadow geyser
quasi kernel
#
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

drifting ore
#

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

shadow geyser
drifting ore
#

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

quasi kernel
#

Clearly the library of stds

drifting ore
#
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```
drifting ore
#

lol

#

@shadow geyser

quasi kernel
#

Oh I have no idea, I was just making a stupid joke

drifting ore
#

goddamn

#

i think ill have to isolate mods one at a time

quasi kernel
#

this still remains my main lead, and it's horrifying

drifting ore
#

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

shadow geyser
quasi kernel
#

(with charge)

shadow geyser
#

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

quasi kernel
#

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.

shadow geyser
#

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

quasi kernel
#

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

drifting ore
#

ok i found the weird issue

#

if you have more than 400 matches

#

for whatever reason

#

the game derps out

quasi kernel
#

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

quaint mirage
#

Hey i don't suppose anyone has an example of creating a recipe with a unit of gas or liquid as apart of it?

gilded hawk
#

What is the simplest way to add a new keybind in the game?

quaint mirage
shadow geyser
quaint mirage
#

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,
    }
}
alpine rune
#

Anyone know why I get an error when I try to add a recipe to a custom trait?

#

works completely fine without the recipe

quaint mirage
alpine rune
quasi kernel
#

@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

gloomy geyser
#

Can someone give me an example of how to get the ID of an object you are clicking on?

shadow geyser
#

because its usually better just for the code to be added to the mod, rather than overwriting

gloomy geyser
quasi kernel
#

I assume the sq stands for square or something

calm depot
#

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

gloomy geyser
calm depot
#

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

gloomy geyser
#

yes, but I wanted to create a context menu for a specific object

#

only I don't know information about this object

calm depot
#

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

willow estuary
#

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.

calm depot
#

"temporary global" - I'm so triggered right now

willow estuary
#

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.

calm depot
#

no no, a github is an English slang word for a pub in an old peoples' community

willow estuary
#

Hold on, isn't that one of those new fancy technical keyboard switches?

calm depot
#

ah yes, I've been meaning to upgrade my mechanical keyboard to a technical one ๐Ÿ˜

willow estuary
#

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?

shadow geyser
calm depot
#

bluemouth? you should ask Tobias Funke about that

willow estuary
#

It's very naughty of me to practice my comedy routines with this channel and I apologize ๐Ÿคช

little vessel
exotic ember
#

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?

random finch
#

Where is the code preventing players not part of a safe zone to not be able to right-click context in a safe zone?

exotic ember
#

otherwise I wouldnt know it was broken

cosmic condor
#

then resub to your mod to see if the online contents match your expectation

exotic ember
#

They dont

#

Thats the point im at

#

Im just gonna delete it and reupload from fresh

quasi kernel
#

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

cosmic condor
#

I don't mind, but I have no capability to help

quasi kernel
#

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.
#

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

exotic ember
#

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?

quasi kernel
#

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

calm depot
#

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)

quasi kernel
#

So you mean OnGameStart?

calm depot
#

for example, yes

quasi kernel
#

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?

calm depot
#

before I answer, what's your goal exactly?

quasi kernel
#

Effectively trying to dynamically create improved flashlight recipes

#

Since by default, I can't remove an empty battery from a flashlight.

calm depot
#

that's your proposed logic, I mean, in plain english, what do you want to change

quasi kernel
#

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.

calm depot
#

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

quasi kernel
#

Flashlight has to be a seperate, empty equivalent.

#

If it's the base flashlight, it wont work because of Drainable limitations in recipes.

calm depot
#

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"

quasi kernel
#

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

calm depot
#

right, but I'm asking why are you doing that, why not just consider no energy to be "doesn't have a battery"

quasi kernel
#

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

calm depot
#

ah, true, but then you could just set a moddata value on the item to indicate whether it "has a battery" or not

quasi kernel
#

Already did that

#

Java side prevents it from functioning

calm depot
#

which then saves you from having to create a new item for every flashlight

#

what do you mean that java prevents it functioning?

quasi kernel
#

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

calm depot
#

hmm, that doesn't sound right

#

you can define a custom isvalid function for a recipe

quasi kernel
#
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
calm depot
#

and have your own logic for determining whether the operation is legit

quasi kernel
#

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.

calm depot
#

so destroy it and then create it

#

and alter its energy after the fact

quasi kernel
#

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

calm depot
#

then also alter the GUI to suppress it if the moddata indicates no battery

#

what you're griping about is a frontend problem ๐Ÿ˜‰

quasi kernel
#

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
calm depot
#

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

gloomy geyser
#

How do I use tooltip in contextmenu?

calm depot
#

actually, did TIS tag flashlights? that would be an even cleaner way of doing identification

quasi kernel
#

Don't believe they have

#

Default flashlight code is using type checking

sly obsidian
#

anyone have a good mod collection they like running?

quasi kernel
#

I just optimized it to use a dictionary for improved performance with larger item quantities

calm depot
#

hm, there is DisplayCategory = LightSource

quasi kernel
#

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

calm depot
#

ah, but that includes candles

quasi kernel
#

Better to just use types for now

calm depot
#

so, what exactly do you mean with regard to this dictionary?

quasi kernel
#
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()]

calm depot
#

but why do you need this?

quasi kernel
#

Helps with mod support, can just add modded flashlights into the table.

calm depot
#

the battery removal can just be a recipe that only allows one of any flashlight

#

ditto for insertion

quasi kernel
#

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

calm depot
#

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

quasi kernel
#

It has three

calm depot
#

what are the input items?

quasi kernel
#

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

calm depot
#

because when you define a recipe, it could have multiple inputs

#

if it doesn't, you just end up with an array of one

quasi kernel
#

Oh I see

#

Must've been a safeguard

calm depot
#

in any case, you are guaranteed that your function will ONLY be called with whatever your recipe allows

quasi kernel
#

My brain hurtss

calm depot
#

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

quasi kernel
#

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.

eternal skiff
#

If i add a car mod to my multiplayer save would i need to soft or hard restart the server

calm depot
quasi kernel
#

Hope I'm not being too bothersome, I'm still new to all this.

calm depot
#

it's fine

quasi kernel
#

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

calm depot
#

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

quasi kernel
#

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

calm depot
#

get it working on its own, git commit it and then investigate any integration issues

quasi kernel
#

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

calm depot
#

well, if you don't like the CLI, GitHub desktop might be OK for you

#

oh snap

quasi kernel
#

I have it from ages ago, haven't used it much but it's there.

calm depot
#

for your purposes you can just use it locally as a Git GUI

#

there is no requirement to ever upload it to GitHub

quasi kernel
#

So create a new repository on my hard drive?

calm depot
#

git existed long before github did

quasi kernel
#

o

#

Man I wish I was smarter with some of this stuff

calm depot
#

git is just content versioning with a built-in upload/download system. services like GitHub were built around it later

quasi kernel
#

Am I still clear to use github-

calm depot
#

what do you mean?

quasi kernel
#

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?

cosmic condor
#

Use GitHub plug in on VS Code

quasi kernel
#

oh ok

calm depot
#

if you're using VSCode, you can just use the Git plugin

cosmic condor
#

You don't need to learn git of you use that plug in

calm depot
#

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?

quasi kernel
pine gulch
#

Does anyone happen to know the WetCooldown value interval? Does 800 mean 800 in-game minutes?

quasi kernel
#

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

calm depot
#

whatever floats your boat, I'd suggest GitHub desktop will be perfectly fine

quasi kernel
#

Oki

#

Took me a bit to figure it out but I have it set up.

gloomy geyser
#

Guys, how do I put color in a subcontextmenu? can someone give me an example?

stiff brook
#

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?

quasi kernel
#

@calm depot is it unreasonable to go the "EmptyFlashlight" route?

#

I have the github repo set up btw

calm depot
#

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

quasi kernel
#

Oh crap, you're right-

#

Then again, couldn't I also just dynamically edit those to accept empties?

calm depot
#

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

quasi kernel
#

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-

calm depot
#

yeah, why would you need to do that?

quasi kernel
#

It's the remove battery that's the part I need to worry about

calm depot
#

hm?

quasi kernel
#

Because rn

#

This needs to change to either use or destroy

calm depot
#

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

quasi kernel
#

The OnTest checks if it has a battery or not

#

Via moddata

calm depot
#

ah right, an "empty battery" is of course valid

quasi kernel
#

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.

calm depot
#

why would you need to?

quasi kernel
#

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

calm depot
#

you mean another mod is removing the battery, but simply sets the drainable state of the flashlight to 0 without any additional data?

quasi kernel
#

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

calm depot
#

if other mods have their own unique items with their own accompanying recipes for dealing with battery removal - what's there to do?

quasi kernel
#

Just change the keep to destroy and change the method they use to mine.

calm depot
#

sounds to me like it would be a better situation for those mods to consider using your mod if it's active

quasi kernel
#

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-

glad ridge
#

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:

calm depot
#

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

quasi kernel
#

I figured, but I also wanna make compatibility easy for them

calm depot
#

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 ๐Ÿ˜‰

quasi kernel
#

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

calm depot
#

actually, I have a better suggestion

quasi kernel
#

So it's an "optional compatibility" type thing

calm depot
#

don't use this whitelist thing

#

check items for a tag

quasi kernel
#

What tag thoguh

#

What items that have batteries use the same tag

calm depot
#

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

quasi kernel
#

ooo

#

So then they can just apply the tag to their item if my mod is active and done?

calm depot
#

precisely

quasi kernel
#

And I just apply the tag to the vanilla items?

#

Smart.

#

Just gotta figure out how tags work lol

calm depot
#

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

quasi kernel
#

So.. keep the whitelist dictionary..?

calm depot
#

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

quasi kernel
#

hm

#

Oh I see now

#

Yeah I wouldnt need the check.

calm depot
#

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

quasi kernel
#

You lost me a bit there

#

Probably cuz im tired and about to go to therapy

calm depot
#

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]

quasi kernel
#

Oo, that'll register in the recipe?

calm depot
#

yeah, the game does this too

quasi kernel
#

Amazing

#

So Id be defining an item type, not a tag, correct?

calm depot
#

and, now that I think about it, you can probably just define the vanilla items as item types

#

yeah

quasi kernel
#

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.

calm depot
#

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

quasi kernel
#

Oo

calm depot
#

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)

quasi kernel
#

So to assign a tag, I assume it's a table I insert into that I access via item.GetItemTypes..?

calm depot
#

no no

#

it goes in your item script

#

look at the vanilla game scripts that define say, the blue pen, or milk

quasi kernel
#

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

calm depot
#

hand-powered torch?

quasi kernel
#

Nono, hand-powered battery charger

#

More compatible and useful with other battery items

#

Plus a mechanical flashlight is already on the workshop

calm depot
#

you'd have to do a lot of winding to charge up an AA battery ๐Ÿ˜›

quasi kernel
#

That's the idea!

#

Would prob charge faster with higher strength

#

Or would it be fitness..?

#

Maybe both.

calm depot
#

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

quasi kernel
#

Yeye

calm depot
#

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

quasi kernel
#

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.

calm depot
#

I think if you're sleepy, you already lose stamina faster, no?

quasi kernel
#

Do you?

#

If so, then nevermind me lol

calm depot
#

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

quasi kernel
#

No I know that, I mean Fitness should be used instead of Strength for the charge per second

calm depot
#

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

quasi kernel
#

Wait nvm I see what you're saying

#

Since fitness already dictates how much fatigue is gained-

calm depot
#

yes

quasi kernel
#

Mfw I'm an idiot LOL

calm depot
#

so all you care about is if they're at stamina level "full/mild/moderate/severe"

quasi kernel
#

Then if it's severe, it's either stupid slow or just not usable.

#

Probably just not usable at that point.

calm depot
#

or just go the sledgehammer route and refuse

#

osnap

quasi kernel
#

Gamingg

#

Alright, this seems like it'll work nicely. Thank you!

#

I'll get it into code n stuff when I get home

calm depot
#

see, the code is just a detail, coding it properly with the right approach is the real challenge ๐Ÿ˜‰

quasi kernel
#

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

calm depot
#

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

quasi kernel
#

Valid

calm depot
#

have grep, can research ๐Ÿ˜‰

quasi kernel
#

grep?

#

I feel like a caveman learning to use a computer again

calm depot
#

it's a command-line tool

quasi kernel
#

Ohh I see

calm depot
#

you can get by just fine on GUI tools of course, but personally, I wouldn't be nearly as productive without a shell

cyan basalt
#

search function in vscode goes hard though

random finch
#

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.

frail dagger
#

Does anyone know of a mod that allows difficulty zoning? So different parts of the map have different difficulties

glad ridge
alpine scroll
#

Where can I see which error is occuring when that red box pops up on the bottom right?

alpine scroll
quaint mirage
#

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

glad ridge
#

only at the end

#

ex: WaterBottleFull/WhiskeyWaterFull/WaterPopBottle/RemouladeWaterFull/WineWaterFull/BeerWaterFull = 5,

glad ridge
quaint mirage
#

Thanks ๐Ÿ˜„ ill try it out now

glad ridge
#

fsho

quaint mirage
#

Worked like a charm once again thanks for the help, this is my first time getting into game modding xD

alpine scroll
glad ridge
quasi kernel
quaint mirage
#

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

spare kiln
quaint mirage
#

Recipe is questionable as it needs a battery, was a suggestion from someone on the server

weak sierra
# quasi kernel <@370376376269930497> What is your wisdom in dynamic recipes

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.

calm depot
#

unless you have some particularly sensible reason for restricting it to only specific containers of water

quaint mirage
#

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 ?

weak sierra
#

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

calm depot
#

no, unfortunately Gas=1 doesn't exist. BlowTorch=1 does, but unlikely to be what you want

quaint mirage
#

That would be ideal if Gas worked the same

weak sierra
#

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

random finch
weak sierra
#

but that's only one sort of difficulty

calm depot
#

Drainables are still just drainables, but they added tagging

#

so bottles with petrol, whilst still their own item, are now identified via their tag

weak sierra
#

well if drainables are drainables then why can i do Salt;1 but not Gas;1 :p

calm depot
#

because those are "special" drainables

weak sierra
#

๐Ÿคจ

calm depot
#

as in, they have their own dedicated key within recipes

weak sierra
#

should look into how that works sometime.

calm depot
#

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

frail dagger
calm depot
#

each zombie is an instance of IsoZombie

quasi kernel
#

Oli you still there?

#

If so, I have a question.

calm depot
#

yep

quasi kernel
#

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.

calm depot
#

huh? why would you need to modify their recipes?

quasi kernel
#

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

calm depot
#

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

quasi kernel
#

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?

calm depot
#

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

quasi kernel
#

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

calm depot
#

you don't add the tags, someone who wants to benefit from your mod does

quasi kernel
#

Nono I mean the

#

Recipes.GetItemTypes.BatteryItem

#

At the end of the recipe

calm depot
#

well, that will be in the destroy clause

#

destroy FlashLight/Rubberduck/Recipes.Blahblah

quasi kernel
#

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

willow estuary
calm depot
#

yeah, Petrol is fine, it's Propane that doesn't have the tags system

#

yet, I'm sure ๐Ÿ˜‰

random finch
calm depot
#

client/ISUI/ISWorldObjectContextMenu.lua

#

I'll hazard a guess that line 1438 answers your question

random finch
#

I've been messing with that for sometime. Hrrmmm, maybe I'm looking at it the wrong way.

calm depot
#

what are you trying to achieve

random finch
#

I want player not on the safehouse perm list to be able to open the right-cick context menu within a safe house zone.

calm depot
#

for what purpose?

random finch
#

So they can interact with items. For example, turn on TV, drink water from sink, flick light switch, etc.

calm depot
#

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

quasi kernel
#
  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?

random finch
#

The context menu won't even open. So an interact check doesnt even seem to be takign palce.

calm depot
#

yep

quasi kernel
#

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-

calm depot
#

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

quasi kernel
#

Do I keep the module base and everything?

calm depot
#

no, pick your own name

#

whatever you want

quasi kernel
#

I assume dont extend to base

calm depot
#

just add imports { Base } and you're good to go

quasi kernel
#

Now I just edit the TorchBatteryRemoval OnCreate to give you back the used item and we're golden

random finch
#
--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?
calm depot
#

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

random finch
quasi kernel
#

I'll wait until yall finish your thing hehe

random finch
#

np

quasi kernel
#

a

calm depot
#

and what safehouse options are configured on the server?

random finch
calm depot
#

jesus christ, use pastebin in future

#

or a snippet

random finch
#

muh bad

quasi kernel
#

Destroying an item is just item:Destroy() right?

#

I'd hope it's that easy-

calm depot
#

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

quasi kernel
#

wait

#

nvm im dumb again

calm depot
#

yeah, the item will get removed by the game

quasi kernel
#

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

calm depot
#

oh, you want its fully qualified name?

#

one sec

quasi kernel
#

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

calm depot
#

yes, I get you

#

I believe getFullType() will do the job

random finch
quasi kernel
#

Sweet

random finch
#

They have to axe their way into the base instead of single shotting walls with a sledge.

calm depot
#

I don't follow. With the server options you sent, anyone can sledgehammer and steal from someone else's safehouse

random finch
#

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.

calm depot
#

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

random finch
#

if you arent on the perm list, admin or owner

#

just to clarify

calm depot
#

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

random finch
#

Hrmm, if i knew where that check actually took place, I'd be able to describe the bug better.

calm depot
#

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

random finch
#

I hope your right

#

Itll save a bit of my sanity

#

I swear there isnt either, i looked everywhere

calm depot
#

have you checked your client's log to see if a lua error is being thrown

random finch
#

no errors

#

I checked for sure

calm depot
#

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

quasi kernel
#

I think something went wrong

calm depot
#

lol

quasi kernel
#

Infinite flashlight generator

calm depot
#

time to P O S T D A T C O D E

random finch
calm depot
#

looks perfectly reasonable to me

quasi kernel
#
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

calm depot
#

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

quasi kernel
#

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

calm depot
#

I'm sure it was, but now it's dead code, delete it

#

actually, before you do

quasi kernel
#

I just commented it out cuz why not

calm depot
#

print out the name of every item in the array

quasi kernel
calm depot
#

I'm curious to see what you get

quasi kernel
#

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

calm depot
#

well, if use is fine, that makes the code even simpler

#

just take the first element of items and set its drain to 0

quasi kernel
#

oh, so I dont have to make a new torch?

#

That's nice.

#

Does use work similarly to keep or something?

calm depot
#

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

quasi kernel
#

The orig recipe was using keep

#

I dunno if keep == use tho

calm depot
#

I see, probably not, try it

quasi kernel
#

I dont think they're treated the same

calm depot
#

sounds like you have it even easier

quasi kernel
#

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

calm depot
#

yeah, that won't do, perfect

quasi kernel
#

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

calm depot
#

technically you don't need false

#

just batteryRemoved

quasi kernel
#

Well yeah since that'd be either a nil or not value

calm depot
#

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

quasi kernel
#

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 (?)

calm depot
#

change your logic, don't use hasBattery, use batteryRemoved

quasi kernel
#

Because this is what diferrentiates between the battery and the item apparently

calm depot
#

i.e. invert the condition

#

we only care if it's in batteryRemoved state

quasi kernel
#

Wouldnt batteryRemoved just imply nil

#

Wait I see what you mean

calm depot
#

the state machine is thus:

  1. virgin item, has no mod data
  2. player removes battery, set mod data to indicate batteryRemoved
  3. when attempting to insert battery, return batteryRemoved
quasi kernel
#

I'm still worried about the "the battery" comment left behind the devs

calm depot
#

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?

quasi kernel
#

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

calm depot
#

oh, I see what you're doing

quasi kernel
#

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

calm depot
#

nah, just wrap their function

quasi kernel
#

wrap their function?

#

Like just keep the old one and re-use it?