Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AppVersion = 3.0
- AppName = "TurtleControll"
- Slot = 1
- cc = 1
- paramAlt = 0
- SettingPlace = 'TurtleControll.data'
- Names4App = {"TC","tc","Controller","turtleer","TurtleCommander","upd8r","u8"}
- Apps4Apps = {0,0,0,0,0,'upd8r.lua','upd8r.lua'}
- CTRLMode = false
- Rednet = false
- if term.isColor() == true then
- term.setBackgroundColor(colors.blue)
- end
- if fs.exists(SettingPlace) == true then
- loadSettings()
- else
- Settings = {["Lable"] = 1}
- end
- turtle.select(Slot)
- TurtleID = Settings["Lable"]
- if TurtleID == 1 then
- turtleN = os.getComputerID()
- elseif TurtleID == 2 then
- turtleN = os.getComputerLabel()
- else
- turtleN = 'turtle'
- end
- function saveSettings()
- file = fs.open(SettingPlace,"w")
- file.write(textutils.serialize(Settings))
- file.close()
- end
- function loadSettings()
- file = fs.open(SettingPlace,"r")
- Settings = textutils.unserialize(file.readAll())
- file.close()
- end
- function rednet()
- while true do
- input = nil
- rednet.open("right")
- local id,message = rednet.receive()
- local input = textutils.unserialize(message)
- if input["checksum"] == AppName then
- if input["mode"] == "key" then
- doNr(input["do"])
- elseif input["mode"] == "terminal" then
- terminal(input["do"])
- end
- else
- rednet()
- end
- end
- end
- function makeColor(qwert,trewq)
- if term.isColor() == true then
- if qwert == nil then
- qwert = colors.white
- end
- term.setTextColor(qwert)
- if trewq ~= nil then
- term.setBackgroundColor(trewq)
- end
- end
- end
- function settings()
- term.clear()
- term.setCursorPos(1,1)
- print("The Setting Area are still on developing")
- print()
- print("1 = Name of turtle in Terminal =>", TurtleID)
- print()
- print() -- 5
- print()
- print()
- print()
- print()
- print("e|Exit = exit Settings")
- write("Edit Point = ") --19
- point = read()
- if point == '1' then
- term.clear()
- term.setCursorPos(1,1)
- print("Name of the Turtle in terminal +top +run")
- print("0 = turtle")
- print("1 = ID (",os.getComputerID(),")")
- print("2 = Label (",os.getComputerLabel(),")")
- print()
- print("e = exit settings")
- write("Set to =>") setto = read()
- if setto == 'e' then
- --NIL
- else
- Settings['Lable'] = setto
- saveSettings()
- settings()
- end
- else end
- end
- function input(pPre)
- if pPre == nil then
- tInput = nil
- tInput = {}
- else
- tInput = pPre
- end
- local inputString = read()
- for match in string.gmatch(inputString, "(%S+)") do
- table.insert(tInput, match)
- end
- return tInput
- end
- function install()
- a = fs.open("startup","w")
- strings = 'shell.setAlias('
- for i=1,#Names4App do
- x = Names4App[i]
- y = Apps4Apps[i]
- if y == 0 then
- y = 'TurtleControll.lua'
- end
- a.writeLine(strings..'"'..x..'","'..y..'")')
- end
- a.close()
- dev()
- print("installed!")
- end
- function tfBack(Input)
- if Input == "true" or Input == "t" or Input == "1" then
- return true
- elseif Input == "false" or Input == "f" or Input == "0" then
- return false
- else print("Try true or false")
- local qwas = read()
- tfBack(qwas)
- end
- end
- function doNr(param)
- if(param == 200) then turtle.forward() dev() if turtle.detect() then print("Detecting something") end print("Forward") --up
- elseif (param == 208) then turtle.back() dev() print("Backward") --down
- elseif (param == 203) then turtle.turnLeft() dev() print("Turn Left") --left
- elseif (param == 205) then turtle.turnRight() dev() print("Turn Right") --right
- elseif (param == 2) then turtle.place() dev() print("Place Block") --1
- elseif (param == 3) then turtle.dig() dev() print("Dig") --2
- elseif (param == 4) then turtle.attack() dev() print("Attack") --3
- elseif (param == 5) then turtle.craft() dev() print("Craft") --4
- elseif (param == 6) then turtle.drop() dev() print("Drop Items") --5
- elseif (param == 7) then turtle.suck() dev() print("Suck Items") --6
- elseif (param == 8) then turtle.digUp() dev() print("Dig up") --7
- elseif (param == 9) then turtle.digDown() dev() print("Dig Down") --8
- elseif (param == 10) then microTerminal("get") dev() --9
- elseif (param == 11) then microTerminal("put") dev() --0
- elseif (param == 25) then dev() fell(false) --p
- elseif (param == 24) then fell(true) --o
- elseif (param == 23) then --i ist leer
- elseif (param == 25 or param == 157) then if CTRLMode == true then CTRLMode = false dev() else CTRLMode = true dev() end --CTRL L
- elseif (param == 17) then if CTRLMode == true then detect(2) else turtle.up() dev() if turtle.detectUp() then print("Detecting something") end end print("Up") --w
- elseif (param == 31) then if CTRLMode == true then detect(3) else turtle.down() dev() if turtle.detectDown() then print("Detecting something") end end print("Down") --s
- elseif (param == 16) then turtle.placeUp() dev() print("Place Block Up") --q
- elseif (param == 35) then help() --h
- elseif (param == 22) then update() --u
- elseif (param == 48) then microTerminal("BlockPlacer") --b
- elseif (param == 49) then microTerminal("BlockPlacer") --n
- elseif (param == 38) then microTerminal("ladder") --l
- elseif (param == 33) then microTerminal("field") --f
- elseif (param == keys.r) then makeColor(colors.red) write("App@",turtleN," > ") makeColor() run = read() shell.run(run) dev()--r
- elseif (param == keys.e) then shell.exit() --e
- elseif (param == keys.v) then microTerminal("BlockRemover") dev()
- elseif (param == keys.y) then drop() --y
- elseif (param == keys.x) then suck() --X
- elseif (param == 30) then turtle.placeDown() dev()print("Place Block Down") --a
- elseif (param == 20) then terminal() --t
- elseif (param == keys.d) then write("Go forward to detect") detect(1)
- elseif (param == keys.enter) then turtle.dig() dev() print("Dig") --enter
- elseif (param == 52) then
- if Slot >= 16 then
- dev() print("No more Slots left") --.
- else
- Slot=Slot+1 turtle.select(Slot) dev() print("Now using slot ", Slot) --.
- end
- elseif (param == 51) then if Slot <= 1 then dev() print("No more slots left") --,
- else Slot=Slot-1 dev() turtle.select(Slot) print("Now using slot " ..Slot) end
- end
- end
- function Main()
- while true do
- local sEvent, param = os.pullEvent("key")
- if(sEvent == "key") then
- if paramAlt == param then
- cc = cc+1
- print(cc," times")
- else
- if cc ~= 1 then
- cc = 1
- end
- end
- paramAlt = param+0
- doNr(param)
- end
- end
- end
- function dev()
- term.clear()
- term.setCursorPos(1,1)
- makeColor()
- print(AppName," AppVersion: ",AppVersion)
- print("Releash ",TimeRel)
- print("action@",turtleN)
- if (CTRLMode == true) then
- makeColor(colors.red)
- print("Detect Mode")
- makeColor()
- else
- makeColor(colors.green)
- print("Normal Mode")
- makeColor()
- end
- end
- function terminalerr(pError,pZw)
- local errors = {
- ["home"] = "home <x> <y> <z>",
- ["goTo"] = "goTo <xTo> <yTo> <zTo> <xNow> <yNow> <zNow>",
- ["rail"] = "rail <lenght> (0 for flat ground) (0 for skipt info)",
- ["gpAlias"] = "gpAlias <Name> <Side = 1|2|3> <ChestNr>",
- ["get"] = "get <Side = 1|2|3> <ChestNr> (<Slot>)",
- ["put"] = "put <Side = 1|2|3> <ChestNr> (<Slot>)",
- ["plant"] = "plant <lenght> <Slot Tree> <Slot Dirt|false>",
- ["fell"] = "fell <lenght>",
- ["SuperMiner"] = "SuperMiner <Dest> (<trochslot or 0>) (<false>)",
- ["buildChest"] = "buildChest <high>",
- ["field"] = "field <lenght> <drop slot 1[true|false]>",
- ["ladder"] = "ladder <deep> <[Number|detect|Slot]> <come back [true|false]",
- ["BlockRemover"] = "BlockRemover <forward> <right> <down>",
- ["BlockPlacer"] = "BlockPlacer <forward> <right> <up>",
- ["MultiField"] = "MultiField <Fields> <Length of field> <Plant [true|false]",
- }
- makeColor(colors.red)
- print(errors[pError])
- if pZw == nil then
- makeColor()
- write(pError.." ")
- local temp = input()
- terminal(temp)
- end
- end
- function microTerminal(pOne)
- print("Need more information")
- terminalerr(pOne,0)
- write(pOne.." ")
- terminal(input({pOne}))
- end
- function terminal(preset)
- if preset == nil or preset[1] ~= "more" then
- term.clear()
- term.setCursorPos(1,1)
- write("TurtleControll Terminal")
- term.setCursorPos(1,2)
- makeColor(colors.red)
- write("terminal@",turtleN," > ")
- makeColor()
- end
- if preset == nil then
- local tInput = input()
- else
- local tInput = preset
- end
- if tInput[2] == "d" then
- tInput[2] = "detect"
- end
- if tInput[1] == 'more' then
- cl()
- write(tInput[2])
- input({tInput[2]})
- end
- if (tInput[1] == "forward" or tInput[1] == "f") then
- if (tInput[2] == "detect") then
- if (tInput[3] ~= nil) then
- detect(1,tonumber(tInput[3]))
- else
- detect(1)
- end
- else
- a = tonumber(tInput[2])
- while a > 0 do
- dev(true)
- print(a," left")
- turtle.forward() a = a-1
- end
- dev(true)
- print("Finish")
- end
- elseif (tInput[1] == "up" or tInput[1] == "u") then
- if (tInput[2] == "detect") then
- if (tInput[3] ~= nil) then
- detect(2,tonumber(tInput[3]))
- else
- detect(2)
- end
- else
- a = tonumber(tInput[2])
- while a > 0 do
- dev(true)
- print(a," left")
- turtle.up() a = a-1
- end
- dev(true)
- print("Finish")
- end
- elseif (tInput[1] == "down" or tInput[1] == "d") then
- if (tInput[2] == "detect") then
- if (tInput[3] ~= nil) then
- detect(3,tonumber(tInput[3]))
- else
- detect(3)
- end
- else
- a = tonumber(tInput[2])
- while a > 0 do
- dev(true)
- print(a," left")
- turtle.down() a = a-1
- end
- dev(true)
- print("Finish")
- end
- elseif (tInput[1] == "back" or tInput[1] == "b") then a = tonumber(tInput[2])
- while a > 0 do turtle.back() a = a-1 end
- elseif (tInput[1] == "BlockRemover") then
- if tInput[2] == nil or tInput[3] == nil or tInput[4] == nil then
- terminalerr(BlockRemover)
- else
- BlockRemover.Start(tInput[2],tInput[3],tInput[4])
- end
- elseif (tInput[1] == "BlockPlacer") then
- if tInput[2] == nil or tInput[3] == nil or tInput[4] == nil then
- terminalerr(BlockPlacer)
- else
- BlockPlacer.Start(tInput[2],tInput[3],tInput[4])
- end
- elseif (tInput[1] == 'home') then
- if (tInput[2] == nil or tInput[3] == nil or tInput[4] == nil) then
- terminalerr("home")
- else
- shell.run('Haus.lua '..tInput[2]..' '..tInput[3]..' '..tInput[4])
- end
- elseif (tInput[1] == 'goTo' or tInput[1] == 'go') then
- if (tInput[2] == nil or tInput[3] == nil or tInput[4] == nil or tInput[5] == nil or tInput[6] == nil or tInput[7] == nil) then
- terminalerr("goTo")
- else
- goTo(tInput[2],tInput[3],tInput[4],tInput[5],tInput[6],tInput[7])
- end
- elseif (tInput[1] == "app" or tInput[1] == "run" ) then shell.run(tInput[2])
- elseif (tInput[1] == "train" or tInput[1] == "rail") then
- if tInput[2] == nil then
- terminalerr("rail")
- else
- Train.start(tInput[2],tInput[3],tInput[4])
- end
- elseif (tInput[1] == "help") then help()
- elseif (tInput[1] == "drop") then
- if (tInput[2] ~= nil) then
- drop(tonumber(tInput[2]))
- else
- drop()
- end
- elseif tInput[1] == "gpAlias" then
- if (tInput[2] == nil or tInput[3] == nil or tInput[4]) then
- terminalerr("gpAlias")
- else
- Settings["ChestSide"..tInput[2]] = tInput[3]
- Settings["ChestNr"..tInput[2]] = tInput[4]
- saveSettings()
- end
- elseif tInput[1] == "get" then
- if in_table("ChestSide"..tInput[2],Settings) == true then
- local temp = tInput[2]
- local sslot = tInput[3]
- tInput[2] = Settings["ChestSide"..temp]
- tInput[3] = Settings["ChestNr"..temp]
- tInput[4] = sslot
- end
- if (tInput[2] == nil or tInput[3] == nil) then
- terminalerr("get")
- else
- ChestFkt.go(tInput[3],tInput[2])
- suck(tonumber(tInput[4]))
- ChestFkt.goBack(tInput[2])
- dev()
- end
- elseif tInput[1] == "put" then
- if in_table("ChestSide"..tInput[2],Settings) == true then
- local temp = tInput[2]
- local sslot = tInput[3]
- tInput[2] = Settings["ChestSide"..temp]
- tInput[3] = Settings["ChestNr"..temp]
- tInput[4] = sslot
- end
- if (tInput[2] == nil or tInput[3] == nil) then
- terminalerr("put")
- else
- ChestFkt.go(tInput[3],tInput[2])
- drop(tonumber(tInput[4]),0)
- ChestFkt.goBack(tInput[2])
- dev()
- end
- elseif tInput[1] == "upd8r" then
- shell.setDir("/")
- print("GET UPD8R")
- a = http.get("http://tinyurl.com/upd8r")
- a = a.readAll()
- b = fs.open("upd8r.lua","w")
- b.write(a)
- b.close()
- shell.run("upd8r.lua")
- elseif tInput[1] == "buildChest" then
- if (tInput[2] == nil) then
- terminalerr("buildChest")
- else
- ChestFkt.build(tonumber(tInput[2]))
- end
- elseif (tInput[1] == "exit" or tInput[1] == "e") then
- dev() print("Terminal closed") tInput = nil
- elseif (tInput[1] == "nTr" or tInput[1] == "plant") then
- if (tInput[2] == nil or tInput[3] == nil or tInput[4] == nil) then
- terminalerr("plant")
- else
- placeTrees(tInput[2],tInput[3],tInput[4])
- end
- elseif (tInput[1] == "settings") then settings()
- elseif (tInput[1] == "field") then
- if (tInput[2] == nil) then
- terminalerr("field")
- else
- Feld(tInput[2],tInput[3])
- end
- elseif (tInput[1] == "SuperMiner" or tInput[1] == "sm") then
- if (tInput[2] == nil) then
- terminalerr("SuperMiner")
- else
- SuperMiner(tInput[2],tInput[3],tInput[4])
- end
- elseif (tInput[1] == "fell" or tInput[1] == "gTr") then
- if (tInput[2] == nil) then
- terminalerr("fell")
- else
- automaticTrees(tInput[2])
- end
- elseif (tInput[1] == "install") then
- install()
- elseif (tInput[1] == "MultiField" or "mf") then
- if (tInput[2] == nil or tInput[3] == nil or tInput[4] == nil) then
- terminalerr("MultiField")
- else
- MultiField(tInput[2],tInput[3],tInput[4])
- end
- else
- print("Not given") sleep(1) terminal()
- end
- end
- function in_table(element,table)
- for _, value in pairs(table) do
- if value == element then
- return true
- end
- end
- return false
- end
- function detect(where,max) --Where[1 detect,2 detect up, 3 detect down]
- goThrow = 0
- going = true
- if where == 1 then
- while turtle.detect() == false and going == true do
- turtle.forward()
- goThrow = goThrow+1
- if max ~= nil then
- if max == goThrow then
- going = false
- end
- end
- dev(false)
- makeColor(colors.red)
- print("Go ",goThrow," steps now")
- makeColor()
- end
- makeColor(colors.green)
- print("Finish")
- makeColor(colors.green)
- elseif where == 2 then
- while turtle.detectUp() == false and going == true do
- turtle.up()
- goThrow = goThrow+1
- if max ~= nil then
- if max == goThrow then
- going = false
- end
- end
- dev(false)
- makeColor(colors.red)
- print("Go ",goThrow," steps now")
- makeColor()
- end
- makeColor(colors.green)
- print("Finish")
- makeColor()
- elseif where == 3 then
- while turtle.detectDown() == false and going == true do
- turtle.down()
- goThrow = goThrow+1
- if max ~= nil then
- if max == goThrow then
- going = false
- end
- end
- dev(false)
- makeColor(colors.red)
- print("Go ",goThrow," steps now")
- makeColor()
- end
- dev()
- makeColor(colors.green)
- print("Finish")
- makeColor()
- end
- end
- function checkDown(xxx)
- if turtle.detectDown() == true then
- drop(xxx)
- end
- end
- function SuperMiner(dest,ptorch,run)
- if ptorch ~= nil and ptorch ~= 0 then
- torch = true
- tS = tonumber(ptorch)
- else
- torch = false
- end
- if run ~= nil then
- dig = false
- else
- dig = true
- end
- dist = tonumber(dest)
- count = 0
- if dig == true then
- while dist > 0 do
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- turtle.turnRight()
- dist = dist-1
- if count == 3 and torch == true then
- turtle.select(tS)
- turtle.placeDown()
- end
- count = count+1
- dev()
- print(dist.." left")
- end
- else
- while dist > 0 do
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- dist = dist-1
- dev()
- print(dist.." left")
- end
- end
- dev()
- makeColor(colors.green)
- print("Finish!")
- makeColor()
- end
- function fell(tf)
- if tf == false then
- a = 0
- b = 0
- elseif tf == true then
- b = 0
- makeColor(colors.green)
- print("Last tree high = ",a)
- makeColor()
- end
- makeColor(colors.red)
- print("Wait..:")
- print("Tree is felling....")
- if tf == false then
- turtle.dig()
- turtle.forward()
- while turtle.detectUp() do
- turtle.digUp()
- turtle.up()
- a = a+1
- b = b+1
- end
- while b > 0 do
- turtle.down()
- b = b-1
- end
- elseif tf == true then
- while a > 0 do
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.up()
- if turtle.detect() then
- turtle.dig()
- turtle.turnLeft()
- turtle.dig()
- turtle.turnLeft()
- turtle.dig()
- turtle.turnLeft()
- turtle.dig()
- turtle.turnLeft()
- end
- a = a-1
- b = b+1
- end
- while b > 0 do
- turtle.down()
- b = b-1
- end
- end
- dev()
- makeColor(colors.green)
- print("Tree high = ",a)
- print("Finish!")
- makeColor()
- end
- function placeTrees(pX,pSlot,pDirt)
- dirt = true
- slot = tonumber(pSlot)
- if dirtslot == 'false' then
- dirt = false
- else
- dirt = tonumber(pDirt)
- end
- a = pX*5
- b = a+0
- c = 4
- while a > 0 do
- turtle.forward()
- if turtle.detect() == true then
- turtle.dig()
- end
- c = c+1
- if c == 5 then
- turtle.down()
- if turtle.detectDown() == false then
- if dirt == true then
- turtle.select(dirtslot)
- turtle.placeDown()
- turtle.select(slot)
- end
- end
- turtle.up()
- turtle.placeDown()
- c = 0
- end
- a = a-1
- end
- while b > 0 do
- turtle.back()
- b = b-1
- end
- dev()
- makeColor(colors.green)
- print("Finish!")
- makeColor()
- end
- function automaticTrees(pX)
- x = pX*5
- y = x+0
- while x > 0 do
- turtle.forward()
- if turtle.detect() == true then
- fell(false)
- x = x-1
- end
- x = x-1
- end
- while y > 0 do turtle.back() y=y-1 end
- dev()
- makeColor(colors.green)
- print("All trees are fell!")
- makeColor()
- end
- function drop(tfxx,tfg)
- if tfxx ~= nil then
- turtle.select(tfxx)
- if tfg == nil then
- turtle.dropDown()
- else
- turtle.drop()
- end
- else
- tfxx = 1
- while tfxx <= 16 do
- turtle.select(tfxx)
- if tfg == nil then
- turtle.dropDown()
- else
- turtle.drop()
- end
- tfxx = tfxx+1
- end
- end
- turtle.select(1)
- end
- function suck(tfxx)
- if tfxx ~= nil then
- turtle.select(tfxx)
- turtle.suck()
- else
- tfxx = 1
- while tfxx <= 16 do
- turtle.select(tfxx)
- turtle.suck()
- tfxx = tfxx+1
- end
- end
- turtle.select(1)
- end
- function MultiField(pAnz,pLenght,pPlant)
- local x = pAnz+0
- local going = (pAnz*3)-3
- while pAnz > 0 do
- Feld(pLenght,pPlant)
- turtle.turnRight()
- local fw = 3
- while fw > 0 do
- turtle.forward()
- fw = fw-1
- end
- turtle.turnLeft()
- anz = anz-1
- end
- turtle.turnLeft()
- turtle.turnLeft()
- while going > 0 do
- turtle.forward()
- going = going-1
- end
- dev()
- makeColor()
- print("Finish!")
- makeColor()
- end
- function Feld(pLenght,pPlant)
- dev()
- makeColor(colors.red)
- print("Working...")
- makeColor()
- a = pLenght
- b = a+0
- a = tonumber(a)
- tf = tfBack(pPlant)
- turtle.forward()
- while a > 0 do
- turtle.digDown()
- if tf == true then turtle.placeDown() end
- turtle.turnRight()
- turtle.forward()
- turtle.digDown()
- if tf == true then turtle.placeDown() end
- turtle.back()
- turtle.turnLeft()
- turtle.forward()
- a = a-1
- end
- turtle.turnRight()
- turtle.turnRight()
- while b > 0 do
- turtle.forward()
- b = b-1
- end
- turtle.turnRight()
- turtle.turnRight()
- turtle.back()
- checkDown(2)
- dev()
- makeColor(colors.green)
- print("Finish!")
- makeColor()
- end
- function update()
- if fs.exists("upd8r.lua") == true then
- shell.run("upd8r.lua")
- shell.run("TurtleControll.lua")
- shell.exit()
- else
- a = http.get("http://goo.gl/7gUVmb")
- b = fs.open(shell.getRunningProgram(),"w")
- b.write(a.readAll())
- b.close()
- shell.run(shell.getRunningProgram())
- end
- end
- function goTo( x, y, z, xPos, depth, zPos)
- while depth > y do
- if turtle.up() then
- depth = depth - 1
- elseif turtle.digUp() or turtle.attackUp() then
- else
- sleep( 0.5 )
- end
- end
- if xPos > x then
- while xDir ~= -1 do
- turtle.turnLeft()
- end
- while xPos > x do
- if turtle.forward() then
- xPos = xPos - 1
- elseif turtle.dig() or turtle.attack() then
- else
- sleep( 0.5 )
- end
- end
- elseif xPos < x then
- while xDir ~= 1 do
- turtle.turnLeft()
- end
- while xPos < x do
- if turtle.forward() then
- xPos = xPos + 1
- elseif turtle.dig() or turtle.attack() then
- else
- sleep( 0.5 )
- end
- end
- end
- if zPos > z then
- while zDir ~= -1 do
- turtle.turnLeft()
- end
- while zPos > z do
- if turtle.forward() then
- zPos = zPos - 1
- elseif turtle.dig() or turtle.attack() then
- else
- sleep( 0.5 )
- end
- end
- elseif zPos < z then
- while zDir ~= 1 do
- turtle.turnLeft()
- end
- while zPos < z do
- if turtle.forward() then
- zPos = zPos + 1
- elseif turtle.dig() or turtle.attack() then
- else
- sleep( 0.5 )
- end
- end
- end
- while depth < y do
- if turtle.down() then
- depth = depth + 1
- elseif turtle.digDown() or turtle.attackDown() then
- else
- sleep( 0.5 )
- end
- end
- makeColor(colors.green)
- print("Finish!")
- makeColor()
- end
- function leiterBuilder(pDeep,pSlot,pBack)
- a = read(pDeep)
- Slot = tonumber(pSlot)
- turtle.select(Slot)
- qwas = tfBack(pBack)
- b = 0
- if a == "detect" then
- while not turtle.detectDown() do
- turtle.place()
- turtle.down()
- b = b+1
- end
- if tfBack(qwas) then
- while b > 0 do
- turtle.up()
- b = b-1
- end
- end
- Main()
- elseif a == "Slot" then
- a = turtle.getItemCount(Slot)
- else
- a = tonumber(a)
- end
- while a > 0 do
- turtle.place()
- turtle.down()
- a = a-1
- b = b+1
- end
- if tfBack(qwas) == true then
- while b > 0 do
- turtle.up()
- b = b-1
- end
- end
- dev()
- makeColor(colors.green)
- print("Finish!")
- makeColor()
- end
- BlockPlacer = {
- Start=function(pForward,pRight,pDown)
- dev()
- xSide = tonumber(pForward)
- ySide = tonumber(pRight)
- zSide = tonumber(pDown)
- a = xSide+0
- b = ySide+0
- c = zSide+0
- Comp = xSide*ySide*zSide
- CompSLot = Comp/64
- print("That's are ",Comp," Blocks. ")
- print("Put Material in Slot 1 - 16 (Need "..CompSLot.."Slots")
- print("press enter to start...")
- while true do local sEvent, param = os.pullEvent("key")
- if(sEvent == "key") then
- if (param == 28) then
- BlockPlacer.remove()
- break
- end
- end
- end
- dev()
- makeColor(colors.green)
- print("Finish!")
- makeColor()
- Main()
- end,
- Status=function()
- term.clear()
- term.setCursorPos(1,1)
- print("Print...")
- print("X = ",xTemp)
- print("Y = ",yTemp)
- print("Z = ",zTemp)
- term.setCursorPos(1,5)
- print("I have ",MathTemp," blocks / "..Comp)
- jhf = Comp-MathTemp
- hfj = (MathTemp*100)/Comp
- print(jhf," blocks left")
- print(hfj,"%")
- ChestFkt.checkSlots()
- print("Slot = "..Slot)
- jhf = nil
- hfj = nil
- end,
- remove=function()
- print("Please wait...")
- aTemp = a+0
- bTemp = b+0
- cTemp = c+0
- xTemp = 1
- yTemp = 1
- zTemp = c+0
- MathTemp = 0
- while cTemp > 0 do
- while aTemp > 0 do
- turtle.turnRight()
- while bTemp > 0 do
- ChestFkt.checkSlots()
- turtle.placeDown()
- MathTemp = MathTemp+1
- BlockPlacer.Status()
- if bTemp > 1 then
- if turtle.detect() then turtle.dig() end
- turtle.forward()
- xTemp = xTemp+1
- end
- bTemp = bTemp-1
- end
- bTemp = b+0
- while bTemp > 1 do
- turtle.back()
- bTemp = bTemp-1
- xTemp = xTemp-1
- end
- bTemp = b+0
- turtle.turnLeft()
- if aTemp > 1 then
- if turtle.detect() then turtle.dig() end
- turtle.forward()
- yTemp = yTemp+1
- end
- aTemp = aTemp-1
- end
- aTemp = a+0
- while aTemp > 1 do
- turtle.back()
- aTemp = aTemp-1
- yTemp = yTemp-1
- end
- if cTemp > 1 then
- turtle.up()
- zTemp = zTemp-1
- xTemp = 1
- yTemp = 1
- end
- cTemp = cTemp-1
- aTemp = a+0
- bTemp = b+0
- end
- cTemp = c+0
- while cTemp > 0 do
- if cTemp > 1 then
- turtle.up()
- end
- cTemp = cTemp-1
- end
- end,
- }
- ChestFkt = {
- checkSlots = function()
- if turtle.getItemCount(Slot) <= 0 then
- if Slot <= 16 then
- Slot = Slot+1
- turtle.select(Slot)
- end
- end
- end,
- build=function(aIn)
- print("High of the Tower/Chests")
- a = aIn
- b = a+0
- print("Build Blocks in Slots 1-8")
- print("Chests in Slot 9-16")
- print("Press enter to start|Type e or exit for end")
- xyz = read()
- if (xyz == 'e' or xyz == 'exit') then
- dev()
- else
- shell.run("Haus.lua 6 6 "..a.." go")
- Slot = 9
- turtle.select(Slot)
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- turtle.dig()
- turtle.up()
- turtle.dig()
- turtle.down()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- while a > 0 do
- turtle.place()
- ChestFkt.checkSlots()
- turtle.up()
- a = a-1
- end
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- while b > 0 do
- ChestFkt.checkSlots()
- turtle.place()
- turtle.down()
- b = b-1
- end
- turtle.turnRight()
- while a > 0 do
- ChestFkt.checkSlots()
- turtle.place()
- turtle.up()
- a = a-1
- end
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- while b > 0 do
- ChestFkt.checkSlots()
- turtle.place()
- turtle.down()
- b = b-1
- end
- turtle.turnRight()
- turtle.forward()
- while a > 0 do
- ChestFkt.checkSlots()
- turtle.place()
- turtle.up()
- a = a-1
- end
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- while b > 0 do
- ChestFkt.checkSlots()
- turtle.place()
- turtle.down()
- b = b-1
- end
- turtle.back()
- turtle.turnLeft()
- end
- end,
- go=function(chest,side)
- temp = 0
- if side == '1' then
- turtle.turnLeft()
- elseif side == '2' then
- turtle.forward()
- elseif side == '3' then
- turtle.turnRight()
- turtle.forward()
- end
- chest = chest-1
- while chest > 0 do
- turtle.up()
- chest = chest-1
- temp = temp+1
- end
- end,
- goBack=function(side)
- while temp > 0 do
- turtle.down()
- temp = temp-1
- end
- if side == '1' then
- turtle.turnRight()
- elseif side == '2' then
- turtle.back()
- elseif side == '3' then
- turtle.back()
- turtle.turnLeft()
- end
- end,
- }
- BlockRemover = {
- Start=function(pForward,pRight,pDown)
- term.clear()
- term.setCursorPos(1,1)
- local back = true
- xSide = tonumber(pForward)
- ySide = tonumber(pRight)
- zSide = tonumber(pDown)
- a = xSide+0
- b = ySide+0
- c = zSide+0
- Comp = xSide*ySide*zSide
- print("That's are ",Comp," Blocks. ")
- print("press enter to start...")
- while true do local sEvent, param = os.pullEvent("key")
- if(sEvent == "key") then
- if (param == 28) then
- BlockRemover.remove()
- break
- end
- end
- end
- dev()
- makeColor(colors.green)
- print("Finish!")
- makeColor()
- Main()
- end,
- Status=function()
- term.clear()
- term.setCursorPos(1,1)
- print("Scanning...")
- print("X = ",xTemp)
- print("Y = ",yTemp)
- print("Z = ",zTemp)
- term.setCursorPos(1,5)
- print("I have ",MathTemp," blocks")
- jhf = Comp-MathTemp
- hfj = (MathTemp*100)/Comp
- print(jhf," blocks left")
- print(hfj,"%")
- jhf = nil
- hfj = nil
- end,
- remove=function()
- print("Please wait...")
- aTemp = a+0
- bTemp = b+0
- cTemp = c+0
- xTemp = 1
- yTemp = 1
- zTemp = c+0
- MathTemp = 0
- while cTemp > 0 do
- while aTemp > 0 do
- turtle.turnRight()
- while bTemp > 0 do
- turtle.digDown()
- MathTemp = MathTemp+1
- BlockRemover.Status()
- if bTemp > 1 then
- if turtle.detect() then turtle.dig() end
- turtle.forward()
- xTemp = xTemp+1
- end
- bTemp = bTemp-1
- end
- bTemp = b+0
- while bTemp > 1 do
- turtle.back()
- bTemp = bTemp-1
- xTemp = xTemp-1
- end
- bTemp = b+0
- turtle.turnLeft()
- if aTemp > 1 then
- if turtle.detect() then turtle.dig() end
- turtle.forward()
- yTemp = yTemp+1
- end
- aTemp = aTemp-1
- end
- aTemp = a+0
- while aTemp > 1 do
- turtle.back()
- aTemp = aTemp-1
- yTemp = yTemp-1
- end
- if cTemp > 1 then
- turtle.down()
- zTemp = zTemp-1
- xTemp = 1
- yTemp = 1
- end
- cTemp = cTemp-1
- aTemp = a+0
- bTemp = b+0
- end
- if back == true then
- cTemp = c+0
- while cTemp > 0 do
- if cTemp > 1 then
- turtle.up()
- end
- cTemp = cTemp-1
- end
- end
- end,
- }
- Train = {
- ["Slots"] = {
- [1] = 'Rails',
- [2] = 1, [3] = 1, [4] = 1, [5] = 1, [6] = 1,[7] = 1, "Dirt",8,8,8,8,8,8,
- [12] = "Motor Rail",[13] = 12, [14] = 12,
- [15] = "Redstone Torch",[16] = 15,
- },
- CheckSlot=function(y)
- while turtle.getItemCount(Slot) == 0 do
- if Slot+1 > y then
- print("Out of Material")
- a = 0
- else
- Slot = Slot+1
- Train.sel()
- end
- end
- end,
- status=function()
- term.clear()
- term.setCursorPos(1,1)
- print("a =",a)
- print("temp =",temp)
- end,
- speed=function()
- if temp == Detectby then
- Slot = 15
- Train.sel()
- Train.CheckSlot(16)
- elseif temp == Detectby+1 or temp == Detectby+2 then
- Slot = 12
- Train.sel()
- Train.CheckSlot(14)
- elseif temp == Detectby+3 then
- Slot = 15
- Train.sel()
- Train.CheckSlot(16)
- temp = 0
- else
- Slot = 1
- Train.sel()
- Train.CheckSlot(7)
- end
- end,
- sel=function()
- turtle.select(Slot)
- end,
- start=function(lenght,flat,maybe)
- Detectby = 10
- temp = 0
- a = lenght
- if flat ~= nil and flat ~= '1' then
- CheckGround = false
- else
- CheckGround = true
- end
- if maybe ~= nil then
- for i=1,#Train["Slots"] do
- print("Slot:",i,"=",Slots[i])
- end
- print("e for exit|t or f for follow rails")
- a = read()
- end
- if a == "e" then
- shell.exit()
- elseif a == "t" or a == "f" then
- a = 0
- while turtle.detectDown() == true do
- turtle.forward()
- a = a+1
- Train.status()
- end
- else
- a = tonumber(lenght)
- while a > 0 do
- if CheckGround == true then
- turtle.down()
- if turtle.detectDown() == false then
- Slot = 8
- Train.sel()
- Train.CheckSlot(11)
- turtle.placeDown()
- end
- turtle.up()
- end
- Train.speed()
- turtle.placeDown()
- turtle.forward()
- a = a-1
- temp = temp+1
- Train.status()
- end
- end
- end, }
- dev()
- Main()
Add Comment
Please, Sign In to add comment