base for representing a level as a string

This commit is contained in:
Kistaro Windrider 2023-10-08 00:41:24 -07:00
parent 62fe5f51d3
commit b536d2c987
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -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),