Jump to content

Allow tile-entities to share the same energy storage(Dynamic based on #of Tiles)


GyroEmpire

Recommended Posts

I've created a solar panel block that generates power. I would like to be able to place them next to each other to allow them to share the same power storage and generation based on the blocks size. On top of that, i would also like to pull the power out of any one of the blocks, and drain the same internal buffer. I'm not really sure how to go about this efficiently. I'm not to familiar with how multi-blocks work, should this be one of them? Or should i have them export to each others buffers(I think this would cause bad lag, and they would have to have huge buffers to compensate for energy production). I'm pretty sure i can write the code for however it will work, just need some help determining how it should work(When, where, and how to do the things that need to be done).

Link to comment
Share on other sites

Every method used is different, and almost every mod designs there own power system. Unless you want to make an addon for BC2 or UE or something. Start putting together ideas and trying them out.

Link to comment
Share on other sites

Hows this sound? On placed check for other solar panels around it, if there are none create a new tile-entity, if there are some, add to a variable in the main  tile entity, increasing the gen and storage. The problems are that 1. I dont know how to differentiate between the tile entities to add to variables

2. I dont know how to get power out of any of them but the main one.

Ps. Im using king lemming's api, so i can use rf.

Link to comment
Share on other sites

How about something like this:

 

Every solar panel has its own tile entity. Each tile entity has a List (lets call it otherPanels) that will contain a list of all other solar panels in the structure.

When placed, the tile checks adjacent blocks for solar panel tiles, and if it finds one, it requests from it its otherPanels list, sets it as its own.

It then notifies every tile in that list that it is now also part of the list (enumerate through the list and call .addToOtherPanels(this) or something for each element).

 

You can also now call some method for every other panel to notify them that the storage capacity has increased.

 

When any panel loses energy, it enumerates through that list and tells all the other panels to decrease their internal buffers by the appropriate amount.

 

So basically every panel keeps track of the total capacity and current energy level for the whole structure, and they are all synced when any of those changes by whatever panel caused the change.

 

I feel like there's a way you can do this recursively, but I haven't thought it through enough for that.

 

I don't know if this is the best approach, but it's all I could come up with off the top of my head at 2am. Let me know what you think

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

By using this site, you agree to our Terms of Use.