. . . Posted January 29, 2024 Share Posted January 29, 2024 Hello, I'm kind of confused on how I would go about editing a component action in componentactions.lua if anyone knows what I'd have to do it would be really helpful since I couldn't find a topic either on how I could do this! What I want to do is to edit the "fuel" componentaction then I can try to make it so fuels can have multiple fueltypes (I want to make lightbulbs useable as burnable fuel and cave/lantern fuel) but I'm completely lost on how I would edit this .. fuel = function(inst, doer, target, actions) if not (doer.replica.rider ~= nil and doer.replica.rider:IsRiding()) or (target.replica.inventoryitem ~= nil and target.replica.inventoryitem:IsGrandOwner(doer)) then if inst.prefab ~= "spoiled_food" and inst:HasTag("quagmire_stewable") and target:HasTag("quagmire_stewer") and target.replica.container ~= nil and target.replica.container:IsOpenedBy(doer) then return end for k, v in pairs(FUELTYPE) do if inst:HasTag(v.."_fuel") then if target:HasTag(v.."_fueled") then table.insert(actions, inst:GetIsWet() and ACTIONS.ADDWETFUEL or ACTIONS.ADDFUEL) end return end end end end, Any help is greatly appreciated! Thank you for your time!! Link to comment https://forums.kleientertainment.com/forums/topic/154050-how-do-you-go-about-editing-a-component-action-in-componentactionslua/ Share on other sites More sharing options...
Rickzzs Posted January 30, 2024 Share Posted January 30, 2024 (edited) utils.sim(function() local _1, v, _ = UPVALUE.get(EntityScript.CollectActions, "COMPONENT_ACTIONS") if v then local SCENE = v.SCENE if SCENE then local SCENE_inventoryitem_fn = SCENE.inventoryitem SCENE.inventoryitem = function(inst, doer, actions, right) if doer:HasTag("rabbitfriendly") and inst.prefab == "rabbit" and doer.replica.inventory ~= nil and (doer.replica.inventory:GetNumSlots() > 0 or inst.replica.equippable ~= nil) and (right or not inst:HasTag("heavy")) then table.insert(actions, ACTIONS.PICKUP) end return SCENE_inventoryitem_fn(inst, doer, actions, right) end end local USEITEM = v.USEITEM if USEITEM then local USEITEM_repairer_fn = USEITEM.repairer if USEITEM_repairer_fn then USEITEM.repairer = function(inst, doer, target, actions, right, ...) if right then if doer.replica.rider ~= nil and doer.replica.rider:IsRiding() then if not (target.replica.inventoryitem ~= nil and target.replica.inventoryitem:IsGrandOwner(doer)) then return USEITEM_repairer_fn(inst, doer, target, actions, right, ...) end elseif doer.replica.inventory ~= nil and doer.replica.inventory:IsHeavyLifting() then return USEITEM_repairer_fn(inst, doer, target, actions, right, ...) end if target:HasTag("repairable_any") then for k, v2 in pairs(MATERIALS) do if inst:HasTag("work_" .. v2) or inst:HasTag("finiteuses_" .. v2) or inst:HasTag("health_" .. v2) or inst:HasTag("freshen_" .. v2) then table.insert(actions, ACTIONS.REPAIR) end end end end return USEITEM_repairer_fn(inst, doer, target, actions, right, ...) end end utils.sim=AddSimPostInit UPVALUE.get= function GetValueRecursive(obj, key, depth) local MAXDEPTH = 10 if type(depth) ~= "number" then depth = 1 end if depth > MAXDEPTH then --CONSOLE.err("GetValueRecursive: reached max depth", obj, key, depth) return nil, nil, nil end -- print("[get]", obj, key) local up = 1 local name, value = nil, nil local temp_name, temp_value, temp_up = nil, nil, nil local ret = nil while true do name, value = debug.getupvalue(obj, up) -- print("[upvalue]", name, value, up) if name == nil then break elseif name == key then ret = value break elseif type(value) == "function" then temp_name, temp_value, temp_up = GetValueRecursive(value, key, depth + 1) if temp_value then obj = temp_name ret = temp_value up = temp_up break end end up = up + 1 end return obj, ret, up end Edited January 30, 2024 by Rickzzs 1 Link to comment https://forums.kleientertainment.com/forums/topic/154050-how-do-you-go-about-editing-a-component-action-in-componentactionslua/#findComment-1696174 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now