Server Code:
m = peripheral.wrap("top") bridge = peripheral.wrap("right") rednet.open("top") mfsu_0e = 0 mfsu_2e = 0 Cy = 1 --Mikees script bridge.clear() width = 200 local storageUnits = { { ["id"] = "mfsu_Main", ["name"] = "Main Power" } } local offset = 0 for key, storageUnit in pairs(storageUnits) do pxOffset = offset * 20 storageUnit["label"] = bridge.addText(4, 4 + pxOffset, storageUnit["name"], 0x000000) storageUnit["bar"] = bridge.addBox(4, 14 + pxOffset, 0, 5, 0xCC0000, 0.9) -- storageUnit["bar"].setZIndex(2) storageUnit["bg"] = bridge.addBox(4, 14 + pxOffset, width, 5, 0x000000, 0.5) offset = offset + 1 end --Mikees script end while true do local senderID, message, distance = rednet.receive() x = message:find("x") x = x+1 msg = message:sub(x) value = string.sub(message, 1, x-2) write(msg..": "..value) if msg == mfsu_0 then do mfsu_0e = value end end if msg == mfsu_2 then do mfsu_2e = value end end storageUnit = mfsu_Main capacity = 80000000 amount = mfsu_0e+mfsu_2e barwidht = width / capacity * amount write(mfsu_0e) storageUnit["bar"].setWidth(barwidht) endClient Code:
m = peripheral.wrap("top") rednet.open("top") mfsu0 = peripheral.wrap('mfsu_0') mfsu2 = peripheral.wrap('mfsu_2') while true do -- MFSU_0 amount = mfsu0.getEUStored() rednet.broadcast(amount.."xmfsu_0") write(amount) -- MFSU_2 amount = mfsu2.getEUStored() rednet.broadcast(amount.."xmfsu_2") write(amount) -- Other Funktions os.sleep(10) term.clear() term.setCursorPos(1,1) endThe Clients sends strings like 40000000xmfsu_0
The server should decode them in to:
mfsu_0 (id of the mfsu) and 40000000 (actual energy)
Then he should save 40000000 to mfsu_0e
The last Part is for changing the bar on the glasses.
amount = mfsu_0e+mfsu_2e is because i have 2 msfu's that i want to combine.