Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,574 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Mouse click #125253
04/20/07 15:12
04/20/07 15:12
Joined: Mar 2006
Posts: 724
the Netherlands
Frits Offline OP
User
Frits  Offline OP
User

Joined: Mar 2006
Posts: 724
the Netherlands
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
Re: Mouse click [Re: Frits] #125254
04/20/07 15:45
04/20/07 15:45
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
First things I noticed were

my.enable_sonar=off in the turn_disk_event: I think you need to put a wait(1) before this. because it is also edited in the action, i don't think you need to change it here.

Also, are you sure that the event is being triggered? It's relying on a certain key (280), cursor pan > -200, and mouse_left = 0...


xXxGuitar511
- Programmer
Re: Mouse click [Re: xXxGuitar511] #125255
04/20/07 16:19
04/20/07 16:19
Joined: Mar 2006
Posts: 724
the Netherlands
Frits Offline OP
User
Frits  Offline OP
User

Joined: Mar 2006
Posts: 724
the Netherlands
No problem with triggering the event.
The problem is like I described in the last lines of my post.


I like to keep scripting simple, life is hard enough as it is.
Regards,
Frits
Re: Mouse click [Re: Frits] #125256
04/20/07 17:00
04/20/07 17:00
Joined: Oct 2003
Posts: 702
Z
zazang Offline
User
zazang  Offline
User
Z

Joined: Oct 2003
Posts: 702
You could prevent the trigger like this :-
if(event_type==event_sonar && disk_is_moving[my.disk_ID] == 0)

However I am curious how can the counter increase if you have while(mouse_left == 1) { wait(1);}

I think it has to do with your trace function.Is it triggered from mouse_left button ?
Please paste that function too.

Re: Mouse click [Re: zazang] #125257
04/21/07 16:00
04/21/07 16:00
Joined: Mar 2006
Posts: 724
the Netherlands
Frits Offline OP
User
Frits  Offline OP
User

Joined: Mar 2006
Posts: 724
the Netherlands
while(mouse_left == 1) { wait(1);} simply waits until the mouse button is released and then goes on with the script.
It has nothing to do with the trace function, the problem was that the counter did not increase by 1 but by 3 or 4, and the pan value was also increased with more or less then the given 30..
Problem solved, I had to remove two lines of the script.


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

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1