ID:168951
 
I have a proc so far which sends up to a party of 3 into a battle, my next step is creating a list inside the proc which determines who goes first by looking at all the mob's speed variable. How would i go about creating this? I also would like to know how to access the list to find the next player in the list so i twill brin gup his turn.

Thanks in advance.

-Tazor
I would also like to know how this works.
Ok. Your mistake here is creating a list that's local to the proc. The list wont exist after the proc is done and you wont be able to access it from another proc even while it still exists (unless you specifically pass the list on to another proc).
If you want to make a turn based battle system it's best to use datums.
Datums are pretty much objects (like area, turf, obj, mob, etc) but can't be placed on the map, and only contain a few built in vars/procs.
They're data objects (that's where the name comes from). We can store/access/manipulate a bunch of data very easily by placing it in datums.

A basic turn based battle system's datum would look something like this.
battleDatum
var/list/players[0]
var/currentTurn = 0
proc/turn()
//Add 1 to src.currentTurn. So if it was player 5's turn, when turn() is called it'll become player 6's.
src.currentTurn++

//This is just here so that if there's only 6 players, and it gets to turn 7, it moves back to turn 1. Thus starting the loop over again.
if(src.currentTurn < src.players.len)
src.currentTurn = 1

//We'll make a var and set it to who ever is src.currentTurn in the list. Ie, if src.currentTurn is 3, it'll select the 3rd object in the list.
var/mob/currentPlayer = players[src.currentTurn]
world << "It's [currentPlayer]'s turn!"

//Give currentPlayer an attack verb.
currentPlayer.verbs += /mob/verb/attack

//This var is on every player, it points to their battleDatum when they're in battle.
mob/var/battleDatum/battle

mob/verb/attack()
world << "[src] attacks!"
//We call the src.battle.turn() proc when we're done attacking, and it'll move on to the next persons turn.
src.battle.turn()
In response to DarkView
where would the checking the player's speed to see who goes first go?
In response to Tazor07
It runs list in order, but it doesnt run by who has the the higher speed variable.