Jump to content




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


  • You cannot reply to this topic
1 reply to this topic

#1 Vliekkie

  • New Members
  • 17 posts
  • Location6 feet under.. the void ^^

Posted 27 March 2012 - 04: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  


#2 Luanub

    Lua Nub

  • Members
  • 1,135 posts
  • LocationPortland OR

Posted 27 March 2012 - 08: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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users