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) :
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 :
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).
Spoiler
if func then
setfenv( func, tEnv )
local tResults = { pcall( function() return func() end ) }
if tResults[1] then
local n = 1
while (tResults[n + 1] ~= nil) or (n <= nForcePrint) do
print( tostring( tResults[n + 1] ) )
n = n + 1
end
else
printError( tResults[2] )
end
else
printError( e )
end
This issue can easily be fixed by searching the greatest key of the table of results before printing them :
Spoiler
if func then
setfenv( func, tEnv )
local tResults = { pcall( function() return func() end ) }
if tResults[1] then
for k,v in pairs(tResults) do
nForcePrint = math.max(nForcePrint, k - 1)
end
for n = 1, nForcePrint do
print( tostring( tResults[n + 1] ) )
end
else
printError( tResults[2] )
end
else
printError( e )
end
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 on 18 December 2013 - 09:25 PM