[beginner] help with first script, syntax, vars, and names
Posted: Wed Sep 23, 2015 8:32 pm
Hello, I am completely new to both python and freePIE. I just made my first script, and, it works, but I've a few questions about how you use python and freePIE to get things done.
Here's the script in full:
Now my questions,
Firstly, because the function assigns a new value to lastx, and the var is also used outside of the function, the var needs to be global. To do that, I tried usingbut python just said: Oh, what's "nil"? So instead of nil, I just gave it a value of 0. But what I really want to do, is say in python; "Ok, I want to reserve a name, as a global var, don't give it a value yet, just reserve it." How do I do that? Is there a special way you do that in python?
Secondly, does freePIE have a more elegant, or better way to check if the value of mouse.deltaX has changed?
Something along the lines ofrather than making and comparing it to vars.
Thanks to you!
Here's the script in full:
Code: Select all
if starting:
diagnostics.debug("hello world")
speech.say("penis")
lastx = 0
def print_lastx():
lastx = mouse.deltaX
diagnostics.debug(lastx)
if mouse.deltaX != lastx:
print_lastx()
Firstly, because the function assigns a new value to lastx, and the var is also used outside of the function, the var needs to be global. To do that, I tried using
Code: Select all
lastx = nil
Secondly, does freePIE have a more elegant, or better way to check if the value of mouse.deltaX has changed?
Something along the lines of
Code: Select all
if changed(mouse.deltaX):
Thanks to you!