Hi,
With logic bricks you can check for example if a property called ‘cakes’ is greater than 10.
But how to check if the property ‘cakes’ is greater than property ‘pizzas’? I think this is not possible with logic bricks so I think I need a python script, but I’m a noob with python (but I’m learning :eyebrowlift2:). So I started searching on the internet but I wasn’t able to find a script or something that could help me.
I hope you can help me with this.
Also, when I have that script that checks if a property is greater than another property, how can I activate a Actuator?
Thanks
with bricks
prop -> expression -> whatever
in expression:
cakes > pizza
so it checks if cakes is bigger then pizzas
Thanks, much easier than I thought.
np, if you do it with an prop, set it on changed mode.
here the python version
def property(cont):
#get the object using this script
own = cont.owner
#check if object has the properties
if 'cakes' in own and 'pizza' in own:
#get a property from the owner
cakes = own['cakes']
pizza = own['pizza']
else:
print('No properties found in object')
return
#check what item is bigger, like the expression brick
if cakes > pizza:
print('The cakes around here are way bigger then pizzas')
else:
print('Pizza is still bigger then cakes')
call it test.py, always -> python - module mode- test.property
Thanks for your help. I’ll sure save the python version to my computer because I can sure learn from it, but the expression brick did the trick already
I think this is not possible with logic bricks so I think I need a python script, but I’m a noob with python (but I’m learning :eyebrowlift2:). So I started searching on the internet but I wasn’t able to find a script or something that could help me.
so i made you an example. topic has a good title, i am sure more people can use it.
Also, when I have that script that checks if a property is greater than another property, how can I activate a Actuator?
hook an always->python->property to the script
def property(cont):
#get the object using this script
own = cont.owner
#get actuator
actuator_1 = cont.actuators['Property']
#to get sensors use below (remove # at the start)
#sensor_1 = cont.sensors['sensor_name_here']
#check if object has the properties
if 'cakes' in own and 'pizza' in own:
#get a property from the owner
cakes = own['cakes']
pizza = own['pizza']
else:
print('No properties found in object')
return
#check what item is bigger, like the expression brick
if cakes > pizza:
print('The cakes around here are way bigger then pizzas')
#activate an actuator
cont.activate(actuator_1)
else:
print('Pizza is still bigger then cakes')
Thanks for explaining how to activate the actuator !! I’m beginning with learning python so this is very useful to me.