base for representing a level as a string
This commit is contained in:
parent
62fe5f51d3
commit
b536d2c987
@ -469,6 +469,13 @@ function parser:val(_, ...)
|
||||
return ret
|
||||
end
|
||||
|
||||
function parser:bind(_, fn, ...)
|
||||
local f = self[fn]
|
||||
return function()
|
||||
f(...)
|
||||
end
|
||||
end
|
||||
|
||||
-->8
|
||||
--ship behavior
|
||||
|
||||
@ -958,6 +965,24 @@ end
|
||||
-->8
|
||||
-- example level
|
||||
|
||||
level_parser = parser.new{}
|
||||
mknew(level_parser)
|
||||
|
||||
function level_parser:parse_level(lvl)
|
||||
local ret = {}
|
||||
self:parse_into(lvl,
|
||||
function(row)
|
||||
if (#row < 2 or type(row[1] ~= "number")) return
|
||||
local idx = row[1]
|
||||
local x = ret[idx] or {}
|
||||
for j=2,#row do
|
||||
add(x, row[j])
|
||||
end
|
||||
ret[idx]=x
|
||||
end)
|
||||
return ret
|
||||
end
|
||||
|
||||
function spawn_rnd_x(typ)
|
||||
s = typ.new{
|
||||
x = rnd(104),
|
||||
|
Loading…
Reference in New Issue
Block a user