Jump to content




lua prompt correction (for results like "sthing, nil, sthing")


4 replies to this topic

#1 aaa

  • Members
  • 53 posts

Posted 18 December 2013 - 10:25 PM

Using the lua prompt, when we expect a result like 3,nil,a, the prompt only displays 3. This happen for example when receiving an empty message throught rednet, or simply typing '3,nil,"a"' using the prompt. This occurs because once the results of the code are computed, they are printed one after the other until the first nil result, wich is supposed to be the end of the table of results (but not necessarily is) :

Spoiler
part of the code found in the rom


This issue can easily be fixed by searching the greatest key of the table of results before printing them :
Spoiler

I'm not sure I noticed it in the good place, but, IMO, this is a misfunctionnement of the lua prompt and I suggest to fix this default program (as a default program, not by any user rewriting it like I did).

Edited by aaa, 18 December 2013 - 10:25 PM.


#2 Alice

  • Members
  • 429 posts
  • LocationBehind you.

Posted 18 December 2013 - 11:45 PM

Copy the program into a folder, edit it yourself.
If you can do it in Lua, then why do it in Java?
It's not that hard, what, 9/10 lines of code you must edit?

Edited by Death, 18 December 2013 - 11:45 PM.


#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 18 December 2013 - 11:56 PM

He's not suggesting ANYTHING be done in Java. He's suggesting that the alteration he's already made be applied to the "official" version of the script.

Anyway, aaa, it may interest you to know that table.maxn(sometable) reliably returns the highest index in a regular numerically indexed table.

#4 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 21 December 2013 - 07:21 PM

View PostDeath, on 18 December 2013 - 11:45 PM, said:

Copy the program into a folder, edit it yourself.
If you can do it in Lua, then why do it in Java?
It's not that hard, what, 9/10 lines of code you must edit?
I feel like this counts as a bug in a default CC program, and if that's the case, it should be fixed accordingly.

Edited by Kingdaro, 21 December 2013 - 07:21 PM.


#5 aaa

  • Members
  • 53 posts

Posted 25 December 2013 - 05:37 PM

View PostKingdaro, on 21 December 2013 - 07:21 PM, said:

I feel like this counts as a bug in a default CC program, and if that's the case, it should be fixed accordingly.

Right, I agree. I did not want to waste time of admins for minor problems (they pay more attention for the bugs' section), but it looks like a bug, though minor. I may try my luck in the proper section.

@Bomb Block. Thx for explaining my thought. As a non native speaker, I may be confusing. thx for table.maxn too, I did not know this function (I only knew #<table> / table.getn).

Edited by aaa, 25 December 2013 - 05:38 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users