editor={ paused=true, cam={x=0,y=0}, selected_tile=3, init=function() set_update(editor.update) editor.show_menu() end, show_menu=function() menu.show({ {"NEW MAP", editor.new}, {"LOAD MAP", function() textbox.show("FILENAME TO LOAD:",editor.load, mapa.name) end}, {"SAVE MAP", function() if mapa.name~=nil then editor.save(mapa.name) else textbox.show("FILENAME TO SAVE:",editor.save, mapa.name) end end}, -- {"BACK TO EDITOR", function() editor.paused=false end}, {"EXIT", main_init}, -- {"ENNER LLOR NEIM", function() textbox.show("PELANDRUSC!") end} }, function()editor.paused=false end) end, floodfill=function(x,y,tile) local t=mget(x,y) mset(x,y,tile) if x0 and mget(x-1,y)==t then editor.floodfill(x-1,y,tile) end if y0 and mget(x,y-1)==t then editor.floodfill(x,y-1,tile) end end, update=function() cls() camera(editor.cam.x, editor.cam.y) map(0,0,0,0,mapa.w, mapa.h) local mx,my=mousex()+editor.cam.x,mousey()+editor.cam.y local tx,ty=mx>>3,my>>3 local rx,ry=tx<<3,ty<<3 rect(rx-1, ry-1, rx+8, ry+8, 10) camera(0,0) if not editor.paused then if mbtn(1) then mset(tx,ty,editor.selected_tile) end if btnp(KEY_RIGHT) then editor.cam.x=editor.cam.x+8 end if btnp(KEY_LEFT) then editor.cam.x=editor.cam.x-8 end if btnp(KEY_UP) then editor.cam.y=editor.cam.y-8 end if btnp(KEY_DOWN) then editor.cam.y=editor.cam.y+8 end if btnp(KEY_F) then editor.floodfill(tx,ty,editor.selected_tile) end if btnp(KEY_RETURN) then editor.selected_tile=mget(tx,ty) end if btnp(KEY_ESCAPE) then editor.paused=true editor.show_menu() end if btnp(KEY_TAB) then update=editor.update_tileset end end end, update_tileset=function() cls() sspr(0,0,128,128,0,0) local mx,my=mousex(),mousey() local tx,ty=mx>>3,my>>3 local rx,ry=tx<<3,ty<<3 rect(rx-1, ry-1, rx+8, ry+8, 10) if btnp(KEY_TAB) or btnp(KEY_ESCAPE) then update=editor.update end if mbtnp(1) then if tx<16 and ty<16 then editor.selected_tile=ty*16+tx end update=editor.update end end, new=function() mapa.new(128,128) editor.paused=false end, save=function(filename) mapa.save(filename) editor.paused=false end, load=function(filename) mapa.load(filename) editor.paused=false end }