how to do this correctly so if the property value is 1 for example it active the actuator
i know its something like this and ? is what i missed:
if own[“prop”] ? 1:
cont.activate(Sound)
how to do this correctly so if the property value is 1 for example it active the actuator
i know its something like this and ? is what i missed:
if own[“prop”] ? 1:
cont.activate(Sound)
==
WKnight02.
a few more
equal to ==
bigger or equal >=
smaller or equal <=
not exactly the same !=
count up +=
count down -=
thank you, we need to add in code the line: from Rasterizer import *
import bge
GameLogic = bge.logic
from Rasterizer import *
cont = GameLogic.getCurrentController()
own = cont.owner
Sound = cont.actuators["Sound"]
if own["prop"] == 1:
cont.activate(Sound)
is there another method without the need of ( from Rasterizer import * ) so if the property value is 1 for example it active the actuator
something like:
import bge
GameLogic = bge.logic
cont = GameLogic.getCurrentController()
own = cont.owner
Property = own["prop"]
Sound = cont.actuators["Sound"]
if Property.value ? 1:
cont.activate(Sound)
thank you with >= we don’t need (from Rasterizer import *)
but
import bge
GameLogic = bge.logic
cont = GameLogic.getCurrentController()
own = cont.owner
Sound = cont.actuators["Sound"]
if own["prop"] >= 1:
cont.activate(Sound)
is there another method with equal to (==) without the need of from Rasterizer import * )
or something like:
import bge
GameLogic = bge.logic
cont = GameLogic.getCurrentController()
own = cont.owner
Property = own[“prop”]
Sound = cont.actuators[“Sound”]
if Property.value ? 1:
cont.activate(Sound)
indeed if a >= b: is the way to go
anyway why are you doing a rename from bge.logic to gamelogic?
if you import bge, you can just do bge.logic… or at least give it a shorter name instead of using it’s very outdated form.
but what sort of property are you setting?
for Int/Float you use <= or ==
for Boolean you use if prop: or if not prop:
if prop:
cont…
Why not simply use a property sensor + AND controller + actuator?
i’m learning python slowly thank you for the useful tips.
i was wrong if i do like this i need the line (from Rasterizer import *):
import bge
GameLogic = bge.logic
from Rasterizer import *
cont = GameLogic.getCurrentController()
own = cont.owner
Sound = cont.actuators["Sound"]
if own["prop"] == 1:
cont.activate(Sound)
and if i do like this i don’t need the line (from Rasterizer import *):
import bge
cont = bge.logic.getCurrentController()
own = cont.owner
Sound = cont.actuators["Sound"]
if own["prop"] == 1:
cont.activate(Sound)