Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local t = {
- ["purple"] = {
- side = "left",
- flux_level = 1,
- flux_max = 7
- },
- ["lime"] = {
- side = "back",
- flux_level = 1,
- flux_max = 7
- },
- ["orange"] = {
- side = "right",
- flux_level = 1,
- flux_max = 7
- },
- ["white"] = {
- side = "front",
- flux_level = 1,
- flux_max = 5
- }
- }
- ----------------------------
- --Prints Table for debugging
- ----------------------------
- local function printTable(e)
- if type(e) == "table" then
- for k,v in pairs(e) do -- for every element in the table
- print(k,v)
- printTable(v) -- recursively repeat the same procedure
- sleep(2)
- print()
- end
- else -- if not, we can just print it
- print(e)
- end
- end
- ---------------------------
- --Updates table when redstone changes
- ---------------------------
- local function getUpdate()
- t.purple.flux_level = rs.getAnalogInput(t.purple.side)
- t.lime.flux_level = rs.getAnalogInput(t.lime.side)
- t.orange.flux_level = rs.getAnalogInput(t.orange.side)
- t.white.flux_level = rs.getAnalogInput(t.white.side)
- print("Updated")
- printTable(t)
- sleep(1)
- end
- ---------------------------
- --Emits bundled redstone when flux_max is exceeded
- ---------------------------
- local function stopProduction(index)
- if t.["..index.."].flux_level >= t.["..index.."].flux_max then
- print("stopProduction")
- rs.getBundledOutput(colours.index)
- end
- end
- ---------------------------
- --Starts the script
- ---------------------------
- local function start()
- while true do
- if os.pullEvent("redstone") then
- --getUpdate() -- updates table
- stopProduction(purple)
- end
- end
- end
- start()
- stopProduction(purple)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement