generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: What's wrong with my coroutine setup?

Previous Thread :: Next Thread 
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
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
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
20 Sep 2015 05:22 PM
bump
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
20 Sep 2015 05:25 PM
bump
/
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
20 Sep 2015 05:26 PM
bump
//
Report Abuse
cntkillme is not online. 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
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
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 is not online. 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
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
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
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
20 Sep 2015 05:36 PM
bump
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
20 Sep 2015 05:39 PM
bump1
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
20 Sep 2015 05:45 PM
bumping for eternity
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
20 Sep 2015 05:48 PM
bump4lyfe
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
20 Sep 2015 05:51 PM
goosebump
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
20 Sep 2015 05:59 PM
bumper cars
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
20 Sep 2015 06:03 PM
roadbump
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
20 Sep 2015 06:12 PM
average everyday bump that lives life to the fullest
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
20 Sep 2015 07:21 PM
never ending bumps
Report Abuse
JonathanW123 is not online. JonathanW123
Joined: 04 Apr 2012
Total Posts: 5832
20 Sep 2015 07:28 PM
you forgot to stretch your neck before you scripted.


Falcons for Life
Report Abuse
JonathanW123 is not online. JonathanW123
Joined: 04 Apr 2012
Total Posts: 5832
20 Sep 2015 07:29 PM
and crack your back!


Falcons for Life
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
20 Sep 2015 09:33 PM
lol what
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image