0 registered members (),
1,459
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Very bad if
#230532
10/06/08 14:44
10/06/08 14:44
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
Hi, I don't get this. I have a very semple if statement here. I keep getting and error (undeclared identifier) here the 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.
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Re: Very bad if
[Re: sadsack]
#230534
10/06/08 15:02
10/06/08 15:02
|
Joined: Mar 2003
Posts: 1,095 Germany
nightshade
Serious User
|
Serious User
Joined: Mar 2003
Posts: 1,095
Germany
|
You have written :
IF (campla==1) {
canera_state();
your forgot to set the }
Anyways, in which line do you get the Error?
Last edited by nightshade; 10/06/08 15:02.
|
|
|
Re: Very bad if
[Re: Lukas]
#230546
10/06/08 16:35
10/06/08 16:35
|
Joined: Sep 2008
Posts: 66
falagar8
Junior Member
|
Junior Member
Joined: Sep 2008
Posts: 66
|
oh deer! and I don't mean buffalo either. 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.
Last edited by falagar8; 10/06/08 16:36.
|
|
|
Re: Very bad if
[Re: sadsack]
#230575
10/06/08 19:20
10/06/08 19:20
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
Hi all, Well I think I made right all that you said was wrong. Here is the full 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
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Re: Very bad if
[Re: sadsack]
#230581
10/06/08 19:48
10/06/08 19:48
|
Joined: Feb 2006
Posts: 385 Oldenburg,Germany
Ralph
Senior Member
|
Senior Member
Joined: Feb 2006
Posts: 385
Oldenburg,Germany
|
this:
if (campla==1)
{
canera_ship();
}
else
if(campla == 0)
{
cam_walking();
}
should be this:
if (campla==1)
{
canera_ship();
}
else{
if(campla == 0)
{
cam_walking();
}
}
So he was right! Ralph
|
|
|
Re: Very bad if
[Re: Ralph]
#230590
10/06/08 20:32
10/06/08 20:32
|
Joined: Sep 2008
Posts: 66
falagar8
Junior Member
|
Junior Member
Joined: Sep 2008
Posts: 66
|
@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: 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.
|
|
|
Re: Very bad if
[Re: falagar8]
#230598
10/06/08 21:45
10/06/08 21:45
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
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
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|