Log In  

Cart [#plang-0#] | Code | 2019-05-10 | License: CC4-BY-NC-SA | Embed
2

Implementation of lox language (see this awesome book to learn more about it) in PICO-8.

Try typing basic commands like:

rectfill(32, 32, 58, 58, 9)
print("hello", 10, 10, 8)

For more syntax reffer to this page. I dont think I've implemented OOP, tho.

Runs a basic AST-walker, so it might be slow, but I got some simple PICO-8 carts running, like this one:

Cart [#planghello-0#] | Code | 2019-05-10 | License: CC4-BY-NC-SA | Embed
2

(see the source code)

P#64285 2019-05-10 09:07

This is cool! A problem I noticed is that when in splore escape won't pause. This can be fixed by changing your _update() function to

function _update()
 t+=1
 if stat(30) then
  t=0
  local c=stat(31)
  if c=="\b" then
   if(#input>0) input=sub(input,1,#input-1)
  elseif c=="\r" then
   poke(0x5f30, 1)
   local x,y=cget()
   rectfill(0,y-1,#input*4+16,y+5,0)
   print(": "..input,x,y,6)
   local i=input
   input=""
   print("")
   color(7)
   ext(i)
  else
   if (c=="p") poke(0x5f30, 1)
   input=input..c
  end
 end
end

So that the pause suppression only happens when you press enter or p.

EDIT: you might also want to prevent people from typing double wide characters, they don't get erased properly.

P#66690 2019-08-15 04:00 ( Edited 2019-08-15 04:07)

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-08-17 23:51 | 0.068s | 4194k | Q:40