#mod_development

1 messages ยท Page 15 of 1

quasi kernel
#

All of this in recipecode.lua

#

It works the way I expected, it just sets the item's useDelta and adjusts the battery that way

jagged ingot
#

Probably for lighting-engine purposes.

#

Technically the more draw calls you have the less performant the render tick is.

#

The game uses a kind of macroed GL command API for both sprites and UI elements.

#

Not sure if these splits adds multiple calls to the frame.

#

Oh, and I'm not sure if file-size is a factor when slicing sprites.

steady herald
#

well crap

#

the code worked

#

(also works on radios but semantics)

#

but the texture pack doesnt overwrite

heady crystal
#

Anybody know how to remove a vehicle in MP? I am doing vehicle:permanentlyRemove() server-side, but the vehicle disappears then reappears a few seconds later

steady herald
#

i was going off a premade tv mod tho so i definetly could have gone wrong somewhere

weak sierra
#

how do you add a recipe via lua

cyan basalt
#

do you need to add a brand new recipe?

#

or edit one

weak sierra
#

new one

#

though i wouldn't mind knowing how to do the latter as well

#

that'll come up soon enough

#

im assuming editing one is something like editing an item script

#

at runtime

cyan basalt
#

you don't use lua you write a new recipe definition

quasi kernel
#

I believe new recipes are done via scripts, not lua, but I could be mistaken.

cyan basalt
#

just like making a new item

weak sierra
#

yeah but no

#

i need to do it in lua

#

dynamically adding them depending on if diff mods are present

cyan basalt
#

ohhh i see

quasi kernel
#

oh

#

hm

weak sierra
#

i dont wanna have a crapton of submods

cyan basalt
#

do you have the java decompiled? check out Recipe.java for how it all works

weak sierra
#

i dont, usually the javadocs has enough info

#

but yeah i prob shud

cyan basalt
weak sierra
#

ive done it with rider before

#

my trial is prob over but i have another decompiler around

quasi kernel
#

rider my beloved

cyan basalt
#

whatever works best for you

weak sierra
#

anyway im not sure i need to decompile for this, i just was poking around looking for "recipe" and it's i guess in scriptmanager

quasi kernel
#

I should prob decompile zomboid soon

cyan basalt
#

yeah it is

weak sierra
#

kept finding recipemanager

#

and thinking "surely this is it"

#

but no

#

lol

cyan basalt
#

best of luck

shadow geyser
#

javadoc says that the Recipe() contructor is public, so maybe just try calling that?

weak sierra
#

there's a ParseScript method

#

that looks interesting

quasi kernel
#

hec

#

probably shouldve figured sourceItem would be a userdata val

cyan basalt
#

public class Recipe extends BaseScriptObject yep

weak sierra
#

what is userdata anyway

shadow geyser
#

userdata is just what kahlua calls the java objects

cyan basalt
#

ohhhh that makes sense and it explains why my instanceof hasn't worked b4 lol

quasi kernel
#

trying to print it to get its data but bleh

weak sierra
#

ah.

quasi kernel
#

not gonna happen from what it looksl ike

weak sierra
#

y'all sound like u might be knowledgeable enough to help with another thing i was working on

shadow geyser
#

its alot more complicated than that but thats practically what it always is with regards to PZ kahlua

cyan basalt
#

do tostring(data) it generally works for me if it has a tostring

weak sierra
#

i want to store the builder of a tile in moddata for it

#

i hooked into ISBuildAction

#

but it seems to not have anything to put the data onto

quasi kernel
weak sierra
#

because it's not an IsoObject

quasi kernel
#

I tried :ToString()

#

forgot lua funnies

#

I have a feeling it might still just

#

print the data location

weak sierra
#
performBuildAction_original = ISBuildAction.perform

function ISBuildAction:perform()
    print("UDDTST: Perform firing..")
    if self then
        if (performBuildAction_original ~= nil) then
            performBuildAction_original(self)
        else
            print("UDDTST: Original function backup is nil.")
        end
        if self.item then
            self.item:getModData()['udderly:builder'] = getPlayer():getUsername()
            self.item:transmitModData()
            print("UDDTST: Reading back mod data.. builder: "..tostring(self.item:getModData()['udderly:builder']))
        else
            print("UDDTST: self.item is nil")
        end
    else
        print("UDDTST: self is nil")
    end
end```
#

this is what i was doing

#

but item isn't something that can store moddata

#

it's a table or smth

#

which confused me

shadow geyser
weak sierra
#

i just did lol

#

oh

#

thru a build menu

#

any random construction

#

like stairs for instance

shadow geyser
#

oh not like a specific tile, you want all tiles to store that stuff?

weak sierra
#

yes

#

anything built

cyan basalt
#

ahhh that's kinda cool

#

logging the builder of each tile

weak sierra
#

mhm

#

for use with a sledgehammering whitelist

quasi kernel
weak sierra
#

so that ppl can destroy their own shit but not anythign else

#

and admins can see who did what

#

but it doesn't work

cyan basalt
quasi kernel
#

Is this something I consult the java docs for

steady herald
#

ok i found a pretty decent tutorial

#

fingers crossed it works

cyan basalt
steady herald
#

YES

#

YES

#

YES

#

YESSSSSS

cyan basalt
#

NICE

#

better call saul

steady herald
#

am i allowed to post the mod link?

shadow geyser
# weak sierra ```lua performBuildAction_original = ISBuildAction.perform function ISBuildActi...

if I had to guess, I don't think self.item is the what ends up on the ground. you can see in the perform() at line 159, some constructor function is called on the self.item. so self.item already exists before it has been created and placed. and if it exists before it was even placed, it definitely isn't an isoobject and won't have a modData field. Im not exactly sure what type of object it is, probably some kind of reference object for creating the tile but it won't end up being the actual object there. you might need add checks at the very beginning of the perform call, a loop to gather all the objects on the tile using getObjects(), then do it again after the constructor. Then you can compare both lists and see which item on the world is the one that was newly placed. or maybe you can just do some comparisons with self.item and the isoobject after the constructor. not sure which would be easier.

cyan basalt
steady herald
#

hell ye

#

i

#

have noticed

#

a bug

#

comes through ze radio

quasi kernel
#

Is there a way to associate a boolean with a specified instance?

#

I need to add a "hasBattery" bool to flashlights and the like somehow.

#

Because of how it's programmed, flashlights treat having no batteries and an empty battery as the same thing.

halcyon dagger
#

hey! anyone an idea why player:getLastPos() is not defined even tho player is? Is that related to kahlua?

local spawnHordeForEachPlayer = function()
    local players = getOnlinePlayers()
    if players then
        for index = 0, players:size() -1 do
            local player = players:get(index)
            if player then
                local playerPos = player:getLastPos()
                createHordeInAreaTo(playerPos.x, playerPos.y, 100, 100, playerPos.x, playerPos.y, 100)
            end
        end
    end
end
cyan basalt
#

how can you set the modData for something? and how does modData work? I know it's just a KahluaTable but what's it for

shadow geyser
shadow geyser
quasi kernel
#

Does that mean I can just do like

cyan basalt
#

Rad

#

Thanks!

quasi kernel
#
local modData = torch:getModData()
modData.HasBattery = torch:getUsedDelta() > 0
#

Kinda sorta?

shadow geyser
#

yeah

quasi kernel
halcyon dagger
shadow geyser
#

you probably read it from some other code. I can't remember where, but I do remember lastpos being used as a variable name

weak sierra
#

anyone ever spend like two hours editing the copy of a file in the workshop directory that's being superceded by an uploaded version, testing over and over, only to realize what you've done?

#

kinda weird that the local version doesn't take precedence

quasi kernel
#

Is there a method for detecting when an item spawns?

weak sierra
#

LuaManager doesn't seem to be accessible from Lua

#

am i missing something :P

quasi kernel
#

Okay nevermind, I've figured out how to check containers with OnFillContainer and OnRefreshInventory (thank you creator that made Time Decreases Loot), but now I need to figure out how to identify what's a flashlight or not with mod support.

random finch
#

Doors placed in safehouses where there wasnt doors before produce no KeyID?

cyan basalt
#

do you guys know if there's any way to draw a vector in PZ's engine? I wanna see a debug line so I can actually see them like in other game engines. im guessing not but it would be nice

sly orchid
#

Why does this c/c++ compiler keep saying that the stdio header file cant be found

#

Somethin brokey

jagged ingot
#

Think there should be line drawing in there.

#

Not 100% sure.

#

If not, check for public methods in zombie.ui.UIElement.

#

That's the self.javaObject referenced for all UI.

cyan basalt
#

I'll take a look!

#

import zombie.debug.LineDrawer; ๐Ÿค”

cyan basalt
#

I'm seeing stuff about drawing lines in LineDrawer.java as well but I don't know if that's debug or actually raycasting lol

jagged ingot
#

I don't know about diagonal lines but I know about straight lines.

#

I recall seeing some line drawing stuff somewhere but too long ago to remember exactly.

#

Might've also been internal Java stuff.

cyan basalt
jagged ingot
#

@cyan basalt ๐Ÿ™‚ I think that the ISUIElement.lua file shows that.

#

It expands on what you can feed into the Java methods.

#

Where it says tex or texture as a param, try passing nil.

cyan basalt
#

Hmmm ok Iโ€™ll see thanks!

pine gulch
#

Is it possible to make modded "buff drinks"? For example, adding stress reduction to a hot drink via an ingredient? I know some vanilla items do it with 41.73

opal yew
#

Not sure if I go here for help so I'm trying to run a modded MP server, but this one mod called "Mod Options" keeps crashing it. I tried looking for ways to fix it and some say I need to disable anti-cheat12 or something, but idk how to do that.. Any advice?

glad ridge
#

via the internet

quasi kernel
#

Would it be smart to seperate my mod into two?

#

I was originally wanting to make a "Hand Crank" mod for battery regeneration, but now I'm thinking I'll have to get an "API" (dunno if thats the right term) uploaded first for fixing the batteries.

#

The DeadBatteryAPI would just make it so Dead Batteries are properly added to the game and items have designated checks for whether or not they actually contain a battery, along with a provided table of what items are permitted in the TorchInsert / TorchRemove methods.

opal yew
quasi kernel
#

Or, alternatively, you can do it the copy-paste way which is a little faster.

quasi kernel
#

I've become genuinely concerned about credit. How should I do it?

#

I'm using "Time Decreases Loot" for a code reference of what I want to do, but I'm also editing a lot of the code for my own purposes.

#

Should I contact the original uplaoder for permission to upload, link his mod, what's the best plan of action?

#

All else fails I guess I could trial and error myself.

opal yew
#

So I still have the issue for "mod options" when I try to load into the map, I always get this message

#

but the weird thing is, if I do solo with these mods enabled, it works just fine

#

it's just MP thats all funky

quasi kernel
#

Some mods can get wonky in Multiplayer, but personally I've had minimal issues with Mod Options.

shadow geyser
alpine rune
#

quick question how hard would it be to make a mod where if you press a keybind while holding a weapon a soundbyte plays?

quasi kernel
#

I wouldn't imagine too difficult, there's an entire lua event for key presses iirc

alpine rune
#

good good, would there be any info or tutorial on how to make it

quasi kernel
#

That much I dunno

alpine rune
#

hmm

#

I'll look around, thank you

cyan basalt
#

should be as simple as adding a function to OnKeyPressed

alpine rune
#

Thank you!

dusky remnant
#

i need help

#

bad

pine gulch
dusky remnant
#

can someone help me please

#

my game wont load because of certain mods i dont know what one making that happened

mellow oyster
#

How does item distributions tables work? im trying to figure out why i cant find my items

undone elbow
#

How to start coop in debug mode with client and server consoles?

steady herald
gloomy geyser
#

guys, can someone explain to me how I get exactly what I'm clicking with the right button with this function?
OnFillWorldObjectContextMenu

cosmic condor
steady herald
#

hoping i can make some more complex mods in the future

#

hoping with the help of my teachers at uni. i can find a way to add sound to the shout when q is pressed

#

that opens the door to a lot of memes

cosmic condor
#

but it has to work on MP

#

I have no idea how to fix tv sounds on mp lol

steady herald
#

crap i never thought of testing my mods in mp

cosmic condor
#

the sound on tv/radio will shuffle at random and will not play full lengths of sound clips

#

no idea if we can do anything with FMOD

shadow geyser
quasi kernel
#

What would be the most effective way to detect flashlights in containers?

#

I'm wanting to make it so I can apply modData when they're added, but I'm unsure how possible that is.

#

I'm testing OnFillContainer atm but I don't know if that applies to inventory or not.

#

Okay so it does not, it's only for the initial loading from the looks of it.

gloomy geyser
#

I wanted it to work for a specific object

shadow geyser
#

you loop through the items and check them. names aren't always that easy, because some items don't have a nice name that easily identifies them. alot of the time you have to just settle with the tile name or sprite id.

#

for some simple stuff, ive just manually checked what the ID of a tile is, then you can do something like the following

alpine rune
#

does anyone know why an offset script would prevent the game from loading?

shadow geyser
# gloomy geyser I wanted it to work for a specific object
local objs = sq:getObjects()
if objs:size() > 0 then
    if objs:get(0):getSprite() then
        local id = objs:get(0):getSprite():getID()
        if id >= 220032 and id <= 220079 then --220055 is the HC glass roof
            if id >= 220032 and id <= 220047 then return 2 --slopes probably exist twice, but the 2nd one is hidden because of iso perspective
            elseif id >= 220050 and id <= 220061 then return 1
            elseif id == 220078 or id == 220079 then return 1
            end
        end
    end
end
quasi kernel
#

Does this mean it'd be better to try and use IDs for items rather than names for checking if an item is compatible with batteries or not?

shadow geyser
#

so in the places im checking for the id, ive identifies that the id is associated for the tile im looking for. not very readible I understand, but can't be bothered to figure out a better way because it just works and cba

shadow geyser
quasi kernel
#

Oooh oki

gloomy geyser
#

hmmmmm

shadow geyser
#

like one type of wooden floor doesn't have a super readable name that says it is a wooden floor. but I found the ID with some testing, and then just continued to use that ID. maybe there is a better way to do it though

gloomy geyser
#

ok, i will try that. Thanks!

alpine rune
radiant venture
#

can someone help me fix my evolved recipe? i have a problem so specific that i can't find anything on it

drifting ore
#

I want to code something, anyone need an UI for his mod ?

steady herald
drifting ore
#

Any idea of mod otherwise anyone ?

steady herald
drifting ore
steady herald
jagged ingot
drifting ore
steady herald
#

ooof

#

ill annoy my teachers with it next month then lol

drifting ore
jagged ingot
#

@thin hornet has an environment that automagically sets things up otherwise. ๐Ÿ™‚

thin hornet
#

well yeah pzpw is not only restricted to typescript, it can also just contains lua

#

it will compile and do the work

#

2.0 should be released today

cyan basalt
#

im hyped for that ^

fleet thunder
#

CalcLightInfo() is it broken?

thin hornet
#

CalcLightInfo doesnt seem to even exist

fleet thunder
#

Really?

jagged ingot
#

I really wish that they'd either take it down or make a notice about it being that old. =/ You're not the first one to be confused.

jagged ingot
#

It's not official however it's all but up-to-date.

fleet thunder
#

Yeah i found new one thank u, but why they are not updating docs, even if it will not be updated it is not replaced by this?

jagged ingot
#

I'm part of a project that is documenting as a third-party with other modders that involves stuff that I mentioned above.

fleet thunder
jagged ingot
#

pzpw will be very useful for paid / commissioned mod work. ๐Ÿ˜„

fleet thunder
#

PZPW?

jagged ingot
#

@thin hornet 's environment for Typescript modding for PZ.

fleet thunder
#

Ah i dont like Typescript modding i preffer lua

#

But idunno why but Lua not work fine for me

jagged ingot
#

Options are good. ๐Ÿ™‚

#

Sometimes I just Lua too.

quasi kernel
#

tbh I wouldnt mind using TypeScript, just another learning opportunity.

#

I've made a fair amount of progress on my battery upgrade mod, so that's always welcome.

#

Only thing is that one of my checks seems to be bugging out so I get to fix it (yay!)

fleet thunder
#

Color of getting light source so hard why :(

quasi kernel
#

Are walkies even considered drainable..?

fleet thunder
#

(I dont know how can i explain sorry) How can i get variables like, getCurrentSquare() have .lighting gives a something but when i try with print always nil what i'm doing wrong?

quasi kernel
#

I'm personally unsure, but I believe there's def a way

#

There's a mod that adds a fear of the dark trait so I know there's gotta be a way to detect light.

fleet thunder
#

I need get color of light not darkness, darkness thing already done

#

Always getting nil

robust arch
#

is there anything to make the minimap bigger?

weak sierra
#

what's up with recipes with a period in them not loading properly?

#

can i get away with it if i use a backslash as escape char or anything?

#

ex:

#
LOG  : General     , 1661366074869> [KitsuneMagazineCraftingVFE] Assigning Recipes To Magazine..
LOG  : General     , 1661366074869> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge .22 10-rd Magazine", skipping.
LOG  : General     , 1661366074869> [KitsuneMagazineCraftingVFE] Adding "Forge 9mm 15-rd Magazine" to magazine..
LOG  : General     , 1661366074869> [KitsuneMagazineCraftingVFE] Adding "Forge 9mm 17-rd Magazine" to magazine..
LOG  : General     , 1661366074869> [KitsuneMagazineCraftingVFE] Adding "Forge 9mm 20-rd Magazine" to magazine..
LOG  : General     , 1661366074869> [KitsuneMagazineCraftingVFE] Adding "Forge 9mm 30-rd Magazine" to magazine..
LOG  : General     , 1661366074869> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge .45 7-rd Magazine", skipping.
LOG  : General     , 1661366074870> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge .44 8-rd Magazine", skipping.
LOG  : General     , 1661366074870> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge .223 3-rd Magazine", skipping.
LOG  : General     , 1661366074870> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge .223 20-rd Magazine", skipping.
LOG  : General     , 1661366074870> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge .308 20-rd Magazine", skipping.
LOG  : General     , 1661366074870> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge .308 3-rd Magazine", skipping.
LOG  : General     , 1661366074870> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge 5.56mm 30-rd Magazine", skipping.
LOG  : General     , 1661366074870> [KitsuneMagazineCraftingVFE] Could not find recipe "Forge 7.62mm 30-rd Magazine", skipping.```
#

all happy until it contains a period lol

quasi kernel
#
local old_torchInsert = Recipe.OnCreate.TorchBatteryInsert
function Recipe.OnCreate.TorchBatteryInsert(items, result, player)
    local modData = result:getModData()
    for i=0, items:size()-1 do
          -- we found the battery, we change his used delta according to the battery
        if items:get(i):getType() == "Battery" then
            result:setUsedDelta(items:get(i):getUsedDelta());
            if modData.hasBattery == nil then BatteryFixes.applyBatteryFix(result) end
            modData.hasBattery = true
        end
    end
end
#

Is there something wrong here?

weak sierra
#

a friend reminded me i could be using translation strings

#

and i will

#

that'll be a lot of work to redo

#

derp

quasi kernel
#

Like, can you not overwrite vanilla methods or something? It's returning the correct data, it's just not.. using that data.

weak sierra
#

i can't tell u how many times ive run into that shit

#

lol

#

u definitely can overwrite vanilla methods

#

they have to be on the same folder path as the original script

#

hopefully that's all that it is, if not there might be other stuff to worry about

quasi kernel
#

Same.. folder path..?

#

But how is that even possible with a mod

#

Am I just gonna have to overwrite the torches and stuff that use the method and make it into a new method or somethin?

calm shale
#

who would be down to make a mod for me?

cosmic condor
#

why someone would do that?

calm shale
cosmic condor
#

pitch your idea first

#

if someone can, they will offer to help

calm shale
#

I was thinking the HEV suit from half life would be an interesting addition ahaha

quasi kernel
#

id be so down to make it if I was better at modding

#

Would be neat if it had the HEV UI and everything

#

And used batteries to increase protection

jagged ingot
winter bolt
#

i would want to make that but i've burnt myself out on clothing modding really badly lmao

zenith agate
#

Dont know if this belongs in mapping or here; But how would I go about replacing the default game world textures? (More specifically the grass texture / color)
Is there a way, perhaps overwriting the used tilesheet by the world somehow?

cosmic condor
zenith agate
#

-- It might not be possible at all

cosmic condor
zenith agate
#

Thanks for the tip

cosmic condor
zenith agate
weak sierra
#

since items (at least books? which is what im doing) have DisplayName

#

how do i set up translation there

#

do i put the translatable string thing in DisplayName?

#

do i omit DisplayName? is it outdated?

sage bluff
#

hi, i have a question, i was looking for project zomboid folders to find how i can change the carpentry recipies, i then came across this. Was this npc folder always in the game?

#

and if so, what was it used for, cause npcs arent here yet

cosmic condor
weak sierra
#

yeah and how does it work on the other end

cosmic condor
# weak sierra do i omit DisplayName? is it outdated?
module Base
{
    item Your_Item
    {
        DisplayCategory = Container,
        WeightReduction    =    85,
        Weight    =    1.0,
        Type    =    Container,
        Capacity    =    50,
        DisplayName    =    Item Bag,
        Icon    =    Bag_Item,
        OpenSound   =   Bag_Item,
        CloseSound   =   Bag_Item,
        PutInSound   =   Bag_Item,
        MetalValue = 15,
        RunSpeedModifier = 0.95,
        ReplaceInSecondHand = Bag_Item_LHand holdingbagleft,
        ReplaceInPrimaryHand = Bag_Item_RHand holdingbagright,
        WorldStaticModel = Bag_Item,
    }
}
weak sierra
#

so is DisplayName just ignored?

#

what's the point of including it

cosmic condor
#

DisplayName = Item Bag, will be translated

weak sierra
#

wouldn't it only be seen if a translation file doesn't exist for a given language?

cosmic condor
#

pardon?

weak sierra
#

well ur defining the name relative to the name of the item itself

#

Your_Item = "Whatever You Want"

#

if you then make it have

#

DisplayName = "Potato"

cosmic condor
#

yes

weak sierra
#

it'll show up "Whatever You Want" in game

#

not "Potato"

#

unless there's no translation

#

yes?

#

k

cosmic condor
#

not sure if I understand lol

#

DisplayName is what it will show in the game

#

while item Your_Item is item ID

quasi kernel
#

@weak sierra I think it's overriding the functions correctly, I think there's something somewhere else just.. ignoring my changes..?

cosmic condor
#

Are you trying to replace vanilla items?

quasi kernel
#

No

#

I'm trying to rework how flashlights work

#

So instead of it just purely using :UsedDelta(), it uses a new modData boolean called "hasBattery"

#

So you can take out dead batteries instead of it just treating it like a flashlight with no battery.

cosmic condor
#

What does it have to do with translation?

quasi kernel
#

Nono they talked to me earlier about other things

#

Am just pinging them about that

#

Not the translations

cosmic condor
#

ah okay ๐Ÿ˜…

#

I'm sleepy

quasi kernel
#

I still need help though, I dunno why it's just ignoring my function returns.

#

Does zomboid just not use those lines or something?

#

It's running and everything so I don't understand why it's not..?

weak sierra
# cosmic condor not sure if I understand lol

if you assign it by the item ID, and what you assign in the translation is in the translation file rather than DisplayName, it would seem that DisplayName only matters when there's no translation for the current language

#

im 99% sure im correct

#

and i dont know why u don't understand what im saying xD

weak sierra
#

be sure that u wanna do that cuz if anyone else has to add code to that it'll ignore it

quasi kernel
#

hmm

#

I was storing it just in case as a fallback, but now I don't really need it anymore.

weak sierra
#

runs a search for the function

#

it's def used

#

your code should be under the server folder

#

is it?

quasi kernel
#

Lemme double check

#

Im p sure it is but ill check

#

oh my god

#

i may be an idiot

#

I left an old duplicate file in there without

#

ever

#

changing

#

it

#
require "recipeCode"

local old_veryTorchRemoval = Recipe.OnTest.TorchBatteryRemoval
function Recipe.OnTest:TorchBatteryRemoval(sourceItem, result)
    local torches = getSpecificPlayer(0):getInventory():FindAll("Torch")
    if torches:size() > 0 then
        print(tostring(torches:get(0)))
    end
    return old_veryTorchRemoval(self, sourceItem, result)
end
#

this explains a lot

cosmic condor
quasi kernel
#

Wait it still doesnt work

#

mfw

quasi kernel
#

I have like half of the logic working

#

It's the battery removal that's not working at this point

#

Insertion works, it won't let you insert a battery if one is already in its place.

#

But you can't remove the battery if it's empty, so the flashlight is just dead forever..?

#
function Recipe.OnCreate.TorchBatteryRemoval(items, result, player)
    for i=0, items:size()-1 do
        local item = items:get(i)
        local modData = item:getModData()
        -- we found the battery, we change his used delta according to the battery
        if BatteryFixes.batteryItemWhitelist[item:getType()] then
            result:setUsedDelta(item:getUsedDelta());
            -- then we empty the torch used delta (his energy)
            item:setUsedDelta(0);

            if modData.hasBattery == nil then BatteryFixes.applyBatteryFix(item); end -- Apply patch if it isn't present.
            modData.hasBattery = false

            print("No longer has battery.")
        end
    end
end
#

Any idea why this may not work..?

#
function Recipe.OnTest.TorchBatteryRemoval(sourceItem, result) -- Patch of OnTest.Recipe.TorchBatteryRemoval to detect if a battery is present.
    local sItem = sourceItem
    local res = result
    local modData = sourceItem:getModData()

    if modData.hasBattery == nil then BatteryFixes.applyBatteryFix(sItem); end
    return modData.hasBattery;
end
#

This code is functioning because it returns if it has a battery or not properly.

#

Dismantling works just fine which is the strangest thing.

#

I'm going insane because I don't know why this couldnt be working.

#

All this is doing is replacing some code in recipecode.lua

#

Is this just an engine limitation? Is something in java preventing this from working?

weak sierra
#

is it supposed to do this crusty shit when you use translatable recipe strings

#

reads book to find out

#

and the recipes aren't available

#

ugh

#

oh how fun it is to add translation strings to a previously working mod

quasi kernel
#

is zomboid this consistently painful

weak sierra
#

yes

#

it is

quasi kernel
#

agony

weak sierra
#

yes

#

every mod takes me about 36-50 hours of work

#

the actual work is more like 4-6 hours

#

the rest is bullshit

quasi kernel
#

I've been working for the past 2 hours trying to figure out why it could possibly be that batteries simply can't be taken out specifically when their condition is 0

#

I've literally reprogrammed the functions to NOT DO THAT

#

AND THEY'RE STILL DOING THAT

weak sierra
#

make sure ur function is running

quasi kernel
#

IM DYING

weak sierra
#

add print statements

quasi kernel
#

I HAVE

#

IT'S PRINTING

weak sierra
#

mm

quasi kernel
#

IT'S RETURNING THE RIGHT DATA TOO

weak sierra
#

madness

#

so what's the symptomatic problem

quasi kernel
weak sierra
#

no battery come out?

#

maybe batteries delete themselves at 0 somehow?

quasi kernel
#

No, I just can't take out the battery.

weak sierra
#

oh

#

ok so

quasi kernel
#

It's just perpetually stuck in there since the option to take it out ceases to be

weak sierra
#

did u override the OnTest method

#

for the removal recipe

#

it might check for a battery with >0

quasi kernel
#
function Recipe.OnTest.TorchBatteryRemoval(sourceItem, result) -- Patch of OnTest.Recipe.TorchBatteryRemoval to detect if a battery is present.
    local sItem = sourceItem
    local res = result
    local modData = sourceItem:getModData()

    if modData.hasBattery == nil then BatteryFixes.applyBatteryFix(sItem); end
    print("Has battery: "..tostring(modData.hasBattery))
    return modData.hasBattery;
end
weak sierra
#

fuck if i know

#

:|

#

i've learned a lot but i only started a few weeks ago

quasi kernel
#

I started like 2 days ago

#

And I'm in agony

weak sierra
#

i started in late july

#

and yeah

#

so am i

#

i very understand your pain

#

im sorry

quasi kernel
#

Man I just wanted to make it so batteries recharge

#

Literally EVERY FUNCTION WORKS but the ONTEST ONE!!

weak sierra
#

u know what pisses me off more than literally anything else?

quasi kernel
#

watch it be a mistype

#

?

weak sierra
#

if you have a mod on the workshop

#

the workshop version takes priority over the local one

#

so u see no changes unless u copy the code code to the workshop foldr

quasi kernel
#

omg

#

no

weak sierra
#

so i have constantly juggle files between two locations when working on existing mods

#

or unsub from my own shit

#

and delete it

quasi kernel
#

That's horrible

weak sierra
#

it makes me so damn mad

#

the first few dozen hours

#

i spent like 16 hours trying to mod without changes taking effect

#

because i assumed it was sensible when it is not

#

:|

#

always assume everything is there to piss u off and u'll do better

#

works for me anyway

#

eventually u start to figure out the madness

#

and things start to make sense

#

but

#

then there's more layers of nonsense

quasi kernel
#

MAn

weak sierra
#

i spent 2 hours adding translations and now the recipes dont exist ingame

quasi kernel
#

mfw

weak sierra
#

and the book doesnt give me them

#

@quasi kernel what'd u name ur script file

#

the one that overrides the thing that isnt workin

#

it's usually good to name it the same as the original with something added to the end to ensure it loads after

#

like ISWhatever_Patch

quasi kernel
#

"BatteryCheckUpdates"

weak sierra
#

if it loads before it'll get overridden

#

shit loads alphabetically

quasi kernel
#

I'm going to die

weak sierra
#

it loads on mod order

#

AND alphabetically

#

so prefix/postfix names to tweak when shit loads

quasi kernel
#

I thought vanilla lua loaded before mod order

weak sierra
#

i mean maybe? lemme look at a log

#

nah

#

its mixed in

quasi kernel
#

WHAT

#

WHY

#

WHO

weak sierra
quasi kernel
#

AAAAAAAAAGH

weak sierra
#

lol

#

ikr

quasi kernel
#

IM GOING TO CRY

weak sierra
#

hey at least i had a hint for u

#

imagine if i didnt

#

:|

quasi kernel
#

thank

#

you

#

so

#

much

#

Lets hope to god it works

weak sierra
#

the timeline of figuring that out by hand is pain

quasi kernel
#

it

#

still doesnt work

#

im in genuine pain

#

am I not overriding it correctly?

weak sierra
#

let me show u an override i did like

#

yesterday that owrks

#
local original = ISFixAction.perform

function ISFixAction:perform()
    original(self)
    --0-10% to not raise repair count based on maintenance level.
    if (1 + ZombRand(100)) <= self.character:getPerkLevel(Perks.Maintenance) then
        self.item:setHaveBeenRepaired(1)
    end
end```
#

lua is a really fucking stupid language

#

so

#

there's two ways to call methods

#

and declare them

#

and one implicitly passes "self"

quasi kernel
#

: and .

#

I know that much

weak sierra
#

im saving it with the dot, which doesnt

quasi kernel
#

: has self built-in

weak sierra
#

then since the original had the :

quasi kernel
#

. doesn't have self

weak sierra
#

im overriding with that

#

and since there's a contradiction

#

im expressly passing self into the original

#

the one ur overriding doesn't have : tho

quasi kernel
#

yeah so im

#

confused

weak sierra
#

i cant get any method that i write and put in a table to run

#

so

#

u and me both

#

i hate lua

#

i've programmed for like 17 years

#

lol

#

so all my methods are local or global with prefixes to their names..

#

ive seen shit other ppl do not work for me due to file paths and folder structures

#

which is a headache of an extra layer to have matter

#

i had to do prefixes with numbers/letters to manipulate script run order

#

all kinds of nonsense

#
Recipes_EN = {
    Recipe_ReconditionM9 = "Recondition M9",
    Recipe_ReconditionTEC9 = "Recondition TEC-9",
    Recipe_ReconditionM1911 = "Recondition M1911",
    Recipe_ReconditionG17 = "Recondition G17",
    Recipe_ReconditionDE = "Recondition D-E",
    Recipe_ReconditionM105 = "Recondition M10-5",
    Recipe_ReconditionMagnum = "Recondition Magnum",
    Recipe_ReconditionM625 = "Recondition M625",
    Recipe_ReconditionM500 = "Recondition M500",
    Recipe_ReconditionM500Sawnoff = "Recondition Sawed-off M500",
    Recipe_ReconditionM500SawnoffNoStock = "Recondition Sawed-off M500 (No Stock)",
    Recipe_ReconditionDoubleBarrelShotgun = "Recondition Double Barrel Shotgun",
    Recipe_ReconditionDoubleBarrelShotgunSawnoff = "Recondition Sawed-off Double Barrel Shotgun",
    Recipe_ReconditionSP12 = "Recondition SP-12",
    Recipe_ReconditionSP12F = "Recondition SP-12 (Folded)",
    Recipe_ReconditionR700 = "Recondition R700",
    Recipe_ReconditionW1866 = "Recondition W1866",
    Recipe_ReconditionMSR788 = "Recondition MSR788",
    Recipe_ReconditionR1022 = "Recondition R1022",
    Recipe_ReconditionMR223 = "Recondition MR223",
    Recipe_ReconditionMR223F = "Recondition MR223 (Folded)",
    Recipe_ReconditionM14 = "Recondition M14",
    Recipe_ReconditionSKS = "Recondition SKS",
    Recipe_ReconditionAK47= "Recondition AK-47",
    Recipe_ReconditionAK47F = "Recondition AK-47 (Folded)",
    Recipe_ReconditionCAR15 = "Recondition CAR-15",
    Recipe_ReconditionCAR15D = "Recondition CAR-15 Delta",
    Recipe_ReconditionM16 = "Recondition M16",
    Recipe_ReconditionMP5 = "Recondition MP5",
    Recipe_ReconditionMP5SD = "Recondition MP5SD",
}
#

some of these recipes are assigned to magazine #3

#

in the game when i mouse over said magazine

#

and then i read the book and they do not show up in crafting at all

#

prior to adding this translation string set

#

and renaming the items

#

it worked fine

#

(PPSh is added dynamically by another mod and that shit all works do not worry about that)

#

the other two are at the bottom

#

u can see they have names defined..

#
    Recipe_ReconditionMP5 = "Recondition MP5",
    Recipe_ReconditionMP5SD = "Recondition MP5SD",```
quasi kernel
#

..and it isn't using them.

#

mfw

weak sierra
#

this shit is in

#

UdderlyGunReconditioning/media/lua/shared/translate/EN/

#

and the file is named Recipes_EN.txt

#

which matches the zomboid translation crap i found here:

#

which is on TIS github

#

so it should be legit

#

(well not that file obviously, but that github)

#

e.g.

#
Recipes_EN = {
    Recipe_Add_Crafted_Trigger = "Add Crafted Trigger",
    Recipe_Add_Motion_Sensor_V1 = "Add Motion Sensor V1",```
#

and just to complete showing the info

#

here's one of the recipes

#
        recipe Recipe_ReconditionMP5
    {
        MP5=1,
        ScrapMetal=35,
        SheetMetal=1,
        Screws=10,
        BlowTorch=8,
        keep [Recipe.GetItemTypes.WeldingMask],
        keep [Recipe.GetItemTypes.Screwdriver],
        keep [Recipe.GetItemTypes.Hammer],

        SkillRequired:MetalWelding=10;Aiming=8;Maintenance=6,
        Sound:BlowTorch,
        NeedToBeLearn:true,
        Result:MP5,
        Time:350.0,
        Category:Firearm,
        OnGiveXP:MetalWeldingAndMaintenance10,
        OnCreate:ReconditionGun,
        RemoveResultItem:true,
    }```
#

they are in GunConditioningRecipes.txt

#

in

#

UdderlyGunReconditioning/media/scripts/

#

hm

#

now that i think of it i did move them out of a folder

#

and i did learn at some point that it seemed to use folders to determine category

#

regardless of it having "Category:Firearm"

#

so perhaps i need to shove it back in a Firearm folder.

quasi kernel
#

mayb

weak sierra
#

ive had it with copying my shit to the workshop versions, time to unsub from myself

#

lol

#

im working on 3 mods

#

one has three submods

#

it's a headache

quasi kernel
#

Im just trying to make a "BetterBatteries" mod

#

But apparently that was a mistake

weak sierra
#

been planning to try to make rechargeable batteries at some point

#

i sense that will suck

quasi kernel
#

Not possible btw

#

Already tried

weak sierra
#

eh?

quasi kernel
#

Radios are hardcoded on the java end to only accept Base.Battery

weak sierra
#

that's fuckin stupid

quasi kernel
#

Trust me, the entire point I started this mod was to add rechargables

#

So now I just have to make the regular ones rechargable

weak sierra
#

technically u can recharge alkaline batteries it's just dangerous and inconsistent

quasi kernel
#

yea

weak sierra
#

already went thru all this thought

#

in advance

#

lol

quasi kernel
#

thinking it might require an electrical skill or somethin

weak sierra
#

cuz i knew it might be hardcoded..

#

it's really no wonder so many modders are pissy and quit doing it

#

heh

quasi kernel
weak sierra
#

oh i bet Translate has to be upper case

#

i bet that's what's fuckin me

#

im on linux after all

#

half the shit is lowercase half of it is capitalized

#

pretty irritating

quasi kernel
#

I'm literally going to reprogram it to use a custom check for the OnTest

weak sierra
#

note to self: gun model has to be defined after the item otherwise it is invisible

#

:)

quasi kernel
#

And if it magicall works

#

Im going to be sad

weak sierra
#

progress

#

it shows up now but the translation string is still not working

#

maybe i didnt fix that one tho

#

checks others

#

nope.

#

how the fuck

#

looks in her mods for another mod with Recipes_EN.txt to reference

#

mhm..

#

right

#

so im the only jackass trying to use this name format

#

oh weird i typed just recipes and see results with Recipes_EN.txt

#

whatever

jagged ingot
#

Omg 95/98 brings back memories.

#

Haha

quasi kernel
#

Delta, are you good with modding?

#

Im this close to breaking all of the bones in my body because I can't understand why my check doesn't work

jagged ingot
weak sierra
#

wiat..

#

you

quasi kernel
#

I'm trying to make a mod that modifies how BatteryRemoval and Insertion works, right?

weak sierra
#

you put underscores in the file

#

but u put spaces in the recipe?

#

this makes me wanna punch someone

#

-_-

#

takes a breath

quasi kernel
#
require "recipecode"
BatteryFixes = {}

BatteryFixes.batteryItemWhitelist = {  -- Whitelist of "torches" and other items that can have their batteries added and removed. Uses dictionary for efficiency.
    ["Torch"] = true;
    ["HandTorch"] = true;
    ["Rubberducky2"] = true;
}

function BatteryFixes.applyBatteryFix(item) -- Applies the battery patch included with the mod.
    local modData = item:getModData()
    print("Checking if patch has already been applied..")
    print("Patch applied: "..tostring(modData.hasBattery ~= nil))
    if modData.hasBattery == nil then
        print("Patched.")
        modData.hasBattery = item:getUsedDelta() > 0
        print(modData.hasBattery)
    end
end

function BatteryFixes.OnTest.TorchBatteryRemoval (sourceItem, result)
    local modData = sourceItem:getModData()
    if modData.hasBattery == nil then BatteryFixes.applyBatteryFix(sourceItem) end
    print("Can remove battery: "..tostring(modData.hasBattery))
    return modData.hasBattery
end

function Recipe.OnCreate.TorchBatteryRemoval(items, result, player)
    print("Firing.")
    for i=0, items:size()-1 do
        local item = items:get(i)
        local modData = item:getModData()
        -- we found the battery, we change his used delta according to the battery
        print("Is valid item: "..tostring(BatteryFixes.batteryItemWhitelist[item:getType()]))
        if BatteryFixes.batteryItemWhitelist[item:getType()] then
            result:setUsedDelta(item:getUsedDelta());
            -- then we empty the torch used delta (his energy)
            item:setUsedDelta(0);

            if modData.hasBattery == nil then BatteryFixes.applyBatteryFix(item); end -- Apply patch if it isn't present.
            modData.hasBattery = false

            print("No longer has battery.")
        end
    end
end

function Recipe.OnTest.TorchBatteryInsert(sourceItem, result)
    local sourceItem = sourceItem
    local res = result
    local modData = sourceItem:getModData()

    if BatteryFixes.batteryItemWhitelist[sourceItem:getType()] then
        if modData.hasBattery == nil then BatteryFixes.applyBatteryFix(sourceItem); end
        --local returnData = (not modData.hasBattery)
        --print("Item lacks battery: "..tostring(returnData))
        return (not modData.hasBattery)
    end
    return true -- the battery
end

function Recipe.OnCreate.TorchBatteryInsert(items, result, player)
    local modData = result:getModData()
    for i=0, items:size()-1 do
          -- we found the battery, we change his used delta according to the battery
        if items:get(i):getType() == "Battery" then
            result:setUsedDelta(items:get(i):getUsedDelta());
            if modData.hasBattery == nil then BatteryFixes.applyBatteryFix(result) end
            modData.hasBattery = true
        end
    end
end

function Recipe.OnCreate.DismantleFlashlight(items, result, player)
    for i=1,items:size() do
        local item = items:get(i-1)
        if BatteryFixes.batteryItemWhitelist[item:getType()] then
            if Recipe.OnTest.TorchBatteryRemoval(item) then -- Updated to use Recipe.OnTest.TorchBatteryRemoval to use the same logic for checking if a battery can be taken out upon destruction.
                local battery = player:getInventory():AddItem("Base.Battery")
                if battery then
                    battery:setUsedDelta(item:getUsedDelta())
                end
            end
            break
        end
    end
end
weak sierra
#

seriously, this sort of thing is super unintuitive

quasi kernel
#

This is literally

#

my entire file

#

And I don't possibly understand

#

Why it's not working

jagged ingot
#

Does it error?

quasi kernel
#

No

weak sierra
#

of course not

#

then it'd be easy to fix

#

haha

#

it's the quiet shit due to subtle inner workings of PZ that fuck you

quasi kernel
#

Everything works

#

Fine and dandy

#

EXCEPT

#

FOR THE BATTERY REMOVAL

jagged ingot
#

Mmmm well I haven't touched this area of the API. I'll take a read.

quasi kernel
#

IT STILL ACTS LIKE IT'S USING THE :GETDELTA() CHECK

jagged ingot
#

c a l m ๐Ÿ™‚

weak sierra
#

post the original function

#

so i can compare it without doing another search

#

lol

quasi kernel
#
-- Return true if recipe is valid, false otherwise
function Recipe.OnTest.TorchBatteryRemoval (sourceItem, result)
    return sourceItem:getUsedDelta() > 0;
end
weak sierra
#

i have to go rename all of my recipes now

quasi kernel
#

Yes, the space is there.

weak sierra
#

because someone decided '_' == ' '

quasi kernel
#

all in recipecode.lua

#

OnTest is somehow failing.

#

I'm using a require for a safeguard, I have it named in a such a way that it should always load afterwards, it prints everything I want, I don't understand

jagged ingot
#

Yeah that API is very confusing.

weak sierra
#

anyone who has ever done the thing i just did could have seen my mistake so easily

#

now that i know what it was

#

it's sad nobody read it

jagged ingot
#

Hey @thin hornet Do you know battery stuff?

weak sierra
#

cudda saved me 3 hours

jagged ingot
#

I'm utterly lost.

#

I know about useDelta but does the item update?

weak sierra
#

u hav wrong arg count

#

in ur code

quasi kernel
#

wat

weak sierra
#

OnTest doesn't have player

#

look at original

#

that's borkin it

#

now naturally it doesn't tell you this

jagged ingot
weak sierra
#

oh wait i looked at the wrong recipe

#

er

#

function

quasi kernel
weak sierra
#

nevermind

#

disregard me

quasi kernel
#

was about to say

#

lol

weak sierra
#

im dying of frustration and misread

quasi kernel
#

its oki

thin hornet
#

am i late to the party?

quasi kernel
#

Nono you're on time

weak sierra
#

the party is on fire

quasi kernel
#

I'm in agony

thin hornet
#

XD

weak sierra
#

pls to bring extinguisher

quasi kernel
#

I think we just need to flood the building

thin hornet
#

whatsup

weak sierra
#

i just figured my problem out, and it's that the translation string system has a bunch of dumb not clear things that are done quietly like replacing bits of strings

#

but pwrcosmic still needs help

quasi kernel
#

I don't know if this is just zomboid being weird or what, every other function replacement has worked just fine.

#

The only difference I see in this stupid function is that there's a single space between the function name and the ()

thin hornet
#

what are you trying to do in OnTest?

quasi kernel
#

Check if the flashlight has a battery, and if it does, remove it.

#

It's replacing the :GetDelta() checks of the original and adds a boolean modData of "hasBattery" to flashlights

#

So players are SUPPOSED to be able to remove and add dead batteries.

thin hornet
#

ahh

quasi kernel
#

(idk about add, but removing is needed for my mod concept)

#

If I can get this working, I can finally start implementing the Hand Crank.

thin hornet
#

i yeah cause vanilla flashlight doesnt remove depleted battery right

quasi kernel
#

It treats a depleted battery as a noenxistent battery

#

Hence why I converted it to a boolean

#

So you can't just remove dead batteries from flashlights.. forever.

#

Problem is, when a battery dies, it's just perpetually stuck in the flashlight and can't be taken out.

#

Despite the custom check making no reference to :getdelta()

#

It works perfectly fine on every other charge.

thin hornet
#
function BatteryFixes.OnTest.TestTorchMustHaveBattery(sourceItem, result)
    local modData = sourceItem:getModData()
    return modData.hasBattery || sourceItem:getUsedDelta() > 0;
    --- true if hasBattery is set or if it has used delta left
end

function BatteryFixes.OnTest.TestTorchMustNotHaveBattery(sourceItem, result)
    local modData = sourceItem:getModData()
    return not modData.hasBattery && sourceItem:getUsedDelta() <= 0;
    --- false if hasBattery not set and used delta is zero
end
#

when inserting just set has battery

#

when removing unset it

quasi kernel
#

But I do that though-

weak sierra
#

while ur here and knowing things, is it really hardcoded in java that radios accept only Base.Battery?

quasi kernel
#

If it actually isnt im totally making rechargables

weak sierra
#

then i wont have to

#

that'd be nice

#

lol

#

i dont have a decompile on this machine yet

quasi kernel
#

Also do || and && work in lua?

weak sierra
#

or id look

weak sierra
#

for or you type "or"

#

but it doesnt work bitwise

quasi kernel
#

I know that but Im just asking cuz of the funny

weak sierra
#

at all

quasi kernel
#

Cuz it's in his code I might as well ask

weak sierra
#

mm

#

google

#

dont think so

quasi kernel
#

Didnt figure

weak sierra
#

probably works in other languages like i do and just did it by habit

quasi kernel
#

probs

thin hornet
#

i dont think you need to apply any patch

quasi kernel
#

valid

#

Then how do I get batteries out of flashlights-

#

Dead ones I mean

thin hornet
weak sierra
#

u could just spawn one and make it empty..?

#

if u cant

thin hornet
#

on the recipe to remove battery use OnTest:BatteryFixes.OnTest.TorchHaveBattery
on the recipe to insert battery use BatteryFixes.OnTest.TorchDontHaveBattery

quasi kernel
#

So you're saying I have to change vanilla recipe definitions

#

To use the new functions

weak sierra
#

u can override those if u want yeah

#

in this case i would have tried to override the function too tho

#

cuz.. mod support!

#

you can do it in a mod still tho

#

u have to loop thru all recipes that seem to conform to what u want

#

and modify them in code

#

if it can't be done by patching the original function

quasi kernel
#

I have no idea how to do that

thin hornet
#

copy the original recipe and add Override:true,

quasi kernel
#

Am I able to just leave everything else out?

thin hornet
#

you add what you need to it

#

you just override those that need the extra stuff

quasi kernel
#
recipe Remove Battery
   {
     keep Torch/HandTorch/Rubberducky2,

     Result:Battery,
     Time:30,
     OnTest:Recipe.OnTest.TorchBatteryRemoval,
     OnCreate:Recipe.OnCreate.TorchBatteryRemoval,
     StopOnWalk:false,
   }
weak sierra
#

ugh so i fixed the translations showing up but broke the recipe showing up

#

i fucking hate this

quasi kernel
#

But then have another script that's just..

#
recipe Remove Battery
   {
     OnTest:BatteryFixes.OnTest.TestTorchMustHaveBattery,
     Override:true
   }
#

?

thin hornet
#

nope

quasi kernel
#

agony

thin hornet
#

have to copy all

#

the content

quasi kernel
#

Won't that cause mod incompatibilities?

thin hornet
#

i will

weak sierra
#

only if they mess with the same recipe

#

u can modify it dynamically instead

quasi kernel
#

everything about this is agonizing

weak sierra
#

if u need to

quasi kernel
#

How do I mdoify it dynamically

weak sierra
#

by retrieving the recipe on startup and tweaking the value

quasi kernel
#

I see

weak sierra
#

local recipe = ScriptManager.instance:getRecipe("Remove Battery")

#

to get the recipe

#

iirc

#

then

#

well for items it'd be DoParam idr for recipe

quasi kernel
#

Did I do anything wrong or is it just zomboid jank-

weak sierra
#

zomboid jank and u probably did something wrong too

thin hornet
#

xd

weak sierra
#

but figuring out what u did wrong

#

is made very hard by zomboid's lack of feedback

#

about many issues

quasi kernel
#

I gotta figure out how to have compatibility with Better Flashlights-

thin hornet
#

ok i was eating sorry

weak sierra
#

this translation system is a fuck

thin hornet
#

check if the other mod override those recipe

#

if not then youll be compatible?

weak sierra
#

assuming they use the stock recipes, yeah

#

they prob do

quasi kernel
#

They override.

thin hornet
#

two mod that override the same recipe are probably not meant to be compatible

weak sierra
#

u can make it do it anyway.. it just sucks :)

weak sierra
#

๐Ÿ˜”

thin hornet
#

what do they do with the override?

#

did they add a OnTest?

quasi kernel
thin hornet
#

thats it?

quasi kernel
#

And they did add an OnTest of their own, but it doesn't override.

#

It functions on it's own accord.

thin hornet
#

copy paste their recipe here

#

just that one recipe

quasi kernel
#

For the vanilla modification?

thin hornet
#

for better flashlight

quasi kernel
#
recipe Remove Battery
    {
        keep BF_HeadLight/HandTorch_Army1/HandTorch_Army2/HandTorch_ManLite/HandTorch_CK_LED/Torch1/Torch2/Torch3/Torch4/Torch5/Torch6/Torch7/TorchArmy1/TorchArmy2/BF_SpiffoLite/BF_EgenerexLite/BF_OldFlashlight,

        Result:Battery,
        Time:30,
        OnTest:Recipe.OnTest.TorchBatteryRemoval,
        OnCreate:Recipe.OnCreate.BF_TorchBatteryRemoval,
        StopOnWalk:false,
    }
#

What fun

#

Seems they still use the default and just use a custom for create

#

I dont think any of their lua modifies Recipe.OnTest though

#

Only "copies" it

thin hornet
#

then we can easily make it compatible

weak sierra
#

easily is relative

#

u have to know shit

#

lol

quasi kernel
#

How do you figure if Recipe.OnTest.TorchBatteryRemoval isn't functioning correctly?

#

Would I just force them to use my method?

#

I puposely made my item lookup a dictionary specifically for compatibility so

weak sierra
#

two things you can do:

quasi kernel
#

If the mod exists, to add their items, I can simply just add all of the item names to the dictionary.

weak sierra
#

you can either make your stuff have their stuff in it for compat and override their method as necessary depending on what it does

#

making sure ur mod loads later

#

OR

#

u can edit the existing recipe to tweak the one OnTest setting

#

which is more complex but shorter once you know how - that said i've never edited a recipe before, just items

quasi kernel
#

OnCreate is.

weak sierra
#

nono

#

to tweak it to yours

quasi kernel
#

Ohh

weak sierra
#

instead of also overriding the recipe

quasi kernel
#

So like, make the OnTest convert over to mine..?

#

I wish the OnTest override worked-

#

It'd make mod compatibility so much better

weak sierra
#

or if you like the kludgey way (very simple tho), make a second branch of your mod that uses their OnCreate and requires their mod

#

but has ur OnTest

#

as a submod

quasi kernel
#

Would rather have it in the main mod so people don't gotta do that

weak sierra
#

of course

#

:p

#

me too that's why i suffer

#

:)

#

i make all my mods dynamically intercompatible and allow others to use them as frameworks

#

ugh

#

modular everything

#

i dont understand why the recipe is gone now

#

fix translation -> recipe disappear

quasi kernel
#

I just don't understand why specifically TorchBatteryRemoval doesn't work

weak sierra
#

me either

#

a normal language would tell u something went wrong

#

but KahLua? nah

#

im really salty excuse my sassiness

#

so much frustration at this translation system

jagged ingot
#

Are you talking about type safety or something like assignment errors?

weak sierra
#

well ur overriding an existing function

#

in, e.g., C#, it'd require an override keyword

#

and it'd only let it happen if the something existed

#

in lua it's just defining a fresh function quietly if it is mistargeted

#

and u never know

quasi kernel
#

For some stupid reason I have a hunch that the space is part of it

jagged ingot
#

@weak sierra I mentioned this already, but Typescript modding is a thing now in PZ.

weak sierra
#

im aware

#

but i also don't know javascript yet and just finished learning lua

jagged ingot
#

Since you were talking about error reporting, I thought I'd mention it.

weak sierra
#

i might look into it in the future

#

ive read its tutorial already

jagged ingot
#

Ok.

quasi kernel
#

I guess im just irritated, I was doing so well then this just inexplicably decides to not do its only job

weak sierra
#

not sure if it being in typescript would help with that anyway tho

#

cuz.. in the end the typescript is being translated to lua

#

for runtime

#

so runtime errors will still be runtime errors unless ur introducing a lua-based typescript VM

#

in which case ur introducing lag

#

cuz more overhead

#

im pretty sure it's just a translator tho

quasi kernel
#

the log is outputting it and everything

weak sierra
#

have u read the actual log?

#

the debug log only shows some stuff that comes out in my experience

#

like loading errors won't be in there

#

syntax errors

#

etc

quasi kernel
#

dead battery, still sees its there

#

??????????????

weak sierra
#

my understanding was that it just always had a battery

#

and 0 was treated as "no battery"

#

the battery being just the flashlights fullness

thin hornet
#

if the battery is dead it still in it

quasi kernel
#

That's how it is in vanilla

weak sierra
#

as a concept

quasi kernel
#

In the mod, I want dead batteries to be a thing so you can recharge them

weak sierra
#

yeah i know

quasi kernel
#

I don't want your batteries to just be magically eaten by hungry flashlight monster

weak sierra
#

but.. the test for having a battery is always gonna be true? idk i didnt read all ur code

#

u storing it in moddata or smth?

quasi kernel
#

yes

weak sierra
#

nod

thin hornet
#

all item that can take a battery should have used a Tag

#

-.-

quasi kernel
#

after taking it out

weak sierra
#

lots of things should have lots of things

#

but PZ seems like it was written originally by an inexperienced team at game design

#

(no offense intended)

#

and then retrofitted to have better systems as they learned

#

which is unfortunately true of many indie titles

quasi kernel
#

It's just specifcally when the battery is dead when the menu wont come up to remove it

thin hornet
#

i mean the betterflashlight mod check for each item types

#
if sourceItem:getType() == "BF_HeadLight" or sourceItem:getType() == "HandTorch_Army1" or sourceItem:getType() == "HandTorch_Army2" or sourceItem:getType() == "HandTorch_ManLite" or sourceItem:getType() == "HandTorch_CK_LED" or sourceItem:getType() == "Torch1" or sourceItem:getType() == "Torch2" or sourceItem:getType() == "Torch3" or sourceItem:getType() == "Torch4" or sourceItem:getType() == "Torch5" or sourceItem:getType() == "Torch6" or sourceItem:getType() == "Torch7" or sourceItem:getType() == "TorchArmy1" or sourceItem:getType() == "TorchArmy2"  or sourceItem:getType() == "BF_EgenerexLite" or sourceItem:getType() == "BF_SpiffoLite" or sourceItem:getType() == "BF_OldFlashlight"then
quasi kernel
#

That's why I made a dictionary to optimize that a bit LOL

#

I wanted support to be seamless for that mod

thin hornet
#

yeah

weak sierra
#

fuckin

#

they're also doing getType over and over

#

do it once

#

jesus

thin hornet
#

overrides the recipe

quasi kernel
#

Mine just does a ["Torch"] = true

thin hornet
#

and add this

#
BatteryFixes.batteryItemWhitelist = {  -- Whitelist of "torches" and other items that can have their batteries added and removed. Uses dictionary for efficiency.
    ["Torch"] = true,
    ["HandTorch"] = true,
    ["Rubberducky2"] = true,
    ["BF_HeadLight"] = true,
    ["HandTorch_Army1"] = true,
    ["HandTorch_Army2"] = true,
    ["HandTorch_ManLite"] = true,
    ["HandTorch_CK_LED"] = true,
    ["Torch1"] = true,
    ["Torch2"] = true,
    ["Torch3"] = true,
    ["Torch4"] = true,
    ["Torch5"] = true,
    ["Torch6"] = true,
    ["Torch7"] = true,
    ["TorchArmy1"] = true,
    ["TorchArmy2"] = true,
    ["BF_EgenerexLite"] = true,
    ["BF_SpiffoLite"] = true,
    ["BF_OldFlashlight"] = true,
}
quasi kernel
#

Should I override the dynamic way?

thin hornet
#

his function only do vanilla stuff but checks for his items

#

so all you need to do is override recipe script txt and check for his types

quasi kernel
#

Alright, I can look into that.

weak sierra
#

do u know how recipe name translation works Konijima?

quasi kernel
#

Would it be better to dynamically add those items or is there no way of checking?

weak sierra
#

i've been fighting with it for 4 hours now

weak sierra
quasi kernel
#

It'd be nice for it to still be "up to date" with Better Flashlights if they ever add a new one.

weak sierra
#

in the names

#

kludgey but will probably work fine

#

u'd have to loop thru all items tho

#

heheh

thin hornet
#

Recipe_Attach_Hunting_Knife_to_Spear = ""

#

you take the name and replace space with _

weak sierra
#

yeah and apparently u dont put Recipe_ in ur recipe name

#

so, let's say u have no space

#

or underscores

#

the translation is working but now my recipes dont show up in the game

quasi kernel
#

I'd have to hook the override to an event, what event should I hook to?

thin hornet
#

why no Recipe_?

weak sierra
#

cuz it automatically strips it

#

and then doesnt find the translation

#

lmao

#

anyway

#

it seems it magically decided to work now

#

musta forgot to restart the game last test

#

so

#

the fact that entries in Recipes_EN.txt have Recipe_ added

#

and that u can't have underscores in ur recipe names

#

because it confuses the stupid thing

#

both made me get so lost

#

cuz i had both going on

#

i had recipes named like

quasi kernel
#

Should I just rely on the Better Flashlights dude to update his mod to be compatible with mine or-

thin hornet
#

you may have to add the module name

weak sierra
#

Recipe_Forge762_71Drum

#

on the actual recipe

#

thinking it'd work if i then did Recipe_Forge762_71Drum = "Forge 7.62mm 71-rd Drum"

#

and it's over there lookin for

#

"Forge762 71Drum"

#

-_-

quasi kernel
#

How do you show the full log btw

weak sierra
#

user folder/zomboid/console.txt

#

if it's an old one u find them in logs folder in zomboid folder

thin hornet
#
if (var3.contains("=") && var3.contains("\"")) {
   if (var3.trim().startsWith("Recipe_")) {
      var8 = var3.split("=")[0].replaceAll("Recipe_", "").replaceAll("_", " ").trim();
      var9 = var3.split("=")[1];
      var9 = var9.substring(var9.indexOf("\"") + 1, var9.lastIndexOf("\""));
   } else {
weak sierra
#

ima stick that in my notes in case this fucks with me again lol

thin hornet
#

clearly remove the Recipe_

weak sierra
#

yeah i did

thin hornet
#

but you need it in your text file

weak sierra
#

just the translation one yes