AdditionalPylons

q.lua

Jun 16th, 2026 (edited)
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.54 KB | None | 0 0
  1. local a = ...
  2. if not a then error("Must include a valid command sequence") end
  3. local cmds = {
  4.     ["l"]=turtle.turnLeft,
  5.     ["r"]=turtle.turnRight,
  6.     ["d"]=turtle.down,
  7.     ["u"]=turtle.up,
  8.     ["f"]=turtle.forward,
  9.     ["b"]=turtle.back,
  10.     ["a"]=function() turtle.turnLeft() turtle.turnLeft() end,
  11.     ["s"]=os.reboot
  12. }
  13. for c,rep in a:gmatch("(%a)(%d*)") do
  14.     local cmd = cmds[c]
  15.     if not cmd then error("Unrecognised command: "..c) end
  16.     if tonumber(rep) then
  17.         for i=1,tonumber(rep) do
  18.             cmd()
  19.         end
  20.     else cmd() end
  21. end
Advertisement
Add Comment
Please, Sign In to add comment