|
| 20 Sep 2015 05:20 PM |
-- the problem is in this function -- can someone explain to me coroutine.yield() i was using it to pause a function and then resume it but it didnt work correctly -- i tested this and when the other function is resumed it glitches out and im confused -- should i be using coroutine.wrap() for any reason? -- god im so confused -- ask for the rest of the script if you need it
local function CustomSong(Song) if coroutine.status(TrackLoop) == "running" or coroutine.status(TrackLoop) == "normal" then coroutine.yield(TrackLoop) end if Sound.IsPlaying then Sound:Pause() end local NewSong = Instance.new("Sound", Speaker:WaitForChild("Speakers")) NewSong.Pitch = 1 NewSong.Volume = 1 Load(Song) local Id = GetNumberFromString(Song) NewSong.SoundId = "rbxassetid://"..Id local function CleanoutCustoms() if NewSong then NewSong:Stop() NewSong:Destroy() end if coroutine.status(TrackLoop) == "suspended" then coroutine.resume(TrackLoop) end if Sound.IsPaused then Sound:Resume() end end delay(500, CleanoutCustoms) while NewSong.TimeLength == 0 do wait() end NewSong:Play() UpdateTitle(MarketplaceService:GetProductInfo(Id).Name) delay(NewSong.TimeLength, CleanoutCustoms) end |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Sep 2015 05:27 PM |
Too long of a script but here's an example of coroutine.yield:
local myThread = coroutine.create(function() for i = 1, 10 do coroutine.yield(); print(i); end end);
coroutine.resume(myThread); -- 1 coroutine.resume(myThread); -- 2 coroutine.resume(myThread); -- 3 coroutine.resume(myThread); -- 4 coroutine.resume(myThread); -- 5 coroutine.resume(myThread); -- 6 coroutine.resume(myThread); -- 7 coroutine.resume(myThread); -- 8 coroutine.resume(myThread); -- 9 coroutine.resume(myThread); -- 10 |
|
|
| Report Abuse |
|
|
|
| 20 Sep 2015 05:31 PM |
so if i did coroutine.yield() of the coroutine at hand from another function and then resumed it after say 100 seconds it would work perfectly? this is confusing.
lines: coroutine.yield(TrackLoop) -- stops the trackloop coroutine and im assuming the wait also? delay(NewSong.TimeLength, CleanoutCustoms) -- delays for the song timelength coroutine.resume(TrackLoop) -- resumes the waiting and all the other stuff?
im getting strange glitches please help! no errors whatsoever |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Sep 2015 05:32 PM |
| yes if nothing changes that causes stuff to go weird then that'd work fine |
|
|
| Report Abuse |
|
|
|
| 20 Sep 2015 05:34 PM |
this is the resumed function: after being tampered with by the other function, it begins to glitch in the way that it cuts songs too short or interrupts them.
local function RunSongs() while true do if Progress > #Songs then Progress = 1 end local Id = GetNumberFromString(Songs[Progress]) Sound.SoundId = "rbxassetid://"..Id while Sound.TimeLength == 0 do wait() end Sound:Play() UpdateTitle(MarketplaceService:GetProductInfo(Id).Name) wait(Sound.TimeLength) Progress = Progress+1 Sound:Stop() end end |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
| 20 Sep 2015 06:12 PM |
| average everyday bump that lives life to the fullest |
|
|
| Report Abuse |
|
|
| |
|
|
| 20 Sep 2015 07:28 PM |
you forgot to stretch your neck before you scripted.
Falcons for Life |
|
|
| Report Abuse |
|
|
|
| 20 Sep 2015 07:29 PM |
and crack your back!
Falcons for Life |
|
|
| Report Abuse |
|
|
| |
|