Skip to content

Split CEnvProjectedTexture data between different games. #381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 2, 2021

Conversation

vinci6k
Copy link
Contributor

@vinci6k vinci6k commented Jan 25, 2021

Continuation of #380 - due to me not testing the data properly (sorry @jordanbriere 😅).

Tested the changes in HL2DM, CSS, and CSGO.
The only issue I ran into was the hardcoded lightcolor keyvalue - setting the type as Color makes the data unusable:

[SP] Caught an Exception:
Traceback (most recent call last):
  File "..\addons\source-python\packages\source-python\commands\auth.py", line 44, in __call__
    return self.callback(*args)
  File "..\addons\source-python\plugins\flashlight\flashlight.py", line 52, in inspect_weapon
    PlayerF(index).toggle_torch()
  File "..\addons\source-python\plugins\flashlight\flashlight.py", line 111, in toggle_torch
    owner_handle=self.inthandle
  File "..\addons\source-python\plugins\flashlight\flashlight.py", line 157, in create
    texture.light_color = color
  File "..\addons\source-python\packages\source-python\entities\_base.py", line 246, in __setattr__
    for server_class, instance in self.server_classes.items():
  File "..\addons\source-python\packages\source-python\entities\_base.py", line 231, in __getattr__
    raise AttributeError('Attribute "{0}" not found'.format(attr))

AttributeError: Attribute "server_classes" not found

This is quite odd as setting the same keyvalue with set_key_value_color() works fine. What am I doing wrong here?
For the time being, I renamed that keyvalue to light_color_string and set the type as STRING.

@satoon101 was correct about m_LinearFloatLightColor being the Orange Box/L4D2 equivalent of m_LightColor from CSGO, but it doesn't use the Color object. Instead it uses a Vector containing floats ranging from 0 to 1 (e.g. Vector(1, 0, 0) would be red).

@jordanbriere
Copy link
Contributor

jordanbriere commented Jan 25, 2021

The only issue I ran into was the hardcoded lightcolor keyvalue - setting the type as Color makes the data unusable:

The error you get isn't quite explicit, but I believe the AttributeError caught is in fact when the manager attempts to get FieldType.Color which doesn't exists. To map an hardcoded keyvalue to <get/set>_key_value_color, you have to use COLOR32 as type. However, since it appears to be translated as a string of floats, the color methods are likely to raise about it if the values are between 0-1 because they expect a string of ints so defining it as string is probably for the best anyway.

@vinci6k
Copy link
Contributor Author

vinci6k commented Jan 26, 2021

To map an hardcoded keyvalue to <get/set>_key_value_color, you have to use COLOR32 as type.

Ah.. so that was the problem.

However, since it appears to be translated as a string of floats, the color methods are likely to raise about it if the values are between 0-1 because they expect a string of ints so defining it as string is probably for the best anyway.

Using set_key_value_color('lightcolor', color) works, but trying to use get_key_value_color('lightcolor') raises:

ValueError: KeyValue does not seem to be a color: ''.

Guess I'll leave it as a string then.

@jordanbriere jordanbriere merged commit 56645a6 into Source-Python-Dev-Team:master Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants