How do you access Properties in python? Does propertysensor.getValue() actually get the value of the property? or does it just return the value that the sensor is checking for? I need to get the value of the property, or find another way to store variables in between the executions of the script. I want to campare a variable in the script with the
variable the same script got, in the same circumstance, in it’s last execution. I was going to try and see if the script simply “remembered” variables in between executions, but before I could, I realized that my comparison needed the previousVariable in order to continue the running of the script. And if I defined the previousVariable as 0, so it would run the first time around, the previousVariable would always be zero. So my current solution is to define the previousVarible outside the script, in a Property. I would “get” the Property and assign it to “previousVariable” at the start of the script, and then “set” the Property at the end of the script to the current “variable”(To be the previousVariable of the next execution). Once again, if I’m confusing (which I usually am)and you still want to stick with me, you can ignore all this previousVariable stuff and focus on the first three lines of questions. I’m sorry for posting so many questions in such a short period of time. I just have this single goal in mind and I keep hitting snags. I just want to do it all while the complexities of my script are still in my head. :-?
Hehe, your coming along fine, thats exactly how you would do things. Fortunately, using properties in python is really quite simple
object = controller.getOwner() #Gets the object
object.prop = 1 #Sets the prop named “prop” to 1
print object.PreviousVariable #Prints the value of the prop named “PreviousVariable” to the console window
You can even set props from python that aren’t defined on the object and it will work.
You’ll have the hang of python in no time!
thanks!