Posted By: gSet
Action when object is in view - 09/17/10 16:58
I've got a slightly strange requirement, here. I'm using a first-person movement script, and I'm wondering if it's possible to activate a certain event (such as send a bit value to the parallel port) when a specific object is in view. I'm still in the process of learning Lite-C so I really just need to know if this is possible and if it's going to be complex. Any advice would be appreciated!
Posted By: EvilSOB
Re: Action when object is in view - 09/17/10 17:06
No worries.
All you need to do is research events as triggered by "c_scan", so you
can perform a "port_out" command to send data to the serial or parallel port.
Both "c_scan" and "port_in / port_out" commands can be found in the manual.
Posted By: Saturnus
Re: Action when object is in view - 09/18/10 17:18
Depending on how "in view" is meant, you can also use the CLIPPED flag.
Posted By: gSet
Re: Action when object is in view - 09/20/10 16:31
Thanks for the suggestions! This should work great
Posted By: gSet
Re: Action when object is in view - 09/21/10 15:53
Alright, so I've been trying to learn to use c_scan, but for some reason this just isn't working for me. I've read all the documentation and searched the forums but to no avail. What I'm trying to do is essentially have one model use ProxFinish to detect when another entity comes within 400 quants (in any direction) and then load a specific level. Sounds easy, right? There must be something simple I'm doing wrong or forgetting. Here's what I've got.
Sorry it isn't tabbed, not sure how to do that. Also, camera_follow is just a simple function that does exactly what it sounds like.
action ProxFinish() {
my.emask |= ENABLE_DETECT;
while(1) {
c_scan(my.x,my.pan,vector(0,0,400),SCAN_ENTS);
wait(1);
}
}
action PlayWalk() {
camera_follow(me);
my.emask |= ENABLE_SCAN;
VECTOR vFeet;
vec_for_min(vFeet,me);
while (1) {
my.pan += (key_cul-key_cur)*10*time_step;
var distance = (key_cuu-key_cud)*30*time_step;
c_move(me, vector(distance,0,0), NULL, GLIDE);
c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE);
my.z = hit.z - vFeet.z;
if (event_type == EVENT_SCAN) {
level_load("Level1.wmb");
}
wait(1);
}
}
Posted By: Sajeth
Re: Action when object is in view - 09/21/10 16:49
First, youre using the event-system in a wrong way, I suggest to look it up in the manual again.
Second, just use vec_dist(my.x,player.x) for distance detection.
Posted By: gSet
Re: Action when object is in view - 09/23/10 13:35
Problem solved. It was a dumb mistake, I just didn't find the documentation very clear... Came about it with enough trial and error.