need hellp : C-script to lite-C

Posted By: CodeMaster

need hellp : C-script to lite-C - 01/17/11 22:29

I try to translate some old code in lite-c, and i do not know how to define rot_angle and rot_speed in this function. What i must use vector pointer, vector, var, entity,...? What is wrong here?

Code:
function rotate_model(rot_angle,rot_speed) {
	if (my.pan == rot_angle) { return; }
	temp.x = ang(rot_angle - my.pan);
	if (temp.x > 0) { result = 1; }
	if (temp.x < 0) { result = -1; }
	my.pan_force = rot_speed * ang(rot_angle - my.pan);
	my.pan_velocity += (time_step * my.pan_force) - (minv(time_step*0.7,1) * my.pan_velocity);
	temp.x = ang(rot_angle.pan - (my.pan + my.pan_velocity));
	if (temp.x > 0 && result == -1) || (temp.x < 0 && result == 1) { my.pan_velocity = ang(rot_angle.pan - my.pan); }
	c_rotate(my,vector(my.pan_velocity * time_step,0,0),IGNORE_PASSABLE|IGNORE_YOU|IGNORE_MODELS|USE_BOX);
}


Posted By: Logan

Re: need hellp : C-script to lite-C - 01/17/11 23:41

It looks like you could just declare them as vars. Certainly don't declare them as VECTORs or ANGLEs--that would just complicate things, especially because you're only changing my.pan in that function. According to your code vars would be fine--or if you want to be more Lite-C-like, you could use int, double, float, etc.

function rotate_model(var rot_angle, var rot_speed)
{}
Posted By: CodeMaster

Re: need hellp : C-script to lite-C - 01/17/11 23:52

thank you Logan but i already try this and then i have error "pan is not a member of function"
Posted By: Logan

Re: need hellp : C-script to lite-C - 01/17/11 23:57

That has to do with rotate_angle. In C-Script you probably defined rotate_angle as var rotate_angle[3];... in Lite-C you'll have to say ANGLE* rotate_angle;.

I had the same confused moment a couple days ago.

Hope that answers your question.
Posted By: CodeMaster

Re: need hellp : C-script to lite-C - 01/18/11 00:07

nope, rot_angle defined only in brackets in this function anywhere else. I also try define this with ANGLE out of function but wont work
Posted By: Logan

Re: need hellp : C-script to lite-C - 01/18/11 00:14

What about when you access rotate_angle.pan? That's what I'm talking about. Unless this is supposed to be rot_angle... in which case there's your problem.
Posted By: CodeMaster

Re: need hellp : C-script to lite-C - 01/18/11 00:16

ohh sorry i made mistake i fix this in my script but not here, this is rot_angle but still wont work
Posted By: Logan

Re: need hellp : C-script to lite-C - 01/18/11 01:06

So what is it saying exactly?
© 2024 lite-C Forums