In the general script file the states are filled out like this, creating a machine object
local fsm = machine.create({
initial = 'Idle',
events = {
{ name = 'InitRun', from = { 'Run', 'Dash', 'Attack', 'Slide' }, to = 'Run' },
{ name = 'InitJump', from = { 'Run', 'Idle' }, to = 'Jump' },
{ name = 'InitSlide', from = { 'Run', 'Idle' }, to = 'Slide' },
{ name = 'InitDash', from = { 'Run', 'Idle', 'Jump', 'Fall' }, to = 'Dash' },
{ name = 'InitAttack', from = { 'Run', 'Jump', 'Idle', 'Fall' }, to = 'Attack' },
{ name = 'InitIdle', from = { 'Run', 'Dash', 'Attack', 'Slide' }, to = 'Idle' },
{ name = 'InitFall', from = { 'Run', 'Jump', 'Attack', 'Slide', 'Jump', 'Dash' }, to = 'Fall' },
{ name = 'InitDeath', from = '*', to = 'Death' },
{ name = 'InitCutscene', from = '*', to = 'Cutscene' },
}
})
the error I get is
attempt to index local 'event' (a nil value)
which seems to be because self.events[e] is recognised as nil for some reason (e being the current state call), for an example of when this is called if fsm:can('Run') then
function machine:can(e)
local event = self.events[e]
local to = event and event.map[self.current] or event.map['*']
return to ~= nil, to
end