Jump to content




Tower Builder V2


  • You cannot reply to this topic
5 replies to this topic

#1 EpicTreeMiner

  • Members
  • 17 posts
  • LocationSouth 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)

Thanks
Luke

Finished code:

Spoiler
PS. 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:

#2 sjele

  • Members
  • 334 posts
  • LocationSomewhere 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

#3 EpicTreeMiner

  • Members
  • 17 posts
  • LocationSouth Africa

Posted 13 January 2013 - 07:54 AM

View Postsjele, on 13 January 2013 - 07:03 AM, said:

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

#4 EpicTreeMiner

  • Members
  • 17 posts
  • LocationSouth Africa

Posted 14 January 2013 - 12:39 AM

Bump, anyone have any intrest?

#5 MrHohenheim

  • Members
  • 26 posts
  • LocationDebrecen

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 by MrHohenheim, 14 January 2013 - 02:01 AM.


#6 pielover88888

  • Members
  • 66 posts
  • LocationIn 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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users