Added indexed function
This commit is contained in:
parent
a47e14ffca
commit
fd1e314ec9
1 changed files with 12 additions and 3 deletions
|
|
@ -6,7 +6,7 @@ require 'makegrid'
|
|||
---@field current integer
|
||||
LevelHandler = {
|
||||
levels = {
|
||||
'test3', 'test2', 'test'
|
||||
'test2', 'test', 'test3'
|
||||
},
|
||||
current = 1,
|
||||
}
|
||||
|
|
@ -18,13 +18,22 @@ function LevelHandler:next()
|
|||
if self.current > #self.levels then
|
||||
self.current = 1
|
||||
end
|
||||
local levelPath = string.format('levels/%s', self.levels[self.current])
|
||||
local levelPath = 'levels/' .. self.levels[self.current]
|
||||
return MakeGrid( require( levelPath ) )
|
||||
end
|
||||
|
||||
-- Returns first level
|
||||
---@return Grid
|
||||
function LevelHandler:first()
|
||||
local levelPath = string.format('levels/%s', self.levels[1])
|
||||
local levelPath = 'levels/' .. self.levels[1]
|
||||
return MakeGrid( require( levelPath ) )
|
||||
end
|
||||
|
||||
-- Returns level by its index in table
|
||||
---@param i number
|
||||
---@return Grid
|
||||
function LevelHandler:indexed(i)
|
||||
self.current = i
|
||||
local levelPath = 'levels/' .. self.levels[self.current]
|
||||
return MakeGrid( require( levelPath ) )
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue