Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (bdgogo), 1,447 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19056 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
c_trace, enable_stuck, enable_block #125708
04/22/07 16:06
04/22/07 16:06
Joined: Mar 2006
Posts: 724
the Netherlands
Frits Offline OP
User
Frits  Offline OP
User

Joined: Mar 2006
Posts: 724
the Netherlands
I made a block (8 x 24 quants) as a map entity. Center at 12,4.
Now I try to move this block horizontaly with 8 quants per mouse click in a field with barriers around it.
The block starts hugging the left wall.
So I trace 20 quants (12+8) to the right and the left, to see if there are any obstacles.
variables;
Code:

var trace_right[3];
var trace_left[3];
var dist_left;
var dist_right;


And in a function (only movement to the right is displayed);
Code:

function move_slider_event()
{
..............
vec_set(trace_right,vector(20,0,0));
dist_right=c_trace(my.x,trace_right.x,ignore_me|use_polygon);
vec_set(trace_left,vector(20,0,0));
vec_rotate(trace_left,vector(180,0,0));
dist_left=c_trace(my.x,trace_left.x,ignore_me|use_polygon);
if(dir_right==0)
{
c_move(my,vector8,0,0),nullvector,ignore_me|use_polygon);
}
..............
}


When I look at the values of dist_right and dist_left, they never get 0, while there is no obstical at the right side, it gives a number higher then the place of the barrier.
(dist_left should be 12 to my opinion and dist_right 0)
I thought that in c_trace the second value is how far to trace, so the value dist_right should be 0, because in the trace distance there is no obstical.
But now I think that I am totaly wrong about this. Can somebody explain to me how the c_trace works???? (I have already looked in aum 56).
--------
I also tried out in the action for the block;
Code:

action slider_act
{
my.enable_stuck=on;
my.enable_block=on;
my.enable_entity=on;
my.event=move_slider_event;
...........
}


And in the function, if the block hits the wall or another entity, revers the direction;
Code:

.................
if(event_type==event_stuck||event_type==event_block)
{
beep();
if(direction==1) {direction=-1;} else {direction=1;}
}
..................


But that does not work either. When the block hits the wall, the event is not called.
Am I doing something wrong here, can somebody explain this to me????


I like to keep scripting simple, life is hard enough as it is.
Regards,
Frits
Re: c_trace, enable_stuck, enable_block [Re: Frits] #125709
04/22/07 17:20
04/22/07 17:20
Joined: Aug 2003
Posts: 169
Tennessee, US
Ahriman Offline
Member
Ahriman  Offline
Member

Joined: Aug 2003
Posts: 169
Tennessee, US
c_trace will send a ray from a starting point in the coordinate system to another so you would need to set the point relative to your starting point. For example if your starting point is the box(my.x,my.y,my.z) and you want to trace along the X axis 10 units the second vector would be((my.x + 10),my.y,my.z)...

Re: c_trace, enable_stuck, enable_block [Re: Ahriman] #125710
04/23/07 11:25
04/23/07 11:25
Joined: Mar 2006
Posts: 724
the Netherlands
Frits Offline OP
User
Frits  Offline OP
User

Joined: Mar 2006
Posts: 724
the Netherlands
Thanks, that make sence. I forgot to add in the second vector the my.position so I think that the trace was form the center (green lines) instead of from the entity.

Now I change the script as follows (again only the horizontal moving is showing)
Code:

// trace to the right
vec_set(trace_right,vector(my.x+scan_dist,my.y,my.z));
dist_right=c_trace(my.x,trace_right.x,ignore_me|use_polygon);
if(dist_right==0 && move_left==0)
{
c_move(my,vector(8,0,0),nullvector,ignore_me|ignore_maps);
// second trace after moving
dist_right=c_trace(my.x,trace_right.x,ignore_me|use_polygon);
if(dist_right==0)
{
move_right=1;
move_left=0;
}
else
{
move_right=0;
move_left=1;
}
}
else
{
// trace to the left
beep();
vec_set(trace_left,vector(my.x-scan_dist,my.y,my.z));
dist_left=c_trace(my.x,trace_left.x,ignore_me|use_polygon);
if(dist_left==0 && move_right==0)
{
c_move(my,vector(-8,0,0),nullvector,ignore_me|ignore_maps);
// second trace after moving
beep();
dist_left=c_trace(my.x,trace_left.x,ignore_me|use_polygon);
if(dist_left==0)
{
move_right=0;
move_left=1;
}
else
{
move_right=1;
move_left=0;
}
}
}


Now I can move the slider to the right, but when it hits the barrier, I only hear the first beep and the slider will not move to the left.
What am I doing wrong here? Please help?


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 | chip programmers | 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