Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ins = {...}
- local fnil = {}
- for i = 1, #ins do
- local a = string.lower(ins[i])
- local b = tonumber(a)
- if b then
- if i == 1 or type(tonumber(ins[i - 1])) == "number" then
- error("Number in wrong pos", 0)
- end
- ins[i] = tostring(ins[i - 1]) .. a
- ins[i - 1] = fnil
- else
- if a == "down" or a == "up" or a == "left" or a == "right" or a == "forward"
- or a == "back" or a == "dig" or a == "digdown" or a == "digup"
- or a == "suck" or a == "suckdown" or a == "suckup" or a == "drop"
- or a == "dropdown" or a == "dropup" or a == "sel" then
- --
- else
- error(tostring(a) .. " is an invalid command.")
- end
- ins[i] = a
- end
- end
- for i = #ins, 1, -1 do
- local a = ins[i]
- if a == fnil then
- table.remove(ins, i)
- end
- end
- for i = 1, #ins do
- local a = ins[i]
- local cmd = a:match("%a+")
- local cnt = tonumber(a:match("%d+"))
- local cnt2
- if cmd == "sel" then
- cnt2 = 1
- else
- cnt2 = type(cnt) == "number" and cnt or 1
- end
- for o = 1, cnt2 do
- if cmd == "forward" then
- turtle.forward()
- elseif cmd == "back" then
- turtle.back()
- elseif cmd == "left" then
- turtle.turnLeft()
- elseif cmd == "right" then
- turtle.turnRight()
- elseif cmd == "down" then
- turtle.down()
- elseif cmd == "up" then
- turtle.up()
- elseif cmd == "dig" then
- turtle.dig()
- elseif cmd == "digdown" then
- turtle.digDown()
- elseif cmd == "digup" then
- turtle.digUp()
- elseif cmd == "drop" then
- turtle.drop()
- elseif cmd == "dropdown" then
- turtle.dropDown()
- elseif cmd == "dropup" then
- turtle.dropUp()
- elseif cmd == "suck" then
- turtle.suck()
- elseif cmd == "suckdown" then
- turtle.suckDown()
- elseif cmd == "suckup" then
- turtle.suckUp()
- elseif cmd == "sel" then
- turtle.select(cnt)
- else
- error("Invalid command caught late: " .. tostring(cmd))
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement