Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 27 Aug 2015 07:49 PM |
im bad thanks for the help
im trying to do a cool fade animation thing while minimizing the lines and being efficient
thanks loves |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 07:55 PM |
I'm not exactly sure what you're asking but.
If you use delay(function, (waitTime) end)
You can run multiple lines at the same time.
Example: for i = 1, 2 delay(function, 0.25 print("YEP") end) end
You would see two Yep's pritned at the same time after 0.25 seconds. |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 27 Aug 2015 08:05 PM |
Well the line of code would already be running in the coroutine but i would want to start it again before it completes, but still have it complete what it was doing just be doing it twice same time
thank you for that other bit of code tho didn't know about it before |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 27 Aug 2015 08:13 PM |
basically
local BorderPixelGrow = coroutine.create(function() for i = 0, 90 do wait(.2) brick[i].Transparency = .1 end end end end)
local BorderPixelShrink = coroutine.create(function() for i = 0, 90 do wait(.2) brick[i].Transparency = .5 end end end end)
coroutine.resume(BorderPixelGrow) wait(.5) coroutine.resume(BorderPixelShrink) wait(.5) coroutine.resume(BorderPixelGrow)
but wouldnt work because already running like a fridge |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 08:16 PM |
| uhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
| |
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 27 Aug 2015 09:03 PM |
but if i do
local BorderPixelGrow = coroutine.create(function() for i = 0, 90 do wait(.2) brick[i].Transparency = .1 end end end end)
local BorderPixelShrink = coroutine.create(function() for i = 0, 90 do wait(.2) brick[i].Transparency = .5 end end end end)
local BorderPixelGrow1 = coroutine.create(function() for i = 0, 90 do wait(.2) brick[i].Transparency = .1 end end end end)
while 1 == 1 do coroutine.resume(BorderPixelGrow) wait(.5) coroutine.resume(BorderPixelShrink) wait(.5) coroutine.resume(BorderPixelGrow1) end
it would work perfectly |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
| |
|
|
| 27 Aug 2015 09:23 PM |
local Mode = nil
local BorderPixelGrow = coroutine.create(function() Mode = "Growing" for i = 0, 90 do wait(.2) if Mode == "Shrinking" then break end brick[i].Transparency = .1 end end)
local BorderPixelShrink = coroutine.create(function() Mode = "Shrinking" for i = 0, 90 do wait(.2) if Mode == "Growing" then break end brick[i].Transparency = .5 end end)
coroutine.resume(BorderPixelGrow) wait(.5) coroutine.resume(BorderPixelShrink) wait(.5) coroutine.resume(BorderPixelGrow)
Lord of all things, breaded and unbreaded. |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 27 Aug 2015 09:25 PM |
| i want it to continue to grow tho the bricks ie 80 thru 99 and start up growing bricks 0 thru 99 again when started up at the same time, because bricks 0 thru 40 will be shrunk already by the second coroutine |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 09:29 PM |
local Mode = nil
local BorderPixelGrow = function() Mode = "Growing" for i = 0, 90 do wait(.2) if Mode == "Shrinking" then break end brick[i].Transparency = .1 end end
local BorderPixelShrink = function() Mode = "Shrinking" for i = 0, 90 do wait(.2) if Mode == "Growing" then break end brick[i].Transparency = .5 end end
spawn(BorderPixelGrow) wait(.5) spawn(BorderPixelShrink) wait(.5) spawn(BorderPixelGrow)
Lord of all things, breaded and unbreaded. |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 27 Aug 2015 09:31 PM |
I don't want it to stop the current coroutine or function just run another thread of it, like a clone or copy. so I can have 2 sets fading in and fading out at the same time |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 09:35 PM |
local BorderPixelGrow = function() for i = 0, 90 do wait(.2) brick[i].Transparency = .1 end end
local BorderPixelShrink = function() for i = 0, 90 do wait(.2) brick[i].Transparency = .5 end end
spawn(BorderPixelGrow) wait(.5) spawn(BorderPixelShrink) wait(.5) spawn(BorderPixelGrow)
Lord of all things, breaded and unbreaded. |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 27 Aug 2015 09:37 PM |
That doesn't work because the first coroutine is already running by the time it is called upon a 2nd time
it works if I duplicate the local coroutine and name it something different and then call upon that |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 09:48 PM |
That's no longer coroutines. I'm spawning the functions instead.
Lord of all things, breaded and unbreaded. |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 27 Aug 2015 11:18 PM |
| But I want them to run at the same time |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 11:32 PM |
They do.
Lord of all things, breaded and unbreaded. |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 27 Aug 2015 11:33 PM |
| I thought functions ran the whole way through before continuing along in the script? |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 11:54 PM |
try this
local BorderPixelGrow1 = function() for i = 0, 90 do wait(.2) brick[i].Transparency = .1 end end end)
for i = 1,3,1 do wait(1) spawn(BorderPixelGrow1 ) end |
|
|
| Report Abuse |
|
|
|
| 27 Aug 2015 11:59 PM |
I used spawn(), which is similar to coroutines in that it's non-blocking.
Lord of all things, breaded and unbreaded. |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 28 Aug 2015 12:03 AM |
but i want it to
1. Begin making all the bricks transparent (lets say it takes 10 seconds to complete) 2. Before all the bricks are made transparent, after 2 seconds, all of the bricks are made nontransparent again 3. all of the bricks start becoming transparent again (but before step 1 finishes or before step 2 finishes too)
Does anyone know if the delay function allows the script to continue down the thread or does it act as a wait? |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 28 Aug 2015 12:04 AM |
ghost thanks for your help im a literal idiot and didnt realize you added spawn
i thought you were just calling the function :(
thx for putting up with me |
|
|
| Report Abuse |
|
|