Playmaker Forum

PlayMaker Feedback => Action Requests => Topic started by: MS80 on June 30, 2014, 07:41:42 AM

Title: Send message (multiple parameter of different type)
Post by: MS80 on June 30, 2014, 07:41:42 AM
How to send a message to a script with more than one parameter of different type needed?

F.e. PostScore(string name, int score)

The action "send message" allows only one parameter, is it possible to create a action with more than one parameter (f.e with integrated temporary array)? Maybe there is another solution?!

Hope you can help me...
Thanks!
Title: Re: Send message (multiple parameter of different type)
Post by: jeanfabre on July 02, 2014, 06:49:34 AM
Hi,

Currently, it's not really possible. You'll have to make a custom action to call that method with several parameters.

 [EDIT] It is indeed possible using the "call method" action.

Bye,

 Jean
Title: Re: Send message (multiple parameter of different type)
Post by: Alex Chouls on July 02, 2014, 09:19:05 AM
SendMessage is a Unity function and only accepts one parameter.

But you should be able to use Call Method to call a method with multiple parameters...
Title: Re: Send message (multiple parameter of different type)
Post by: jeanfabre on July 02, 2014, 09:20:21 AM
D'oh :)

 Thanks Alex for correcting me, I forgot about that action... :)

 Bye,

 Jean
Title: Re: Send message (multiple parameter of different type)
Post by: MS80 on July 03, 2014, 03:31:48 PM
Thanks! I already found the "Call Method" action, which is great! Also found a testpackage how to use it, unfortunatly I dont get it to work with the script I need!

I get the errormessage: Method Name is invalid: PostScore

Attached is a script which works just fine, but I want to control this script via playmaker (parts of it without the gui stuff)! Setting the string and int is no problem, function "GetScore" works, too! But function "PostScore" needs 2 parameters (string, int). If I use "PostScore" with only one parameter I can use it with "send message" action...

Hope you can help me.
Title: Re: Send message (multiple parameter of different type)
Post by: jeanfabre on July 10, 2014, 09:49:25 AM
Hi,

 there is a know bug in where if the method as different signatures it gets confused.

 Bye,

 Jean
Title: Re: Send message (multiple parameter of different type)
Post by: Alex Chouls on July 12, 2014, 12:09:45 PM
There's an updated Call Method action here:
http://hutonggames.com/playmakerforum/index.php?topic=7526.0

Please give that a go. It should fix the bug with method overrides...
Title: Re: Send message (multiple parameter of different type)
Post by: MS80 on July 14, 2014, 05:26:14 PM
Sadly no!  :'(  I have already tried the updated Call Methode action...

=> "Invalid Method Name or Parameters: PostScore"

I also tried "get component" workaround, without success!
Any ideas??
Title: Re: Send message (multiple parameter of different type)
Post by: Alex Chouls on July 14, 2014, 05:29:47 PM
This is with the update? And parameters set to match the method signature? Can you post a screenshot of the Call Method action setup?
Title: Re: Send message (multiple parameter of different type)
Post by: MS80 on July 14, 2014, 06:54:29 PM
Sure! Here is a screenshot....

I used the one you provided (with the link above).
Parameters should match the method (Playername=string, Score=int)

Errormessage is the same if I use get component and use component variable...

Title: Re: Send message (multiple parameter of different type)
Post by: Alex Chouls on July 14, 2014, 07:18:45 PM
Does PostScore have a float return type?
Title: Re: Send message (multiple parameter of different type)
Post by: MS80 on July 14, 2014, 07:25:27 PM
To be onest I dont know if it has a return type, I assume not (script is attached in upper post)! Thought if variable is set to none it is ignored....

I recognized a second error message in the console:
"Failed to call function PostScore of class Highscore
Calling function PostScore with no parameters but the function requires 2.
UnityEngine.MonoBehaviour:StartCoroutine(String)
Highscore:Start() (at Assets/Highscore/Script/Highscore.cs:30)"
Title: Re: Send message (multiple parameter of different type)
Post by: jeanfabre on July 21, 2014, 06:14:24 AM
Hi,

 I see, you can't typically use methods that are asynchrone, which is exactly what you are trying to call.


so, create a new function "void CallPostScore(PostScore(string name, int score)" that simply calls in turn PostScore, and that is going to work.

 Bye,

 Jean
Title: Re: Send message (multiple parameter of different type)
Post by: MS80 on July 24, 2014, 05:09:23 PM
Thx Jean!

Sorry beeing a bonehead... tried what you descriped but no matter how I do it, getting lots of errors  :-\

Could you please go a bit more into detail how to add the function and to call in turn PostScore? maybe showing off a small code snippet ?!
Title: Re: Send message (multiple parameter of different type)
Post by: jeanfabre on July 31, 2014, 07:31:11 AM
Hi,

 yes of course:

 here is the new method you need to add to the script itself for "Call Method" action to work:

Code: [Select]
public void CallPostScore(string name, int score)
{
Debug.Log("CallPostScore");
StartCoroutine(PostScore(name,score));
}

so in the "Call Method", the method will be "CallPostScore" and you create 2 variable, one string and one int and you are good to go!

Bye,

 Jean
Title: Re: Send message (multiple parameter of different type)
Post by: MS80 on July 31, 2014, 05:21:13 PM
Many thanks, Jean!

I was very very close to it, no idea what was going wrong!?  :-X
Now it performs like expected! "CallMethod" action is a mighty one, it even showed me a error because the function has no return, after setting to "none" it runs out of the box!

I salute the way how playmaker cooperates with script components, it multiplies it's power!