Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Ayumi, 1 invisible), 1,085 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
problem #96888
10/31/06 20:09
10/31/06 20:09
Joined: Aug 2006
Posts: 68
A
alex5801 Offline OP
Junior Member
alex5801  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 68
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

Re: problem [Re: alex5801] #96889
11/01/06 04:21
11/01/06 04:21
Joined: Jun 2005
Posts: 39
Australia
S
Static707 Offline
Newbie
Static707  Offline
Newbie
S

Joined: Jun 2005
Posts: 39
Australia
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

Re: problem [Re: Static707] #96890
11/01/06 10:22
11/01/06 10:22
Joined: Aug 2006
Posts: 68
A
alex5801 Offline OP
Junior Member
alex5801  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 68
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

Re: problem [Re: Static707] #96891
11/01/06 14:31
11/01/06 14:31
Joined: Jan 2003
Posts: 1,738
Nashua New Hampshire
anonymous_alcoho Offline
Senior Developer
anonymous_alcoho  Offline
Senior Developer

Joined: Jan 2003
Posts: 1,738
Nashua New Hampshire
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.


"Oh no, it's true! I'm a love magnet!" Calvin from Calvin and Hobbes My name's Anonymous_Alcoholic.
Re: problem [Re: anonymous_alcoho] #96892
11/01/06 23:22
11/01/06 23:22
Joined: Aug 2006
Posts: 68
A
alex5801 Offline OP
Junior Member
alex5801  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 68
so u mean put the ent_add into a function
but wat about the enable_click

Re: problem [Re: alex5801] #96893
11/02/06 05:04
11/02/06 05:04
Joined: Jun 2005
Posts: 39
Australia
S
Static707 Offline
Newbie
Static707  Offline
Newbie
S

Joined: Jun 2005
Posts: 39
Australia
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.


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1