Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 23 Nov 2012 05:06 PM |
What's taking so long!? I'm creating a game reliant on two or more players, and if one player leaves in the middle of the game giving us only one player, I want it to go back to the beginning of the script. Goto would be extremely helpful right now and I don't want to go through the troubles of coroutines or anything like that for something so simple. |
|
|
| Report Abuse |
|
|
thumper10
|
  |
| Joined: 17 Apr 2009 |
| Total Posts: 3304 |
|
| |
|
xSIXx
|
  |
| Joined: 06 Aug 2010 |
| Total Posts: 9202 |
|
|
| 23 Nov 2012 05:13 PM |
workspace.Script.Disabled = true workspace.Script.Disabled = false |
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 23 Nov 2012 05:15 PM |
| Oh yeah, and I'm referencing the need for GOTO. |
|
|
| Report Abuse |
|
|
|
| 23 Nov 2012 05:17 PM |
Hey...
When you use goto, what happens to all the variables that were initialized and defined before the goto? Do they stay the same and make a huge mess in the flow of the program? |
|
|
| Report Abuse |
|
|
|
| 23 Nov 2012 05:25 PM |
| That's sloppy coding. You should be able to accomplish your task with the current implementation of Lua. |
|
|
| Report Abuse |
|
|
Roundel
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 469 |
|
| |
|
thumper10
|
  |
| Joined: 17 Apr 2009 |
| Total Posts: 3304 |
|
| |
|
Solotaire
|
  |
| Joined: 30 Jul 2009 |
| Total Posts: 30356 |
|
| |
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
| |
|
Solotaire
|
  |
| Joined: 30 Jul 2009 |
| Total Posts: 30356 |
|
|
| 23 Nov 2012 05:49 PM |
function Init() game.Players.ChildRemoved:connect(function() if #game.Players:GetChildren() < 2 then break end end)
-- the rest of your script end
game.Players.PlayerAdded:connect(function(player) if #game.Players:GetChildren() == 2 then Init() end end) |
|
|
| Report Abuse |
|
|
Solotaire
|
  |
| Joined: 30 Jul 2009 |
| Total Posts: 30356 |
|
| |
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 23 Nov 2012 05:56 PM |
> Goto would be extremely helpful right now
No. No. Nooo. Goto is evil. Horrible. You may think "I'll just add a little goto statement here*
It ruins your idea of how your program flows, and makes it really confusing to work with any large script. Seriously. Read the xkcd comic. Don't use goto's. Please don't.
I suggest instead of using a goto statement, you use a 'break' statement.
|
|
|
| Report Abuse |
|
|
|
| 23 Nov 2012 06:50 PM |
function dogame() while wait() do --codepls --use break for if players <= 2 then break end end dogame() end
dogame() kyw.
~ Moo logic = logical logic ~ |
|
|
| Report Abuse |
|
|
Merely
|
  |
| Joined: 07 Dec 2010 |
| Total Posts: 17266 |
|
|
| 23 Nov 2012 07:47 PM |
| A goto isn't going to redefine variables or make things back to how they were before. It's just going to break your poorly coded script. |
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 23 Nov 2012 08:08 PM |
@Merely Please get the heck out, you moneybag. |
|
|
| Report Abuse |
|
|
thumper10
|
  |
| Joined: 17 Apr 2009 |
| Total Posts: 3304 |
|
|
| 23 Nov 2012 08:12 PM |
@Tenal You're so mean to Merely :( Here Merely, have a cookie.
~ I ate Sorcus ~ |
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 23 Nov 2012 08:13 PM |
@thumper Well, he called my script 'poorly coded'. He was mean to me first. |
|
|
| Report Abuse |
|
|
129K
|
  |
| Joined: 23 Aug 2011 |
| Total Posts: 19010 |
|
|
| 23 Nov 2012 08:14 PM |
"He was mean to me first."
i've never thought you were this stupid |
|
|
| Report Abuse |
|
|
thumper10
|
  |
| Joined: 17 Apr 2009 |
| Total Posts: 3304 |
|
|
| 23 Nov 2012 08:14 PM |
@Tenal Oh, mkay. I'll take that cookie back now.
~ I ate Sorcus ~ |
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 23 Nov 2012 08:15 PM |
@129k Learn some grammar, you MrNicNac fanboy. |
|
|
| Report Abuse |
|
|
thumper10
|
  |
| Joined: 17 Apr 2009 |
| Total Posts: 3304 |
|
|
| 23 Nov 2012 08:16 PM |
"i've never thought you were this stupid" ur faic
On Topic: Honestly I'm OK with 5.1, but I here 5.2 is "faster". The thing is, isn't Lua already fast?
~ I ate Sorcus ~ |
|
|
| Report Abuse |
|
|
129K
|
  |
| Joined: 23 Aug 2011 |
| Total Posts: 19010 |
|
|
| 23 Nov 2012 08:16 PM |
"Learn some grammar" oh no she's going for the grammar |
|
|
| Report Abuse |
|
|
thumper10
|
  |
| Joined: 17 Apr 2009 |
| Total Posts: 3304 |
|
|
| 23 Nov 2012 08:16 PM |
GAH! *hear
~ I ate Sorcus ~ |
|
|
| Report Abuse |
|
|
thumper10
|
  |
| Joined: 17 Apr 2009 |
| Total Posts: 3304 |
|
|
| 23 Nov 2012 08:17 PM |
Tenal vs. 129K This should be interesting. I'm betting on Tenal.
~ I ate Sorcus ~ |
|
|
| Report Abuse |
|
|