Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --CraftyTurtle
- function empty()
- print ("Program terminated, emptying slots.")
- for i = 1, 12, 1 do
- turtle.select(i)
- turtle.dropDown()
- end --for end
- turtle.select(16)
- turtle.dropUp()
- print ("Turtle is empty. Thanx for using CraftyTurtle. See you soon.")
- b = b+1
- end --function end
- function fill() --fill inventory with contents
- print("starting function fill")
- print ("Creating table.")
- slotTable = {"y","y","y","n","n","y","n","n","y","y","y","c"} --create table of the slots to be used and not in the turtles inventory. When it comes to "c" (close) program part should terminate.
- print ("Table created")
- print("Testing table")
- for i=1, 12, 1 do
- print(slotTable[i])
- print("This was slotTable")
- end
- local x = 1
- print("after local x")
- while x == 1 do
- print("Inside while x == 1")
- while turtle.suckDown do --as long as there is materials in chest below
- print("Inside while suckDown")
- for i = 1, 12, 1 do --go through slots 1 to 12
- print(i)
- turtle.select(i)
- if slotTable[i] == y then --look in tablearray
- turtle.suckDown() --fill the slot
- elseif slotTable[i] == n then --if this returns n it means slot should stay empty
- print ("This slot is not in use.")
- elseif slotTable[i] == c then --if this returns c the function shall close
- print("All slots full!")
- x = x+1 --this closes the function
- else
- end --if-elseif-end
- end --for-loop end
- end --while end
- end --while end
- end --function end
- function make()
- print("starting function make")
- local x = 1
- while x == 1 do
- while turtle.dropUp() == true do --if there is space left in chest
- turtle.select(16) --select slot 16
- if turtle.getItemCount() == 0 then --if slot 16 in empty
- turtle.craft() --make things with the materials in the slots filled
- turtle.dropUp() --put things in chest above
- print ("Tillverkade en stack")
- elseif turtle.dropUp ~= false then --if chest above has space left
- turtle.dropUp() --empty slot 16 to chest
- turtle.craft() --make the things
- turtle.dropUp() --put things in chest above
- print ("Tillverkade en stack")
- --terminates the function
- else
- print ("Målkista är full!!!!") --if chest is full it will be prompted. If the chest becomes full during work (as in not full before function starts), I assume both prints would be done (this and the one below)?
- a = 3
- end --if-elseif end
- end --while end
- print ("Målkistan är full!") --if turtle.dropUp returns false chest is full and player will be prompted this
- x = x+1
- end --while end
- end --function end
- function wait()
- print("starting wait")
- local x = 1
- while x == 1 do
- if a == 2 then
- while not turtle.suckDown() do --while there are no materials in chest
- print ("Väntar på material.....") --print waiting for mats..
- end --while end
- elseif a == 3 then
- while not turtle.dropUp() do --I assume this means that as long as chest above is full 'turtle.dropUp' will return false?
- print ("Chest full. Waiting for user to empty it.")
- end --while end
- else
- print ("a was neither 2 nor 3...")
- end --if-elseif end
- end --while end
- end --function end
- --main program
- print ("Welcome to CraftyTurtle.")
- print("Place a chest under and above the turtle.")
- print("This program will terminate when chest below is empty.")
- a = 1
- b = 1
- d= 1
- while b == 1 do
- while d == 1 do
- while turtle.suckDown() do --Would this be the same as 'while turtle.suckDown == true do'?
- print("inside first while loop")
- while turtle.dropUp() do --while there is materials in chest below And if there is space in chest on top
- print ("ready to work.")
- fill()
- make()
- end --while end
- print ("Top chest full. Terminating")
- end --while end
- d = d +1
- end --while d end
- empty()
- end --while b end
Advertisement
Add Comment
Please, Sign In to add comment