vec_dist help

Posted By: sadsack

vec_dist help - 09/11/08 19:27

I been working on this for many days now on and off. I am trying to print out the distances beteen two Ent.
I been over the manual and other code and still have not been able to make it work. It is something simple that I am doing wrong. It compile and runs, it is just not printing to the screen the distance of the two objects.
CODE:
Code:

/////////////////////////////////////renny was here //////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
ENTITY* house;

ENTITY* snowman;

STRING* dis = "#30";



var distance;

distance = vec_dist(house.z,snowman.z);





TEXT* greetings_txt =
{
	pos_x = 20;
	pos_y = 20;
	string (dis);
	flags = VISIBLE;
}




action get_dis_house()
{
	house = my;
	snowman = you;
	my.ambient = 100;
	while (1)
	{
vec_dist(house.z,snowman.z);

str_for_num(dis,distance); 
	
	if(distance >100) 
	
{sys_exit ("Thank you for playing");}
	
	 wait (1);
	}

}

function main()
{
	
	level_load ("");
	wait(2);	// wait until the level is loaded
	vec_set(camera.x, vector(-2500, 0, 100));
	ent_create("house.mdl", vector(0, 0, 0), NULL);
	ent_create("snowman.mdl", vector(0, 0, 600),NULL );
}



I hope some one can point me in the right way to make it work?
Thank You
renny
Posted By: flits

Re: vec_dist help - 09/11/08 19:52

distance = vec_dist(house.z,snowman.z);
Posted By: sadsack

Re: vec_dist help - 09/11/08 20:57

Originally Posted By: flits
distance = vec_dist(house.z,snowman.z);


is what I have.......... are you saying that it is wrong and should ne somethink else?
renny
Posted By: DJBMASTER

Re: vec_dist help - 09/11/08 21:00

But you haven't put it in a function, you have tried to run it outside, straight after the distance declaration. You can't do this. You have to use...

distance = vec_dist(house.z,snowman.z) inside a function.
Posted By: Slin

Re: vec_dist help - 09/11/08 21:05

but still, I have to repeat flits:

distance = vec_dist(house.z,snowman.z);
Posted By: sadsack

Re: vec_dist help - 09/12/08 00:04

this is my new function, but it still will not print to the screen.


function farapart_help()
{
vec_dist(my.z,you.z);
return;

}

I sure someone can use this comm and make it work.
Thank You
renny
Posted By: flits

Re: vec_dist help - 09/12/08 10:50

like slin said you will need to change .z

like i said you need add distance =

Code:
action get_dis_house()
{
	house = my;
	snowman = you;
	my.ambient = 100;
	while (1)
	{
distance = vec_dist(house.x,snowman.x);

str_for_num(dis,distance); 
	
	if(distance >100) 
	
{sys_exit ("Thank you for playing");}
	
	 wait (1);
	}

}

Posted By: sadsack

Re: vec_dist help - 09/12/08 14:23

Thank you flits, But I have tryed that, but will tryed it again.
I been working on this for a few days now so I have tryed just about every thing.

Thank You
renny

Edit:

I try what you had and it did not work, played around with it and put it in it own function and called it, some told me to do. that did not work.
It look like that comm. does not work, I have yet seen it work in any code I have found.



Thank you for your help, but spending days on just trying to print a few numbers
to the screen is cazy. There is other things to spend my time on. I can see why all my game making friends told me not to buy 3D Game Stuido. they said it was full of bugs.
bye
Posted By: Bot190

Re: vec_dist help - 09/12/08 23:29

just wondering but what does this mean? STRING* dis = "#30"; whats the #30 supposed to be?
Posted By: sadsack

Re: vec_dist help - 09/13/08 22:44

that let you put 30 digits of numbers.
renny
Posted By: frazzle

Re: vec_dist help - 09/14/08 09:56

This might be simple to solve by using a simple panel with a digit parameter wink wink
I actualy never use a text object to display numeric values by calculation, I only use it for string content.
For displaying numeric values, I mostly do it via a panel with no background attached.
Nevertheless, str_for_num should work in this case as well so just try it only with a panel.

Thanks in progress

Frazzle
Posted By: flits

Re: vec_dist help - 09/14/08 10:50

Code:
action get_dis_house()
{
draw_begin();
	house = my;
	snowman = you;
	my.ambient = 100;
	while (1)
	{
distance = vec_dist(house.x,snowman.x);

str_for_num(dis,distance); 
if(distance == 0)
{
draw_text("you got a problem",20,20,vector(255,255,0));
}
else
{
draw_text(dis,20,20,vector(255,255,0));
}
	
	if(distance >100) 
	
{sys_exit ("Thank you for playing");}
	
	 wait (1);
	}

}

Posted By: sadsack

Re: vec_dist help - 09/14/08 14:38

Thanks flits, but there is not any display on the screen. I will look over your code.
Thank you very much.
renny
Posted By: flits

Re: vec_dist help - 09/14/08 15:34

if there is nothing on the screen make sure that get_dist_house is running because it always answers somthing
© 2024 lite-C Forums