New conversion_c module

All other Source.Python topics and issues.
arawra
Senior Member
Posts: 190
Joined: Fri Jun 21, 2013 6:51 am

New conversion_c module

Postby arawra » Mon Jan 27, 2014 1:38 pm

What would be the proper way to retrieve a CPlayerInfo or CPlayerGenerator instance? Importing * from conversion_c is throwing me a few errors.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Jan 27, 2014 1:55 pm

CPlayerGenerator should just be imported itself, still from player_c:

Code: Select all

from player_c import CPlayerGenerator

You then iterate over that to get all PlayerInfo instances. We are removing the leading "C" from the object names, so that will probably become PlayerGenerator in the future.

If you have a userid, index, etc... and you wish to get the PlayerInfo instance from that value, you then import from conversions_c. Notice that there is an "s" at the end of conversions_c that you are missing. Also, the players.helpers and entities.helpers modules have been updated to import the conversions_c functions, as well. Those modules should act just the same as they did before. I might refine the imports in the entities.helpers module so that it does not import conversions to and from userid/playerinfo. Also notice that it is now PlayerInfo and not CPlayerInfo. The main reason for the conversions being implemented is that previously you could instantiate a CPlayerInfo instance by using either a userid or the CEdict instance. We wanted to get away from allowing multiple types to allow instantiation, so instead we decided providing conversion functions was a better way to go.

Satoon
arawra
Senior Member
Posts: 190
Joined: Fri Jun 21, 2013 6:51 am

Postby arawra » Mon Jan 27, 2014 3:06 pm

Getting an ImportError

from conversions_c import PlayerInfo

The new release included your changes from yesterday, right? Do I need to recompile from source?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Jan 27, 2014 3:44 pm

You do not import the object types from conversions_c. You import converting functions:

Code: Select all

# Converting to an index from other types
index_from_edict
index_from_basehandle
index_from_inthandle
index_from_pointer
index_from_userid
index_from_playerinfo

# Converting to an Edict instance from other types
edict_from_index
edict_from_basehandle
edict_from_inthandle
edict_from_pointer
edict_from_userid
edict_from_playerinfo

# Converting to a CBaseHandle instance from other types
basehandle_from_index
basehandle_from_edict
basehandle_from_inthandle
basehandle_from_pointer
basehandle_from_userid
basehandle_from_playerinfo

# Converting to an integer handle from other types
inthandle_from_index
inthandle_from_edict
inthandle_from_basehandle
inthandle_from_pointer
inthandle_from_userid
inthandle_from_playerinfo

# Converting to a CBaseEntity pointer from other types
pointer_from_index
pointer_from_edict
pointer_from_basehandle
pointer_from_inthandle
pointer_from_userid
pointer_from_playerinfo

# Converting to a userid from other types
userid_from_index
userid_from_edict
userid_from_basehandle
userid_from_inthandle
userid_from_pointer
userid_from_playerinfo

# Converting to a PlayerInfo instance from other types
playerinfo_from_index
playerinfo_from_edict
playerinfo_from_basehandle
playerinfo_from_inthandle
playerinfo_from_pointer
playerinfo_from_userid


Again:
satoon101 wrote:The main reason for the conversions being implemented is that previously you could instantiate a CPlayerInfo instance by using either a userid or the CEdict instance. We wanted to get away from allowing multiple types to allow instantiation, so instead we decided providing conversion functions was a better way to go.

Satoon

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 77 guests