bigpeking
|
  |
| Joined: 17 May 2008 |
| Total Posts: 1023 |
|
|
| 15 Jun 2011 04:46 PM |
I made electricity current rods that create currents between them if they are powered. It works all fine, it can power an infinite amount, but, if there are two that aren't directly connected to the generator, you can move the one directly connected, and they will keep powering eachother. I've tried several ways and none of them have worked. I need someone to help me think of a way to make it so that they in some way need to be directly or indirectly connected to the generator. Here's the revelant part of the script:
while true do wait(.05)
selected = {} x = script.Parent.Parent:getChildren() count = 0 for i,v in pairs(x) do if v.Name == "CurrentPole" then if v.Powered.Value == true then if v ~= script.Parent then if (script.Parent.Generator.Position - v.Generator.Position).magnitude <= 25 then count = count + 1 table.insert(selected,v) end end end end if v.Name == "CurrentGenerator" then if (script.Parent.Generator.Position - v.Generator.Position).magnitude <= 25 then count = count + 1 table.insert(selected,v) end end end
if count >= 1 then script.Parent.Powered.Value = true else script.Parent.Powered.Value = false end
end |
|
|
| Report Abuse |
|
|
bigpeking
|
  |
| Joined: 17 May 2008 |
| Total Posts: 1023 |
|
|
| 15 Jun 2011 05:27 PM |
Bump.
I'll try almost all suggestions, so at least try. |
|
|
| Report Abuse |
|
|
bigpeking
|
  |
| Joined: 17 May 2008 |
| Total Posts: 1023 |
|
|
| 15 Jun 2011 06:18 PM |
| Not posting isn't helping me solve this any faster. |
|
|
| Report Abuse |
|
|
BEART12
|
  |
| Joined: 22 Oct 2008 |
| Total Posts: 3190 |
|
|
| 15 Jun 2011 06:22 PM |
| Check the layout of your code and place ends carefully . |
|
|
| Report Abuse |
|
|
bigpeking
|
  |
| Joined: 17 May 2008 |
| Total Posts: 1023 |
|
|
| 15 Jun 2011 06:24 PM |
| I'm fairly certain all the ends are placed correctly, but lemme check. |
|
|
| Report Abuse |
|
|
bigpeking
|
  |
| Joined: 17 May 2008 |
| Total Posts: 1023 |
|
|
| 15 Jun 2011 06:25 PM |
Yep, they're all correct.
And by the way, the code works fine, I just can't figure out what to add to make it so that it has to in some way be connected to the generator. |
|
|
| Report Abuse |
|
|
BEART12
|
  |
| Joined: 22 Oct 2008 |
| Total Posts: 3190 |
|
|
| 15 Jun 2011 06:27 PM |
What do you mean by connected?
Constantly touching? |
|
|
| Report Abuse |
|
|
|
| 15 Jun 2011 06:28 PM |
| It's because you never check to see if their farther away. All you do is see when they are close to it, and then powers them, but after that it never checks to see if they're no longer within range. So, if it's never checking the ones away from it, last they heard is that they have power and so nothing changes when they're no longer in range. |
|
|
| Report Abuse |
|
|
BEART12
|
  |
| Joined: 22 Oct 2008 |
| Total Posts: 3190 |
|
|
| 15 Jun 2011 06:33 PM |
So do .... Under your other magnitude bit...
elseif Samecode here > then--Away from it
|
|
|
| Report Abuse |
|
|
bigpeking
|
  |
| Joined: 17 May 2008 |
| Total Posts: 1023 |
|
|
| 15 Jun 2011 10:56 PM |
This isn't the entire code, it does disconnect if it gets too far away.
But my problem is that if you have the generator, then a current pole, then another current pole, then one more current pole, all spaced out so that the current connects in a line, if you remove the one closest to the generator, the two ones not connected will be able to power each other. |
|
|
| Report Abuse |
|
|
bigpeking
|
  |
| Joined: 17 May 2008 |
| Total Posts: 1023 |
|
| |
|
bigpeking
|
  |
| Joined: 17 May 2008 |
| Total Posts: 1023 |
|
|
| 16 Jun 2011 10:19 AM |
| Iiiiii will keep bumpiiiiiiing till the eeeeeeend |
|
|
| Report Abuse |
|
|
hyper900
|
  |
| Joined: 14 May 2009 |
| Total Posts: 873 |
|
|
| 16 Jun 2011 10:22 AM |
if mode:FindFirstChild("Poleconnectedtogenerator", false) then Stuff for electricity between the two left |
|
|
| Report Abuse |
|
|
hyper900
|
  |
| Joined: 14 May 2009 |
| Total Posts: 873 |
|
| |
|
alexmach1
|
  |
| Joined: 02 May 2008 |
| Total Posts: 1977 |
|
|
| 16 Jun 2011 10:24 AM |
| why dont you make a value called 'number' for the number of poles away from the generator, so that if pole 2 sees that pole 1 is not active, then that means it is no longer connected to the generator and thus shuts down. |
|
|
| Report Abuse |
|
|
bigpeking
|
  |
| Joined: 17 May 2008 |
| Total Posts: 1023 |
|
|
| 16 Jun 2011 10:31 AM |
| I can't determine how far and how many poles away, because players are able to move the poles around. |
|
|
| Report Abuse |
|
|
alexmach1
|
  |
| Joined: 02 May 2008 |
| Total Posts: 1977 |
|
|
| 16 Jun 2011 10:32 AM |
| are they all connected together, or in a sequence (line)? |
|
|
| Report Abuse |
|
|
bigpeking
|
  |
| Joined: 17 May 2008 |
| Total Posts: 1023 |
|
|
| 16 Jun 2011 05:27 PM |
| They are seperate poles that can be spaced out, and they aren't in a perfect line. |
|
|
| Report Abuse |
|
|
bigpeking
|
  |
| Joined: 17 May 2008 |
| Total Posts: 1023 |
|
| |
|
alexmach1
|
  |
| Joined: 02 May 2008 |
| Total Posts: 1977 |
|
|
| 16 Jun 2011 08:55 PM |
| not what i asked. do they all connect together or are they connected in a line. |
|
|
| Report Abuse |
|
|