Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- If U have a question, write under the YT video.
- ---Y O U T U B E--- video: https://www.youtube.com/watch?v=7xZGikxhSY4
- My channel, please subscribe: https://www.youtube.com/c/DelfaverMatteo_Games
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- ]]--
- --[[ Variables ]]--
- FollowBlockID = 4 -- cobblestone
- --[[ Functions ]]--
- function prt(what, types)
- if what == nil then
- print("prt() what is nil")
- return false
- end
- if types == nil then
- print("prt() types is nil")
- return false
- end
- if types == "debug" then
- Log(what)
- print("Debug: " .. what)
- elseif types == "msg" then
- print(what)
- elseif types == "error" then
- print("ERROR: " .. what)
- end
- return true
- end
- function install()
- if not fs.exists("Database") then
- fs.makeDir("database")
- local file = fs.open("database/road.log", "w")
- file.close()
- return false
- else
- return true
- end
- end
- function Log(what)
- what = tostring(what)
- file = fs.open("database/turtlelog.txt", "a")
- -- file.writeLine(http.get("http://swisspcguru.esy.es/time.php").readAll() .. ": " .. what)
- file.writeLine(what)
- file.close()
- end
- function SaveRoad(what)
- if not fs.exitis("database/road.log") then
- prt("SaveRoad() | database/road.log not fond, start install()", "debug")
- return install()
- else
- prt("SaveRoad() | database/road.log fond, start save road", "debug")
- end
- end
- function fuel()
- fueling = false
- for i = 1, 16 do
- turtle.select(i)
- if turtle.refuel(0) then
- local halfStack = math.ceil(turtle.getItemCount(i)/2)
- if turtle.refuel(halfStack) then fueling = true end
- end
- end
- if fueling then
- prt("fuel() | fueled", "debug")
- return true
- else
- prt("fuel() | not fueled", "debug")
- return false
- end
- end
- function move()
- while FindRoad() do end
- end
- function FindRoad()
- local success, data = turtle.inspectDown()
- prt(tostring(succes) .. " name: " .. data.name .. " | metadata: " .. data.metadata, "debug")
- if success then
- prt("FindRoad() | success", "debug")
- if data.name == "minecraft:wool" and data.metadata == 14 then
- if turtle.forward() then
- prt("FindRoad() | turtle.getFuelLevel(): " .. turtle.getFuelLevel(), "debug")
- if turtle.getFuelLevel() <= 10 then
- prt("FindRoad() | turtle.getFuelLevel() <= 10" .. turtle.getFuelLevel(), "debug")
- if fuel() then
- prt("FindRoad() | fuel() is true", "debug")
- return FindRoad()
- else
- --nem tudott tankolni
- prt("I don't fueling", "msg")
- read()
- return false
- end
- end
- prt("FindRoad() | turtle.forward() true", "debug")
- success, data = turtle.inspectDown()
- prt("FindRoad() | turtle.forward() data.name: " .. data.name, "debug")
- else
- prt("FindRoad() | turtle.forward() false", "debug")
- if turtle.getFuelLevel() <= 10 then
- prt("FindRoad() | turtle.getFuelLevel() <= 10" .. turtle.getFuelLevel(), "debug")
- if fuel() then
- prt("FindRoad() | fuel() is true", "debug")
- return FindRoad()
- else
- --nem tudott tankolni
- prt("I don't fueling", "msg")
- read()
- return false
- end
- else
- --nem tud mozogni
- return false
- end
- end
- else
- if not SearchRoad() then
- --Road end
- prt("I found the route end", "msg")
- read()
- return
- end
- end
- return true
- else
- return false
- -- Nincs alatta block
- end
- end
- function SearchRoad()
- turtle.back()
- turtle.turnLeft()
- turtle.forward()
- local success, data = turtle.inspectDown()
- prt(tostring(succes) .. " name: " .. data.name .. " | metadata: " .. data.metadata, "debug")
- if success then
- if data.name == "minecraft:wool" and data.metadata == 14 then
- prt("1st search is pass", "debug")
- return FindRoad()
- else
- for i = 1, 2 do
- turtle.turnLeft()
- end
- turtle.forward()
- local success, data = turtle.inspectDown()
- prt(tostring(succes) .. " name: " .. data.name .. " | metadata: " .. data.metadata, "debug")
- if success then
- if data.name == "minecraft:wool" and data.metadata == 14 then
- return FindRoad()
- else
- turtle.back()
- turtle.turnRight()
- return FindRoad() --loopba visszamegy
- end
- else
- --nincs alatta block
- end
- end
- else
- --nincs alatta block
- end
- end
- install()
- move()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement