Tuxmelv Posted October 3, 2013 Posted October 3, 2013 I'm looking at tweaking a program http://pastebin.com/1sqCRqjj, for monitoring a large bank of Redstone Energy Cells. Problem is, I have to manually edit the program with 4 lines every additional REC I have. As I'm currently at 70 RECs and growing, I would like to make this part dynamic where I enter the total RECs I have and it appends the name for me, adding the below up to the max number of RECs I have. Thoughts? { ["id"] = "redstone_energy_cell_(X)"; ["name"] = "Cell(X-1)" }, Quote
phazeonphoenix Posted October 3, 2013 Posted October 3, 2013 I think this is what you're needing local storageUnitCount = 69 -- Total number of RECs minus 1 since the cell id starts with 0. local storageUnits = {} for i=0, storageUnitCount do storageUnits = { ["id"] = "redstone_energy_cell_" .. i, -- you concatenate with the .. operator ["name"] = "Cell" .. i+1 } end That will build the same table structure you've had to manually define before. I'm a bit confused how you're reading the individual RECs though. Sensors? Computers at each REC? Quote
Tuxmelv Posted October 3, 2013 Author Posted October 3, 2013 I have wired modems on each REC, then the program uses the following code (with net defined as a peripheral.wrap on the modem side) via OpenPeripheral as part of the base tekkit pack. for i=#storageUnits,1,-1 do storageUnit = storageUnits[i] capacity = capacity + net.callRemote(storageUnit["id"], "getMaxEnergyStored") amount = amount + net.callRemote(storageUnit["id"], "getEnergyStored") end Quote
Tuxmelv Posted October 6, 2013 Author Posted October 6, 2013 Thanks Phazeonphoenix! The table code is awesome, but looks like it doesn't count 1 REC. I haven't had time to troubleshoot to see which one is missing. That shouldn't be a problem. Quote
phazeonphoenix Posted October 6, 2013 Posted October 6, 2013 I think the problem might be the fact that every value but the name field starts counting at 0. Do you have a redstone_energy_cell_0 or do you have a redstone_energy_cell_70? It's easy to change the code to start counting at 1. local storageUnitCount = 70 -- change this local storageUnits = {} for i=1, storageUnitCount do -- change this storageUnits = { ["id"] = "redstone_energy_cell_" .. i, ["name"] = "Cell" .. i -- change this } end Quote
Tuxmelv Posted October 7, 2013 Author Posted October 7, 2013 It starts at redstone_energy_cell_0. I was testing this out in a temp creative world first. Had 60 RECs, set it to 59 (2 sets of 30 for max Redstone Energy Conduits) and wired both of them up to the computer via modems. Shows 35.4 mil MJ instead of 36 mil MJ. Being 1 short doesn't bother me that much when there are that many. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.