Hi guys how are you?
I´m trying to delete a property In game (a Float one) without using python and I simply can´t.
I have a player that takes a powerup like the star in Mario bros, and I want this property last for a while. I can add the property to the object but cannot remove it.
I tryied several ways and nothing works, and theres not much in the web about logic bricks removing properties.
Any help would be great, thank you!
Hi, I’m fine, heh.
I don’t think you can delete a property without using Python, but why do you need to delete it? Why not use a timer value or something, and just evaluate if it’s within a ‘power-up time’ range?
I do not know a non-python way ever.
how about this:
any sensor you like -> Python module: Property.AND_delete -> property actator prop: <propertyNameToDelete>
or
any sensor you like -> Python module: Property.OR_delete -> property actator prop: <propertyNameToDelete>
Property.py:
#--- BGE callable
def AND_delete(cont):
if not allPositive(cont):
return
delete(cont)
def OR_delete(cont):
if not onePositive(cont):
return
delete(cont)
def delete(cont):
own = cont.owner
for actuator in cont.actuators:
try:
propName = actuator.propName
except AttributeError:
continue
del own[propName]
#--- internal utils (just copy&paste to your file if you need them)
def onePositive(cont):
for sensor in cont.sensors:
if sensor.positive:
return True
def allPositive(cont):
for sensor in cont.sensors:
if not sensor.positive:
return False
return True