problem

Posted By: alex5801

problem - 10/31/06 20:09

Code:
  
ACTION player_action
{
my.gravity = 3;
my.z_offset = 6;
player = my;
my.shadow = on;
ent_create("sword.mdl",my.x,attach_weapon);

ent_create("player2.mdl", you.x, computer_player);
ent_create("player.mdl", my.x);

if(key_q==1)
{
if(player1.state_skill==1 && Player2.state_skill== 0)
{
ent_remove (my);
me = ent_add ("player2.mdl", my.x);
ent_remove(you);
you = ent_add ("player1.mdl",you.x);
}
else{
if(player1.state_skill==0 && Player2.state_skill== 1)
{
ent_remove (my);
me = ent_add ("player1.mdl", my.x);
ent_remove(you);
you = ent_add ("player2.mdl",you.x);
}
}
}


action computer_player{
computer = me;


while (computer !=NULL)
{
me.vec[0] = you.vec[0]-60;
me.vec[1] = you.vec[0]-60;
if(key_g ==1)
{
me.vec[0] = you.vec[0]+60;
me.vec[1] = you.vec[0]+60;
}
if(key_b==1)
{
me.vec[0] = you.vec[0]-60;
me.vec[1] = you.vec[0]-60;
}
}

}




this code is use to swap character to use in the game and how player can command the computer player
anyone know what is the problem with the coding in green color? i keep getting problem when i include it to run the level
Posted By: Static707

Re: problem - 11/01/06 04:21

Hey Alex,

I am not really sure what the code is supposed to do. But I imagine you are getting some problems due to some coding errors. (Such as while loops without waits).

You would need to format the code correctly. (It would look something like this)
Code:
FUNCTION computer_player
{
computer = me;
while (computer !=NULL)
{
me.vec[0] = you.vec[0]-60;
me.vec[1] = you.vec[0]-60;
if(key_g ==1)
{
me.vec[0] = you.vec[0]+60;
me.vec[1] = you.vec[0]+60;
}
if(key_b==1)
{
me.vec[0] = you.vec[0]-60;
me.vec[1] = you.vec[0]-60;
}
wait(1);
}

}

ACTION player_action
{
my.gravity = 3;
my.z_offset = 6;
player = my;
my.shadow = on;
ent_create("sword.mdl",my.x,attach_weapon);
ent_create("player2.mdl", you.x, computer_player);
ent_create("player.mdl", my.x);
while(me)
{
if(key_q==1)
{
if(player1.state_skill==1 && Player2.state_skill== 0)
{
ent_remove (my);
me = ent_add ("player2.mdl", my.x);
ent_remove(you);
you = ent_add ("player1.mdl",you.x);
}
else
{
if(player1.state_skill==0 && Player2.state_skill== 1)
{
ent_remove (my);
me = ent_add ("player1.mdl", my.x);
ent_remove(you);
you = ent_add ("player2.mdl",you.x);
}
}
}
wait(1);
}
}



Could you give us a bit more detail as to what you want the code to do in game, and what the actually error is.

Good luck,

Static
Posted By: alex5801

Re: problem - 11/01/06 10:22

in this game got 2 character
first green code part is to let player to swap to use between 2 character
the 2nd green coding is let player to give command to the other character that he is not controling
Posted By: anonymous_alcoho

Re: problem - 11/01/06 14:31

Quote:

You would need to format the code correctly. (It would look something like this)




A code can be formatted in anyway, so long as all the grammer is correct.

Code:

You can have:

action player1 { my.health = 50; my.enable_click = on; my.event = doSomething(); while(1) { my.x += 5 * (key_w - (key_s); wait(1); } }

and

action player1 {
my.health = 50;
my.enable_click = on;
my.event = doSomething();
while(1) {
my.x = 5 * (key_w - key_s);
wait(1);
}
}

and

action player1
{
my.health = 50;
my.enable_click = on;
my.event = doSomething();
while(1)
{
my.x = 5 * (key_w - key_s);
wait(1);
}
}



The only difference between the three formats are readability. So long as you have the right number of brackets/parenthesis and all the semicolons, any format works. (Bottoms my favorite). My point is that, coding errors aren't usually due to a bad format. But a bad format (such as the first example) makes it so much easier to screw up.

The reason why I like the third format is because you see all the brackets and you can easily tell when one is missing, whereas on first glance with the second one, the first bracket seems to be missing.
Posted By: alex5801

Re: problem - 11/01/06 23:22

so u mean put the ent_add into a function
but wat about the enable_click
Posted By: Static707

Re: problem - 11/02/06 05:04

Your right. Formatting was the wrong word, I should have said something like, "correct syntax" as it relates to the coding not the formatting.

I am sorry but I don't understand what the script is supposed to do. The understanding issue is probably on my side.
© 2024 lite-C Forums