playMaker

Author Topic: Send message (multiple parameter of different type)  (Read 10323 times)

MS80

  • Junior Playmaker
  • **
  • Posts: 64
Send message (multiple parameter of different type)
« 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!
« Last Edit: June 30, 2014, 08:00:34 AM by MS80 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Send message (multiple parameter of different type)
« Reply #1 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
« Last Edit: July 02, 2014, 09:21:16 AM by jeanfabre »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4003
  • Official Playmaker Support
    • LinkedIn
Re: Send message (multiple parameter of different type)
« Reply #2 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...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Send message (multiple parameter of different type)
« Reply #3 on: July 02, 2014, 09:20:21 AM »
D'oh :)

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

 Bye,

 Jean

MS80

  • Junior Playmaker
  • **
  • Posts: 64
Re: Send message (multiple parameter of different type)
« Reply #4 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.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Send message (multiple parameter of different type)
« Reply #5 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

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4003
  • Official Playmaker Support
    • LinkedIn
Re: Send message (multiple parameter of different type)
« Reply #6 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...

MS80

  • Junior Playmaker
  • **
  • Posts: 64
Re: Send message (multiple parameter of different type)
« Reply #7 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??

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4003
  • Official Playmaker Support
    • LinkedIn
Re: Send message (multiple parameter of different type)
« Reply #8 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?

MS80

  • Junior Playmaker
  • **
  • Posts: 64
Re: Send message (multiple parameter of different type)
« Reply #9 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...

« Last Edit: July 14, 2014, 06:56:33 PM by MS80 »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4003
  • Official Playmaker Support
    • LinkedIn
Re: Send message (multiple parameter of different type)
« Reply #10 on: July 14, 2014, 07:18:45 PM »
Does PostScore have a float return type?

MS80

  • Junior Playmaker
  • **
  • Posts: 64
Re: Send message (multiple parameter of different type)
« Reply #11 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)"
« Last Edit: July 14, 2014, 07:40:52 PM by MS80 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Send message (multiple parameter of different type)
« Reply #12 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

MS80

  • Junior Playmaker
  • **
  • Posts: 64
Re: Send message (multiple parameter of different type)
« Reply #13 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 ?!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Send message (multiple parameter of different type)
« Reply #14 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