|
| 31 Jul 2011 07:20 PM |
Active = not Active Current = Active while Active == Current and HowMuch > - 9.4 do
If that is in a function, and it is called twice, shouldn't only one loop be running?
~Think Inside The Squiggles~ |
|
|
| Report Abuse |
|
|
Boomarang
|
  |
| Joined: 15 Jul 2008 |
| Total Posts: 919 |
|
|
| 31 Jul 2011 07:24 PM |
| If you have a nested loop then, yes, one should run until it dies, then run again. A nested loop. |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 07:26 PM |
Example (PART OF SCRIPT):
function toClose() ChangeColor("Bright red") Active = not Active Current = Active while Active == Current and HowMuch < .1 do wait(.05) Door.CFrame = Door.CFrame + Vector3.new(0, .1, 0) HowMuch = HowMuch + .1 end end
function toOpen() ChangeColor("Dark green") Active = not Active Current = Active while Active == Current and HowMuch > - 9.4 do wait(.05) Door.CFrame = Door.CFrame - Vector3.new(0, .1, 0) HowMuch = HowMuch - .1 end end
toOpen() wait(1) toClose()
Shouldn't the loop in toOpen stop and only the one in toClose run? Because, it doesn't... ~Think Inside The Squiggles~ |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 07:28 PM |
Bump
~Think Inside The Squiggles~ |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 07:34 PM |
^
~Think Inside The Squiggles~ |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 07:58 PM |
Help please?
~Think Inside The Squiggles~ |
|
|
| Report Abuse |
|
|
Newtrat
|
  |
| Joined: 13 Jun 2011 |
| Total Posts: 196 |
|
|
| 31 Jul 2011 08:03 PM |
I think the issue is that you're using Current as a global variable, so when you change Current in toClose it changes Current back in toOpen as well... hence Current is always equal to Active (since you set Current = Active in both functions) except for the split second in the first line of toClose... which goes by too fast for the engine to recognize the change.
Try changing the lines to local Current = Active
or maybe renaming one of the Current variables. |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 08:04 PM |
In that case, yes, because the function is running on the same thread as the rest of the script. However, if you are doing it with events, it won't work that way, since functions called by events are run on seperate threads, so they won't interfere with the flow of the rest of the script.
~Sorcus |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 08:05 PM |
Conflicting answers...
~Think Inside The Squiggles~ |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 08:06 PM |
Whatever answer I give will always be the correct one. :D
~Sorcus |
|
|
| Report Abuse |
|
|
| |
|
Newtrat
|
  |
| Joined: 13 Jun 2011 |
| Total Posts: 196 |
|
|
| 31 Jul 2011 08:12 PM |
| @crazypotato4: really? I would have thought that it wouldn't matter whether the functions were called by events or not; since they're in the same script the variable Current should be the same variable in both of them as the script is currently written... or anyway that's what I thought. Does it work differently because Current isn't declared as being local to the script? Do I have no idea what I'm talking about? (Maybe.) |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 08:13 PM |
*Uses Newtrat's advice*
~Think Inside The Squiggles~ |
|
|
| Report Abuse |
|
|
|
| 31 Jul 2011 08:15 PM |
Sorry crazy, but Newtrat's fix worked...
~Think Inside The Squiggles~ |
|
|
| Report Abuse |
|
|