S
Smenkare
Guest
Create event
exampleList = ds_list_create();
ds_list_add(exampleList,1);
ds_list_add(exampleList,10);
ds_list_add(exampleList,10);
ds_list_add(exampleList,30);
choice = 0;
weight_sum = 0;
for(var i=0; i<ds_list_size(exampleList);i++)
{weight_sum += exampleList[|i]}
Draw event
if (keyboard_check_released(vk_left))
{
draw_text(500, 300, choice);
}
release key event
for(var t = 0,ix =-1, r = random(weight_sum); t < r ; t+=exampleList[|ix])
{ix+=1};
if(ix>-1)
{choice= exampleList[|ix]} ;
And the problem is: i dont want to get value in choice but i want to get index of picked value from ds_list. I cant find any information how to get int from ds_list indexes. I think im just stupid. Is making ds_map of ds_list the only way to acces indexes?
exampleList = ds_list_create();
ds_list_add(exampleList,1);
ds_list_add(exampleList,10);
ds_list_add(exampleList,10);
ds_list_add(exampleList,30);
choice = 0;
weight_sum = 0;
for(var i=0; i<ds_list_size(exampleList);i++)
{weight_sum += exampleList[|i]}
Draw event
if (keyboard_check_released(vk_left))
{
draw_text(500, 300, choice);
}
release key event
for(var t = 0,ix =-1, r = random(weight_sum); t < r ; t+=exampleList[|ix])
{ix+=1};
if(ix>-1)
{choice= exampleList[|ix]} ;
And the problem is: i dont want to get value in choice but i want to get index of picked value from ds_list. I cant find any information how to get int from ds_list indexes. I think im just stupid. Is making ds_map of ds_list the only way to acces indexes?