So if I create an object with events, say, Sprite, I can immediately do Sprite.Value('Var')=stuff, without doing any additional picking since the created object is picked.
Is this the same with System.Create("Sprite") in python? If not, is there some way to pick the object?
You can select the newly created sprite in python with:
So I tried this code:
and I get the message:
SyntaxError: can't assign to function call
You need to use SetValue:
Oh I see. Is that construct-specific? If so, is there a good Construct Python documentation available? I checked the wiki and there's not a whole lot there.
As always, the best recommendation is Silent Cacophony's Python Shell:
That's kinda neat. I tried messing with it but I'm not sure it still does what I want, but maybe I don't get it.
For example, let's say I want to set a color filter.
I can do something like dir(System) to find that, then dir(System.SetFilter), but I stil don't get how to use SetFilter in python. E.g. what arguments does it take, and what syntax would you put them in, stuff like that (I do need to know how to do something like Sprite.SetFilter(Args) in python btw ) Seems like the default editor for scripting also fills in the commands on the bar on the right so I'm not sure exactly what that program is meant for.
The python functions take the same number of arguments as their event counterparts. So events are the reference.
If the argument in events is a color then in python it is in this form:
so to set the filter of Sprite to red:
Sprite.SetFilter( System.rgb(255,0,0) )
If the argument in events is a object then in python it is the OID of that object.
If the argument in events is a combo box then in python it is the index of the list, starting from zero.
Develop games in your browser. Powerful, performant & highly capable.
Just a (non-related) thought/suggestion, but maybe it would be beneficial to have all python related questions and answers under their own sub-forum, for easier accessibility. It would certainly make finding what we need much simpler, rather than trawling though generic help.
As I said, just a thought/suggestion/wishful thinking.