You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
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.
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: ''.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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_LinearFloatLightColorbeing the Orange Box/L4D2 equivalent ofm_LightColorfrom 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).