Advertisement
fatboychummy

go.lua

Aug 27th, 2019
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.99 KB | None | 0 0
  1. local ins = {...}
  2.  
  3. local fnil = {}
  4.  
  5. for i = 1, #ins do
  6.   local a = string.lower(ins[i])
  7.   local b = tonumber(a)
  8.   if b then
  9.     if i == 1 or type(tonumber(ins[i - 1])) == "number" then
  10.       error("Number in wrong pos", 0)
  11.     end
  12.     ins[i] = tostring(ins[i - 1]) .. a
  13.     ins[i - 1] = fnil
  14.   else
  15.     if a == "down" or a == "up" or a == "left" or a == "right" or a == "forward"
  16.       or a == "back" or a == "dig" or a == "digdown" or a == "digup"
  17.         or a == "suck" or a == "suckdown" or a == "suckup" or a == "drop"
  18.           or a == "dropdown" or a == "dropup" or a == "sel" then
  19.     --
  20.  
  21.     else
  22.       error(tostring(a) .. " is an invalid command.")
  23.     end
  24.     ins[i] = a
  25.   end
  26. end
  27.  
  28. for i = #ins, 1, -1 do
  29.   local a = ins[i]
  30.   if a == fnil then
  31.     table.remove(ins, i)
  32.   end
  33. end
  34.  
  35. for i = 1, #ins do
  36.   local a = ins[i]
  37.   local cmd = a:match("%a+")
  38.   local cnt = tonumber(a:match("%d+"))
  39.   local cnt2
  40.   if cmd == "sel" then
  41.     cnt2 = 1
  42.   else
  43.     cnt2 = type(cnt) == "number" and cnt or 1
  44.   end
  45.  
  46.   for o = 1, cnt2 do
  47.     if cmd == "forward" then
  48.       turtle.forward()
  49.     elseif cmd == "back" then
  50.       turtle.back()
  51.     elseif cmd == "left" then
  52.       turtle.turnLeft()
  53.     elseif cmd == "right" then
  54.       turtle.turnRight()
  55.     elseif cmd == "down" then
  56.       turtle.down()
  57.     elseif cmd == "up" then
  58.       turtle.up()
  59.     elseif cmd == "dig" then
  60.       turtle.dig()
  61.     elseif cmd == "digdown" then
  62.       turtle.digDown()
  63.     elseif cmd == "digup" then
  64.       turtle.digUp()
  65.     elseif cmd == "drop" then
  66.       turtle.drop()
  67.     elseif cmd == "dropdown" then
  68.       turtle.dropDown()
  69.     elseif cmd == "dropup" then
  70.       turtle.dropUp()
  71.     elseif cmd == "suck" then
  72.       turtle.suck()
  73.     elseif cmd == "suckdown" then
  74.       turtle.suckDown()
  75.     elseif cmd == "suckup" then
  76.       turtle.suckUp()
  77.     elseif cmd == "sel" then
  78.       turtle.select(cnt)
  79.     else
  80.       error("Invalid command caught late: " .. tostring(cmd))
  81.     end
  82.   end
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement