Posted 23 May 2016 - 04:01 PM
                Full program text, offending/misbehaving/misused code below
The issue Im having is within function buildPlatform(x,y), the if statement
Always behaves as ci and y are not equal, but will print them out as being equal, see below.

I suspect Im misunderstanding about LUA here but Im can't find it on my own.
                
            
function refreshItems()
	for ai=1,16 do
		if turtle.getItemCount(ai)~=0 then
			turtle.select(ai)
			break
		end
	end
end
function placeBlock()
	refreshItems()
	turtle.placeDown()
end
function placeLine(lineNum)
	for bi=1,lineNum do
		if bi~=1 then
			turtle.forward()
		end
		placeBlock()
	end
end
function moveNextRowRight()
	turtle.turnRight()
	turtle.forward()
	turtle.turnRight()
end
function moveNextRowLeft()
	turtle.turnLeft()
	turtle.forward()
	turtle.turnLeft()
end
function buildPlatform(x,y)
	for ci=1,y do
		placeLine(x)
		if ci ~= y then
			print ("ci: "..tostring(ci))
			print ("y: "..tostring(y))
			if ci % 2 == 1 then
				moveNextRowRight()
			else
				moveNextRowLeft()
			end
		end
	end
end
local runtimeArgs = { ... }
intX = runtimeArgs[1]
intY = runtimeArgs[2]
turtle.forward()
buildPlatform(intX,intY)
The issue Im having is within function buildPlatform(x,y), the if statement
		if ci ~= y then
			print ("ci: "..tostring(ci))
			print ("y: "..tostring(y))
			if ci % 2 == 1 then
				moveNextRowRight()
			else
				moveNextRowLeft()
			end
		end
Always behaves as ci and y are not equal, but will print them out as being equal, see below.

I suspect Im misunderstanding about LUA here but Im can't find it on my own.
 
        