A
Alan Régis
Guest
I'm building a custom dice roller in wich the number of sides of the dice is provided by user through a get_integer_assync function. Here's the code:
This is the "dice_roll" script:
And Finally:
Now the issue: Everything works as intended except for the result of the dice, wich always returns 1. something like this:
>(left click custom dice object)
>Opens Dialog "How many sides?"
>User insert a value, let's say 999
>This text shows on screen: "You rolled a d999 and got a 1"
Needless to say i tested it many times, so it's not a coincidence. It always returns 1.
What am i doing wrong? Can someone please help me?
(and sorry for the bad english.)
Code:
// In the Create Event
show_roll = false ;
dice_type = "" ;
Code:
// in the Mouse Left Press Event
dice_question = get_integer_async("How many sides?","");
Code:
// In the Async Dialog Event
dice_check = ds_map_find_value(async_load, "id");
if dice_check == dice_question
{
if ds_map_find_value(async_load, "status")
{
if ds_map_find_value(async_load, "result") != ""
{
dice_type = ds_map_find_value(async_load, "result");
script_execute(dice_roll) ;
}
}
}
Code:
show_roll = true;
randomize() ;
dice_result = irandom_range(1,dice_type) ;
Code:
// In the Draw Event
draw_self() ;
pos_vertical = obj_chatbox.y + 15 ;
pos_horizontal = obj_chatbox.x + 25 ;
if show_roll
{
draw_set_font(font_dados) ;
draw_text(pos_horizontal, pos_vertical, "Rolled a d" + string(dice_type) + " and got a " + string(dice_result)) ;
}
>(left click custom dice object)
>Opens Dialog "How many sides?"
>User insert a value, let's say 999
>This text shows on screen: "You rolled a d999 and got a 1"
Needless to say i tested it many times, so it's not a coincidence. It always returns 1.
What am i doing wrong? Can someone please help me?
(and sorry for the bad english.)