generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Can't think of a way to do this right

Previous Thread :: Next Thread 
bigpeking is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. BEART12
Joined: 22 Oct 2008
Total Posts: 3190
15 Jun 2011 06:27 PM
What do you mean by connected?

Constantly touching?
Report Abuse
BladzofChaos70 is not online. BladzofChaos70
Joined: 27 Sep 2008
Total Posts: 2550
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 is not online. 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 is not online. 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 is not online. bigpeking
Joined: 17 May 2008
Total Posts: 1023
16 Jun 2011 08:59 AM
Bump.
Report Abuse
bigpeking is not online. bigpeking
Joined: 17 May 2008
Total Posts: 1023
16 Jun 2011 10:19 AM
Iiiiii will keep bumpiiiiiiing till the eeeeeeend
Report Abuse
hyper900 is not online. 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 is not online. hyper900
Joined: 14 May 2009
Total Posts: 873
16 Jun 2011 10:23 AM
if model*
Report Abuse
alexmach1 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. bigpeking
Joined: 17 May 2008
Total Posts: 1023
16 Jun 2011 06:38 PM
Bump
Report Abuse
alexmach1 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image