Jump to content

Recommended Posts

Hi there! I'm working on some kind of machinery that works differently based on the resources given. I was able to get the custom action and animation to work. But somehow it only works when I put my cursor on other entities.

5jNm3DV.png

I wanted it to works only when putting an special item over the machine. Like putting the klaus key over the loot stash and the unlock action shows up.

ZYQVlgi.png

local VENDINGMACHINE = GLOBAL.Action({ mount_valid=true })    
VENDINGMACHINE.str = "Suicide"
VENDINGMACHINE.id = "VENDINGMACHINE"
VENDINGMACHINE.fn = function(act)
    if act.doer ~= nil and
    act.target ~= nil and
    act.doer:HasTag("player") and
    act.target.components.vendingmachine and
    act.target.prefab then

        act.target.components.vendingmachine:working(act.doer)
        act.doer.components.health:DoDelta(-9999) -- to check if the action is success
        return true
    else
        return false
    end
end

AddAction(VENDINGMACHINE)

AddComponentAction("SCENE", "vendingmachine", function(inst, doer, actions, right)
    if right then
        table.insert(actions, ACTIONS.VENDINGMACHINE)
    end
end)

local vendingmachine_handler = ActionHandler(ACTIONS.VENDINGMACHINE, "dolongaction")

AddStategraphActionHandler("wilson", vendingmachine_handler)
AddStategraphActionHandler("wilson_client", vendingmachine_handler)

 

I know I have to use act.invobject in function(act). But when I tried, the character just said that he can't do that and the action longer works. Does anyone  know how to make it work in the way I wanted? Thanks.

Edited by Norfeder
grammar

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...