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

(Question)Unable to get my platform program to work.

Started by Vliekkie, 27 March 2012 - 03:04 PM
Vliekkie #1
Posted 27 March 2012 - 05:04 PM
So.. I tried to create a program that builds me a platform a a ratio of 2:1
its not working.. can anyone take a peek and check if something is wrong?

term.clear()
term.setCursorPos(1,1)
print("Area?")
o=read()

o=b
a=tonumber(o)
b=tonumber(o)/2
x=0
y=0
s=1

while y<b do
y=y+1
  while x<a do
   turtle.forward()
   turtle.placeDown()
      if turtle.getSlotcount()==0 then
	  s=s+1
	  turtle.selectSlot("s")
	  else
    end

q=bit.band(y, 1)


    if q==("1") then

       turtle.turnRight()
       turtle.forward()
       turtle.turnRight()

    elseif q==("0") then


       turtle.turnLeft()
       turtle.forward()
       turtle.turnLeft()

end
end  
Luanub #2
Posted 27 March 2012 - 09:50 PM
For one losts of nasty global vars, i would change them all to local that will never hurt.

The main issue I see with the code is you have these two lines following each other:

o=read()

o=b

Do you want o to = read() or to = b? once this portion of the code has ran o = b and the input from the read() is gone.