Python and behaviors

This forum is currently in read-only mode.
  • Can Python access and/or modify behaviors? From what I've tried so far it does not seem to be possible.

    For example, if I want to change sprite[CustomMovement].XSpeed, how would I set that or get the value of in script?

    Thanks!

  • that's correct.

    you can still use python though, with the python() expression

    Sprite - Custom Movement - Set X Speed to:

    python("myspecialequation(1,5,x,y)+math.cos(12)/Sprite.Width")[/code:2c7nxwqa]
    
    if it gets messy, or you want to tweak it alot:
    an alternative is to set a python variable:
    [code:2c7nxwqa]XSpeed=myspecialequation(1,5,x,y);[/code:2c7nxwqa]
    
    Then in the event sheet:
    [b]Sprite  -  Custom Movement   -   Set X Speed to:[/b]
    [code:2c7nxwqa]python("XSpeed")[/code:2c7nxwqa]
    
    for retrieving the value of Sprite[CustomMovement].XSpeed, the only thing I can think of is to set a private or global variable to Sprite[CustomMovement].XSpeed just before the script in the eventsheet, then using the variable in your script in place of the expression
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the example! I figured there would be syntax issues since the way Construct specifies Behaviors would clash with Python syntax, so this is a pretty good work around.

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