This seems like it would be a simple thing to do, all i want to do is add a value of 1 to a game integer property when it detects a positive pulse from a sensor
here is the script so far:
import bge
def main():
cont = bge.logic.getCurrentController()
own = cont.owner
collision = cont.sensors ["Collision"]
points = own ["pointsys"]
if collision.positive:
points = points + 1
import bge
def main():
cont = bge.logic.getCurrentController()
own = cont.owner
collision = cont.sensors ["Collision"]
<b>#points = own["pointsys"] #AVOID using this line</b>
if collision.positive:
own["pointsys"] += 1
main()
I’m a beginner in python but I think the reason you couldn’t increment the value before was because unlike in the python console, normally the game loops the code continuously(with ALWAYS sensor) so when the game loop the variable “points” is set back to default value with it
If you must store the value of a property to a variable you should do it inside def__init__(self) since everything inside here only run once(I think)