Author Topic: Loading Lua code dynamically for fun and profit (on-calc Lua editor)  (Read 14368 times)

0 Members and 2 Guests are viewing this topic.

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: Loading Lua code dynamically for fun and profit (on-calc Lua editor)
« Reply #15 on: July 05, 2011, 02:01:35 pm »
I love you.
This was the only which lacked to the TI-Nspire

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Loading Lua code dynamically for fun and profit (on-calc Lua editor)
« Reply #16 on: July 06, 2011, 01:03:59 pm »
Darn this is epic ExtendeD. A lot of people liked to program on-calc when they did 83+ stuff. I bet this will be appreciated by many Nspire owners too. O.O

Offline BrownyTCat

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 420
  • Rating: +37/-8
    • View Profile
Re: Loading Lua code dynamically for fun and profit (on-calc Lua editor)
« Reply #17 on: July 06, 2011, 05:54:57 pm »
I hope if ndless 3 comes out we can have a robust editor with a compiler.

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: Loading Lua code dynamically for fun and profit (on-calc Lua editor)
« Reply #18 on: July 06, 2011, 08:03:37 pm »
with a compiler.

A what ? for Lua ?
« Last Edit: July 06, 2011, 08:04:26 pm by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: Loading Lua code dynamically for fun and profit (on-calc Lua editor)
« Reply #19 on: July 07, 2011, 10:08:11 am »
Even if it's not a compiler, it looks like one...
How should we call that ? an "encryptor" ?

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: Loading Lua code dynamically for fun and profit (on-calc Lua editor)
« Reply #20 on: July 07, 2011, 11:17:41 am »
Even if it's not a compiler, it looks like one...
How should we call that ? an "encryptor" ?
Well .. a shell ?
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Loading Lua code dynamically for fun and profit (on-calc Lua editor)
« Reply #21 on: July 07, 2011, 11:20:38 am »
I think he means that if Ndless 3 comes it'd be good to have an on-calc text editor with a LUA>TNS Converter. Keep it simple :)

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: Loading Lua code dynamically for fun and profit (on-calc Lua editor)
« Reply #22 on: July 07, 2011, 11:25:37 am »
I was talking of the tool which produces TNS files from LUA code.
I don't really know what a shell is, but I think it's something different. (The interpretor is a shell, isn't it ?)
« Last Edit: July 07, 2011, 11:27:13 am by Chockosta »

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: Loading Lua code dynamically for fun and profit (on-calc Lua editor)
« Reply #23 on: July 07, 2011, 11:48:59 am »
I think he means that if Ndless 3 comes it'd be good to have an on-calc text editor with a LUA>TNS Converter. Keep it simple :)
^this
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Loading Lua code dynamically for fun and profit (on-calc Lua editor)
« Reply #24 on: September 29, 2012, 10:24:37 am »
Huge up, sorry :/

I'm having trouble with OCLua : why can't I use a for loop which runs more than 128 times ?

This code brings the calc into an infinite loop :
Code: [Select]
for i = 0, 128 do
end
And this works fine :
Code: [Select]
for i = 0, 127 do
end

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Loading Lua code dynamically for fun and profit (on-calc Lua editor)
« Reply #25 on: September 29, 2012, 10:35:13 am »
I haven't tried your code, but I assume you put that in on.paint .
Probably what is happening is that on.paint get's called again (sometimes it does this when execution time is a bit too long), causing it too loop constantly.
But that's just a theory.

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Loading Lua code dynamically for fun and profit (on-calc Lua editor)
« Reply #26 on: September 29, 2012, 10:51:49 am »
Huge up, sorry :/

I'm having trouble with OCLua : why can't I use a for loop which runs more than 128 times ?

This code brings the calc into an infinite loop :
Code: [Select]
for i = 0, 128 do
end
And this works fine :
Code: [Select]
for i = 0, 127 do
end


Could you post more of the code ?

Also, I'm not sure about Jim's theory - well I haven't found myself in such case before. but maybe with timers and stuff it may happen... weird though...
« Last Edit: September 29, 2012, 10:53:28 am by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Loading Lua code dynamically for fun and profit (on-calc Lua editor)
« Reply #27 on: September 29, 2012, 11:30:53 am »
Here is the code which doesn't work for me.

In fact, once I try the code I just posted, it works ??? but just try the one I joined (it's the page 3).

Also, do you know a way to get text from a *.tns ?
« Last Edit: September 29, 2012, 11:31:31 am by Matrefeytontias »

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Loading Lua code dynamically for fun and profit (on-calc Lua editor)
« Reply #28 on: September 29, 2012, 11:56:50 am »
Copying and pasting some text might work, as would accessing TI-BASIC variables... but without external help, TI's proprietary Lua, which does not have io.* and os.* functions (i.e., among other limitations and incompatibilities with standard Lua, no external file access) cannot get text from a .tns.
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Loading Lua code dynamically for fun and profit (on-calc Lua editor)
« Reply #29 on: September 29, 2012, 12:13:47 pm »
Copying and pasting some text might work, as would accessing TI-BASIC variables... but without external help, TI's proprietary Lua, which does not have io.* and os.* functions (i.e., among other limitations and incompatibilities with standard Lua, no external file access) cannot get text from a .tns.
I believe he's talking about the OcLua's text in page 2 which is a Notes page. So not-related with TI's Nspire-Lua. But still, it's a closed format.

The "only" easy way is to open it with the computer software. Then copy/paste it wherever you want it.


Anyway, about your script : no problems for me for any of your codes...
(Also, remember to put the least possible code (only the final graphics/screen drawing -related things) in the paint method since it's going to get called quite often and you don't want it to slow the rest :)
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation