Jump to content

Recommended Posts

I would like to add a right-click action on the anchor prefab which already has an action to raise and lower the anchor.

To do so I created an empty component named interactions and used the AddComponentAction function

AddComponentAction("SCENE", "interactions", function(inst, doer, actions, right)
--AddComponentAction("SCENE", "anchor", function(inst, doer, actions, right) same behaviour ("anchor" is a prefab but also a component)
    if right then
        doer.components.talker:Say("Wololo")
        --table.insert(actions, GLOBAL.ACTIONS.TRAVEL)
    end
end)

AddStategraphActionHandler("wilson", GLOBAL.ActionHandler(GLOBAL.ACTIONS.TRAVEL, "give"))
AddStategraphActionHandler("wilson_client", GLOBAL.ActionHandler(GLOBAL.ACTIONS.TRAVEL, "give"))

When I am in the game and as long as I put my mouse on the prefab, the player will repeat "Wololo" in a loop without moving.

But when i use table.insert(actions, GLOBAL.ACTIONS.TRAVEL) nothing happens

I know for sure that my Action named TRAVEL is working perfectly because i am using it on other custom prefabs

Any ideas on how to fix it?

you don't need to change the code within componentactions.lua.
The AddComponentAction already adds your code and executes it after the original one. And since you see the Wololo, it is executed correctly.

So we need to debug your travel action.
When you enable this table.insert code, does the game show you the possible action for rightclick? And when rightclicking, nothing happens? Or does it not even show you the travel action?
It is some time ago I modded actions, but it also might have to do with the priority, try changing GLOBAL.ACTIONS.TRAVEL.priority=2 , at least I had to do this for my new action to show up together with the pickup action.

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