Jump to content

Recommended Posts

Hi,

I'm trying to learn the format for adding new stategraphs. I know what I want to do and how to do it, but I don't understand how to plug it in. So I'm just trying to re-add an existing stategraph as a placeholder.

Where am I messing up?

in modmain.lua I have:

 

local State = GLOBAL.State
local TimeEvent = GLOBAL.TimeEvent
local EventHandler = GLOBAL.EventHandler
local FRAMES = GLOBAL.FRAMES

local breatherstate =   State({
    name = "breather",
    tags = { "busy", "pausepredict", "nomorph", "nodangle" },

    onenter = function(inst)
        ForceStopHeavyLifting(inst)
        inst.components.locomotor:Stop()
        inst.Physics:Stop()
        inst.AnimState:PlayAnimation("powerdown")

        if inst.components.playercontroller ~= nil then
            inst.components.playercontroller:RemotePausePrediction()
        end
    end,
    onexit = function(inst)
        inst.components.locomotor:Stop()
    end,

    timeline =
    {
        TimeEvent(120 * FRAMES, function(inst)
            --Lava Arena adds nointerrupt state tag to prevent hit interruption
            inst.sg:RemoveStateTag("nointerrupt")
        end),
    },

    events =
    {
        EventHandler("animover", function(inst)
            if inst.AnimState:AnimDone() then
                inst.sg:GoToState("idle")
            end
        end),
    },
})
AddStategraphState("wilson", breatherstate)
AddStategraphState("wilson_client", breatherstate)


local breatherevent = EventHandler("breather",
        function(inst)
            inst.sg:GoToState("breather")
        end),

AddStategraphEvent("wilson", breatherevent)
AddStategraphEvent("wilson_client", breatherevent)

 

In my mod, I call:
 

inst.sg:PushEvent("breather")

 

The game runs and my tests say that the event is being pushed. But nothing happens. When I change it to PushEvent("powerdown"), it works. So obviously I'm not adding the stategraph correctly.

Please help T.T

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