Log In  

Cart #plang-0 | 2019-05-10 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

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 | 2019-05-10 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

(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]

Follow Lexaloffle:          
Generated 2024-03-28 19:02:58 | 0.011s | Q:20