3
$\begingroup$

Could I associate actuator's value with message sensor's subject?

I need, when I receive a message, to convert its subject in my actuator's value.

What I've tried:

enter image description here

Python controller's code:

import bge

def add_score():
    cont = bge.logic.getCurrentController()
    score = cont.owner
    player = score.name

    for sensor in cont.sensors:
        for body in sensor.bodies:
            for subject in sensor.subjects:

                try:
                    point = int(subject)
                except ValueError:
                    point = 0

                if player not in score: #it starts score
                    start(score, player)

                score[player] += point

                act = score.actuators['text1']
                act.value = str(score[player])

def start(score, pl):
    score[pl] = 0
$\endgroup$

1 Answer 1

1
$\begingroup$

Your trying to overcomplicate things. The property actuator changes a value which you can do in python by setting the property yourself.

score['Text'] = score[player]
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .