Niels
Member
Hi everyone,
I'm trying to learn more about GM:studio's data structures, so I decided to make a turn based RPG( light) project and use arrays and DS_lists in it.
I build a small setup for what's going to be a combat log for the turn based combat with a DS_list.
Problem with it is that I want to make it scroll up like those old MUD's and RPG's like Baldur's gate did. (newest attack is on the bottom line of the log, and older entries are placed above it).
I managed to do this with the DS_list_sort option and put it to descending.
Problem is that the basic attack line includes the damage variable: " you attack thin air for" + string(dmg) + "damage!");
And that actually messes the whole order of entries up....
This is my code:
Create event:
I'm trying to learn more about GM:studio's data structures, so I decided to make a turn based RPG( light) project and use arrays and DS_lists in it.
I build a small setup for what's going to be a combat log for the turn based combat with a DS_list.
Problem with it is that I want to make it scroll up like those old MUD's and RPG's like Baldur's gate did. (newest attack is on the bottom line of the log, and older entries are placed above it).
I managed to do this with the DS_list_sort option and put it to descending.
Problem is that the basic attack line includes the damage variable: " you attack thin air for" + string(dmg) + "damage!");
And that actually messes the whole order of entries up....
This is my code:
Create event:
step event:stepcounter = 0;
time_line = 60;
dmg = 0;
battle_log = ds_list_create();
log_order = 1;
draw event://destroy
if mouse_check_button(mb_left) {
global.halt = false;
ds_list_destroy(battle_log);
instance_destroy();
}
//timeline
stepcounter ++;
if stepcounter == time_line {
dmg = irandom(5); //will change when weapons are in
ds_list_add(battle_log,string(log_order) + " you attack thin air for" + string(dmg) + "damage!"); //template will change!
stepcounter = 0;
log_order ++;
ds_list_sort(battle_log, false);
}
draw_self();
for (i = 0; i < ds_list_size(battle_log); i ++ ) {
draw_set_halign(fa_middle);
draw_text_transformed(x,y + 60 - (10 * i), ds_list_find_value(battle_log,i),0.5,0.5,0);
}