Pick Created in Python

This forum is currently in read-only mode.
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • 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:

    SOL.Sprite[/code:17ps0prp]
  • Thanks!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So I tried this code:

    SOL.Sprite.Value('Home')=System.globalvar("tempHome")

    and I get the message:

    SyntaxError: can't assign to function call

  • You need to use SetValue:

    SOL.Sprite.SetValue('Home', System.globalvar("tempHome"))

  • 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:

    http://www.scirra.com/forum/viewtopic.php?f=8&t=6158&p=50287

  • 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:

    System.rgb(255,128,0)

    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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)