This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Alekso56's profile picture

[LUA] Print doesn't print everything if there's a nil present.

Started by Alekso56, 21 April 2015 - 06:21 PM
Alekso56 #1
Posted 21 April 2015 - 08:21 PM
VERSION:
1.41 to 1.74pr20 (probably earlier too)
DESCRIPTION:
i typed print(1,2,nil,3) and it printed 1 2
EXPECTED RESULT:
1 2 nil 3
REPRODUCTION STEPS:
lua -> print(1,2,nil,3)
FIX:
https://github.com/a...craftLua/pull/1
Edited on 21 April 2015 - 06:23 PM
Dragon53535 #2
Posted 22 April 2015 - 11:22 PM
From Bios.lua

function print( ... )
	local nLinesPrinted = 0
	for n,v in ipairs( { ... } ) do
		nLinesPrinted = nLinesPrinted + write( tostring( v ) )
	end
	nLinesPrinted = nLinesPrinted + write( "\n" )
	return nLinesPrinted
end
ipairs goes from 1 to n as long as every index from 1 to n exists. Since 3 is nil. ({…})[3] doesn't exist. So ipairs will loop for 1 and 2, and stop.
Edited on 22 April 2015 - 09:22 PM
HPWebcamAble #3
Posted 09 February 2016 - 11:49 PM
This was fixed, for anyone wondering in the future (like I was)

https://github.com/dan200/ComputerCraft/issues/78
Lyqyd #4
Posted 10 February 2016 - 12:59 AM
Thanks for letting us know.