025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
| |
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 06 Apr 2015 04:53 PM |
nvm
just cant do it from cmdbar |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 06 Apr 2015 04:53 PM |
while wait() do end
while wait() do end
It will fire the first while loop, not the second. You can do this instead
while wait() do
while wait() do end
end |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 06 Apr 2015 04:53 PM |
| Actually you can run multi lined scripts in command bar. It doesn't look pretty but it works |
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 06 Apr 2015 04:54 PM |
nvm on my nvm
it doesn't fire
here's my code
while wait(1 * 60) do spawnEgg("Egg1"); end
while wait(2 * 60) do spawnEgg("Egg2"); end
while wait(5 * 60) do spawnEgg("Egg3"); end
while wait(8 * 60) do spawnEgg("Egg4"); end
while wait(10 * 60) do spawnEgg("Egg5"); end
while wait(20 * 60) do spawnEgg("Egg6"); end
while wait(25 * 60) do spawnEgg("Egg7"); end
while wait(40 * 60) do spawnEgg("Egg8"); end
while wait(60 * 60) do spawnEgg("Egg9"); end
function spawnEgg(egg) if game.Lighting:FindFirstChild(egg) then local copy = game.Lighting:FindFirstChild(egg):Clone() copy.Parent = workspace copy.CFrame = CFrame.new(math.random(-552,552), 15 , math.random(-460, 647)) end end |
|
|
| Report Abuse |
|
|
| |
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 06 Apr 2015 04:55 PM |
so
while wait(1 * 60) do spawnEgg("Egg1");
while wait(2 * 60) do spawnEgg("Egg2");
while wait(5 * 60) do spawnEgg("Egg3");
while wait(8 * 60) do spawnEgg("Egg4");
while wait(10 * 60) do spawnEgg("Egg5");
while wait(20 * 60) do spawnEgg("Egg6");
while wait(25 * 60) do spawnEgg("Egg7");
while wait(40 * 60) do spawnEgg("Egg8");
while wait(60 * 60) do spawnEgg("Egg9"); end end end end end end end end
end
function spawnEgg(egg) if game.Lighting:FindFirstChild(egg) then local copy = game.Lighting:FindFirstChild(egg):Clone() copy.Parent = workspace copy.CFrame = CFrame.new(math.random(-552,552), 15 , math.random(-460, 647)) end end |
|
|
| Report Abuse |
|
|
|
| 06 Apr 2015 04:56 PM |
| WHY ARE YOU USING LIGHTING FOR STORAGE |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 06 Apr 2015 04:56 PM |
Or, you can use coroutines or the spawn function. I prefer coroutines.
coroutine.resume(coroutine.create(function() while true do --yourstuff end end))
while true do --morestuff end |
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
| |
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 06 Apr 2015 05:00 PM |
| I don't really understand coroutines I've tried b4 |
|
|
| Report Abuse |
|
|
wonuf
|
  |
| Joined: 28 May 2013 |
| Total Posts: 133 |
|
|
| 06 Apr 2015 05:02 PM |
Put them in a function and spawn them
functiom Loop1() spawn(function() while...etc end) end
functiom Loop2() spawn(function() while...etc end) end
Loop1() Loop2() |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 06 Apr 2015 05:02 PM |
Just use spawn() if you don't understand
spawn(function() while true do --stuff end end))
while true do --more stuff end |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 06 Apr 2015 05:03 PM |
| And Lighting is the old way of storing random junk. Use ServerStorage and ReplicatedStorage. |
|
|
| Report Abuse |
|
|
wonuf
|
  |
| Joined: 28 May 2013 |
| Total Posts: 133 |
|
|
| 06 Apr 2015 05:05 PM |
| If running from a server script, rayk999 |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 06 Apr 2015 05:05 PM |
| I've included ReplicatedStorage in my answer, too |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 06 Apr 2015 05:19 PM |
"Or, you can use coroutines or the spawn function. I prefer coroutines."
spawn uses coroutines :)
I script -~ chimmihc |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 06 Apr 2015 05:24 PM |
None of you considered the even moderately sensible thing
while wait(1 * 60) do spawnEgg("Egg1"); while wait(2 * 60) do spawnEgg("Egg2"); while wait(5 * 60) do spawnEgg("Egg3"); while wait(8 * 60) do spawnEgg("Egg4"); while wait(10 * 60) do spawnEgg("Egg5"); while wait(20 * 60) do spawnEgg("Egg6"); while wait(25 * 60) do spawnEgg("Egg7"); while wait(40 * 60) do spawnEgg("Egg8"); while wait(60 * 60) do spawnEgg("Egg9");
Can just become
local t = 0; while wait(1) do t = t+1 spawnEgg('Egg1') if t%2 == 0 then spawnEgg('Egg2') end -- etc |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 06 Apr 2015 05:29 PM |
| In the future if you do need to run two loops simultaneously, I think spawn(function() end) is better. Since it's ROBLOX specific it's handled C-side which means real threading. Lua's coroutines aren't real threads, which means you can't get any benefit from multi-core processors. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 06 Apr 2015 05:31 PM |
| It's actually better because it uses your scripts idle time instead of making them compete |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 06 Apr 2015 05:33 PM |
"It's actually better because it uses your scripts idle time instead of making them compete"
Can you explain in more detail please? |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 06 Apr 2015 05:38 PM |
| Instead of making new threads and stuff, it uses the time that the current thread is supposed to be yielding with wait() and runs it in that time instead. It's an interesting way to handle things like that and much better than coroutines unless it is imperative they operate at the same time as eachother |
|
|
| Report Abuse |
|
|