Thanks for your reply.
I have check all my code million times.
by default side =0;
only selected ball have side 1 or 2.
all my functions are in global script and imported in room script file.
Basically I click on hotspot to attribute a side and a ball.
one hotspot for each side and a global int for each side.
left GI 46 and right GI 47
the code when interacting each ball is:
(exemple with ball[4])
Code: ags
The last hotspot is used to calculate the weight on each side.
the code when interacting is:
Code: ags
everything seems to be ok but.....
:'(
I have check all my code million times.
by default side =0;
only selected ball have side 1 or 2.
all my functions are in global script and imported in room script file.
Basically I click on hotspot to attribute a side and a ball.
one hotspot for each side and a global int for each side.
left GI 46 and right GI 47
the code when interacting each ball is:
(exemple with ball[4])
//in room script file
if(GetGlobalInt(46) == 0 && GetGlobalInt(47) == 0)
{Display("you must select a side first.");}
else{
if(GetGlobalInt(46) == 1)
{
ball_side(4,1);
SetGlobalInt(47, 0);
SetGlobalInt(46, 0);
}
if(GetGlobalInt(47) == 1)
{
ball_side(4,2);
SetGlobalInt(46, 0);
SetGlobalInt(47, 0);
}
}
//in main global script
function ball_side(int ball,int side)
{
ball[ball].side = side;
}
function Compareweight( w_left, w_right)
{
if(w_right < w_left){ return 1;}
if(w_right > w_left){ return 2;}
}
function Weighing()
{
int i = 0;
int w_left = 0;
int w_right = 0;
int big_w = 0;
while(i<5){
if (ball[i].side == 1)
{w_left += ball[i].weight;}
if (ball[i].side == 2)
{ w_right += ball[i].weight;}
i++;
}
big_w = Compareweight( w_left, w_right);
Display("Left %d", w_left);
Display("Right %d", w_right);
return big_w;
}
The last hotspot is used to calculate the weight on each side.
the code when interacting is:
int Bigger;
Bigger = Weighing();
if(Bigger == 1)
{
Display("Side left.");
}
if(Bigger == 2)
{
Display("Side right.");
}
everything seems to be ok but.....
:'(