Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------------------
- --------------------------------- HELPERS ----------------------------------
- ----------------------------------------------------------------------------
- local function str2array(str)
- local array = {}
- for i = 1, #str do
- array[i] = str:sub(i, i)
- end
- return array
- end
- local turtleMoveFunction = {
- f = turtle.forward,
- b = turtle.back,
- u = turtle.up,
- d = turtle.down,
- l = turtle.turnLeft,
- r = turtle.turnRight,
- }
- ----------------------------------------------------------------------------
- --------------------------------- PROGRAMS ---------------------------------
- ----------------------------------------------------------------------------
- local programs = {
- help = function(args)
- print("Usage: lig <program> [param, [...]]")
- end,
- m = function(args)
- if #args < 1 then
- print("Usage: lig m <path>")
- return
- end
- for node in string.gmatch(args[1], "[a-z][0-9]*") do
- local direction = string.sub(node, 1, 1)
- local length = string.sub(node, 2)
- if turtleMoveFunction[direction] == nil then
- print("Error: Undefined direction!")
- return
- end
- if not length then
- length = 1
- end
- for i = 1, length, 1 do
- breakCount = 30
- while (not turtleMoveFunction[direction]) and breakCount > 0 do
- sleep(0.1)
- breakCount = breakCount - 1;
- end
- end
- end
- end
- }
- ----------------------------------------------------------------------------
- ----------------------------------- ARGS -----------------------------------
- ----------------------------------------------------------------------------
- local function execArgs(args)
- local program = "help"
- if #args >= 1 then
- program = table.remove(args, 1)
- end
- if programs[program] ~= nil then
- print("Executing program: "..program)
- programs[program](args)
- print("Executed.")
- else
- print('Not found program!');
- return;
- end
- end
- ----------------------------------------------------------------------------
- ----------------------------------- MAIN -----------------------------------
- ----------------------------------------------------------------------------
- print("LigCraftSoft - lig - v0.1");
- local args = {...}
- execArgs(args);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement