17 posts
Location
South Africa
Posted 13 January 2013 - 06:44 AM
I recently finished the code for a tower builder program. It builds a full circle with a 10 block diameter and then moves up and loops, im working on the setting for a glass block row every 6 rows.It has about 80 lines of code and you define the height of the tower in the program. It even builds a ladder up the inside edge (in development still)ThanksLukeFinished code:Spoiler
print("Build tower how high?") local x = tonumber( read() )term.clear()– slotCheck NEEDS cleaning up, help?function slotCheck()if turtle.getItemCount(1) <2 thenif turtle.getItemCount(2) <2 thenif turtle.getItemCount(3) <2 thenif turtle.getItemCount(4) <2 thenif turtle.getItemCount(5) <2 thenif turtle.getItemCount(6) <2 thenif turtle.getItemCount(7) <2 thenif turtle.getItemCount(8) <2 thenif turtle.getItemCount(9) <2 thenprint("Add Items…")endendendendendendendendendendfor o = 1,(x) doslotCheck()elsefor i = 1,4 doturtle.placeDown()turtle.forward()turtle.placeDown()turtle.turnRight()turtle.forward()turtle.turnLeft()turtle.forward()turtle.placeDown()turtle.forward()turtle.placeDown()turtle.forward()turtle.turnRight()turtle.forward()turtle.placeDown()turtle.forward()turtle.placeDown()turtle.turnLeft()turtle.forward()turtle.turnRight()turtle.forward()turtle.placeDown()turtle.forward()turtle.placeDown()turtle.forward()endturtle.up()endendPS. I have only been using lua for 2 days now, thats why this is such a simple program.http://pastebin.com/n4t0wFMV (Code Link) :lol:/>
318 posts
Location
Somewhere on the planet called earth
Posted 13 January 2013 - 07:03 AM
slotCheck = function()
needFill = {} --Slots that needs something to fill them with
slots = ""
for i = 1, 9 do --Looping through the slots
if turtle.getItemCount(i) <= 1 then
table.insert(needFill, #needFill+1, i)
end
end
for loc = 1, #needFill do
slots = slots.." , "..tonumber(needFill[loc])
end
print("The slots: "..slots.." needs items in them")
end
This should clean up your slotCheck function a bit.
If you have 1 or less item in slots 1, 4 and 5 it should say:
The slots: 1, 4, 5 , needs items in them
17 posts
Location
South Africa
Posted 13 January 2013 - 07:54 AM
slotCheck = function()
needFill = {} --Slots that needs something to fill them with
slots = ""
for i = 1, 9 do --Looping through the slots
if turtle.getItemCount(i) <= 1 then
table.insert(needFill, #needFill+1, i)
end
end
for loc = 1, #needFill do
slots = slots.." , "..tonumber(needFill[loc])
end
print("The slots: "..slots.." needs items in them")
end
This should clean up your slotCheck function a bit.
If you have 1 or less item in slots 1, 4 and 5 it should say:
The slots: 1, 4, 5 , needs items in them
I actually thought about doing that, but considering you only use one block type for the tower (hopefully), when you run out of blocks in slot 1, it automatically takes from slot 2, etc, so in the end if it needs blocks, it needs them in ALL slots. :)/> but nice code and feel free to add it and improve it
17 posts
Location
South Africa
Posted 14 January 2013 - 12:39 AM
Bump, anyone have any intrest?
26 posts
Location
Debrecen
Posted 14 January 2013 - 01:55 AM
i testing now
not working pastebin get n4t0wFMV 1
bios:338: [string "1"]:27: 'end'
expected (to close 'for' at line 25)
Edited on 14 January 2013 - 01:01 AM
63 posts
Location
In a library that's in a village, huddling my advanced computer as zombies bang on the door.
Posted 14 January 2013 - 10:13 AM
Goodness, PLEASE, use spoilers or a pastebin link, instead of having the code in the post, as it get's long lol. Otherwise, that seems pretty cool.