Author Topic: Lua code optimizer for pc  (Read 11913 times)

0 Members and 1 Guest are viewing this topic.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Lua code optimizer for pc
« Reply #15 on: January 06, 2012, 04:43:33 am »
Yes, that should do :)

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: Lua code optimizer for pc
« Reply #16 on: January 06, 2012, 04:47:45 am »
thanks, changed it :)

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Lua code optimizer for pc
« Reply #17 on: January 06, 2012, 04:52:26 am »
This is a bit more trickier, but it should work too.
Escape sequences like "\012" or "\002" don't need the 0's too. But of course you must be sure they aren't followed by a normal character.
I suppose you might need some regular expressions for this.

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: Lua code optimizer for pc
« Reply #18 on: January 06, 2012, 04:55:24 am »
hmm, that's indeed a bit tricky xp

but i'll try it

are there any other optimizations in the code itself?
what is the default setting for text-align? since that default can be removed too..

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Lua code optimizer for pc
« Reply #19 on: January 06, 2012, 04:56:38 am »
Don't remove it, you need it for compatibility in newer versions AFAIK.

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: Lua code optimizer for pc
« Reply #20 on: January 11, 2012, 01:36:23 pm »
UPDATE!!!

include external .lua files by using %, followed by the name of the file (without the .lua)

example main file:
Code: [Select]
function on.create()
%varsinit
end


varsinit.lua file:
Code: [Select]
menu = true
game = false
highscore = (var.recall("HS")  or 0)
score = 0

results in:
Code: [Select]
function on.create()
menu = true
game = false
highscore = (var.recall("HS")  or 0)
score = 0
end
« Last Edit: January 11, 2012, 03:21:54 pm by Nick »

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Lua code optimizer for pc
« Reply #21 on: January 11, 2012, 02:23:25 pm »
UPDATE!!!

include external .lua files by using #, followed by the name of the file (without the .lua)

example main file:
Code: [Select]
function on.create()
#varsinit
end


What ??

#varsinit returns the number of elements in the "varsinit" table ...
You've overriden the metatables ?
« Last Edit: January 11, 2012, 05:01:35 pm by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: Lua code optimizer for pc
« Reply #22 on: January 11, 2012, 02:26:24 pm »
oh, forgot about that.. thanks for reminding me Ö i feel quite ashamed right now for not having thought of it myself  :-[


i changed it to %<filename>

i hope this isn't a problem?
« Last Edit: January 11, 2012, 03:47:48 pm by Nick »

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Lua code optimizer for pc
« Reply #23 on: January 11, 2012, 03:53:48 pm »
You should make that it only works in the beginning of the file, since % is used for modulus and stuff.
But nice idea anyway.

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: Lua code optimizer for pc
« Reply #24 on: January 11, 2012, 03:57:14 pm »
nah, i want to make it work through the whole file, since it might be useful to make whole parts in different files, and then paste them together.
i did not only do it to include initializations, but for functions and other stuff too

so maybe §<filename> ? i guess that's not used?

and just to be clear, it only adapts those who are at the total left border of the page, it does not change the ones that are in formulas or so..
« Last Edit: January 11, 2012, 03:58:57 pm by Nick »

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Lua code optimizer for pc
« Reply #25 on: January 11, 2012, 06:22:01 pm »
I don't have that wierd S-like symbol on my keyboard, and I have no clue what it means :P

Is it some foreign (to me :P) currency?

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: Lua code optimizer for pc
« Reply #26 on: January 12, 2012, 01:02:43 am »
no, it's  a paragraph sign.. well, if you don't have it, then i won't take it, maybe & or @ ?

aaargh, i really need to find a symbol for it :)

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: Lua code optimizer for pc
« Reply #27 on: January 12, 2012, 11:16:17 am »
UPDATE!!

now it saves settings to an external file, possible settings:
  • Optimize the file (get rid of comments, whitespaces etc)
  • include the needed files
  • save made file automatically with adaptable suffix
  • suffix for the savename, changes to optimized if nothing
  • copy file to clipboard, i don't really see the point of it yet, but it might be useful (?)

Possibilities for include file:
  • %
  • &
  • ~
  • @
  • °
  • £
  • µ

in fact, i like the second one the most, maybe that one?

the lay-out of the program itself changed too, but not that much to upload a new screenie

this is the settings pop-up screen:
« Last Edit: January 12, 2012, 11:18:26 am by Nick »

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Lua code optimizer for pc
« Reply #28 on: January 13, 2012, 09:43:37 pm »
UPDATE!!!

include external .lua files by using #, followed by the name of the file (without the .lua)

example main file:
Code: [Select]
function on.create()
#varsinit
end


What ??

#varsinit returns the number of elements in the "varsinit" table ...
You've overriden the metatables ?

Does that mean
table={1,2,3,4,5,6,7,8,9}
x=#table
And x would equal 9?
That would be useful to use :P
« Last Edit: January 13, 2012, 09:43:56 pm by epic7 »

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: Lua code optimizer for pc
« Reply #29 on: January 14, 2012, 04:46:55 pm »
yeah, that means that :)
« Last Edit: January 14, 2012, 04:47:02 pm by Nick »