[Solved] How to use and check parameters value?

I’ve created two parameters in a function but I’m not getting it how can I use those parameters in the event section and specially how can i check the value of a parameter.

Please show me some events using my parameters above.


One of the things that confused me with GD was working with Functions. I notice that PARAM1 is supposed to be a sprite, but you have it defined as Any Object. I found that changing the Object Type to “Sprite” will make adding events and actions much easier, since GD will now recognize the entity passed by PARAM1 as a sprite and will show the appropriate sprite conditions and actions.

For PARAM2, you need to use the GetArgumentAsString function - it is a little tricky to find it, but here is how you do it:

  1. add action Variables / String of a Scene Variable
  2. define the variable that will hold the passed parameter
  3. set equal
  4. To the right side on the Text field, click on 19%20PM
  5. scroll down to Functions and select “Get function parameter text”
  6. in the pop up parameter window, enter (in your case) direction
    That will pull the value into a variable that you can then reference

You should also read the section Bouh linked, as it gives a good overview (but not as much depth as you need to answer your question).

1 Like

GetArgumentAsString successfully return parameter value. But the two block events below are not working. Please have look. What is the problem? :thinking:

@poly-puzzles By assigning it to object variable it’s working perfectly now. Thanks a lot man.

Somehow I am not able to do it in my project

This is how I set up the action

This is how I am using it (I tried even adding the objects as parameter,but still not working)

This is similar to @RIR360’s example above. But why is it not working?

Hopefully this is an easy one, but I can’t sort it out.

Suppose I have a very basic function that will square a number (x * x) [yes, I know pow() exists :slight_smile: ]

I have set up my function and pass it a value. How do I reference the value? I’ve tried every permutation I can think of, but I can’t get it to work. I have tested that the inbound number has the right value, and that the textbox inside the function gets called (this is just for debugging).

Regardless, I cannot get the value passed to the function to show in a text box, or be used in that function. Is there a different syntax other than “Variable(ParameterName)”?

I appreciate the help.

Set up of function parameters:

Call of function:

Code of function:

SOLVED (sort of):

Ultimately, the work around was to NOT pass a stand-alone number (which I just can’t figure out how to reference?), and instead assign it to a shell object (and variable) in the scene, and pass the whole thing. Then, referencing the number from the object is easy.

Please let me know if there’s a better way to do this… but it works.

You can read more about types and how use functions parameters on the wiki page.
For Number and Text parameters types you need to use these expressions for get the value contain in your parameter.



The objects, behaviors, and variables type can be directly used.

Here different types in a use of case.

1 Like