Questions about Python

For questions about using Classic.

Post » Mon Dec 06, 2010 2:59 pm

Hey

While I was trying to understand scripts with python I came with a doubt..
in examples like chat_client from the tutorial there are some functions like network_players and I really don't know where I can find that function on podsixnet, there are only a few files like connection but none has this function in.. Probably im doing it wrong..
Just trying to understand this functions, there is a place where I can find all functions and how to use them or this is just a random name for a function created in the game?
B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Post » Tue Dec 07, 2010 8:34 pm

Please, no one??
I'll try to explain in a better way..
there functions (network_players,etc)teclared in the tutorials they exist or is just a random name for them?
where I can find all the functions and their definitions??
B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Post » Wed Dec 08, 2010 3:43 am

[quote="Guif0DA":3pyumuu0]there functions (network_players,etc)teclared in the tutorials they exist or is just a random name for them?
where I can find all the functions and their definitions??[/quote:3pyumuu0]

First, thanks for trying out the Tut. It would probably help to post this in the Online tutorial thread since it would be easy for me to overlook it otherwise.

Anyways..the naming of the functions is covered in the tutorial but basically... In podsixnet all user written functions in the client need to start with "Network_" then I added the "players" part to make the function Network_players. This function is right in the .cap file for the client.
[code:3pyumuu0]def Network_players(self, data):
playertext = ("*** players: " + ", ".join([p for p in data['players']]))
statusBox.AppendText(playertext + "\n")[/code:3pyumuu0]

The above function is in the client code that YOU write. Then in the server you call the code by performing a "player" action like below:
[code:3pyumuu0] def SendPlayers(self):
self.SendToAll({"action": "players", "players": [p.nickname for p in self.players]})[/code:3pyumuu0]

You also write the above function.

So the client waits for a network packet with an action of "players" from the server. When that happens then the function Network_players is called and the data from the server is handled by the client.

Hope this makes sense.
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Wed Dec 08, 2010 4:05 am

[quote="scidave":28kftdwz][quote="Guif0DA":28kftdwz]there functions (network_players,etc)teclared in the tutorials they exist or is just a random name for them?
where I can find all the functions and their definitions??[/quote:28kftdwz]

First, thanks for trying out the Tut. It would probably help to post this in the Online tutorial thread since it would be easy for me to overlook it otherwise.

Anyways..the naming of the functions is covered in the tutorial but basically... In podsixnet all user written functions in the client need to start with "Network_" then I added the "players" part to make the function Network_players. This function is right in the .cap file for the client.
[code:28kftdwz]def Network_players(self, data):
playertext = ("*** players: " + ", ".join([p for p in data['players']]))
statusBox.AppendText(playertext + "\n")[/code:28kftdwz]

The above function is in the client code that YOU write. Then in the server you call the code by performing a "player" action like below:
[code:28kftdwz] def SendPlayers(self):
self.SendToAll({"action": "players", "players": [p.nickname for p in self.players]})[/code:28kftdwz]

You also write the above function.

So the client waits for a network packet with an action of "players" from the server. When that happens then the function Network_players is called and the data from the server is handled by the client.

Hope this makes sense.[/quote:28kftdwz]
I think I understood
sry for my bad english first of all.. and thanks one more time for the help ;)
you first get the ''function' like network that exist in the podsixnet then add a random name and in the server file must be smething declared with that random name to work..that's it?
makes sense then ;)
B
30
S
6
G
5
Posts: 433
Reputation: 6,061


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests