Code:
with (obj_player)// loop through all players
{ds_priority_add(other.score_priority, id, kills)}
place = 0;
ds_list_clear(score_list)
repeat (ds_priority_size(score_priority))
{var is_id = ds_priority_find_max(score_priority);
var is_max = ds_priority_find_priority(score_priority, is_id);
ds_priority_delete_max(score_priority);
if ds_list_find_index(score_list, is_max) == -1
{place += 1;
ds_list_add(score_list, is_max)
}
is_id.is_position = place
}
var result = "place " + string(place) + " = " + string(object_get_name(is_id.object_index)) + ". Kills = " + string(is_max);
ds_list_add(score_list_2, result)
^^^^^ The last two lines are placed wrong. You haven't got them in the repeat loop, therefore they are only done once, which will add a value to position "0" in the list. So you will only have one entry for each time it's run. The others are all undefined because there are no other entries, and by looking past position 0 you have actually exceeded the size of the list. Those positions don't exist, so have no value, and so "undefined" is what you get.
Code:
with (obj_player)// loop through all players
{ds_priority_add(other.score_priority, id, kills)}
place = 0;
ds_list_clear(score_list)
repeat (ds_priority_size(score_priority))
{
var is_id = ds_priority_find_max(score_priority);
var is_max = ds_priority_find_priority(score_priority, is_id);
ds_priority_delete_max(score_priority);
if ds_list_find_index(score_list, is_max) == -1
{
place += 1;
ds_list_add(score_list, is_max)
}
is_id.is_position = place
var result = "place " + string(place) + " = " + string(object_get_name(is_id.object_index)) + ". Kills = " + string(is_max);
ds_list_add(score_list_2, result)
}
The final bracket is now ending the repeat block, and the last two lines are in it. So it will now get 'place' for each time the block is repeated, and also the details to be added to the second ds list.
drawing a ds list:
Code:
var size = ds_list_size(score_list_2);
if size > 0
{
for (var a = 0; a < size; a++)
{
draw_text(20, 20 + (20 * a), ds_list_find_value(score_list_2, a)) // change these x / y positions to whatever you want
}
}
In this code it is looping through the list, and drawing all of the results. This is one of the most basic ways to do it. You have a start y position, and that has a value being multiplied by 'a' (20 * 0, 20 * 1, 20 * 2 etc) being added to it. A difference of 20 pixels is enough to ensure each line has the vertical space for the default sized font. If you go with a bigger font then you would want to change the value from 20, to the font size plus some extra space.
Done in this fashion it can cover as many entries that will fit on the screen (and beyond), but requires some additions. Such as: the first 20 is the x position in the room, since in my projects the port and view are always the same width as the room (that is not important as to why, and is just my choice to do so). When you have the view scaled you would want the x position to be drawn relative to the view. And the same for the y position.
If you didn't loop through the list then you could just "define" where you want particular lines being drawn (maybe alternating the first being left of the screen center, and the second being right, the third is left, fourth is right etc) Either way you can have the same effects, just as long as you know exactly how many entries there and arrange it accordingly.
Manually:
Code:
draw_set_colour(c_green);
draw_text( whatever, whatever, ds_list_find_value(score_list_2, 0));
draw_set_colour(c_yellow);
draw_text( something, something, ds_list_find_value(score_list_2, 1));
draw_set_colour(c_orange);
draw_text( a different something, a different something, ds_list_find_value(score_list_2, 2));
draw_set_colour(c_red);
draw_text( a different whatever, a different whatever, ds_list_find_value(score_list_2, 3));
OR
For loop:
Code:
var size = ds_list_size(score_list_2);
if size > 0
{
for (var a = 0; a < size; a++)
{
switch (a)
{
case 0:
draw_set_colour(c_green);
draw_text( whatever, whatever, ds_list_find_value(score_list_2, a));
break;
case 1:
draw_set_colour(c_yellow);
draw_text( something, something, ds_list_find_value(score_list_2, a));
break;
case 2:
draw_set_colour(c_orange);
draw_text( a different something, a different something, ds_list_find_value(score_list_2, a));
break;
case 3:
draw_set_colour(c_red);
draw_text( a different whatever, a different whatever, ds_list_find_value(score_list_2, a))
break;
}
}
}
And if you wanted entries with the same 'place' value to share the same colour / font etc......well.......I'll leave you to figure that out