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

window:233: bad argument #1 to 'floor' (number expected, got nil)

Started by thewmatt, 21 December 2015 - 11:17 PM
thewmatt #1
Posted 22 December 2015 - 12:17 AM
so what im trying to do is use variables to set and call data within a table and im getting this error. what do i do?
code:

x,y = term.getSize()
z = 5
while z > 0 do
z = z-1
zX[z] = math.random(x)
zY[z] = math.random(y)
end
zr = z
while zr > 0 do
zr = zr-1
term.setCursorPos(zX[zr],zY[zr])
term.setBackgroundColor(colors.green)
print(" ")
end
Edited on 22 December 2015 - 03:53 AM
Lupus590 #2
Posted 22 December 2015 - 12:28 AM
x doesn't have a value

y also doesn't
Edited on 21 December 2015 - 11:29 PM
thewmatt #3
Posted 22 December 2015 - 04:52 AM
x doesn't have a value

y also doesn't
in the full program they do have a value
Bomb Bloke #4
Posted 22 December 2015 - 05:08 AM
Can't see where that error would come from, but:

zr = z           -- z is 0 (because of the loop you just completed), and now zr is 0 too
while zr > 0 do  -- ... meaning this loop isn't going to do much

… so I'm going to go out on a limb and say that you're still not showing us the code you're actually running, which makes it rather difficult to point out what's wrong. Presumably you're somehow attempting to call term.setCursorPos() with an index of zX / zY that you never actually set.