Jump to content




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


  • This topic is locked This topic is locked
3 replies to this topic

#1 Alekso56

  • Members
  • 62 posts

Posted 21 April 2015 - 07: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 by Alekso56, 21 April 2015 - 07:23 PM.


#2 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 22 April 2015 - 10: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 by Dragon53535, 22 April 2015 - 10:22 PM.


#3 HPWebcamAble

  • Members
  • 933 posts
  • LocationWeb Development

Posted 09 February 2016 - 11:49 PM

This was fixed, for anyone wondering in the future (like I was)

https://github.com/d...Craft/issues/78

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 10 February 2016 - 12:59 AM

Thanks for letting us know.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users