Accessing math_counters from SP
Posted: Thu Nov 26, 2015 4:17 pm
I invite everybody to continue this old discussion on math_counter's, but now in terms of accessing these entities from inside of Source.Python.
The issue me, Ayuto and Absolute discovered is that logic entities like logic_branch, math_counter etc don't get networked. The only thing I did not understand is why we still can't get access to them from server-side plugin even though they don't get networked to clients.
To setup some testing environment
Now let's load the following script
Once we load it, we get:
So. I need to work with logic_ entities. For now I'm bound to using ent_fire, fortunately I only need to fire inputs on them. But still, isn't there any possibility to gain access to them?
The issue me, Ayuto and Absolute discovered is that logic entities like logic_branch, math_counter etc don't get networked. The only thing I did not understand is why we still can't get access to them from server-side plugin even though they don't get networked to clients.
To setup some testing environment
So. I've just created a sample map. It basically consists of func_button, math_counter, light and prop_dynamic.
es_math_counters.bsp | es_math_counters.vmf
Soon as player presses func_button 3 times (math_counter is responsible for counting), light will turn on and prop_dynamic will change its skin.
Here it is in Hammer:
Everything works in-game:
Now let's load the following script
Syntax: Select all
from filters.entities import EntityIter
def dump_entity(classname):
print("Number of '{0}' entities on the map: {1}".format(classname, len(EntityIter(classname))))
def load():
dump_entity("func_button")
dump_entity("prop_dynamic")
dump_entity("math_counter")
Once we load it, we get:
Code: Select all
sp load math_counters
Number of 'func_button' entities on the map: 1
Number of 'prop_dynamic' entities on the map: 1
Number of 'math_counter' entities on the map: 0
So. I need to work with logic_ entities. For now I'm bound to using ent_fire, fortunately I only need to fire inputs on them. But still, isn't there any possibility to gain access to them?