Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- RedScript by XoX
- -- Please leave this header if you edit this.
- local tArgs = { ... }
- if #tArgs == 0 then
- print("How would you like to use RedScript?")
- print("To load a file type the filename")
- print("Other Options: console, help, new")
- tArgs[1] = read()
- end
- if tArgs[1] == "console" then
- print("Not yet.")
- return
- end
- if tArgs[1] == "help" then
- print("RedScript allows you to write scripts which use and trigger redstone signals.")
- print("Syntax & Functions:")
- print("SIDE on/off = stop or start redstone signal.")
- print("wait # = wait a certain amount of seconds")
- print("wait SIDE = wait for an input for the specified side")
- print("goto # = Go to a certain line in the script")
- print("compare a b = compare 2 variables. if a or b is input the user will be asked to type something")
- print("yes COMMAND = Exeuted if compared variables are the same")
- print("no COMMAND = Executed if they are not")
- os.pullEvent("key")
- return
- end
- if tArgs[1] == "new" then
- term.clear()
- term.setCursorPos(1,1)
- print("Filename: ")
- print("rs_")
- term.setCursorPos(4,2)
- nfile = tArgs[2] or read()
- shell.run("edit", "rs_" .. nfile )
- end
- file = fs.open(tArgs[1], "r")
- lines = {}
- repeat
- m = file.readLine()
- lines[#lines + 1] = m
- until m == nil
- file.close()
- i = 1
- while true do
- if lines[i] == nil then break end
- text = {}
- for w in string.gmatch(lines[i], "%S+") do
- text[#text + 1] = w
- end
- if string.lower(text[1]) == "left" or string.lower(text[1]) == "right" or string.lower(text[1]) == "front" or string.lower(text[1]) == "back" or string.lower(text[1]) == "top" or string.lower(text[1]) == "bottom" then
- if string.lower(text[2]) == "on" then
- rs.setOutput(string.lower(text[1]), true)
- elseif string.lower(text[2]) == "off" then
- rs.setOutput(string.lower(text[1]), false)
- else
- print("Syntax Error: Line #" .. i .. " Unknown Subcommand for SIDE: " .. text[2])
- return
- end
- i = i + 1
- elseif string.lower(text[1]) == "wait" then
- if tonumber(text[2]) ~= nil then
- sleep( tonumber(text[2]) )
- elseif string.lower(text[2]) == "left" or string.lower(text[2]) == "right" or string.lower(text[2]) == "front" or string.lower(text[2]) == "back" or string.lower(text[2]) == "top" or string.lower(text[2]) == "bottom" then
- while rs.getInput(string.lower(text[2])) == false do
- sleep(0.05)
- end
- else
- print("Syntax Error: Line #" .. i .. " Wrong argument for WAIT: " .. text[2])
- return
- end
- i = i + 1
- elseif string.lower(text[1]) == "compare" then
- if text[2] == "input" then
- elseif text[3] == "input" then
- else
- end
- i = i + 1
- elseif string.lower(text[1]) == "goto" then
- if tonumber(text[2]) ~= nil then
- i = ( tonumber(text[2]) )
- else
- print("Syntax Error: Line #" .. i .. " Wrong argument for GOTO: " .. text[2])
- return
- end
- elseif string.lower(text[1]) == "" then
- i = i + 1
- elseif string.lower(text[1]) == "" then
- i = i + 1
- elseif string.lower(text[1]) == "" then
- i = i + 1
- elseif string.lower(text[1]) == "" then
- i = i + 1
- else
- print("Syntax Error: Line #" .. i .. " Unknown Command: " .. text[1])
- return
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment