Hi guys. I try to subscribe to topic and get one value from it but i suppose that subscribe.simple don’t want work with me. I wanna do this in really simple way. Can anybody help me if I maybe do something wrong in my script or do you know any ideas how to change subsribe.simple in something working?
from paho.mqtt import subscribe import json from bge import logic import stay import go owner = logic.getCurrentController().owner def get_measurement(): message = subscribe.simple('measurements', hostname="IP", port=PORT) data = json.loads(message.payload) measurement = int(data["value"]) return measurement def stay_or_go(): Xspeed, Yspeed, Zspeed = owner.getLinearVelocity(True) if Zspeed == 0: if get_measurement() == 0: stay() if get_measurement() > 0: go() if __name__ == "__main__": stay_or_go()