Log In  
Follow
Cieroceramics
[ :: Read More :: ]

So this will by my introduction. hello community. I need your help.
so the game I created is a platforming game. for which I designed a external level editor in c++.
my theory is. I can really only fit one level into the pico 8 map editor.
but if I parse my map data as a string, despite adding a few extra thousand lines of code to my file, I will at least have a streamlined way to create and import levels. so far the level editor works great. I tell it how big I want the map and then once I have placed all my tiles I can save it to a text which just writes the x, y position and a type variable. 3 variables in total. so my output file ends up looking something like this

x y t
0 8 0
1 8 0
3 8 0
2 8 0
4 8 0
6 9 0
7 10 0
9 12 0
11 9 3
13 8 0
15 8 0
17 7 0
18 6 0

there has GOT to be a way to parse this data. in regular lua it would be something like

platforms={}
function _makeplatform(x,y,t)
pf.t=t
pf.x=x 
pf.y=y
end
function load_platforms(s)
    local str = s
                for line in string.gmatch(str, "%.+\n" do -- for every line in the string
         for a,b,c in string.gmatch(line, "(%d+)(%d+)(%d+)") do --for every number in the line
          pf =_makeplatform(a,b,c)
                  add(pf, platforms)
         end
                end
     k = 0
end
level1 =[[ 
--copy and paste level output here
]]
function _init()
load_platforms(level1)
end

the big kick in the pants being string.gmatch() not being in pico8.
the good news is, I can basically output this information any way I want since I authored the editor. but whats the nicest way to have pico8 read it in?
my best guess with sub() is to make each number 4 chars long so '2' would be '0002'. that way I can iterate through every 4 numbers. not sure if I like the sound of that solution. so here I am.

this is the level editor.

and here is a very early release of my game. please excuse me for not uploading it to BBS. I am still figuring all this out but I swear once the game is playable again I will put it there.

EDIT:
I just added a Work in progress version of the game to BBS. so maybe it will become more clear what I am trying to accomplish. pease feel free to check it out.

Cart #runrun-0 | 2020-09-23 | Code ▽ | Embed ▽ | No License

P#81948 2020-09-18 04:12 ( Edited 2020-09-23 21:23)