how do you use python conditions (solved)

For questions about using Classic.

Post » Wed Dec 30, 2009 1:29 am

let's say I want to have a MouseKeyboard.OnClick event within python
it that possible?
I know all the python commands are in place for conditions
but I don't know/understand if/how they can be used.

EDIT:solution down there somewhere
Spriter Dev
B
88
S
21
G
12
Posts: 3,240
Reputation: 16,486

Post » Thu Dec 31, 2009 3:36 pm

no, but seriously
is it possible?

are they just used as expressions that evaluate to boolean values?(not at home to test)
Spriter Dev
B
88
S
21
G
12
Posts: 3,240
Reputation: 16,486

Post » Thu Dec 31, 2009 3:53 pm

Time for a python object?
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Thu Dec 31, 2009 6:06 pm

you know about this one, right?
[url:y83kn3sk]http://www.scirra.com/forum/viewtopic.php?f=2&t=5305[/url:y83kn3sk]
Spriter Dev
B
88
S
21
G
12
Posts: 3,240
Reputation: 16,486

Post » Thu Dec 31, 2009 6:33 pm

Well a full blown object might be interesting. I know users would still want the ability to use the editor, but inputting expressions like you can with an object would be cool.
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Thu Dec 31, 2009 7:45 pm

not sure what you mean

unless you mean:
[quote="construct wiki":ullj8d0n]
Script-Event communication

Events can retrieve data from scripts via the Python system expression. For example, the expression:

Python("x")

will return the content of the variable x. Similarly:

Python("myfunc()")

will return the value returned from calling the function myfunc in script. Further, you can use the system condition Python Compare, to directly compare a python variable in an event, such as the variable "x" greater than 100.

Scripts can trigger events by using the Function Object. The Call routine of the Function object takes two parameters: the function name, as a string, and the forget/remember picked objects option, which can be left as 0 (for Forget). For example:

Function.Call("My function", 0) [/quote:ullj8d0n]
if not, what do you mean?
Spriter Dev
B
88
S
21
G
12
Posts: 3,240
Reputation: 16,486

Post » Thu Dec 31, 2009 8:26 pm

For example your py object, what if you could include all the python conditions, actions, and expressions in it, and use it like say the system object.
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Thu Dec 31, 2009 8:33 pm

hmm...but python is mainly there to use the other stuff that the normal construct stuff makes tedious or messy, so it'd be like a super messy, tedious mess of tedium. plus python is a full scripting language, so I'd imagine it'd be hundreds of possible commands and expressions.

anywho
for those who are wondering, I figured out the answer
yes you can use construct conditions in python as boolean expressions
for instance:

[code:1gaz489e]if MouseKeyboard.MouseButtonDown(0):
Sprite.Angle+=1;[/code:1gaz489e]

will increment the sprite angle while the mouse button is down,
but I can't figure out how to make this work or if it works with triggered conditions
I think not, just based on what I know about the SDK
but who knows really.
Spriter Dev
B
88
S
21
G
12
Posts: 3,240
Reputation: 16,486

Post » Sun Jan 03, 2010 11:00 am

I think you'd just want to have the triggered condition with the python script as a subevent?
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests