If we have functions with similar purposes, we can also put them in the same .lua file.
How can we call them after that?
Assume that we have one file named GameScenario.lua, which is used to configure the setting for each round:
gameScenario = {} local function configureGameScenario(round) print("configureGameScenario():"..round) end--local function configureGameScenario() gameScenario.configureGameScenario = configureGameScenario return gameScenarioconfigureGameScenario() will decide the setting according to the input parameter round.
To call it from other file:
local gameScenario = require("GameScenario") gameScenario.configureGameScenario(1)
The above method is to utilize the powerful table of lua.
沒有留言:
張貼留言