Jump to content

Recommended Posts

Posted

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)"

},

Posted

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?

Posted

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

Posted

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.

Posted

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

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...