Very bad if

Posted By: sadsack

Very bad if - 10/06/08 14:44

Hi,
I don't get this. I have a very semple if statement here.
I keep getting and error (undeclared identifier)

here the code:
Code:

#include <acknex.h>
#include <default.c>




function canera_state();
function cam_walking();
var campla = 1;

function main()
{
	video_screen = 1;
	video_mode = 7;
	level_load ("place.wmb");
        ent_create("ship.mdl", vector(0,0,0),NULL);
	
	while(1)
{
	IF (campla==1)
     {

     	canera_state();
     
     
   else
   
     if(campla == 0) 
    cam_walking();
   }


   if (key_a){campla=1;}
   if (key_b){campla=0;}
   wait(1)
	

     
   
} 




function canera_state()

{
	vec_set(camera.x,ship.x);
  vec_set(camera.y,ship.y);
  vec_set(camera.z,ship.z);// move the camera together with the ship entity
  vec_set(camera.pan,ship.pan);
  wait(1)
	
	
}



function cam_walking()

{
	
vec_set(camera.x, vector(-300, 0, 20));	
	
	
}




I have the var set for campla to 1, I should be able to go from one camera pos. to a nother by using the a and b keys.
Well if anyone know what I did wrong here let me know.
Posted By: nightshade

Re: Very bad if - 10/06/08 15:02

You have written :

IF (campla==1)
{

canera_state();

your forgot to set the }

Anyways, in which line do you get the Error?
Posted By: Lukas

Re: Very bad if - 10/06/08 15:32

You seem to use Lite-C, which is case sensitive. That means you have to write "if" instead of "IF".
Posted By: falagar8

Re: Very bad if - 10/06/08 16:35

oh deer!
and I don't mean buffalo either. wink

semicolons, brackets and keywords.
and make your ship global too. Or attach a function as the ships mdl function. And perhaps with mini tasks in this attached function for the ship model.

#include <acknex.h>;
#include <default.c>;


function canera_state();
function cam_walking();
var campla =1;

function main()
{
video_screen = 1;
video_mode = 7;
level_load ("place.wmb");
ent_create("ship.mdl", vector(0,0,0),NULL);

while(1)
{
if(campla==1)
{
canera_state();

}
else
{

if(campla == 0)
{ cam_walking(); }




if (key_a){campla=1;}
if (key_b){campla=0;}

wait(1);





}




}




function canera_state()
{
vec_set(camera.x,ship.x);
vec_set(camera.y,ship.y);
vec_set(camera.z,ship.z);// move the camera together with the ship entity
vec_set(camera.pan,ship.pan);
wait(1);


}



function cam_walking()
{

vec_set(camera.x, vector(-300, 0, 20));


}


syntax and form first.
then style and function.
Rhyme and Reason.





Posted By: sadsack

Re: Very bad if - 10/06/08 17:39

boy, can I be dumb
renny
Posted By: sadsack

Re: Very bad if - 10/06/08 19:20

Hi all,

Well I think I made right all that you said was wrong.
Here is the full code:
Code:

#include <acknex.h>;
#include <default.c>;


ENTITY* ship;
function camera_ship();
function camera_walking();


var campla =1;





action act_ship()
{
ship = me;
me.ambient = 10;
while(1)
{
	if (campla==1)
     {
      
     	canera_ship();
     }
     
   else
   
     if(campla == 0) 
    {
 
    cam_walking();
   }
   
   if (key_z) {me.pan += 3*time_step;}
if (key_x) {me.pan -= 3*time_step;}
if (key_a){c_move (me,vector( 5,0,0),nullvector,NULL);}
if (key_s){c_move (me,vector( -5,0,0),nullvector,NULL);}
if (key_q){c_move (me,vector( 0,0,1),nullvector,NULL);}
if (key_e){c_move (me,vector( 0,0,-1),nullvector,NULL);}
if (key_c) {me.tilt += 3*time_step;}
if (key_v) {me.tilt -= 3*time_step;}
if (key_r) {me.roll -= 3*time_step;}
if (key_t) {me.roll += 3*time_step;}	




wait(1);
}
}


function main()
{
video_screen = 2;
video_mode = 6;
level_load ("place.wmb");
ent_create("ship.mdl", vector(0,0,0),NULL);
}






function camera_ship()

 {
 
 	
 vec_set(camera.x,ship.x);
  vec_set(camera.y,ship.y);
  vec_set(camera.z,ship.z);// move the camera together with the ship entity
  vec_set(camera.pan,ship.pan);	
 	
 	
}



function camera_walking()

{
	
	
vec_set(camera.x, vector(-300, 0, 0));	
	
	
	
}





I still get the same error (undeclared identifier) and it at this line.
if (campla==1)
what need to be identifi???
Thank You
renny
Posted By: Ralph

Re: Very bad if - 10/06/08 19:48

this:
Code:
if (campla==1)
     {
      
     	canera_ship();
     }
     
   else
   
     if(campla == 0) 
    {
 
    cam_walking();
   }


should be this:
Code:
if (campla==1)
     {
      
     	canera_ship();
     }
     
   else{
   
     if(campla == 0) 
    {
 
    cam_walking();
   }
}


So he was right!

Ralph
Posted By: falagar8

Re: Very bad if - 10/06/08 20:32


@sadsack,

not dumb.
Perhaps, get confuse and miss a matching bracket, or semicolon. I know I do a lot.

but all of these are fine and legal syntax:

Code:
 if(campla==1)
{  
       canera_state();
     
}  
else
{

     if(campla == 0) 
      cam_walking();
   
   
   
}


 if(campla==1)
 {  canera_state();}  
 else
 {  if(campla == 0) 
     cam_walking();  }

 if(campla==1) {  canera_state();}  
 else {  if(campla == 0) 
            cam_walking();  }


as long as the keywords are there and the matching brackets. And with the semicolons too.
Which form and style is better and more readable to each coder. And also if you program on a team or at a company and which is the standard or acceptable forms for the team, supervisor, boss, contractor involved.
Posted By: sadsack

Re: Very bad if - 10/06/08 21:45

Well I have tryed all of the above ways and I still get the same error.
the error as to do with this line
if(campla==1)
it stop compiling at that line.

I have tryed a test if statement and it works fine. There is something in this code that is bad.

I have this computer that I have on the web and my work computer that have never been on the web. Some time I make a mistake taking it from the work computer and putting it on this computer.
I have tryed all of the above and at this

boy, I found the problem

problem= { canera_state();}
right= { camera_state();}

Thanks
renny
Posted By: falagar8

Re: Very bad if - 10/06/08 22:04


glad to hear that you found and corrected the problem.

Even, the Script editor can be intrusive.
Placing here and there extra comments and parenthesis. I know its for the aid of the coder and programmer.
But it would be better for me if I do the placing and postioning of these brackets, pound signs, semicolons, and parenthesis myself. Rather than having the editor with this method of developer presumptions and second hand guessing.

unless there is a way to turn off this feature?
Posted By: sadsack

Re: Very bad if - 10/06/08 22:35

Yes old man of the sea, It would be nice to turn all of that crap off.
Here is working code for two cameras.
Code:
////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>

////////////////////////////////////////////////////////////////////

ENTITY* ship;

function camera_walking();
function camera_ship();
var look = 1;

action act_ship()
{
ship = me;
me.ambient = 10;
while(1)
{
if(look==1){camera_ship();}
if(look==0){camera_walking();}
 

 
if (key_z) {me.pan += 3*time_step;}
if (key_x) {me.pan -= 3*time_step;}
if (key_a){c_move (me,vector( 5,0,0),nullvector,NULL);}
if (key_s){c_move (me,vector( -5,0,0),nullvector,NULL);}
if (key_q){c_move (me,vector( 0,0,1),nullvector,NULL);}
if (key_e){c_move (me,vector( 0,0,-1),nullvector,NULL);}
if (key_c) {me.tilt += 3*time_step;}
if (key_v) {me.tilt -= 3*time_step;}
if (key_r) {me.roll -= 3*time_step;}
if (key_t) {me.roll += 3*time_step;}
if (key_o) {look=0;}
if (key_p) {look=1;}


wait(1);
}
}










function main()
{
	video_screen = 1;
	video_mode = 7;
	level_load ("place.wmb");
  
	
	ent_create("ship.mdl", vector(-900, 0, 0), act_ship);
	
   //ent_create("ship1.mdl", vector(200, 0, 0), NULL);
   
   //ent_create("docking.mdl", vector(0, 0, 0), NULL);

	

     
   
}
	


function camera_ship()

 {
 
 	
 vec_set(camera.x,ship.x);
  vec_set(camera.y,ship.y);
  vec_set(camera.z,ship.z);// move the camera together with the ship entity
  vec_set(camera.pan,ship.pan);	
 	
 	
}



function camera_walking()

{
	
	
vec_set(camera.x, vector(-300, 0, 0));	
	
	
	
}










I want to thank you all for youe help.
renny
Posted By: falagar8

Re: Very bad if - 10/07/08 02:11


Thank You.
And "The Old Man and the Sea"
is a very good book by Enrest Hemingway.




And I may be getting up there in the age area
but I'm young in mind and spirit. Unlike being a guido.



As long as you have some interests and hobbies.
And learning and using your mind. wink
3D Game Studio is one thing that does it for me.
Posted By: Blade280891

Re: Very bad if - 10/07/08 16:05

Just a quick note, you had before
else
{
if()
{

}
}
when you could of just done
else if()
{


}

Just a little tip wink
Posted By: sadsack

Re: Very bad if - 10/07/08 19:01

Thanks Blade,
Yes falagar8 Enrest Hemingway was one of my favorite writers when I was a kid.
Some one told me that you was very old, so I call you the old man of the sea.
Tell me what is it like to be old?????????
renny
© 2024 lite-C Forums