S2A.py - the Sensor-To-Actuator library - 1.8

Very cool, can you add a property called dLoc and have the script update it? Then other objects could use the copy property, and pass variables that way.

I know the code is probably easy, I just need to see it so I know how to grab a property in script, and how to Chang it, and update the property

Thank you for all of your work

you can use the S2A.transfer function:

In the demo check the scene Transfer.demo.
Select one of the Cubes
In Logic Panel expand the state buttons (the little (+) icon left of the controller heading)
select the second state
here you see how it works:

the name of the actuator is used to configure it
you can use the (property-)sensor’s name as input

e.g. sCounter
this will be translated to the value of the property (as defined in the property sensor)

You can make an assignement statement to one of the available attributes of the Actuator (it does not matter what actuator type it is).

assuming the property sensor checks for property “counter” and the current value is 3

the actuator’s name “Loc[2]=sCounter” gets translated to:
actuator.Loc[2] = 3
(you can find the available attribute in the BGE API)
In the demo you can see it does not matter if you configure a rotation or location or something else.

It works with single values only, which restricts the setup to one axis. If you need more, you need to write own Python code.

So I’m making this top down shooter game with many spawning enemies (and allies) and allied and enemy turrets should pick the closest targets to shoot at, so after a bit of scrounging on the internet I found S2A.
The piece of script I appear to need for that (closestHitObjectToObject) I can’t seem to get working, the main reason being have have yet no skills in python…
In the attached .blend the “Ally carrier” has a few empties attached to it named “Ally carrier turret”, these turrets should shoot at the on coming drones spawned by the “Enemy carrier”.
I’ve only applied the script to “Ally carrier turret 002”, though it doesn’t shoot at anything but just straight ahead.

Also, I’d like to understand how to make the ship track to the onscreen pointer in perspective instead of orthographic (I read that S2A is also for that, but I REALLY can’t get my head to work around doing that, so now I’m using a script from a youtube tutorial that only works if the game is in orthographical mode)
Thanks in advance…
Fighter for game.blend (698 KB)

Hi Tattorack,

The S2A module is not supposed to be tattered ;). You can take bits and peaces, but this is only recommended if you have a good grasp of Python. Otherwise you will miss important parts.

The general idea behind S2A is that it uses the connected sensors AND the connected actuators. This means you always need both, even if you think you do not. (this is the reason why it is called S2A= Sensors-to-Actuators)

In your specific case it is like that:
> Near sensor “any filter property you like”
–> Python Module:S2A.closestHitObjectToObject
----> TrackToActuator (the object field will be set by the above python call)

See layer <alt+3> in scene S2A_1.4_test (test together with layer <2>)
What it does:
The sensor senses the enemies (by property)
The controllers picks the closest, sets up the actuator to use this object and activates the actuator
The actuator tracks the object until deactivation or getting a different one

Under system mouse cursor
To place an object at the hitpoint under the system mouse cursor:
> Mouse over any (true pulse)
–> Python Module: S2A.hitPositionToPosition
----> any actuator that is owned by the object to be placed (usually the same object as the owner of the controller)

See layer <alt+4> in scene S2A_1.4_test (you can test together with layer <3>)
This method runs in perspective view as well as in orthogonal view.

what it does:
The sensor senses for faces under system mouse cursor by firing a ray along this line.
The controller reads the detected hitposition and places each owner of the actuators at this position.
The actuator will not do anything (it just provide the object to be placed)

Ok, thanks, I’ll see if I can get it done ^^

EDIT: So far so good, it works! ^^

Thank you prof.Monster for these modules. I used “firstBodyToValue” module to feed stamina and mana indicators (scalable planes on HUD overlay) for my character. Working great.