Questions about Python

This forum is currently in read-only mode.
From the Asset Store
Logo Quiz with 150 prepared logos and answers, automatic question and answer mixing
  • 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?

  • 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??

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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??

    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.

    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.
  • > 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??

    >

    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.

    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.
    

    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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)