Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function move(direction, increment)
- local switch = {
- ['up'] = function()
- for i=1,increment,1 do turtle.up() end
- end,
- ['down'] = function()
- for i=1,increment,1 do turtle.down() end
- end,
- ['forward'] = function()
- for i=1,increment,1 do turtle.forward() end
- end,
- ['right'] = function()
- for i=1,increment,1 do turtle.back() end
- end
- }
- local f = switch[direction]
- if(f) then
- f()
- else -- for case default
- print "Defaulted."
- end
- end
- local function rotate(direction)
- local switch = {
- ['left'] = function()
- turtle.turnLeft()
- end,
- ['right'] = function()
- turtle.turnRight()
- end
- }
- local f = switch[direction]
- if(f) then
- f()
- else -- for case default
- print "Defaulted."
- end
- end
- local function place(slot, text)
- turtle.select(slot)
- turtle.place(text)
- end
- local function dig(direction)
- local switch = {
- ['up'] = function()
- turtle.digUp()
- end,
- ['forward'] = function()
- turtle.dig()
- end,
- ['down'] = function()
- turtle.digDown()
- end
- }
- local f = switch[direction]
- if(f) then
- f()
- else -- for case default
- print "Defaulted."
- end
- end
- function operation(optype, direction, slot, text, increment)
- direction = direction or ''
- slot = slot or ''
- text = text or ''
- increment = increment or ''
- local switch = {
- ['dig'] = function()
- dig(direction)
- end,
- ['move'] = function()
- move(direction, tonumber(increment))
- end,
- ['rotate'] = function()
- rotate(direction)
- end,
- ['place'] = function()
- place(tonumber(slot), text)
- end
- }
- local f = switch[optype]
- if(f) then
- f()
- else -- for case default
- print "Defaulted."
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement