![]() ![]() The "maximum neighbor" rule ensures that power can only flow a maximum distance. It doesn't matter if five wires all come together in a knot. In this way, power propagates from supplier through all wires up to a distance of 15, but you don't spend extra CPU figuring out what has power next time. > if this new calculated strength is different from last time, mark it as a change for the next round > if the block receives power, perform its action if the strength is above 0 > if the block can carry power (like a wire), it has strength of the maximum neighbor minus 1, or 0 at minimum > if the block supplies power, it has strength 15 * Twenty times a second, power is calculated on all blocks in the world that are marked as a change, or are a neighbor to a changed block. * If the player flips a switch or places or breaks a block that produces or consumes power, this is marked as a change. * If the player rips up a piece of wire, the empty space left behind is made to be unpowered and marked as a change. * If the player puts down a bit of wire, it is assumed to be unpowered and marked as a change. Only the potential changes are worth computing, to save CPU time. * A set of world locations is kept that indicate something about redstone power has changed or not. Minecraft's method is based on cellular automata rules. So, I really don't know how they did that.Ĭan anyone here, please, give me one insight about this situation ? Maybe a better approach. And if I don't have a machine to use this energy, the generator do not consume any energy. The cables can admit different voltages, and have a "bandwich limit" per model. ![]() I was looking into the minecraft mod approach, where they have a generator which can be linked to at least 6 cables, one at each side of the block. And if I remove one cable in the middle, I would need to do a check to all other cables, to see if they are still a member of one energy line, or if they should create a new energy line to be member. So, I cannot have multiple energy lines connected to a single provider. The problem with this approach, is that each provider can only be a member of one energy line. Then, when one consumer needs energy, I could simple check in the energy line, if is there any provider, and ask for energy. If true, I make this cable a member of this energy line, if false, I would create a new energy line, for this cable. So, everytime I lay down a cable, I could check if this cable is adjacent to any other cable which is already a member of one energy line. I was thinking to have a "parent" gameobject to hold energy lines. And of course, I've a lot of coroutines running in background, which I didn't checked, but I believe that could be very processing consuming, right ? And of course, if I lay down a lot of cables, at some point, the supplier will be exhausted without anyone use this energy. The problems I had with this solution, it's that I'm "consuming" energy without a object to use that, because all cable "ask" for energy, and this energy stay there without being used. And the object which will consume this energy has another script, to only ask this energy. The energy supplier has a script to "provide" energy, every time "someone" ask. Those cables has a coroutine to check if they have any energy inside, and if don't, they do a loop over all other adjacent cables, to "ask" for energy. So everytime I place a new cable, I call a event to all cables checks adjacents cables, and store them in a list. My first approach was to have a script attached to any cable, which would hold a certain amount of energy. And you can add another cable making a cross, to split this electricity to another point. In both games, you need to place some cables to transfer electricity between 2 points. Think about prison architect, or minecraft with the industrial mod. I mean, how can I do this in a good way, where my object will only works, if any energy is been supplied ? But I really don't know the better way to transfer this energy. I'm trying to create a object to my game, which has a need for energy (or water), and to provide this, I need to connect this object to a energy supplier. I've a question, but I don't believe that this should be categorized as a script question.
0 Comments
Leave a Reply. |