Page 2 of 2

Posted: Sat Oct 31, 2015 8:23 am
by Ayuto
The plan is to implement __getitem__ and __setitem__. If we still keep the get_<type>/set_<type> methods it's absolutely backwards compatible, because it's just an addition.

Posted: Sat Oct 31, 2015 9:16 am
by Mahi
Ayuto wrote:The plan is to implement __getitem__ and __setitem__. If we still keep the get_<type>/set_<type> methods it's absolutely backwards compatible, because it's just an addition.
Sounds really good, perfect not to say. Hopefully you'll also add some kind of to_dict() method or a way of iterating over the event variables!

__iter__ would probably be enough, since you could just do:

Syntax: Select all

d = {var: event[var] for var in event}

Posted: Sat Oct 31, 2015 9:31 am
by Ayuto
We can also expose the KeyValues object. Then you would do

Syntax: Select all

event.variables.as_dict()

Posted: Sat Oct 31, 2015 9:31 pm
by Ayuto
I have created a new branch for the __getitem__ implementation. https://github.com/Source-Python-Dev-Team/Source.Python/commit/06658ab791b3db65cd83356798d5ac5f86f7fb21

I think the event system is the same on all branches. Some weeks ago I checked the offset of the KeyValues object and it was the same on all games we support. That's why I just reconstructed the structure of CGameEvent and didn't use an offset. Not sure if we want to change that. I honestly don't think we need to.

Posted: Sat Oct 31, 2015 9:48 pm
by Mahi
Ayuto wrote:I have created a new branch for the __getitem__ implementation. https://github.com/Source-Python-Dev-Team/Source.Python/commit/06658ab791b3db65cd83356798d5ac5f86f7fb21

I think the event system is the same on all branches. Some weeks ago I checked the offset of the KeyValues object and it was the same on all games we support. That's why I just reconstructed the structure of CGameEvent and didn't use an offset. Not sure if we want to change that. I honestly don't think we need to.
Awesome, this looks fantastic! The system just became infinitely times better with the KeyValues addition, for me at least.

Posted: Sat Oct 31, 2015 11:24 pm
by satoon101
I went ahead an removed the first event_test branch. I won't be home for a few days, so please feel free to test this out and let us know if you find any issues or if it works perfectly fine. Once we get confirmation, it looks good enough for me to merge into master.

Posted: Mon Nov 02, 2015 12:06 pm
by Mahi
satoon101 wrote:I went ahead an removed the first event_test branch. I won't be home for a few days, so please feel free to test this out and let us know if you find any issues or if it works perfectly fine. Once we get confirmation, it looks good enough for me to merge into master.
I've spent 5+ hours with the new system and found absolutely no issues with it. Boolean values seem to always come in as 1 and 0, but that hasn't bothered me (you can still do all operations normally, only identity testing fails) and they can easily be converted using bool() if someone really wants a bool. But other than that, seems to work just fine!

Posted: Tue Nov 03, 2015 12:09 am
by satoon101
Awesome! I will merge this when I get home tomorrow morning/afternoon if someone else doesn't before then. Thanks again for the suggestion and testing.