I made the following script for 4 rotating disks;
Code:

DEFINE disk_ID skill1;

var disk_pos[4]; // pos disk --> 1 - 12
var end_pos[4]; // in degrees
var disk_is_moving[4];
var solved_puzzle03;

function turn_disk_event()
{
if(event_type==event_sonar)
{
if(key_pressed(280)==on && (cursor_action_pan.pos_x>-200) && solved_puzzle03==0)
{
my.enable_sonar=off;
while(mouse_left==1) {wait(1);} // wait for release mouse_left button
disk_is_moving[my.disk_ID]=1; // disk is moving
cursor_action_pan.visible=off; // hide cursor panel
end_pos[my.disk_ID]=int(my.pan)+30; // set end pos for ring (degrees)
end_pos[my.disk_ID]%=360; // max. 360 degrees
//
debug_val[4]=end_pos[my.disk_ID];
//
while(my.pan<end_pos[my.disk_ID])
{
my.pan+=.5*time_step;
wait(1);
}
my.pan%=360;
my.pan=int(end_pos[my.disk_ID]);
cursor_action_pan.visible=on;
//
debug_val[5]=my.pan;
//
disk_pos[my.disk_ID]+=1; // set disk pos (1 to 12)
disk_pos[my.disk_ID]%=12; // max. 12
//
debug_val[0]=disk_pos[my.disk_ID];
//
// check_puzzle_03_event();
if(solved_puzzle03==0) // wrong answer
{
disk_is_moving[my.disk_ID]=0; // reset disk
}
}
}
wait(1);
}

// uses: disk_ID
action disk_act
{
my.enable_sonar=on;
my.event=turn_disk_event;

while(1)
{
if(disk_is_moving[my.disk_ID])
{
my.enable_sonar=off;
}
else
{
my.enable_sonar=on;
}
wait(1);
}
}


Now I have some trouble with disk_pos[my.disk_ID]+=1;.
This value is not updated with 1 every time I click the mouse. It depents on the time I hold the left button down.
I thought I could prevent that with while(mouse_left==1) {wait(1);} but that does not help.
Same thing happens with end_pos[my.disk_ID]=int(my.pan)+30;. Here get the pan.value also a random value depending on how long I keep the mouse button down.
I think that I am doing something wrong in this script, but I don't know what, has anybody an idea???


I like to keep scripting simple, life is hard enough as it is.
Regards,
Frits