Hello all,
There is a new library in town :D. It is for BGE users that do not want to take the step into deep Python scripting. Be warned it requires a bit of Python knowledge. But I will provide examples that makes it easier for you to use. So you can use them and learn from them as well.
What is the weakness of the logic bricks?
You can only transfer TRUE/FALSE data from sensors to actuators.
In a lot of cases this is good enough, but sometimes not.
Here is the solution!
[INDENT][INDENT]The All-To-All Library
[/INDENT][/INDENT]What does A2A do?
It provides a way to
- get any value into properties (e.g. mouse positions, object velocity)
- use any value from properties (e.g. set object positions)
- directly assign values (e.g. mouse position -> object position)
- execute small python statements (e.g. setting mouse position, print statements)
The library itself is not that large, but contains a lot of documentation. Don’t worry, you do not need to study the file, just follow the tutorial.
A2A is compatible with 2.49b and 2.5x (at least 2.53). Clarification - you need a Blender version with Python 2.6+ or Python 3.
Here you can find the full documentation including the sources. Thanks to Sunjay03
for hosting.
How to use A2A?
Connect one or more sensors of any type with a Python controller in Module mode. Choose one of the available functions.
Now connect one or more Property actuators.
You control the module by configuring the Property actuators. What field contains what depends on the controllers function.
-
fromProp(cont)
[LIST] -
Assigns the property from the Prop field to the expression in the Value field of the connected actuators. The property belongs to the actuator’s owner.
-
toProp(cont)
-
Assigns the expression from the Value field to the property in the Prop field of the connected actuators. The property belongs to the actuator’s owner.
-
assign(cont)
-
Assigns the expression from the Value field to the expression in the Prop field of the connected actuators.
-
execute(cont)
-
Executes the expression in the Prop field of the connected actuators.
-
The content of the Value field can be used as paramter list (use &Value in the Prop field expression)
[/LIST]The expressions use Python syntax. This allows nearly any Python code to be used. But the lengths of the actuator fields are resticted.
Following keywords are available:
- sensor’s name for all connected sensors
- actuator’s name for all connected actuators
- obj for the owner of the current actuator
- cobj for the owner of the current controller (better use obj)
- scene for the current scene
- RST for the Rasterizer
- GL for the GameLogic
- adict for a dictionary “obj.name” in globalDict (will be created if not present by “globalDict”
- cdict for a dictionary “cobj.name” in globalDict (will be created if not present by “globalDict”
- gdict for global dict
-
$Value the content of the Value field (execute only!) to be the parameter list (it is a string replacement)
All BGE API operations are supported. Please, do not use deprecated syntax.
The A2A-functions support the Property actuator’s Mode flag with
- assign (default)
- add (+ operation)
- others are the same as assign
The following posts contain examples how to use the A2A-library.
How does the A2A work?
Basicly the functions take the content of the Property actuator’s fields. Assembles them to a string and execute the string as Python code.
This is the reason why it uses Python syntax. The above functions define how the string is assembled.
If you want to see the final string, add a property called “debug” with a True value (!= 0) to the controller object. The command strings will be printed to the console.
Troubleshooting
If the string produces errors following information will be printed to the console:
- the command string
- the error
- the actuator’s name
I hope it helps
Attachments
A2A.blend (303 KB)a2a.html.zip.blend (26.8 KB)

