Jump to content




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


  • You cannot reply to this topic
5 replies 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 at a ratio of 2:1
its not working.. can anyone take a peek and check if something is wrong?

Spoiler


#2 Vliekkie

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

Posted 27 March 2012 - 04:35 PM

Oh my.. i double posted..i double posted.. how silly
Can a mod just close the twin? plz and TY

#3 kamnxt

  • New Members
  • 80 posts

Posted 27 March 2012 - 04:42 PM

1. Post the error.
2. What is o=b doing?
3. It should be turtle.select(s), not turtle.select("s"). You want to use the variable s, not the string "s".
4. It should be turtle.getItemCount(s), not turtle.getSlotcount().

#4 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 27 March 2012 - 04:55 PM

There's some errors in the code, I added some comments so you can fix them:
term.clear()
term.setCursorPos(1,1)
print("Area?")
o = read()

o = b -- b is nil, now o is nil also, user input lost
a = tonumber(o)
b = tonumber(o) / 2 -- shorter way: b = a / 2
x = 0
y = 0
s = 1

while y < b do -- it could be a for loop: for y = 0, b do
	y = y + 1 -- remove if using for
	while x < a do -- infinite loop, x never changes
		turtle.forward()
		turtle.placeDown()
		if turtle.getSlotcount() == 0 then -- getSlotcount doesn't exists, it's getItemCount
			s = s + 1
			turtle.selectSlot("s") -- "s" is a string, remove the quotes to use the variable
		else -- else what?
		end
		q = bit.band(y, 1)
		if q == ("1") then -- q is a number, "1" is a string, q will never be "1"
			turtle.turnRight()
			turtle.forward()
			turtle.turnRight()
		elseif q == ("0") then -- same as above
			turtle.turnLeft()
			turtle.forward()
			turtle.turnLeft()
		end
	end
-- end missing
You should also try to use local variables when possible:
local n = 10
local o = read()
And try to indent the code to check that all the end's are in the right place.

#5 Vliekkie

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

Posted 27 March 2012 - 05:15 PM

Lol ok i made some adjustments.. (havnt checked the code that mystic T posted yet)
heres the new code
Spoiler

i added a x=x+1 and fixed some errors but now it runs in circles :o/>

EDIT.. haha thx mystic.. mind checking the new one.. i have a feeling one of my ends are totally misplaced

#6 Vliekkie

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

Posted 27 March 2012 - 05:28 PM

aaah i found it.. moved a end .. made it easier for myself by making it a bit easier to read

here it is dunno if it works yet
Spoiler

works great.. i just needed to add a turtle.placeDown() after the turns.

Woot.. time to create a superflat over a survival

ok.. stoped at a empty slot..
figured out turtle.selectSlot(slotNum) us WRONG..
use turtle.select(slotNum)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users