player.color don't work

Please post any questions about developing your plugin here. Please use the search function before posting!
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

player.color don't work

Postby 8guawong » Thu Sep 25, 2014 1:48 am

Syntax: Select all

player.color = (255, 0, 0, 255)

Code: Select all

  File '../addons/source-python/packages/source-python/entities/entity.py', line 241, in __setattr__
    super(BaseEntity, self).__setattr__(attr, value)
  File '../addons/source-python/packages/source-python/entities/entity.py', line 312, in set_color
    self.rendermode = self.rendermode | 1
  File '../addons/source-python/packages/source-python/entities/entity.py', line 235, in __setattr__
    self.datamaps[attr]._set_value(value)
  File '../addons/source-python/packages/source-python/entities/datamaps.py', line 368, in _set_value
    getattr(self.current_pointer, self.set_attr)(value, self.offset)

Boost.Python.ArgumentError: Python argument types in
    Pointer.set_char(Pointer, int, int)
did not match C++ signature:
    set_char(CPointer {lvalue}, char, int offset=0)
User avatar
L'In20Cible
Project Leader
Posts: 1536
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Thu Sep 25, 2014 3:18 am

Open the file .../addons/source-python/packages/source-python/entities/datamaps.py and replace the line 48 by the following one. All the members I saw registered as FIELD_CHARACTER needs to be handled as integer.

Syntax: Select all

FieldTypes.CHARACTER: 'int',
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

Postby 8guawong » Thu Sep 25, 2014 3:49 am

L'In20Cible wrote:Open the file .../addons/source-python/packages/source-python/entities/datamaps.py and replace the line 48 by the following one. All the members I saw registered as FIELD_CHARACTER needs to be handled as integer.

Syntax: Select all

FieldTypes.CHARACTER: 'int',


Code: Select all

player.color = (0, 0, 255, 255)
  File '../addons/source-python/packages/source-python/entities/entity.py', line 241, in __setattr__
    super(BaseEntity, self).__setattr__(attr, value)
  File '../addons/source-python/packages/source-python/entities/entity.py', line 318, in set_color
    self.render = value
  File '../addons/source-python/packages/source-python/entities/entity.py', line 208, in __setattr__
    self._set_property(attr, value)
  File '../addons/source-python/packages/source-python/entities/entity.py', line 256, in _set_property
    getattr(self.edict, 'set_prop_{0}'.format(prop.type))(prop.prop, value)

OverflowError: Python int too large to convert to C long
User avatar
L'In20Cible
Project Leader
Posts: 1536
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Thu Sep 25, 2014 4:19 am

Replace 'int' by 'uint', then.
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

Postby 8guawong » Thu Sep 25, 2014 4:22 am

L'In20Cible wrote:Replace 'int' by 'uint', then.


Code: Select all

    player.color = (255, 0, 0, 255)
  File '../addons/source-python/packages/source-python/entities/entity.py', line 241, in __setattr__
    super(BaseEntity, self).__setattr__(attr, value)
  File '../addons/source-python/packages/source-python/entities/entity.py', line 312, in set_color
    self.rendermode = self.rendermode | 1
  File '../addons/source-python/packages/source-python/entities/entity.py', line 235, in __setattr__
    self.datamaps[attr]._set_value(value)
  File '../addons/source-python/packages/source-python/entities/datamaps.py', line 368, in _set_value
    getattr(self.current_pointer, self.set_attr)(value, self.offset)

OverflowError: can't convert negative value to unsigned int


:confused:
User avatar
L'In20Cible
Project Leader
Posts: 1536
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Thu Sep 25, 2014 4:26 am

Alright, alright... 'long' :p
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Thu Sep 25, 2014 4:33 am

lol.

I should also mention that the BaseEntity structure is getting a rewrite, currently. We will do our best to test all functionality prior to merging the changes into the master branch. Setting the color used to work fine, until we added in the datamap functionality. Instead of render and rendermode using send properties, the way they work in the current release is to use datamap offsets. These work slightly different than the send props, which is what is causing these errors.
Image
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

Postby 8guawong » Thu Sep 25, 2014 4:38 am

L'In20Cible wrote:Alright, alright... 'long' :p


Code: Select all

    player.color = (255, 0, 0, 255)
  File '../addons/source-python/packages/source-python/entities/entity.py', line 241, in __setattr__
    super(BaseEntity, self).__setattr__(attr, value)
  File '../addons/source-python/packages/source-python/entities/entity.py', line 318, in set_color
    self.render = value
  File '../addons/source-python/packages/source-python/entities/entity.py', line 208, in __setattr__
    self._set_property(attr, value)
  File '../addons/source-python/packages/source-python/entities/entity.py', line 256, in _set_property
    getattr(self.edict, 'set_prop_{0}'.format(prop.type))(prop.prop, value)

OverflowError: Python int too large to convert to C long


:cool:

maybe i'll wait for the rewrite

Return to “Plugin Development Support”

Who is online

Users browsing this forum: Bing [Bot] and 132 guests