Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- DeadGlass Client, by Deadlock989
- -- August 2015
- -- Made for the Industrial Rage server, http://www.kbgmc.com/index.php?forums/
- version = "1.01"
- debug = true
- fails = 0
- messages = {}
- whitelist = {}
- blacklist = {}
- pblocks = {}
- pblock = nil
- e = 0
- s = 0
- units = {
- ["ic2estor"]="EU",
- ["ae2estor"]="AE",
- ["rfestor"]="RF",
- }
- colours = {
- ["white"]=colors.white,
- ["orange"]=colors.orange,
- ["magenta"]=colors.magenta,
- ["lightblue"]=colors.lightblue,
- ["yellow"]=colors.yellow,
- ["lime"]=colors.lime,
- ["pink"]=colors.pink,
- ["gray"]=colors.gray,
- ["lightgray"]=colors.lightgray,
- ["grey"]=colors.gray,
- ["lightgrey"]=colors.lightgray,
- ["cyan"]=colors.cyan,
- ["purple"]=colors.purple,
- ["blue"]=colors.blue,
- ["brown"]=colors.brown,
- ["green"]=colors.green,
- ["red"]=colors.red,
- ["black"]=colors.black,
- }
- colourblocks = {"minecraft:wool", "minecraft:stained_glass", "minecraft:stained_hardened_clay"}
- redstoneblocks = {"minecraft:redstone", "minecraft:redstone_block", "minecraft:redstone_torch"}
- types = {
- ["br"]={"BigReactors-Reactor"},
- ["brac"]={"BigReactors-Reactor"},
- ["brt"]={"BigReactors-Turbine"},
- ["brtr"]={"BigReactors-Turbine"},
- ["ic2estor"]={"batbox","cesu","mfe","mfsu"},
- ["ic2nuclear"]={"nuclear_reactor"},
- ["ae2estor"]={"tilecontroller","blockenergycell","blockdenseenergycell"},
- ["ae2istor"]={"tilechest","tiledrive"},
- ["rfestor"]={"tile_thermalexpansion_cell_basic_name", "tile_thermalexpansion_cell_hardened_name", "tile_thermalexpansion_cell_redstone_name", "tile_thermalexpansion_cell_resonant_name"},
- ["rfgen"]={"tile_thermalexpansion_dynamo_steam_name", "tile_thermalexpansion_dynamo_magmatic_name", "tile_thermalexpansion_dynamo_compression_name", "tile_thermalexpansion_dynamo_reactant_name", "tile_thermalexpansion_dynamo_enervation_name"},
- ["rct"]={"rcsteamturbinetile"},
- ["tanks"]={"rcirontankvalvetile", "rcsteeltankvalvetile", "openblocks_tank", "net_minecraft_src_buildcraft_factory_tiletank", "tileentitycertustank","drum","reactor_fluid_port","solid_fueled_boiler_firebox","liquid_fueled_boiler_firebox"},
- ["rcboiler"]={"solid_fueled_boiler_firebox","liquid_fueled_boiler_firebox"},
- ["istor"]={"chest", "tileskychest", "iron", "gold", "diamond", "copper", "silver", "crystal", "obsidian"},
- ["sensor"]={"openperipheral_sensor"},
- ["light"]={"thermalexpansion_light"},
- ["note"]={"note_block"},
- ["selector"]={"openperipheral_selector"},
- }
- knowntypes = {}
- laste = {}
- lasts = {}
- for i,v in pairs(types) do
- for ii,vv in pairs(types[i]) do
- table.insert(knowntypes,vv)
- end
- end
- function printdebug(text)
- if debug then print(text) end
- end
- function dgerror(text)
- print("ERROR: "..text)
- os.sleep(30)
- os.reboot()
- end
- function searchlist(searchfor,list)
- for i=1,#list do
- if list[i]==searchfor then return true end
- end
- return false
- end
- function mysplit(str, pat)
- local t = {}
- local fpat = "(.-)" .. pat
- local last_end = 1
- local s, e, cap = str:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(t,cap)
- end
- last_end = e+1
- s, e, cap = str:find(fpat, last_end)
- end
- if last_end <= #str then
- cap = str:sub(last_end)
- table.insert(t, cap)
- end
- return t
- end
- function readablenumber(n)
- if n >= 10000000000 then return ""..(math.floor((n/1000000000)+0.5)).." G" end
- if n >= 1000000000 then return ""..(math.floor((n/100000000)+0.5)/10).." G" end
- if n >= 10000000 then return ""..(math.floor((n/1000000)+0.5)).." M" end
- if n >= 1000000 then return ""..(math.floor((n/100000)+0.5)/10).." M" end
- if n >= 10000 then return ""..(math.floor((n/1000)+0.5)).." k" end
- if n >= 1000 then return ""..(math.floor((n/100)+0.5)/10).." k" end
- if n >= 100 then return ""..math.floor((n)+0.5).." " end
- return ""..(math.floor((n*10)+0.5)/10).." "
- end
- function updatemessage(pbi,protocol,message)
- messages[protocol.."/"..pbi] = message
- printdebug(pbi.."/"..protocol..": "..message)
- end
- function max(a,b)
- if a>b then return a end
- return b
- end
- -- returns true if it was added
- function addperipheral(side)
- local result = false
- thistype = peripheral.getType(side)
- if searchlist(thistype,knowntypes) then
- --print("Attaching to the "..side.." ("..thistype..")")
- table.insert(pblocks,{peripheral.wrap(side),thistype,side})
- result = true
- end
- return result
- end
- -- returns true if it was added
- function addmodem(side)
- local result = false
- if peripheral.getType(side) =="modem" then
- result = true
- end
- return result
- end
- -- initialise
- term.clear()
- term.setCursorPos(1,1)
- print("Deadlock989's DeadGlass client "..version.." running!")
- if (os.getComputerLabel()==nil) then
- print("Setting computer label to 'dgclient'.")
- os.setComputerLabel("dgclient")
- end
- sides = peripheral.getNames()
- -- look for modems
- -- first pass: prefer a wireless modem
- servermodemside = nil
- for i=1, #sides do
- if peripheral.getType(sides[i]) =="modem" then
- local thismodem = peripheral.wrap(sides[i])
- servermodemside = sides[i]
- rednet.open(sides[i])
- print("Modem located on the "..sides[i].." opened for networking.")
- end
- end
- if servermodemside == nil then
- dgerror("No modem detected. Rebooting in 30.")
- end
- -- look for peripherals
- local count = 0
- for i=1, #sides do
- if addperipheral(sides[i]) then count = count + 1 end
- end
- if count==0 then
- dgerror("No recognised peripherals. Rebooting in 30.")
- else
- print("Attached to "..count.." recognised peripherals.")
- end
- krazserver = rednet.lookup("krazserver","krazserver")
- while krazserver == nil do
- fails = fails + 1
- print("Can't find krazserver. Waiting ... ("..fails..")")
- os.sleep(10)
- krazserver = rednet.lookup("krazserver","krazserver")
- end
- print("Found krazserver! Sending handshake.")
- rednet.send(krazserver,"hello","handshake")
- print("Running ...")
- function colouredredstone(bits,state)
- for k,v in pairs(rs.getSides()) do
- local current = rs.getBundledOutput(v)
- if state then rs.setBundledOutput(v,colors.combine(current,bits))
- elseif colors.test(current,bits) then rs.setBundledOutput(v,current-bits) end
- end
- end
- -- main loop
- function timedmessages()
- local sleepytime = 2
- -- check all the peripherals are still there
- local i = 1
- while i <= #pblocks do
- local rtype = peripheral.getType(pblocks[i][3])
- if rtype==pblocks[i][2] then i = i + 1
- else
- printdebug(pblocks[i][2].." on "..pblocks[i][3].."has gone missing: removing.")
- table.remove(pblocks,i)
- end
- end
- -- abstract the blocks
- iabstracts = {}
- for pbi,pbt in pairs(pblocks) do
- pblock = pbt[1]
- ptype = pbt[2]
- if searchlist(ptype,types["br"]) and pblock.getConnected() then
- if not pblock.isActivelyCooled() then
- local energy = pblock.getEnergyStored()
- table.insert(iabstracts, {["ptype"]=ptype,
- ["ctype"]="br",
- ["energyproduced"]=pblock.getEnergyProducedLastTick(),
- ["energystored"]=energy,
- ["maxenergystored"]=10000000,
- })
- -- auto control
- if energy > 9000000 then pblock.setActive(false)
- elseif energy < 1000000 then pblock.setActive(true)
- end
- else
- local ft = "steam"
- local fp = pblock.getHotFluidProducedLastTick()
- if (ft==nil) then
- ft = "air"
- fp = 0
- end
- table.insert(iabstracts, {["ptype"]=ptype,
- ["ctype"]="brac",
- ["fluidname"]=ft,
- ["fluidproduced"]=fp
- })
- end
- elseif searchlist(ptype,types["brt"]) and pblock.getConnected() then
- local energy = pblock.getEnergyStored()
- table.insert(iabstracts, {["ptype"]=ptype,
- ["ctype"]="brt",
- ["energyproduced"]=pblock.getEnergyProducedLastTick(),
- ["energystored"]=energy,
- ["maxenergystored"]=10000000,
- })
- table.insert(iabstracts, {["ptype"]=ptype,
- ["ctype"]="brtr",
- ["rotorspeed"]=pblock.getRotorSpeed(),
- })
- elseif searchlist(ptype,types["ic2estor"]) then
- table.insert(iabstracts, {["ptype"]=ptype,
- ["ctype"]="ic2estor",
- ["energystored"]=pblock.getEUStored(),
- ["maxenergystored"]=pblock.getEUCapacity(),
- })
- elseif searchlist(ptype,types["ic2nuclear"]) then
- table.insert(iabstracts, {["ptype"]=ptype,
- ["ctype"]="ic2nuclear",
- ["energyproduced"]=pblock.getEUOutput()*5.0,
- ["heatstored"]=pblock.getHeat(),
- ["heatcapacity"]=pblock.getMaxHeat(),
- })
- elseif searchlist(ptype,types["rct"]) then
- table.insert(iabstracts, {["ptype"]=ptype,
- ["ctype"]="rct",
- ["energyproduced"]=pblock.getTurbineOutput()*2
- })
- elseif searchlist(ptype,types["ae2estor"]) then
- table.insert(iabstracts, {["ptype"]=ptype,
- ["ctype"]="ae2estor",
- ["energystored"]=pblock.getStoredPower(),
- ["maxenergystored"]=pblock.getMaxStoredPower(),
- })
- elseif searchlist(ptype,types["ae2istor"]) then
- cells = ""
- c = pblock.getCellCount()
- for i=1,c do
- slot, status = pblock.getCellStatus(i)
- cells = cells .. string.sub(status,1,1)
- end
- table.insert(iabstracts, {["ptype"]=ptype,
- ["ctype"]="ae2istor",
- ["cellcount"]=c,
- ["cellstatus"]=cells,
- })
- elseif searchlist(ptype,types["rfestor"]) then
- table.insert(iabstracts, {["ptype"]=ptype,
- ["ctype"]="rfestor",
- ["energystored"]=pblock.getEnergyStored(),
- ["maxenergystored"]=pblock.getMaxEnergyStored(),
- })
- elseif searchlist(ptype,types["rfgen"]) then
- table.insert(iabstracts, {["ptype"]=ptype,
- ["ctype"]="rfgen",
- ["energyproduced"]=pblock.getEnergyPerTickInfo(),
- })
- elseif searchlist(ptype,types["tanks"]) then
- info = pblock.getTankInfo()
- for i,v in ipairs(info) do
- cap = v.capacity
- if v.contents == nil then
- amount = 0
- name = "air"
- else
- amount = v.contents.amount
- name = v.contents.name
- end
- table.insert(iabstracts, {["ptype"]=ptype,
- ["ctype"]="tanks",
- ["liquidcapacity"]=cap,
- ["liquidstored"]=amount,
- ["liquidname"]=name,
- })
- end
- elseif searchlist(ptype,types["istor"]) then
- local size = pblock.getInventorySize()
- pblock.condenseItems()
- local su = 100/size
- local full = 0.0
- local count = 0
- for i=1,size do
- local stack = pblock.getStackInSlot(i)
- if stack~= nil then
- full = full + (stack.qty/stack.max_size)*su
- count = count + stack.qty
- end
- end
- table.insert(iabstracts, {["ptype"]=ptype,
- ["ctype"]="istor",
- ["inventorysize"]=size,
- ["fullness"]=full,
- ["itemcount"]=count,
- })
- elseif searchlist(ptype,types["sensor"]) then
- table.insert(iabstracts, {["ptype"]=ptype,["ctype"]="sensor",["block"]=pblock})
- --printdebug("abstracted sensor "..ptype)
- end
- if searchlist(ptype,types["rcboiler"]) then
- table.insert(iabstracts, {["ptype"]=ptype,
- ["ctype"]="rcboiler",
- ["heatstored"]=pblock.getTemperature(),
- })
- end
- end
- -- condense the abstractions
- abstracts = {}
- for ai,at in pairs(iabstracts) do
- --printdebug(at["ctype"].." "..at["ptype"])
- found = false
- if at["ctype"]=="br" or at["ctype"]=="brt" or at["ctype"]=="brac" or at["ctype"]=="ic2estor" or at["ctype"]=="rfestor" or at["ctype"]=="rfgen" or at["ctype"]=="istor" or at["ctype"]=="tanks" or at["ctype"]=="rct" then
- for aii,att in pairs(abstracts) do
- if att["ctype"]==at["ctype"] and (at["ctype"]~="tanks" or at["ptype"]==att["ptype"]) and att["liquidname"]==at["liquidname"] then
- --printdebug("Found previous "..at["ctype"])
- for k,v in pairs(att) do
- if k~="ctype" and k~="ptype" and k~="liquidname" then att[k] = att[k] + at[k] end
- -- BUG WITH FULLNESS
- end
- found = true
- break
- end
- end
- end
- if at["ctype"]=="ae2istor" then
- for aii,att in pairs(abstracts) do
- if att["ctype"]==at["ctype"] then
- for k,v in pairs(att) do
- if k~="ctype" and k~="ptype" and k~="cellstatus" then att[k] = att[k] + at[k]
- elseif k=="cellstatus" then att[k] = att[k] .. at[k] end
- end
- found = true
- break
- end
- end
- end
- if not found then
- table.insert(abstracts,at)
- end
- end
- -- create messages
- for ai,abstraction in pairs(abstracts) do
- ctype = abstraction["ctype"]
- ptype = abstraction["ptype"]
- --printdebug(ctype)
- -- BR reactor
- if ctype=="br" then
- if laste[ctype]==nil then laste[ctype]=1 end
- if abstraction["energyproduced"]>laste[ctype] then laste[ctype] = abstraction["energyproduced"] end
- ppercent = math.floor(((abstraction["energyproduced"]/laste[ctype])*100)+0.5)
- spercent = math.floor((abstraction["energystored"]*100/abstraction["maxenergystored"])+0.5)
- updatemessage(ai,"eout", readablenumber(abstraction["energyproduced"]).."RF/t|"..ptype.."|"..ppercent)
- --updatemessage(ai,"estor", readablenumber(abstraction["energystored"]).."RF|"..ptype.."|"..spercent)
- sleepytime = max(sleepytime,2)
- end
- -- BR actively cooled reactor
- if ctype=="brac" then
- if laste[ctype]==nil then laste[ctype]=1 end
- if abstraction["fluidproduced"]>laste[ctype] then laste[ctype] = abstraction["fluidproduced"] end
- percent = math.floor(((abstraction["fluidproduced"]/laste[ctype])*100)+0.5)
- updatemessage(ai,"fout", readablenumber(abstraction["fluidproduced"]/1000).."B/t|"..ptype.."|"..percent.."|"..abstraction["fluidname"])
- sleepytime = max(sleepytime,2)
- end
- -- BR turbine
- if ctype=="brt" then
- if laste[ctype]==nil then laste[ctype]=1 end
- if abstraction["energyproduced"]>laste[ctype] then laste[ctype] = abstraction["energyproduced"] end
- ppercent = math.floor(((abstraction["energyproduced"]/laste[ctype])*100)+0.5)
- --spercent = math.floor((abstraction["energystored"]*100/abstraction["maxenergystored"])+0.5)
- updatemessage(ai,"eout", readablenumber(abstraction["energyproduced"]).."RF/t|"..ptype.."|"..ppercent)
- sleepytime = max(sleepytime,2)
- end
- if ctype=="brtr" then
- if lasts[ctype]==nil then lasts[ctype]=1 end
- if abstraction["rotorspeed"]>lasts[ctype] then lasts[ctype] = abstraction["rotorspeed"] end
- rpercent = math.floor(((abstraction["rotorspeed"]/lasts[ctype])*100)+0.5)
- updatemessage(ai,"eoutspeed", math.floor(abstraction["rotorspeed"]).." RPM|"..ptype.."|"..rpercent)
- sleepytime = max(sleepytime,2)
- end
- -- Batteries
- if ctype=="ic2estor" or ctype=="ae2estor" or ctype=="rfestor" then
- percent = math.floor((abstraction["energystored"]*100/abstraction["maxenergystored"])+0.5)
- updatemessage(ai,"estor", readablenumber(abstraction["energystored"])..units[ctype].."|"..ptype.."|"..percent)
- sleepytime = max(sleepytime,2)
- end
- -- EU generators - RC turbine, IC2 nuclear
- if ctype=="rct" or ctype=="ic2nuclear" then
- if laste[ctype]==nil then laste[ctype]=1 end
- if abstraction["energyproduced"]>laste[ctype] then laste[ctype] = abstraction["energyproduced"] end
- percent = math.floor(((abstraction["energyproduced"]/laste[ctype])*100)+0.5)
- updatemessage(ai,"eout", readablenumber(abstraction["energyproduced"]).."EU/t|"..ptype.."|"..percent)
- sleepytime = max(sleepytime,2)
- end
- -- IC2 nuclear
- if ctype=="ic2nuclear" then
- hpercent = math.floor((abstraction["heatstored"]*100/abstraction["heatcapacity"])+0.5)
- updatemessage(ai,"eheat", math.floor(abstraction["heatstored"]/100).."%|"..ptype.."|"..hpercent)
- sleepytime = max(sleepytime,2)
- end
- -- RC boiler
- if ctype=="rcboiler" then
- if laste[ctype]==nil then laste[ctype]=1 end
- hpercent = math.floor((abstraction["heatstored"]/10)+0.5)
- updatemessage(ai,"eheat", math.floor(abstraction["heatstored"]).."C|"..ptype.."|"..hpercent)
- sleepytime = max(sleepytime,2)
- end
- -- AE storage
- if ctype=="ae2istor" then
- updatemessage(ai,"aecells",abstraction["cellstatus"].."|"..ptype.."|"..abstraction["cellcount"])
- sleepytime = max(sleepytime,10)
- end
- -- TE dynamos
- if ctype=="rfgen" then
- if laste[ctype]==nil then laste[ctype]=1 end
- if abstraction["energyproduced"]>laste[ctype] then laste[ctype] = abstraction["energyproduced"] end
- percent = math.floor(((abstraction["energyproduced"]/laste[ctype])*100)+0.5)
- updatemessage(ai,"eout", readablenumber(abstraction["energyproduced"]).."RF/t|"..ptype.."|"..percent)
- sleepytime = max(sleepytime,2)
- end
- -- Tanks
- if ctype=="tanks" then
- percent = math.floor((abstraction["liquidstored"]*100/abstraction["liquidcapacity"])+0.5)
- buckets = math.floor(abstraction["liquidstored"]/100)/10
- updatemessage(ai,"tank", readablenumber(buckets).."B|"..ptype.."|"..percent.."|"..abstraction["liquidname"])
- sleepytime = max(sleepytime,2)
- end
- -- storage
- if ctype=="istor" then
- updatemessage(ai,"istor", readablenumber(abstraction["itemcount"]).."|"..ptype.."|"..abstraction["fullness"])
- sleepytime = max(sleepytime, 15 * (abstraction["inventorysize"]/54))
- end
- -- sensors
- if ctype=="sensor" then
- local players = abstraction["block"].getPlayers()
- local message = ""
- local count = 0
- local wcount = 0
- local ncount = 0
- local bcount = 0
- for i,v in ipairs(players) do
- message = message .. v.name .. "!"
- count = count + 1
- local whitelisted = searchlist(v.name,whitelist)
- local blacklisted = searchlist(v.name,blacklist)
- if whitelisted then
- printdebug("Whitelisted player detected")
- wcount = wcount + 1
- end
- if blacklisted then
- printdebug("Blacklisted player detected")
- bcount = bcount + 1
- end
- if not whitelisted and not blacklisted then
- printdebug("Neutral player detected")
- ncount = ncount + 1
- end
- end
- colouredredstone(colors.green, wcount > 0)
- colouredredstone(colors.yellow, ncount > 0)
- colouredredstone(colors.red, bcount > 0)
- if count==0 then message = "No-one"
- else message = string.sub(message,1,-2) end
- updatemessage(ai,"sensor",message.."|"..ptype.."|"..count)
- sleepytime = max(sleepytime,2)
- end
- end
- -- send messages
- for i,v in pairs(messages) do
- rednet.send(krazserver,v,i)
- os.sleep(0.05)
- end
- return sleepytime
- end
- function paddlistener()
- local event, side = os.pullEvent("peripheral")
- printdebug("Peripheral added: "..side)
- addperipheral(side)
- end
- function premovelistener()
- local event, side = os.pullEvent("peripheral_detach")
- printdebug("Peripheral removed: "..side)
- for k,v in pairs(pblocks) do
- if v[3]==side then
- table.remove(pblocks,k)
- print(v[2].." removed from active list")
- break
- end
- end
- end
- function lamps(commands)
- printdebug("Lamps")
- if commands[3]~=nil and commands[3]~=os.getComputerLabel() then return end
- local value = tonumber(commands[2],16)
- for pbk,pbv in pairs(pblocks) do
- if searchlist(pbv[2],types["light"]) then
- pbv[1].setColor(value)
- end
- end
- end
- function note(commands)
- printdebug("Note")
- if commands[3]~=nil and commands[3]~=os.getComputerLabel() then return end
- local note = mysplit(commands[2],"#")
- for pbk,pbv in pairs(pblocks) do
- if searchlist(pbv[2],types["note"]) then
- pbv[1].playSound(note[1],note[2],1,0,0,0)
- end
- end
- end
- function brrod(commands)
- printdebug("BRrods")
- if commands[3]~=nil and commands[3]~=os.getComputerLabel() then return end
- local value = tonumber(commands[2])
- for pbk,pbv in pairs(pblocks) do
- if searchlist(pbv[2],types["br"]) then
- pbv[1].setAllControlRodLevels(value)
- end
- end
- end
- function brflow(commands)
- printdebug("BRflow")
- if commands[3]~=nil and commands[3]~=os.getComputerLabel() then return end
- local value = tonumber(commands[2])
- for pbk,pbv in pairs(pblocks) do
- if searchlist(pbv[2],types["brt"]) then
- pbv[1].setFluidFlowRateMax(value)
- end
- end
- end
- function redstone(commands)
- if commands[3]~=nil and commands[3]~=os.getComputerLabel() then return end
- local red = 0
- if commands[2]=="on" then red = 15 end
- printdebug("Redstone")
- for k,v in pairs(rs.getSides()) do
- rs.setAnalogOutput(v,red)
- end
- end
- function credstone(commands)
- if commands[4]~=nil and commands[4]~=os.getComputerLabel() then return end
- local bits = colours[commands[2]]
- printdebug("CRedstone")
- for k,v in pairs(rs.getSides()) do
- local current = rs.getBundledOutput(v)
- if (commands[3]=="on") then rs.setBundledOutput(v,colors.combine(current,bits))
- elseif colors.test(current,bits) then rs.setBundledOutput(v,current-bits) end
- end
- end
- function updatewhitelist(commands)
- if commands[2]==nil then return end
- whitelist = mysplit(commands[2],",")
- end
- function updateblacklist(commands)
- if commands[2]==nil then return end
- blacklist = mysplit(commands[2],",")
- end
- function eventlistener()
- local event, p1, p2, p3 = os.pullEvent()
- -- broadcasts from server
- if event=="rednet_message" and p3=="krazserver" then
- local sender = p1
- local message = p2
- if sender==nil then return end
- printdebug("Received command "..message)
- local commands = mysplit(message," ")
- if commands[1]=="lamps" then lamps(commands)
- elseif commands[1]=="note" then note(commands)
- elseif commands[1]=="redstone" then redstone(commands)
- elseif commands[1]=="credstone" then credstone(commands)
- elseif commands[1]=="whitelist" then updatewhitelist(commands)
- elseif commands[1]=="blacklist" then updateblacklist(commands)
- elseif commands[1]=="brrods" then brrod(commands)
- elseif commands[1]=="brflow" then brflow(commands)
- end
- -- main loop
- elseif event=="timer" and p1==timedmessage then
- timedmessage = os.startTimer(timedmessages())
- elseif event=="slot_click" then
- local slot = p1
- local side = p2
- local p = peripheral.wrap(side)
- local item = p.getSlot(slot)
- printdebug("Item selector clicked: "..item.id)
- if (searchlist(item.id,colourblocks)) then
- local bits = 2^item.dmg
- for k,v in pairs(rs.getSides()) do
- local current = rs.getBundledOutput(v)
- if colors.test(current,bits) then rs.setBundledOutput(v,current-bits)
- else rs.setBundledOutput(v,colors.combine(current,bits)) end
- end
- end
- if (searchlist(item.id,redstoneblocks)) then
- for k,v in pairs(rs.getSides()) do
- rs.setOutput(v, not rs.getOutput(v))
- end
- end
- end
- end
- -- the loop
- timedmessage = os.startTimer(5)
- while true do
- eventlistener()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement