#mod_development

1 messages · Page 17 of 1

calm depot
#
function Recipe.OnTest.TorchBatteryInsert(item, ...)
    return oldTestInsert(item, ...) and item:getModData().batteryRemoved
end```
#

that's not pseudo code, that is 100% valid lua

quasi kernel
#

Wouldnt that have problems with the tags though?

#

Or am I mistaken

#

Because the original code has no tag checks

calm depot
#

yes, but let's focus on unborking the regular stuff first

quasi kernel
#

Fair point

calm depot
#

get it working first, add features later

quasi kernel
#

Battery Insertion still isnt working even with that method

calm depot
#

what's happening

#

or, not happening

quasi kernel
#

It's not doing anything, not even printing

#
local oldTestInsert = Recipe.OnTest.TorchBatteryInsert
function Recipe.OnTest.TorchBatteryInsert(sourceItem, ...)
    print("Can insert battery: "..tostring(oldTestInsert(sourceItem, ...) and sourceItem:GetModData().batteryRemoved))
    return oldTestInsert(sourceItem, ...) and (sourceItem:getModData().batteryRemoved)
end
calm depot
#

hold on, does it offer you the option to do the insert?

quasi kernel
#

Nope

calm depot
#

sounds to me like you have a syntax error

#

probably never actually loaded the lua code successfully

quasi kernel
#

perhaps

#

Actually, no.

#

It still loads the Recipe.OnCreate.TorchBatteryRemoval()

#

Though because of the nature of lua, it could've error'd in the line.

#

Lua is a per-line language rather than a compiling one so

calm depot
#

heh, that's not actually how it works

#

lua compiles to bytecode

#

compile-time errors and runtime errors are two different things

quasi kernel
#

Oh right

#

bleh

calm depot
#

anyhow, did you restart the game or just use F11 and hit reload?

quasi kernel
#

I'm in debug, so I just slapped reload lua.

calm depot
#

yeah, that isn't going to work now that we wrap the original function

quasi kernel
#

Ah I see

calm depot
#

you need to quit to main menu and load it

quasi kernel
#

Wait, you mean restart as in completely restart or?

#

Because Reset Lua is only on my title screen.

calm depot
#

quit to main menu

#

just quit, load game back up

#

that's all you need to do, nothing else

#

all lua gets reloaded upon loading a save

quasi kernel
#

Nothing comes after

#

It's not firing

calm depot
#

does the option to insert the battery show up?

quasi kernel
#

Nope

calm depot
#

but nothing happens when you click it?

quasi kernel
#

Doesn't show up to begin with

#

I can remove a battery juuuust fine

#

But inserting one is the devils work apparently

calm depot
#

well, if the print statement isn't happening, it isn't executing

quasi kernel
#

Yeup

calm depot
#

do you have all the code in a single file?

quasi kernel
#

Don't know why it isn't

#

At the moment yes

calm depot
#

OK, so it's not a syntax error, otherwise you wouldn't be able to remove

quasi kernel
#

yeup

calm depot
#

simplify the print to just print("yes it executed")

#

at least we've reduced it to the simplest possible first statement

quasi kernel
#

Maybe it's more recipe wonk..?

calm depot
#

why would it be, you didn't try to override the recipe for battery insertion, right?

quasi kernel
#

Dont believe so, but I mean like, what if its somehow wonking out some other way

calm depot
#

nah

#

we're replacing the OnTest function, can't get much simpler than that

quasi kernel
#

And they wrote nothing else.

calm depot
#

sod it, zip up the mod and send it

quasi kernel
#

lemme try one thing rq and see if it magically works

calm depot
#

ok

quasi kernel
#

I doubt it but gonna check anyways

#

Sometimes the stupid stuff works the best

#

Okay yea, nada.

#

I'll send it over rq

#

gimme a bit

calm depot
#

👌

#

so um

#

@quasi kernel look at your lua script, specifically lines 21 and 28

#

see a problem?

#

no no, disregard

#

they're different

#

so, now that the OnTest function just returns true regardless, does it at least show you the menu item?

quasi kernel
#

n

#

You'd think it would but nope

#

Even then, it should still print the "Yes, we've executed" line before returning

calm depot
#

welp, let's see what I get

#

it's not possible you have any lingering copies of code that overwrites the same function is it?

quasi kernel
#

If there was, you'd see it in the file.

calm depot
#

I mean in another mod

quasi kernel
#

Does it work on your end or something?

#

I haven't made any other mods, the only potential problem would be Backpacks and Sleeping Bags, but even then Insert Battery was working fine earlier with it present

#

And they use their own Insert Battery function instead of overriding

calm depot
#

lol

#

I know what's wrong

quasi kernel
#

what

#

Is it something stupid

calm depot
#

I'm checking but yeah, I'm fairly sure

#

check line 1539 of server/recipecode.lua

quasi kernel
#
TorchBatteryInsert_TestIsValid = Recipe.OnTest.TorchBatteryInsert
calm depot
#

yeah, my theory here is that we're quite possibly too late to redefine it

quasi kernel
#

So we have to make a new function is what I'm guessing

#

And make it so the vanilla recipes use that instead

#

But wait, wouldn't that mean the other definitions wouldn't work..?

#
TorchBatteryInsert_OnCreate = Recipe.OnCreate.TorchBatteryInsert
TorchBatteryInsert_TestIsValid = Recipe.OnTest.TorchBatteryInsert
TorchBatteryRemoval_OnCreate = Recipe.OnCreate.TorchBatteryRemoval
TorchBatteryRemoval_TestIsValid = Recipe.OnTest.TorchBatteryRemoval
calm depot
#

your own definitions will of course work, I suspect it's the base ones that we can't override - also, I just looked, I think those are legacy

#

the base game recipes directly hit Recipe.OnTest.TorchBatteryInsert

quasi kernel
#

You mean the TorchBatteryInsert_OnCreate is legacy?

#

I don't see any refs to it anywhere so it could be

calm depot
#

yeah, so basically, if you call Recipe.OnTest.TorchBatteryInsert() from the lua console box, it runs fine

#

which means the recipes code directly obtains the function ref when the recipes are loaded and saves it, making the attempted override do nothing

quasi kernel
#

Well great

#

Just means we gotta redefine the recipe ref

calm depot
#

ah it's not that bad, I have a theory I'm testing

quasi kernel
#

Which also means there's less mod compatibility since we'd have to override 3 recipes instead of 1

#

Then again, I have doubts anyone is gonna modify "Insert Battery into Rubber Duck"

#

And even if they do, they can just use my mod

#

Wait, isn't it possible to go through the recipes and determine which ones are using the old method and manually set them to the new one?

calm depot
#

nah, something looks a bit screwy here

#

the game does implement an internal cache of functions

#

but it shouldn't have already cached that function

#

because nothing should have driven it to test for the recipe being valid

#

secondly, even with that... I still can't insert the battery if we don't override the insertion code

quasi kernel
#

what in the world-

calm depot
#

yeah, I reckon the source item is getting left in some indeterminate state

quasi kernel
#

Maybe its because of use in remove battery..?

#

maybe destroying and re-creating it is a good idea.

calm depot
#

nah, it's not the item actually

quasi kernel
#

Then what do you reckon?

calm depot
#

search your recipes list (B) for inserting a battery

#

they're all missing

quasi kernel
#

You mean this one?

#
module BetterBatteries
{
  {
     imports Base
  }

  recipe Remove Battery
   {
     Torch/HandTorch/Rubberducky2/[Recipe.GetItemTypes.BatteryItem],
     Result:Battery,
     Time:30,
     OnTest:Recipe.OnTest.TorchBatteryRemoval,
     OnCreate:Recipe.OnCreate.TorchBatteryRemoval,
     StopOnWalk:false,
   }
}
calm depot
#

no, I mean in the game

#

if you open the recipes menu, all the battery insertion recipes are missing

quasi kernel
#

what about the other recipes?

#

are they intact?

#

oh my god wait

#

it overwrote the entire freaking recipes file

#

it deleted every recipe there EXCEPT for remove battery

#

The only exceptions being the recipes in their own designated files

#

Maybe it's because I named it recipes.txt?

#

lemme try..

calm depot
#

shit

#

it's my fault

quasi kernel
#

it's because it was named recipes.txt wasnt it

calm depot
#

yep

quasi kernel
#

mfw

#

now the question is does it override correctly or not

calm depot
#

well, you also have a problem

#

it should be imports { Base }

quasi kernel
#

ah

calm depot
#

not { imports Base }

#

line breaks are fine of course

quasi kernel
#

alright, patched that

#

testing it rq

#

even with the incorrect import it still has all the correct recipes back which is welcome

calm depot
#

yeah, it's good now

#

lemme clean up the code, this should be a pinch

quasi kernel
#

There's two remove battery options

#

It didn't override

#

Only added onto

calm depot
#

correct, it won't

quasi kernel
#

So will we just have to modify the original recipe to use our new method?

#

not new method but

calm depot
#

nah, just leave it

quasi kernel
#

accept new items

#

we can fix it later right-

calm depot
#

nobody will really care, you basically always use the right click menu anyway

#

what does need to change is that it ONLY matches on the tag

#

since the original will serve the purpose for vanilla items

quasi kernel
#

you say that but uh

#

there's two right clicks is what I mean

#

its recognizing both

#

and users wont know which one is the patched one

#

We may need to modify the original recipe

#

I'm modifying the vanilla items to use this new system as well so

#

crap

#

there's two removes and all the recipes are gone again-

#

wait nvm

#

it decided to add the old recipes script for some reason

#

lovely

#

Okay yeah, two remove batteries show up in the context menu still

calm depot
#

as intended

quasi kernel
#

Progress nontheless

#

Would be nice to figure out how to make it one, but one step at a time yesyes

#

my worst nightmare came back

#

we have to use destroy

#

oh well, it's hacky but it works i guess

calm depot
#

@quasi kernel ^

quasi kernel
#

thank

#

It might still need to use destroy though because of the keep / use limitations on Drainables

#

But ill check first

#

(Mostly because you can't remove a dead battery from a flashlight which is the whole point of this trouble)

calm depot
#

considering it should be consulting our own OnTest, hopefully not

#

AFAIK, the original reason this didn't work was because the game's OnTest checked for this, now it doesn't

quasi kernel
#

No good.

#

Gotta flip to the destroy method.

calm depot
#

hm

#

one sec

quasi kernel
#

it doesn't consider the flashlight to be a valid item since its getuseddelta is 0 as a drainable

#

so it wont show it as being a valid object to use in crafting

#

This was the whole reason I wanted to go with the "empty flashlight" approach by duplicating existing lights and making empty counterparts

#

Either we do the destroy method which could potentially confuse users, or we do the empty flashlight approach which is messier code-wise but looks cleaner user-end wise

calm depot
#

nah, something's not quite adding up here, I don't see anything in the java code imposing a restriction

quasi kernel
#

Trust me, I already checked for hours on both ends, something is in there and I just can't find it.

calm depot
#

I'll see

quasi kernel
#

Closest lead I got to the lua end of things was the "ISInventoryPaneContextMenu"

#

SInce it checks for recipes on the java side in RecipeManager

#

Line 272

#

It has validity checks in there somewhere

#

Not on the lua end, the java end.

#

Which we can't modify without mod distribution problems.

#

I'm starting to think the empty counterparts may be the way to go

#

Then we can just check recipes if they use a flashlight and add their empty counterpart to the recipe instead

calm depot
#

yeah, looks like it's in RecipeManager

#

welp

quasi kernel
#

I know im insane but I have my partially not insane moments sometimes

#

Now that I think about it, wouldnt empty flashlights actually add more compatibility for some recipes?

#

Since an empty flashlight wouldnt be valid in, say, a flashlight suppressor.

#

Because of the same exact limitation we hit.

calm depot
#

yes, that's why I said it's better not to create a new item

quasi kernel
#

Nono I mean like

#

The seperate item could replace the old recipes

#

Because in the old recipes, if the flashlight has 0 usedelta, it can't be used for the same limitation.

#

However with this sytem, it can be used regardless.

#

In fact, it'd actually save you the battery.

#

We can loop through the recipes, determine if each source is part of our tag, if it is then remove it and replace it with its empty counterpart

#

We'd create the empty counterparts dynamically first though

#

The benefits I feel like would outweight the costs in this type of system

#

A) No weird bar showing up in the item when it's empty
B) Users are no longer forced to use a battery when constructing an item with a flashlight.
C) Would actually provide us more structure to base around our own "Remove Battery" and the like recipes.

#

Plus this shouldn't interfere with mods.

#

They'd, again, have to explicitly opt into the mod by adding the tag.

#

Am I insane or is this making sense

#

I need to check

calm depot
#

oh boy, no no, there's no need for this

random finch
#

No matter which safehouse options are enabled/disabled, it seem players that aren't admin, moderator, safehouse owner, or on safehouse perm list, then they cannot pull up a right-click context menu in the area that the safehouse exist - like at all. It's dependent on where they click, not where they stand.

It seems the only server setting that relies on this occurring is to enable safehouses for players. None of the other safehouse settings mattered after a process of elimination.

This means everyone experiences this issue on MP server?

#

I say issue bc there are checks for other context menu entries that check for safehouse options that aren't even reached due to not being able to use the context menu at all. Wherever that part of it is handled, and it doesn't seem to be in ISWorldObjectContextMenu.lua.

calm depot
#

you're running a 100% unmodded server?

random finch
#

100%

calm depot
#

file a bug on the forums

quasi kernel
#

Oli, what should we do then? I kinda like the empty counterpart solution, even if it's a bit complicated.

random finch
#

Shouldnt I be able to pinpoint the source of the issue if I were pro?

calm depot
#

@quasi kernel one sec, got the working code

random finch
#

If I did that, i could make a mod to fix the issue and file the report

calm depot
#

that would entirely depend on whether the bug lives in Lua or Java

#

either way, report the bug.

random finch
#

Anything related to pvp purposes seems slow to get to 😛

calm depot
#

at the very least, someone in the community will either test to confirm, or deny what you are experiencing

#

@quasi kernel oh, one caveat, we need to move the recipe into Base

quasi kernel
#

@calm depot can't insert into flashlight

#

Batteries aren't seen as legitimate

random finch
#

Alright, I'll do that Oli. Thanks for the suggestions.

calm depot
quasi kernel
#

I know it's stupid, but if this continues to not work as expected, can we attempt my route?

#

Yes, it's more complicated, but that also gives me more opportunity to learn.

calm depot
#

well, I had insertion working

#

removal works fine

#

just gotta work the kinks out of the final step

quasi kernel
#

Removal is working fine for me but not insertion

#

tweaked it a tiny bit rq to change it from getPlayer to use the provided player vari

calm depot
#

oh, heh, seems the game got rather upset about me readding the item

#

it corrupted the inventory

quasi kernel
#

Okay, so dupe the item instead..?

calm depot
#

so the batteries were also buggered

#

yes, indeed

#

might have to nuke this save game

quasi kernel
#

oh LOL

#

DANG

calm depot
#

it's one I use purely for testing

#

precisely for these occasions

quasi kernel
#

oh thank god

#

Ive just been using the debug saves lol

#

been spamming mall cuz why not

#

changed unpack to table.unpack since unpack was deprecated

#

Reloading lua and testing

#

Insert still doesnt work

calm depot
#

yeah, but something's off with the batteries

quasi kernel
calm depot
#

if you look at their energy level, it's some stupid wrong value

quasi kernel
#

Batteries are popping out as expected on my end

#

They just aren't being recognized as a valid component for god knows what reason

calm depot
#

if I look at it in detailed view in inventory, it reports 10/100001 (0%)

#

that does not seem right

#

and I might know why

#

yeah, I do

#

the OnTest function is called, in turn, for each input ingredient

#

so we have to make an exception for batteries

quasi kernel
#

confusion

#

i might just try this in the morning, it's like midnight

calm depot
#
function Recipe.OnTest.TorchBatteryInsert(sourceItem, ...)
   return ((oldTestInsert(sourceItem, ...) or sourceItem:hasTag("BatteryItem")) and sourceItem:getModData().batteryRemoved) or sourceItem:getType() == 'Battery' or sourceItem:hasTag("Battery")
end```
#

sorry, wrong var name

#

there

quasi kernel
#

Well, it works, I can't complain.

#

Admittedly a little disappointed I couldnt explore the more complex route, but hey I can do that another time.

calm depot
#

this avoids the mess of separate items

#

this is the cleanest

#

it's also the least intrusive

quasi kernel
#

This has the tag support too which is nice

calm depot
#

only thing left to do is a bit of cleanup so that the insertion recipe is unified and it's done

quasi kernel
#

Oh yeah, and somehow fix the remove battery-

calm depot
#

currently it won't quite work properly if you use the vanilla recipe, you'll end up with a dupe flashlight

quasi kernel
#

yeah

calm depot
#

er, I meant remove battery recipe, yes

quasi kernel
#

tysm for your help btw

calm depot
#

np

#

it's an interesting idea, and makes the game a bit more realistic than having magically vapourising batteries

quasi kernel
#

yeye

#

I do already have an idea for my next mod which'll be fun

random finch
quasi kernel
#

But I'm gonna finish this one first

#

Probably gonna hit the hay for now, I'll look into things more tomorrow

#

nyoooom

unkempt bronze
#

Anyone know of a solid radio mod that allows players to use TC (not global) on specific channels? Creating an RP server.

shadow geyser
#

why do you still need to do this? I thought using destroy keyword fixed things?

#

I don't think it would help since unless doing some funky business saving the name strings of the recipes, the dictionary won't persist through saves, so you would still need to generate it everytime you join the game. besides I really don't think its as much of a time saver as you think

calm depot
#

you're quite far behind the state of play, that's all done and dusted

shadow geyser
#

if you mean getting colored test, you can add these tags to modify the text. here is an example, where I modify the description to be red, if you don't have the item needed


if beehive_count > 0 then rgb = "<RGB:1,1,1>"
else rgb = "<RGB:1,0,0>" end
tooltip.description = tooltip.description.."<LINE>"..rgb..string.format("%s: %i / 1", "Beehive", beehive_count)

#

does PetrolCan;1 not work?

distant atlas
#

Anyone know of any mods that make it so you don't get scratches on feet?

plucky junco
#

hi guys, anyone knows where the vanilla padlock info are? I would like to apply the padlock to another object that is not a wooden crate

glad ridge
#

can i add action anim to a recipe in the .txt file or does that need to be done in lua?

plucky junco
plucky junco
#

others I don't know 😂

glad ridge
#

wanted that ripsheets one

glad ridge
plucky junco
#

Not that I know

#

Can't make it work?

gilded hawk
#

HaloTextHelper.addText(player, getText("ProxInv_Force_Selected").." "..(ProxInv.isForceSelected and "ON" or "OFF"), HaloTextHelper.getColorGreen())

For some reason this prints "ProxInv_Force_Selected", instead of the localized text

#

Any suggestions why?

#
UI_EN = {
    ProxInv_Force_Selected = "Prox Inv: Force Selected",
}
quasi kernel
#

I awaken, time to figure out the magic that is trying to override a vanilla recipe

cyan basalt
#

@quasi kernel isn't that what I sent you? I edited a vanilla recipe with code

quasi kernel
#

You added onto it, not so much override

#

I need to completely modify it to change from keep to destroy, and also include support for a tag.

cyan basalt
#

ah I see what you mean

#

yeah I just added another source to a keep

#

still the same kind of idea though

quasi kernel
#

Just gotta figure out how to flip it from keep to destroy and I'll be golden

cyan basalt
#

just delete the keep source that matches your criteria and then add a destroy right?

quasi kernel
#

That's what I'm thinking

#

That way I can progressively empty the keep, then just add it to destory instead

#

Gotta figure out how to do that precisely but I can't imagine it's hard

quasi kernel
#
function EditRecipes()
    local allRecipes = getScriptManager().getAllRecipes()
    for ri = 0, allRecipes:size() - 1 do
        local recipe = allRecipes:get(ri)
        local recipeSources = recipe.getSource()
        local recipeResults = recipe.getResult()
        for rsi = 0, recipeSources:size() - 1 do
            local source = recipeSources:get(rsi)
            local sourceItems = source.getItems()
            local result = recipeResults:get(0)

            if result:getFullType() == "Base.Battery" or result:hasTag("Battery") then
                for sii = 0, sourceItems:size() - 1 do
                    local sourceItem = sourceItems:get(sii)
                    if sourceItem:isKeep() then
                        sourceItem:setKeep(false)
                        sourceItem:setDestroy(true)
                    end
                end
            end
        end
    end
end
#

I think this'll work?

#

@cyan basalt what do you think

weak sierra
# shadow geyser does PetrolCan;1 not work?

i was originally discussing with someone who kept insisting you couldn't use units of gas - i haven't tried to and assume it works fine, was trying to make a point to them

#

they said "there's no such thing as 'Gas=1'"

#

apparently they were talking about propane, which.. also can be done that way

#

they apparently apparently meant "there's no tag system group for propane"

#

which was very much not the words that they were using or the examples they were using

quasi kernel
#

I dont think my funny code works

#
function EditRecipes()
    local allRecipes = getScriptManager().getAllRecipes()
    for ri = 0, allRecipes:size() - 1 do
        local recipe = allRecipes:get(ri)
        local recipeSources = recipe.getSource()
        local recipeResults = recipe.getResult()
        for rsi = 0, recipeSources:size() - 1 do
            local source = recipeSources:get(rsi)
            local sourceItems = source.getItems()
            local result = recipeResults:get(0)

            if result:getFullType() == "Base.Battery" or result:hasTag("Battery") then
                print("result is a battery.")
                for sii = 0, sourceItems:size() - 1 do
                    local sourceItem = sourceItems:get(sii)
                    local fullSourceType = sourceItem:getFullType()
                    if fullSourceType == "Base.Rubberducky2" or fullSourceType == "Base.Torch" or fullSourceType == "Base.HandTorch" or sourceItem:hasTag("BatteryItem") then
                        print("Valid item")
                        print(fullSourceType)
                        if sourceItem.isKeep() then
                            sourceItem.setKeep(false)
                            sourceItem.setDestroy(true)
                        end
                    end
                end
            end
        end
    end
end
#

It's bad yes but I just want something functional first

weak sierra
#

im not sure what ur going for with changing source item to destroy rather than keep

#

do we ever destroy the flashlight?

quasi kernel
#

Have to

#

Drainable limitation

#

Can't remove batteries from a flashlight with 0 use delta

#

Unless it's destroy

weak sierra
#

ok so i assume ur also adding a battery to the result then

#

via oncreate

quasi kernel
#

Yes

weak sierra
#

an empty one

#

yeah

quasi kernel
#

And also adding back the flashlight

weak sierra
#

ok so the thing about recipe modification if we/you-and-whoever havent gone over this

#

u wanna do it in shared

#

not at runtime

shadow geyser
#

whats the issue with the code?

weak sierra
#

u CAN do it at runtime but only if nothing has instantiated the recipes

#

same with any scripts

quasi kernel
#

Ok so seperate code in sharedc

#

can dooo

weak sierra
#

yeh

#

it'll run before anything in client/server then

#

MOST shared code will not interfere

#

but be aware if something else for some reason messes with recipes it could

#

very unlikely to mess with battery removal recipes tho without being a problem in the first place in code

#

lol

#

good luck

quasi kernel
#

Thank

#

Hopefully it actually workss

weak sierra
#

🤞🏻

sour island
#

put it in shared

#

make sure it only runs once

quasi kernel
#

It only runs on OnGameStart

sour island
#

too bad for you servers have their own 'client'

#

shared can sometimes get ran twice

quasi kernel
#

agony

sour island
#

recipe stuff belongs in shared regardless

#

that's where the vanilla recipecode.lua is

#

Also do it onGameBoot

#

if anything

#

it should technically NOT* need an event at all

quasi kernel
#

Oo oki

#

It should just run regardless if I don't hook it into a function?

sour island
#

I personally use onGameBoot but I think scripts are parsed preBoot anyway

#

so when Lua gets read anything not included in a function is ran

quasi kernel
#

Ah, figured.

#

I'll still hook it into onGameBoot cuz why not

#

Unless you'd advice otherwise, I'm still new to this all hehe

sour island
#

there wouldn't really be a benefit on being 'first' to modify a code tbh

quasi kernel
#

So just don't hook it to the event and leave it alone?

#

Or wait

#

Nvm I'm dumb

#

Blehh

sour island
#

just use OnGameBoot

quasi kernel
#

Caaaan do!

#

Thank you!

sour island
#

I think more modders should modify scripts on the fly / use the tag system

#

so kudos 👍

#
---Forces a numerically keyed list into a type=true table, Allows for: 'if list[key] == true' checks.
function EHE_Recipe.convertNumericListToKeyedTable(list,table) for _,value in pairs(list) do table[value]=true end end

EHE_Recipe.typesThatCanOpenBoxes = EHE_Recipe.typesThatCanOpenBoxes or {}
---Sub-mod authors will have to use the following function to add more types
EHE_Recipe.convertNumericListToKeyedTable(
    {"Base.IcePick","Base.HandScythe","Base.MeatCleaver","Base.LetterOpener","Base.Katana","Base.Scalpel","Base.GardenFork",}
    ,EHE_Recipe.typesThatCanOpenBoxes)

EHE_Recipe.additionalTagChecks = EHE_Recipe.additionalTagChecks or {}
EHE_Recipe.convertNumericListToKeyedTable(
    {"Screwdriver","DullKnife","SharpKnife","Write","ChopTree","CutPlant","Scissors","Fork","Spoon"}
    , EHE_Recipe.additionalTagChecks)

local ran = false
---Scans through every item, checks for types listed above as well as additional tag checks - avoids redundant tags
function EHE_Recipe.addCanOpenBoxesTagToTypesThatCan()
    if ran then return else ran = true end
    ---Adds "CanOpenBoxes" tag to scripts for type
    local allItems = ScriptManager.instance:getAllItems()

    for i=0, allItems:size()-1 do
        ---@type Item
        local itemScript = allItems:get(i)
        local itemFullName = itemScript:getFullName()
        local tags = itemScript:getTags()
        local addCanOpenBoxesTag = EHE_Recipe.typesThatCanOpenBoxes[itemFullName]
        local tagString = ""
        
        for ii=0, tags:size()-1 do
            ---@type string
            local tag = tags:get(ii)
            if EHE_Recipe.additionalTagChecks[tag] then addCanOpenBoxesTag = true end
            tagString = tagString..tag..";"
        end
        if addCanOpenBoxesTag then itemScript:DoParam("Tags = "..tagString..";CanOpenBoxes") end
    end
end

Events.OnGameBoot.Add(EHE_Recipe.addCanOpenBoxesTagToTypesThatCan)
#

example of something I do in EHE

#

the stuff at the top is just cause I'm lazy / don't like to type so much

#

but it you notice any function calls left in the file - like: EHE_Recipe.convertNumericListToKeyedTable( gets ran as the Lua is read/defined

#

because I need those lists defined for other functions to work - that would be the only case you'd want stuff fired on lua load

#

What are you trying to get out of the code btw?

quasi kernel
#

Back sorry

#

Okay so, I'm essentially trying to convery flashlight recipes into my new recipe type since flashlights cannot have their batteries taken out at 0 usedelta due to drainable crafting limitations

#

The solution was to turn the "remove battery" into a destroy recipe type that simply just gave back the flashlight in the OnCreate method

#

I originally wanted to do a more complex system, but I was advised against it

#

@sour island Sorry for the ping, just wanting to get your attention

sour island
#

np, I muted this server a long time ago lol

quasi kernel
#

Valid

#

I originally wanted to go with a more roundabout method that functioned more similarly to how Smokin' Joe did his Military Flashlight where it had an "empty" counterpart to the original flashlight classified as a normal item

sour island
#

so you want to be able to remove empty batteries basically?

quasi kernel
#

But I was told that may be too intrusive so something like this works better

#

Basically yea

#

Because the whole idea is you could recharge them with a hand crank im gonna make

#

So batteries are less a "one and done" and kinda finite to something more long-term

#

Plus it'd increase their overall viability since I don't see many people going out of their way to level up electrical specifically to modify items to use batteries

sour island
#

Why don't you modify the "remove battery" recipe directly?

quasi kernel
#

It doesn't override

#

It adds onto

#

If I do it via script it just adds another remove battery recipe which is ugly

sour island
#

I mean ratehr than look for matching results/keeps/etc

#

you can just parse for the actual recipe's name

quasi kernel
#

I can do that?

sour island
#

yeah

quasi kernel
#

Oo!

hoary ivy
#

What would i have to do to edit the map of the game like put in zones for other players to see on the map

quasi kernel
#

Show me your ways o wise modder

sour island
#

the recipe object has a 'getName'

quasi kernel
#

So literally just

#

Loop through the recipes and find "Remove Battery"

sour island
#

yeah

quasi kernel
#

huh

#

Well that's underwhelming LOL

sour island
#

you're looping through them anyway - and checking for alot more

#

recipes can also share names

#

so don't add a break for "optimization"

quasi kernel
#

Figured because of funny mods

sour island
#

actually use getOriginalname()

#

name gets translated

quasi kernel
#

Yesyes

sour island
#

items use displaynames for translations, recipes use originalname for untranslated

quasi kernel
#

Very good to know

sour island
#

Are you using CAPSID/intelliJ?

#

I wouldn't have found that otherwise lol

quasi kernel
#

I'm just using vscode

sour island
#

I don't know if you can decompile/annotate in vscode

quasi kernel
#

Like I have IntelliJ lying around

sour island
quasi kernel
#

I have a decompiled version with me too

#

That's the only reason I've gotten as far as I have

sour island
#

yeah but this lets you annotate it into Lua

quasi kernel
#

oo

#

Will check it out

sour island
quasi kernel
#

So it would look more like this..?

#
function EditRecipes()
    print("Editing recipes..")
    local allRecipes = getScriptManager().getAllRecipes()
    for ri = 0, allRecipes:size() - 1 do
        local recipe = allRecipes:get(ri)
        local recipeSources = recipe.getSource()
        local recipeResults = recipe.getResult()

        if recipe.getOriginalName() == "Remove Battery" then
            print("Remove battery recipe found")
            for rsi = 0, recipeSources:size() - 1 do
                local source = recipeSources:get(rsi)
                local sourceItems = source.getItems()
                for sii = 0, sourceItems:size() - 1 do
                    local sourceItem = sourceItems:get(sii)
                    if sourceItem.isKeep() then
                        sourceItem.setKeep(false)
                        sourceItem.setDestroy(true)
                    end
                end
            end
        end
    end
end
sour island
#

gotta use recipe : getOriginalName()

quasi kernel
#

oop

sour island
#

no spaces, just emphasizing the colon

quasi kernel
#

yeye, funny self function

#

I assume isKeep and setKeep yadda yadda are the same?

sour island
#

should be

#

it's the same recipe object

#

you're just looking for it differently

quasi kernel
#

I need to implement tag support too

#

Still new to those, been told they're ebic tho

sour island
#

shouldn't have to

#

aslong as the recipe shares the same name

quasi kernel
#

Oh I see

sour island
#

you could try to support tags but then you'd have to work-backwards again

#

and you never know

#

someone could make a recipe "bang batteries on flashlight"

#

and that'd get picked up if you rely on the ingredients

quasi kernel
#

Pfft fair

sour island
#

you could string.find "remove" and "battery"/"batteries"

#

but then you're finding 3 times for each recipe

quasi kernel
#

It would appear my code errored

#

Lovely

sour island
#

but this is only once - so not that heavy

#

share the error

quasi kernel
#

It seems to be a vanilla error..?

#

ISButton.lua, line 55

sour island
#

is your screen black or missing UI?

quasi kernel
#

Apparently not

#

How weird-

sour island
#

the recipe might have scuffed

#

try opening the craft menu

#

what's the whole error?

#

usually it shows the cascade - ISButton may have been the end

quasi kernel
#

Should I use pastebin or something for this-

sour island
#

can't be that long of an error but sure

#

no one else is talking tho

quasi kernel
#
Callframe at: playUISound
function: onMouseUp -- file: ISButton.lua line # 55 | Vanilla

ERROR: General     , 1661534155205> ExceptionLogger.logException> Exception thrown java.lang.reflect.InvocationTargetException at NativeMethodAccessorImpl.invoke0 (Native Method).
ERROR: General     , 1661534155205> DebugLogStream.printException> Stack trace:
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at se.krka.kahlua.integration.expose.caller.MethodCaller.call(MethodCaller.java:62)
    at se.krka.kahlua.integration.expose.LuaJavaInvoker.call(LuaJavaInvoker.java:198)
    at se.krka.kahlua.integration.expose.LuaJavaInvoker.call(LuaJavaInvoker.java:188)
    at se.krka.kahlua.vm.KahluaThread.callJava(KahluaThread.java:182)
    at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:1007)
    at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:163)
    at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1980)
    at se.krka.kahlua.vm.KahluaThread.pcallBoolean(KahluaThread.java:1924)
    at se.krka.kahlua.integration.LuaCaller.protectedCallBoolean(LuaCaller.java:104)
    at zombie.ui.UIElement.onMouseUp(UIElement.java:1228)
    at zombie.ui.UIElement.onMouseUp(UIElement.java:1183)
    at zombie.ui.UIManager.update(UIManager.java:809)
    at zombie.ui.UIManager.debugBreakpoint(UIManager.java:1796)
    at se.krka.kahlua.integration.expose.MethodArguments.assertValid(MethodArguments.java:120)
    at se.krka.kahlua.integration.expose.LuaJavaInvoker.call(LuaJavaInvoker.java:186)
    at se.krka.kahlua.vm.KahluaThread.callJava(KahluaThread.java:182)
    at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:1007)
    at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:163)
    at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1980)
    at se.krka.kahlua.vm.KahluaThread.pcallvoid(KahluaThread.java:1812)
    at se.krka.kahlua.integration.LuaCaller.pcallvoid(LuaCaller.java:66)
    at se.krka.kahlua.integration.LuaCaller.protectedCallVoid(LuaCaller.java:139)
    at zombie.Lua.Event.trigger(Event.java:64)
    at zombie.Lua.LuaEventManager.triggerEvent(LuaEventManager.java:65)
    at zombie.GameWindow.enter(GameWindow.java:752)
    at zombie.GameWindow.mainThread(GameWindow.java:490)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Cannot invoke "fmod.fmod.FMODSoundEmitter.playClip(zombie.audio.GameSoundClip, zombie.iso.IsoObject)" because "this.uiEmitter" is null
    at zombie.SoundManager.playUISound(SoundManager.java:219)
    ... 31 more
#

Fair

sour island
#

yeah something broke in boot

#

I assume this is after you hit Load?

quasi kernel
#

I rebooted the game and it does this right before the funny title screen

#

Same goes for Reset Lua

undone elbow
#

Is it possible to override a single moodle picture instead of overriding entire texture pack?

sour island
#

local recipeSources = recipe.getSource() local recipeResults = recipe.getResult()

#

:

quasi kernel
#

agony

sour island
#

any getters/setters for java functions need : afaik

quasi kernel
#

Okay, progress

#

It got angry here (?)

#

Oh

#

The N is lowercase

#

mfw

sour island
#

oh it's not held in an array

undone elbow
#

It's enum...

sour island
#

not sure if media/ui/Moodles/Moodle_Bkg_Bad_1.png would work tho

undone elbow
#

I'll try, thanks)

sour island
#

The game get's weird with inventoryItem's and trying to use overwriting filenames

#

but it's intentional, moodles might work

#

This would suggest moodle sprites aren't from the sprite pack tho

#

I guess the rest are in .pack

#

Or these aren't even used - which is true for most of media/

sour island
#

force of habit capitalizing on my part

sour island
quasi kernel
#

Force of habit

#

It seems it doesnt like the isKeep()

#

Regardless of if I use : or .

#

Oh wait, I need to supply a string

#

wait no- there's two isKeeps.

#

One is in Source and the other in Recipe

sour island
#

doesn't seem like you have to parse through source items

quasi kernel
#

yeah figured

#

Changed it to just source

#

fingers crossed..

sour island
#
  • item objects don't have a iskeep
quasi kernel
#

Booted without errors

#

Les go

#

TIme to check recipes

sour island
#

oh a source's item array is strings

#

that's probably why it borked

#

but the source itself has isKeep - so keep doing what you're doing

quasi kernel
#

IT WORKS

#

IT MADE A RANDOM ERROR SOMEWHERE BUT IT WORKS

#

THANK. YOU.

#

Found the error

#

It was old code in the other script

#

Now I can actually start working on the main function of the mod that isn't battery packs-

#

Then I can work on my other mod idea!1

#

I don't think it's quite mod compatible yet, but that's okay

#

It's all I could've wished for

#

Alright, time to sprite a battery crank

sour island
#

👍

quasi kernel
#

Which one do you figure I should base it off of?

#

The small one would be neat, would just be a matter of sizing it up a bit to actually be capable fo fitting a battery comfortably

#

But the big one is also interesting

random finch
sour island
sour island
random finch
#

Well, my main goal is to make a mod to bypass that check.

#

It has to exist. Looked through both LUA & Java.

sour island
#

so what exactly is the issue?

#

if you're not allowed in safehouses then you can't right click at all?

random finch
#

exactly

#

no mods, vanilla

mellow oyster
#

Is there any way to get zombies to have new animations?

sour island
#

then again if it's someone else's safehouse does it matter much?

gloomy geyser
#

Guys, I'm trying to do a TimedAction here, but it's always giving an error on the same line. I put all the correct information I would say. The error is on this line:

ISTimedActionQueue.add(FazerCafeNaCafeteira:new(playerObj, cafeteira, cafe))

How could I resolve this?

quasi kernel
random finch
quasi kernel
#

Thoughts?

cyan basalt
#

looks good! glad you got your stuff working too

mellow oyster
quasi kernel
#

Okay, what would be the best way to go about making a hand crank that slowly increases battery charge and exertion?

mellow oyster
#

or if you can make a recipe that fatigues

gloomy geyser
#

Can someone help me?
I needed to get and delete a specific item in my inventory, how do I get the item and delete it?

mellow oyster
cyan basalt
quasi kernel
#

@sour island I hate to be a bother, but I have a question as to how the best way to handle a cranking action would be

#

I'm thinking one way would be to have an "insert battery" recipe if the battery isn't full, then just add a recipe that only uses the battery crank if it's battery isn't full that sets up a connection to EveryTenMinutes or something similar, then the battery would add a corresponding charge every 10 minutes according to strength and exertion, as well as add exertion.

#

Then if the player runs, hits the max charge of the battery, or otherwise becomes too tired to continue operating, it removes the connection and ends the action (?)

#

Not sure how possible that is but it's an idea

sour island
#

recipes have alot of lua hooks

#

onperform, ontest, etc

#

but making it a timed action is also a good idea

#

I abused crafting for a looped action and it breaks with more traits/quick worker

#

so I don't recommend that lol

quasi kernel
#

Ah I see

#

Hm.. what would you recommend then?

sour island
#

a recipe initiating a timed action

quasi kernel
#

I really want it to be a timed thing so it's just a magical "ha I have a battery not"

sour island
#

oncreate is another lua hook for recipe

quasi kernel
#

Oo

#

So use OnPerform or something?

sour island
#

onperform is akin to start

#

ontest is done every tick the recipe action is being taken

#

oncreate is when the recipe is complete

quasi kernel
#

Alright, I see.

sour island
#

oncreate is what I would use, to initiate a timedaction

#

which you'll have to instance for your own purpose

quasi kernel
#

That'll be new

sour island
#

if that's not something you're used to there's a timed action API

quasi kernel
#

I'm open to learning, so I wouldn't mind creating a new instanced timedaction

#

I just have no idea how they work

#

(There's a lot of new things to me in modding seeing as this is my first mod, apologies)

sour island
#

you can look up files in the media/lua with action is their name

#

there's a particular way to instance lua "objects"

quasi kernel
#

Metatables?

sour island
#

but after that each of the functions are inherited

sour island
#

you can then define your own function for that instance and call back to it's parent

#

via overwriting

quasi kernel
#

I'm somewhat familiar with metatables, not too familiar, but familiar enough to understand they're basically lua's ways of being objects

#

So you're saying the "parent" TimedAction file would have all the functions n junk

sour island
#

tbh I'm mostly self taught but the way I understand it is - everything in Lua is a table - which offer alot of flexibility

quasi kernel
#

And the TimedAction:new() would function as the object we use to do funny stuff

sour island
#

yes

quasi kernel
#

Since TimedAction:new() would create our metatable with refs to the functions

#

I see

sour island
#

but you can/may have to define a :new() for your new type of timed action

quasi kernel
#

Ye I figured

sour island
#

as far I know the API should still be valid

#

probably should be something integrated into the base game files tbh

#

but that would defeat the flexibility

quasi kernel
#

Well, that explains basic setup, but how would I do loops / event connections in that type of file while being able to calculate the "time remaining"?

#

Because there's no "set" amount of time it'll take, it varies greatly.

#

Cuz we're relying on strength, exertion, and the actual starting charge.

sour island
#

timed actions can be looped

#

indefinitely

#

there's an isValid() function to control it

quasi kernel
#

Hm, I see

sour island
#

there's also booleans like canWalk/canRun

#

for the timed action object

quasi kernel
#

Useful

#

Means we can cancel it when they run

sour island
#

yeah

#

check out the class file for timed actions

#

should have all the vars there

quasi kernel
#

Was just about to do that hehe

#

Thank you! You okay if I ask more questions if I get any?

#

I don't wanna be a bother so

#

Figured I'd ask

sour island
#

sure

wind stratus
#

Anyone know if there is a mod out that that makes the UI size larger for the higher resolutions?

cosmic condor
wind stratus
#

Both, for the menu as well as in game

#

Cause this is tiny for me

cosmic condor
#

Did you try changing the font size?

wind stratus
wind stratus
#

ill take a look, currently disabling then enabling all of my mods one at a time because of conflicts tho

alpine rune
#

Does anyone know why zomboid does not like when custom professions use custom traits that have custom recipes attached to them

#

I feel like the code just fails to fail some times

calm depot
#

well, you haven't given any scenarios or errors to debug. I've never seen such things have issues, unless you're mixing a bunch of questionably written mods together

#

also, posting screenshots of text? shame on you

glad ridge
heady crystal
#

Is there an event for vehicle collision?

jagged ingot
#

Good evening.

jagged ingot
# heady crystal Is there an event for vehicle collision?
/**
 * Triggered when the texture of a vehicle part is changed after being damaged.
 *
 * @param character The player who's driving the vehicle.
 */
export type OnVehicleDamageTextureListener = (character: IsoGameCharacter) => void;
#

I think this is the closest you'll get.

#

I don't think it'll fire for every damage instance.

heady crystal
#

I already tried OnVehicleDamageTexture and it doesn't even seem to trigger at all

jagged ingot
#

Hmmm

#

I just went through the core code for vehicles and it's the only thing I'm seeing atm.

#

Might be a feature that's either planned or needs to be suggested.

#

What you could do @heady crystal is write an update method and check vehicles. It'd be somewhat dirty but possible to make your own checker.

heady crystal
#

I wish

#

I can't do that I am afraid, I have no idea how vehicle damage is even implemented

#

Doesn't affect my bikes for some reason and I couldn't find out why

jagged ingot
heady crystal
#

Yeah but the parts don't get damaged on collision that's the thing

jagged ingot
#

Hmm yeah.

#

If no one else has ideas on how to detect collision damage, maybe this is worth suggesting.

heady crystal
#

Only the engine seems to be damaged

jagged ingot
#

I'm looking for a few mods on the workshop that people extend or has API to write Typescript typings. If anyone can suggest mods for this, it'd help. Thanks.

quasi kernel
#

Are TimedActions in the client side?

jagged ingot
heady crystal
#

☝️

#

I know you can call timedactions from shared and server

quasi kernel
#

The only shared file I see for TimedActions is ISBaseAction

#

I guess for consistency it's safer to handle it in the client folder

heady crystal
#

Yeah

quasi kernel
#

Ok so better question, where do I find the sound files so I can choose one for my crank-

jagged ingot
#

If you need to update the server in any way, you can always send a client command.

quasi kernel
#

nvm I may be stupid

heady crystal
#

Have fun

#

There's a lot of files

quasi kernel
#

Oh, I found it in Media/sound

heady crystal
#

Oh you meant the actual sound files lol

quasi kernel
#

I believe I just need to find a suitable file and get its name so I can use it, right?

heady crystal
#

I only looked at it once so I can't remember if they are all perfectly named

#

If you want to use default sound files you need to check the name they specify in a txt file

#

For instance BuildMetalStructureWallFrame

#

This is in Media/scripts/sounds_player.txt

quasi kernel
#

Yeah that seems like a better bet

#

A lot of these sounds seem outdated / unused in the folder

glad ridge
#

does anyone know why an item i've added to the game through crafting only is bugging out and disappearing when i move it from bag to inventory or vice versa, but comes back after a while/when i leave the area?

alpine rune
quasi kernel
#

I take it all the sounds are in sound banks.

jagged ingot
#

No. media/sound/

#

You have the option to put .ogg or .wav files in this folder. Use the relative path from that folder to your file and add it as sound objects in script files.

quasi kernel
#

Nono I dont wanna add a sound, I wanna re-use an existing one

jagged ingot
#

You can extract audio from fmod banks.

quasi kernel
#

My sound skills ain't great, so either we're re-using one in the game or we're going to freesound

jagged ingot
#

It requires a tool.

quasi kernel
#

I take it that it'd be easier to just add my own sound at that point

jagged ingot
#

It's an option.

cedar anvil
#

Can I upload an image here for the question?

alpine rune
#

png and jpeg scares people

cedar anvil
#

oh I see

#

🦕

#

I made a trading mod that uses recipes

#
    {
GardenSaw/Saw/BucketEmpty/TirePump/GardeningSprayEmpty/PipeWrench/Paintbrush/Jack/WateredCan/TinOpener/LugWrench/Scissors,
       keep ATTS.Barcodereader,
       Result:Money=18,
       Time:80.0,
       Category:Zamazon Trading,
    }
#

But When I selected the saw to sell. It sells Scissors first instead of saw.

#

Um so I want to make it sell the selected item first. Is there any way to prevent selling random items?

calm depot
#

yeah, right click the item in inventory and do it that way

#

(sell one)

radiant obsidian
#

is there a basic intro guide for merging or creating mods? I want to combine More Traits and Dynamic Traits Sauce Edition into one more for myself.

calm depot
#

what do you mean by "combine"

radiant obsidian
#

well combine them into one so I can tweak both mods and maybe improve or add things and make sure they're compatible.

#

or should I just tweak them individually, would probably be easier.

calm depot
#

sounds to me like you haven't yet looked at how a mod is actually structured

alpine rune
#

maybe he's new to modding and maybe you're being a dick about it

quasi kernel
calm depot
quasi kernel
#

If you're able to get the source files for both mods (which isn't that difficult to be honest), you can look into merging necessary code and the like.

calm depot
#

if you understand how mods are structured, it becomes self-evident how you would merge them

alpine rune
calm depot
#

again, how am I being a dick?

#

or do you just get off on being hostile to people?

nimble valley
#

I would like to know if it is possible to manipulate world events.. such as blackout for example. Can anyone let me know?

calm depot
#

as in, when they happen?

radiant obsidian
nimble valley
calm depot
#

well, there's getWorld():setHydroPowerOn(true/false)

nimble valley
#

I see, is it possible to retrieve the current power status? If you are in blackout for example

calm depot
#

yeah, IsoWorld has getHydroPowerOn

nimble valley
#

Thanks! you are a god

calm depot
#

water is a bit more crappy, you basically have to "edit" the WaterShutModifier sandbox option to be longer than the number of game nights that have passed

nimble valley
#

Is water separate from energy?

calm depot
#

yeah, water sources consult the sandbox option I just mentioned

#

you could of course just set it to a massive value when you want it on, and a tiny one when you want it off

nimble valley
#

And do you know if there is a possibility of activating the energy of a single city for example?

calm depot
#

possible yes, but the only way I can think of is to create an invisible tile that's an instance of IsoGenerator

#

and I'm not entirely sure you can prevent the emitter sound

#

and of course, you've got to go around and spawn instances of the moveable at various locations

nimble valley
#

I'll do a little study. Thank you very much.

calm depot
#

actually, you could iterate over tiles and call setHaveElectricity() - though from looking at the code, I'm not entirely confident it'll actually work once it's been set to false

#

test it and see

nimble valley
#

Interesting. I will analyze

ancient grail
#

is there a way to call a function whenver a specific item is pickup or dropped on the floor?

how do i write that little code?
i need this for multiple mods

to give an example
i want to create items that are only useful for specific players(cant be stolen or worn by others)
i want to be able to despawn that item whnever the player dies or transfer it somewhere else if possible

thank you

ancient grail
calm depot
#

You know lua yeah?

ancient grail
ancient grail
ancient grail
calm depot
#

you can hook ISInventoryTransferAction

ancient grail
#

ibelieve i should put this on onplayer update right?

calm depot
#

see media/lua/client/TimedActions/ISInventoryTransferAction.lua

ancient grail
#

thnx thnx @calm depot

ancient grail
calm depot
#

the generator trailer mod is a hack; it drops a generator under itself

ancient grail
#

what mods are u working on right now @calm depot

calm depot
#

currently, none

nimble valley
#

I believe the noise will be the last of the problems

#

Anyway thank you. you helped me a lot

calm depot
#

no problem 🙂

quasi kernel
#

I must figure out the magic that is timed actions

#

They will make my hand crank very epic once I figure it out, but it's weird trying to understand some of it

#

I don't have animator talent so I'm just using the default loot anim, though I might switch to craft

#

As for sound, I have 0 clue how to hook a sound in but I'll figure it out!1

calm depot
#

timed actions go into a queue

quasi kernel
#

Nono I know that much

calm depot
#

a good example to examine would be any of the vanilla carpentry ones

quasi kernel
#

And they use metatables with supplied function info on the new()

calm depot
#

since they have both an anim, an item and sound

quasi kernel
#

I'm looking at the generator ones which use both

#

I just dunno if hooking to a vanilla sound is the same as hooking to a modded sound

#

Generator one uses a gas can animation which I switched to Loot temporarily, will be Craft later

#

Sound I'm worried about tho

calm depot
#

it's just rudimentary metatable usage to somewhat simulate having a class instance

quasi kernel
#

I also need to find the difference / activation scenarios of some of the functions

#

And also possibly investigate a loop because it doesn't have a wait which worries me because of the nature of loops without waits in vanilla lua

calm depot
#

the basic principle is, create a table of functions, your new() will create a fresh table with its metatable having an __index that points to your functions table

quasi kernel
#

No I know that

#

I just don't know what function ISActionName.perform() or anything similar does

#

Like I don't know what triggers it

calm depot
#

it doesn't have a wait because you define the amount of time it takes and you will be called back when that amount of time has elapsed

quasi kernel
#

What if it's dynamic though? Will I just wait forever until the action is done?

calm depot
#

what if what's dynamic?

quasi kernel
#

The time it takes to charge a battery.

#

It's not static like 5 seconds.

#

It varies based on the start charge, exertion, strength, etc

calm depot
#

you set the maxTime value on the instance, it's always dynamic

quasi kernel
#

The action is supposed to complete if the user runs (which is already has support for because of how they're set up in vanilla code), if it reaches 1 used Delta, or if the user becomes too exerted to use it

#

Ohh

#

MaxTime is just the maximum time that can be spent on the action?

#

If so, couldn't I just make that math.huge and let the logic handle it..?

calm depot
#

no, it's a bit of a shite name, once you hit max time, the operation completes

quasi kernel
#

Oh

#

So how do I make it so it changes based on my variables-

#

Will I just calculate a "base time" and run off of that?

calm depot
#

you can set the maxTime when the action is instantiated

quasi kernel
#

Formula would be vaguely something like chargePerTick * (strength * strengthModifier) * (exertion * exertion modifier)

calm depot
#

if you also have an update() function, I believe it's called every tick

#

you can manipulate the progress as you wish from there

quasi kernel
#

Oh I can adjust maxTime even after it's instantiated?

#

It might cause the bar to shift forwards a bit quickly at points but that's a sacrifice I'm willing to make for accuracy

calm depot
#

yeah, the base class has a setCurrentTime function too

#

actually, now that I think of it, I think maxTime is just an idiom they use in the vanilla game

#

the actual "meat" of progression is handled by calling setCurrentTime in your update callback

quasi kernel
#

I see

#

So maxTime is kinda redundant in something like this

#

Unless I'm mistaken

#

No wait, it'd still be used

calm depot
#

if you're just deriving from ISBaseTimedAction then yeah, it's irrelevant to you

quasi kernel
#

I am I think

calm depot
#

you can make your derived class work however you wish

#

I'd recommend reading the ISBaseTimedAction file

quasi kernel
#

Alright, I might need some advice as to how to set it up properly tomorrow, cuz I'm gonna be going to bed for now, but yeeee

#

And ye I def will

#

Funny 11PM hours

#

Thank you once again my friend

calm depot
#

any time

gloomy geyser
#

Never mind, I got it here.
Now, how do I delete this item?

calm depot
#

by calling Remove on its container

#

passing the item in question as an argument

ancient grail
#

is there a way to despawn a vehicle via console or by recipe

#

also repair

gloomy geyser
calm depot
#

how about instead, you show your failing code

halcyon dagger
drifting ore
#

did workshop just

#

die

heady kiln
#

attempt one has gone awry

#

how do i flip a model over?

calm depot
#

rotate it in blender

#

or whatever you use for modelling

heady kiln
#

oh, yay, time to learn new software lol

calm depot
#

er, where did you get the model from then?

heady kiln
#

well that is the default game model

#

ive just made the sawed off DB shotgun one handed

#

well, what the game considers one handed

calm depot
#

oh

#

you likely need to create your own anim for it

heady kiln
#

i'll see if i can figure out simple 180 degree rotation of a model first

calm depot
#

if this is only messing up during an anim, like reloading, then it won't work

#

if it's just when aiming, then you should be fine

heady kiln
#

seems to reload just fine, its just aiming and holding in hand that are upside down

#

oh, how do i open an X file in blender?

calm depot
#

I believe your options are to either use a horribly old version of blender, or find something to convert it to FBX

#

though actually, before you go down the conversion route, you should probably check with someone if the game will load an FBX for a weapon model

#

I would hope so, but you never know

heady kiln
#

ah

#

uh, ive converted them to FBX, but blender still cant open them?

calm depot
#

import

heady kiln
#

oh, thanks

calm depot
#

hopefully the converter you used did it correctly - still, it might have scaled to be huge, or incredibly tiny

heady kiln
#

well it was smaller than the default cube, but idk what scale it should be anyway

#

there seems to be a simple scale number input so worst case scenario i brute force it with trial and error

calm depot
#

seems fine - I'd focus on getting the game to use the FBX you have before trying to apply any modifications to it

heady kiln
#

so, the game doesn't seem to want to use FBX, but it also doesn't seem to be loading my rotated model, or if it is, its not actually causing the in game model to be rotated

calm depot
#

did you apply the transformation you made before exporting it

#

there's a modelling tutorial on the forum if you don't know what that means

heady kiln
#

is there simply an "apply" button i need to click?

calm depot
#

no

serene sky
#

Has anybody tough about project zomboid in 3D

calm depot
#

yeah, I hear someone had a go at it and it's called DayZ

#

😏

heady kiln
#

alright then, which forum do i find this tutorial on?

calm depot
#

the official forums

#

you know, the ones run by the creators of this game

serene sky
#

is it even possible

calm depot
#

anything is "possible"

#

it would require an extensive rewrite of the game

#

not to mention the entire team of level and artwork designers you'd need for a 3D map

heady kiln
#

so i applied the transform but still nothing changed

calm depot
#

are you sure it's actually loading your changed file?

#

try mutilating it drastically and see if you at least see the mutilation

#

bend the barrel 90 degrees or whatever

heady kiln
#

i make it thicc

#

well, its working now, but the model is the size of a fucking cruise ship

calm depot
#

did you restart the game after you made the changes?

#

it may have been fine all along

heady kiln
#

i had not been restarting, i had been just relaoding the save, i thought since it reloaded lua it would've worked

calm depot
#

nah, for 3D models, I've found it incredibly unreliable

heady kiln
#

ah, ok

calm depot
#

I restart the whole game if I don't see an expected change

heady kiln
#

ok, just the flipped model in now, lets see if it works after a restart

#

it was rotated 90 degrees off so i fixed that and changed the scale to 0.1 to see if its a more appropriate size

#

correct angle, but still too big and the textures are fucked

calm depot
#

are you scaling it down in Blender or game config?

heady kiln
#

scaling in blender, should i be using game files to do it?

calm depot
#

no

#

do it all in blender

#

just keep scaling it down till it works

#

now that I recall, I had to do this for Bicscalibur

#

and I now also recall that I was able to use an FBX for the weapon model just fine

#

although maybe that's because it's a melee weapon, though that would be silly

heady kiln
#

i'll try again with FBX, since i hadn't been game restarting

#

ok, fbx is working, now to do rotations again

quaint mirage
#

Hey, which perk is metalworking?

#

Looking at this i cant find it

calm depot
#

MetalWelding

#

that javadoc is old as shit

quaint mirage
#

Thank you

#

It needs updating

calm depot
#

better to decompile the code

quaint mirage
#

Like this right

#
function GiveXP_MetalWelding(recipe, ingredients, result, player)
    player:getXp():AddXP(Perks.MetalWelding, 10);
end
calm depot
#

yeah, although you could also have determined that by grepping for AddXP in lua/client and filtering by the word metal

quaint mirage
#

So that would look like.. this?

calm depot
#

as in: grep -R AddXP client |grep Metal

quaint mirage
#

I dont understand this, where would this go?

calm depot
#

that's a shell command

quaint mirage
#

OnGiveXP:GiveXP_MetalWelding,

#

I can run shell within the lua?

calm depot
#

lol, no

#

just a general skill that's good to have when you need to find something in the game's codebase

quaint mirage
#

Is there a general method for adding xp to any skill without writing a function for it?

#

like AddXP(Perks.MetalWelding, 10)?

calm depot
#

I mean, you can structure your code however you want

#

you can write a one-liner if you wish

#

getPlayer():getXp():AddXP(...)

quaint mirage
#

Feel like i could be duplicating something that already exists, could it all be inline here/

#

OnGiveXP:GenericAddXP(Perks.Crafting, 10)

#

Without adding a line to the lua

calm depot
#

if you're writing a recipe, yes, you can make the recipe give XP

#

there are several recipes in the game that do this

quaint mirage
#

I was following the wolf github guide but didnt work for me

calm depot
#

I don't know what that is, just poke through scripts/recipes.txt

quaint mirage
#

I'ma take it that my recipe needs to be in Base module

calm depot
#

no

#

and it preferably shouldn't

quaint mirage
#

See if it try this for examle from the Make Stake recipe

calm depot
#

module names are essentially arbitrary; the purpose of Base is for vanilla stuff to go in it

quaint mirage
#

OnGiveXP:Recipe.OnGiveXP.WoodWork5

#

This doesnt work for me

calm depot
#

well, that's exactly what the game does

#

so something is wrong with your syntax

quaint mirage
#

Ill look more into it

calm depot
#

hint: the problem is probably not that line

quaint mirage
#

Ill try it out now, think i might have had an extra ,

#

module ISSRecipesMod {
    imports {
        Base
    }

    recipe Craft Empty Lighter
    {
         BlowTorch=1,
         Aluminum=1,
         ScrapMetal=2,
         RippedSheets=1,
         keep [Recipe.GetItemTypes.WeldingMask],

         Result:EmptyLighter,
         Sound:PutItemInBag,
         Time:30.0,
         OnGiveXP:Recipe.OnGiveXP.MetalWelding10,
    }

    recipe Refill Empty Lighter
    {
           EmptyLighter=1,
           PetrolCan/PetrolPopBottle/WhiskeyPetrol/WinePetrol/WaterBottlePetrol=1,
           Result:Lighter,
           Time:50.0,
           Category:Survivalist,
    }
}
calm depot
#

looks fine, although as a matter of taste, I'd put refilling in the General category

quaint mirage
#

Ok now we're in business, thanks again for help and ill change the category 😄

calm depot
#

oh actually, while I'm at it, don't match on petrol containers like that

#

use [Recipe.GetItemTypes.Petrol]

quaint mirage
#

Just a question, is a Hammer a keepable type of a unit?

#

or

calm depot
#

otherwise, you're undermining the whole tagging system

quaint mirage
#

Lemme try that

#

So like this?

#

recipe Refill Empty Lighter
{
EmptyLighter=1,
[Recipe.GetItemTypes.Petrol],
Result:Lighter,
Time:50.0,
Category:General,
}

calm depot
#

you still need the amount at the end

#

so, =1

#

or however much you want it to drain

quaint mirage
#

Just 1 is perfect