Can you get a Function's parameter in a script?

0 favourites
  • 3 posts
  • Hey there!

    I'm trying to add a function that is a broad controller for moving NPC's in my game, but I need to input specifically what type of Object I need to move (I already know how to get the Object's UID I just need to determine what object type I'm looking for, ex: Object: Enemy)

    So I'm trying to make a script inside of a function I've created and I'm trying to get the value of one of the function's parameters inside of that script. For example:

    - Function

    - Parameter "Amount"

    - Script inside the function

    - Access "amount" inside of that script

    Alternatively is it possible to input an object type into a parameter using the visual scripting in event sheets?

    Sorry if this is poorly explained, I'm having trouble putting this idea into words!

    Thanks in advance.

  • When you have a script in an event, you should have access to the localVars object that will have all the local variables available in the current scope your in (ie... function, groups) so you can do something like

    localVars.functionParamter

    you can read more about it here

    construct.net/en/make-games/manuals/construct-3/scripting/using-scripting/scripts-in-event-sheets

    in the Accessing local variables section

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • scripts that you define in events end up as functions, notice that the runtime is being passed in, but also you have that localVars objects which has all the local variables in scope

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