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 » Scripting Helpers
Home Search
 

Modifiable Queue Cycle?

Previous Thread :: Next Thread 
phoniex is not online. phoniex
Joined: 03 Feb 2008
Total Posts: 34985
27 Sep 2014 06:32 PM
How do I make a script that will cycle through a list of values, and will work even if the list is modified?

~Rock is dead. Long live paper and scissors!~
Report Abuse
sparker22 is not online. sparker22
Joined: 11 Mar 2010
Total Posts: 846
27 Sep 2014 07:02 PM
Queue are typically tables holding values. We can do it like this.

local Queue = {"sparker22","ReeseMcBlox","Shedletsky","phoniex"}

This table stores a list of player's usernames. Now the Queue will act as if Queue[1] is the first player, so we can make a function to execute it.

function selectplayerfromqueue()
--code here
table.remove(Queue,1)
end

table.remove is able to remove a value then pushes the other values forward.

The table will now look like

{"ReeseMcBlox","Shedletsky","phoniex"}

Want to add a player to the queue? No problem.

table.insert(Queue,#Queue + 1,"sparker22")

Now the table will look like

{"ReeseMcBlox","Shedletsky","phoniex","sparker22"}

Tadaa! We now have sparker22 back in the queue.

That explains how to add and remove values from Queues. table.remove/insert handles a lot of the table ordering with you when dealing with modifying tables so it should be relatively easy if you want to keep pushing the 1st player in the queue to the back. And of course this will work if you modify the table.
Report Abuse
phoniex is not online. phoniex
Joined: 03 Feb 2008
Total Posts: 34985
28 Sep 2014 04:12 PM
Okay, now how do I add values to a table that are derived from another table?

~Rock is dead. Long live paper and scissors!~
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 Sep 2014 04:15 PM
It's like polymorphism in C classes all over again (I forgot the actual name for the practice)
Just do the same thing, surely? Just modify it to suit
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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