Passing variables in lua

Submitted by barnettech on Sat, 07/13/2019 - 22:11

Here is an example of passing variables in lua:


gStateMachine:change('begin-game', {
            level = self.level,
            score = self.score,
            matchispossible = false
        })

then on the receiving end in the BeginGameState.lua

function BeginGameState:enter(def)
    -- grab level # from the def we're passed
    self.level = def.level
    self.score = def.score