Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --{program="MJZ Flattener",version="1.0"}
- -- WIP !
- ---------------------------------------
- -- 14.8.23 v1.0 initial
- ---------------------------------------
- -- ToDo:
- -- Make it work with defined height
- ---------------------------------------
- ---- DESCRIPTION ----------------------
- ---------------------------------------
- --[[
- A simple but yet expandable ground flattener
- --]]
- ---------------------------------------
- ---- PARAMETERS -----------------------
- ---------------------------------------
- local cVersion ="1.0"
- local cPrgName ="MJZ Flatty"
- local debugging=false
- --[[
- /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
- Do not change anything below if you
- don't want the code to break!
- /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
- ]]--
- ---------------------------------------
- ---- VARIABLES ------------------------
- ---------------------------------------
- local time = os.time()
- local formattedTime = textutils.formatTime(time, true)
- local width
- local length
- local height
- ---------------------------------------
- ---- tArgs ----------------------------
- ---------------------------------------
- local tArgs = {...}
- if #tArgs >= 1 then -- no error check
- blnAskForParameters=false
- if tArgs[1]=="help" then blnShowUsage=true end
- if tArgs[1]=="setup" then blnAutoSetup=true end
- if tArgs[1]=="set-up" then blnAutoSetup=true end
- if tonumber(tArgs[1])~=nil then
- maxCounter=tonumber(tArgs[1])
- end
- end
- -- Function to print debug information
- local function debug_print(txt, ...)
- if debugging then
- io.write(string.format(txt .. "\n", ...))
- end
- end
- ---------------------------------------
- -- BASIC FUNCTIONS FOR TURTLE CONTROL -
- ---------------------------------------
- local function ss(s) turtle.select(s) debug_print("Selecting Slot") end
- local function ff() turtle.forward() debug_print("Moving Forward") end
- local function bb() turtle.back() debug_print("moving backward") end
- local function up() turtle.up() debug_print("moving up") end
- local function dn() turtle.down() debug_print("moving down") end
- local function tl() turtle.turnLeft() debug_print("turning left") end
- local function tr() turtle.turnRight() debug_print("turning right") end
- local function df() turtle.dig() debug_print("digging forward") end
- local function def() turtle.detect() debug_print("detecting forward") end
- local function dd() turtle.digDown() debug_print("digging down") end
- local function ded() turtle.detectDown() debug_print("detecting down") end
- local function du() turtle.digUp() debug_print("digging up") end
- local function deu() turtle.detectUp() debug_print("detecting up") end
- local function digfu()
- if turtle.detect() then df() end
- if turtle.detectUp() then du() end
- end
- local function digSides()
- tl()
- if turtle.detect() then df() end
- up()
- if turtle.detect() then df() end
- tr() tr()
- if turtle.detect() then df() end
- dn()
- if turtle.detect() then df() end
- tl()
- end
- local function goRow()
- for l = 1, length-1 do
- digfu()
- digSides()
- ff()
- sleep(1)
- l = l + 1
- end
- end
- local function goBack()
- for b = 1, length-1 do
- bb()
- b = b + 1
- end
- end
- ---------------------------------------
- ---- run -----------------------------
- ---------------------------------------
- -- Asking for the size
- term.clear()
- term.setCursorPos(1,1)
- print("Started .. ")
- print("-------------------")
- print("Let's flatten dat surface.")
- print("What's the length?")
- length = read()
- -- print("-------------------")
- -- print("What's the width? (going to the right side)")
- -- width = read()
- print("-------------------")
- print("What's the height?")
- height = read()
- term.clear()
- term.setCursorPos(1,1)
- write("Flattening at height ") print(height)
- write("and length ") print(length)
- -- write("x")
- -- write (width)
- print(".")
- textutils.slowWrite("Turtle started at " .. formattedTime, 100)
- print("")
- for h= 1, height/2+1 do
- goRow()
- digSides()
- goBack()
- du() up() du() up()
- h = h + 1
- end
- for hh= 1, height/2+1 do
- dn() dn()
- end
- print("Done " .. length .. " blocks")
- print("and " .. height .. " high")
- textutils.slowWrite("Job finished at " .. formattedTime .. "\n", 50)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement