Author Topic: Lua/HTML5 Web Interpreter  (Read 9856 times)

0 Members and 1 Guest are viewing this topic.

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Lua/HTML5 Web Interpreter
« on: February 17, 2013, 09:30:52 pm »
Was bored today, so I made this. It's a Lua interpreter (based on lua.js) with a library that works with a HTML5 canvas. Some functions are implemented and I'm slowly implementing more. At the end, it should support both Nspire Lua and LuaZM graphic functions. (Obviously, suggestions are open :))

Documentation
dofile(url) - Asynchronously executes a remote file. Ex.: Try dofile("http://juju2143.ca/test.lua") :P
gc.drawLine(x1, y1, x2, y2)
gc.drawRect(x, y, w, h)
gc.fillRect(x, y, w, h)
gc.setColorRGB(r, g, b) - Same as their Nspire counterparts
zmg.time()
zmg.ticks() - Same as their LuaZM counterparts

Known issues
- Backspace might not work as expected in some browsers, for some reason.
- dofile() is asynchonous and doesn't lock the terminal while the AJAX thing runs, so print() might print in the input.
- Infinite loops will crash your browser

http://juju2143.ca/lua
« Last Edit: February 18, 2013, 02:50:07 am by Juju »

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7918
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Lua/HTML5 Web Interpreter
« Reply #1 on: February 17, 2013, 10:46:28 pm »
nice so far!
print("THE GAME")

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Spenceboy98

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 547
  • Rating: +59/-2
    • View Profile
Re: Lua/HTML5 Web Interpreter
« Reply #2 on: February 17, 2013, 11:07:47 pm »
You should make it support LuaZM so I can test my programs. :P

It works nicely, but as you said, Backspace doesn't work.

* Spenceboy98 lost.
« Last Edit: February 17, 2013, 11:08:28 pm by Spenceboy98 »
I like milk.

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Lua/HTML5 Web Interpreter
« Reply #3 on: February 17, 2013, 11:18:29 pm »
Backspace works now. Apparently the compacted version of termlib.js is broke, but not the non-compacted version.

And yeah good idea it should also support LuaZM.

EDIT: Every Nspire Lua and LuaZM graphics function are implemented as stubs. Unless I actually implemented them.
« Last Edit: February 17, 2013, 11:44:07 pm by Juju »

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Lua/HTML5 Web Interpreter
« Reply #4 on: February 25, 2013, 01:02:42 pm »
Update bump. Added an editor (type run() in the terminal to run the code, if you add an argument it runs like dofile(file)) and a windowing system. Resizing windows doesn't work though, so don't try.

I guess I could rename this to "Lua/HTML5 Web IDE" as I now aim for an IDE-like functionality, now that I added an editor.
« Last Edit: February 25, 2013, 01:05:04 pm by Juju »

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline DJ Omnimaga

  • Former TI programmer
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55838
  • Rating: +3151/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • DJ Omnimaga Music
Re: Lua/HTML5 Web Interpreter
« Reply #5 on: February 25, 2013, 01:13:25 pm »
This is very interesting. Do you plan much calculator support such as for LuaZM, Nspire Lua and maybe CPLua? Something that would be cool in long terms if you do is the option to develop for the first two at once so it's easier to modify files to port them over the other calc.
In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF



Official Website |T-Shirt store | Reverbnation | Facebook | Youtube | Twitter | Spotify

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Lua/HTML5 Web Interpreter
« Reply #6 on: February 25, 2013, 01:18:45 pm »
I'm aiming for a complete LuaZM simulator with this (as at least 2 people requested), then I could also add Nspire Lua support (with the help of Jim Bauwens). For CPLua, well I wasn't even aware it existed and I have no ClassPad, so I can't really tell. Same for LuaFX, support for it would also be nice.

Oh, I forgot, you can resize the canvas with canvas.mode(mode) or canvas.mode(width, height) where mode is a constant ("nspire", "prizm" or "big").
« Last Edit: February 25, 2013, 01:22:08 pm by Juju »

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Lua/HTML5 Web Interpreter
« Reply #7 on: February 25, 2013, 01:23:18 pm »
Very nice.
I hope you can work with Jim so that it'd be a great all-in-oen tool for Nspire-Lua too.

At one point, can you consider making an API or something so that it can be integrated on other websites (thinking of TI-Planet :P), etc. ?


Also, can you implement by defauls 'class' ? ( http://wiki.inspired-lua.org/class() )
And I've noticed that when there is an error, it doesnt show the line, can you make it do that ?
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Lua/HTML5 Web Interpreter
« Reply #8 on: February 25, 2013, 01:29:38 pm »
Yeah, an integration API will be a pretty good idea.

class can be implemented by default kinda easily (next update?) and AFAIK it actually shows where is the error when there's one. Well, at least on Google Chrome. (What do you mean?)

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Lua/HTML5 Web Interpreter
« Reply #9 on: February 25, 2013, 02:03:25 pm »
Cool :)

I meant that it doesnt show (for me, on Chrome, too), at what line of the text the error is (here, 5) :
« Last Edit: February 25, 2013, 02:03:38 pm by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Lua/HTML5 Web Interpreter
« Reply #10 on: February 25, 2013, 02:13:12 pm »
Ah, yeah, you're right. But it will tell the line number if you made a syntax error (try removing a parenthesis).

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7918
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Lua/HTML5 Web Interpreter
« Reply #11 on: February 25, 2013, 07:04:23 pm »
Mhmm, will you be able to import stuff like luasockets and run IRC bots? XD

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Lua/HTML5 Web Interpreter
« Reply #12 on: February 25, 2013, 08:10:39 pm »
Probably not. I guess.

Also you'll like the new sample preloaded in the editor.
« Last Edit: February 25, 2013, 08:10:55 pm by Juju »

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline DJ Omnimaga

  • Former TI programmer
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55838
  • Rating: +3151/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • DJ Omnimaga Music
Re: Lua/HTML5 Web Interpreter
« Reply #13 on: February 25, 2013, 08:22:00 pm »
Will we see screenshots of game running soon? :P
In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF



Official Website |T-Shirt store | Reverbnation | Facebook | Youtube | Twitter | Spotify

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Lua/HTML5 Web Interpreter
« Reply #14 on: February 25, 2013, 08:34:24 pm »
I guess, yeah. Only clipRect and key* are left to implement in the zmg library, then you'll be able to run all your favorite LuaZM games.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.