playMaker

Author Topic: put a string variable into an Action without that option  (Read 1281 times)

laynardo

  • Junior Playmaker
  • **
  • Posts: 54
    • View Profile
put a string variable into an Action without that option
« on: May 22, 2016, 03:43:32 PM »
hi,
I have a playmaker script, with a text box input. I want to call a text string in there, but there isn't an option in this particular action. How should I approach this?

joduffy

  • Full Member
  • ***
  • Posts: 121
  • Here to help
    • View Profile
    • Online Playmaker Courses
Re: put a string variable into an Action without that option
« Reply #1 on: May 22, 2016, 05:07:02 PM »
Hi Dude,

Can you right click on the action and go edit script. Then post whats inside it.
I think it should be easy enough to edit so that you can use string fsm variables. Just need to see how its setup.
- Jonathan

Online Playmaker Courses available at:
http://courses.jonathanoduffy.com

“I want the world to be a better place because I was here.”  -  Will Smith

laynardo

  • Junior Playmaker
  • **
  • Posts: 54
    • View Profile
Re: put a string variable into an Action without that option
« Reply #2 on: May 22, 2016, 05:26:23 PM »
using UnityEngine;
using System.Collections;
using Crosstales.RTVoice;

namespace HutongGames.PlayMaker.Actions {
   [ActionCategory("Crosstales.RTVoice")]
   public class Speak : SpeakBase {

      public bool reset;

      [Tooltip("Text to speak.")]
      public string Text;

      [Tooltip("Culture for of the voice (default: empty).")]
      public string Culture = "en";

      [Tooltip("Index of the voice from the Speaker.VoicesForCulture()-call.")]
      public int Voice;

      public override void OnEnter() {
//         if (GameObject.Find("RTVoice") == null) {
//            AddRTVoice();
//         }

         switch (Mode) {
            case SpeakMode.Speak:
               Speaker.Speak(Text, AudioSource, Speaker.VoiceForCulture(Culture, Voice), true, Rate, Volume);
               break;
            case SpeakMode.SpeakNative:
               Speaker.SpeakNative(Text, Speaker.VoiceForCulture(Culture, Voice), Rate, Volume);
               break;
         }
         Finish();
      }
   }
}
// Copyright 2016 www.crosstales.com

joduffy

  • Full Member
  • ***
  • Posts: 121
  • Here to help
    • View Profile
    • Online Playmaker Courses
Re: put a string variable into an Action without that option
« Reply #3 on: May 22, 2016, 05:38:07 PM »
Cool.

So what is happening is that the script is using String over FsmString. So what you need to do is just replace it.

So String Text becomes FsmString Text.
Then anywhere you see Text, it now becomes Text.Value

I tried to update the script so that is uses FSM's variables. I can't test it but in theory it should work. The only thing that might cause an error, is if the the of the code tries to use the variables directly and is expecting them in non-Fsm form.

But try it and let me know how it goes.

Code: [Select]
using UnityEngine;
using System.Collections;
using Crosstales.RTVoice;

namespace HutongGames.PlayMaker.Actions {
   [ActionCategory("Crosstales.RTVoice")]
   public class Speak : SpeakBase {

      public bool reset;

      [Tooltip("Text to speak.")]
      public FsmString Text;

      [Tooltip("Culture for of the voice (default: empty).")]
      public FsmString Culture = "en";

      [Tooltip("Index of the voice from the Speaker.VoicesForCulture()-call.")]
      public FsmInt Voice;

      public override void OnEnter() {
//         if (GameObject.Find("RTVoice") == null) {
//            AddRTVoice();
//         }

         switch (Mode) {
            case SpeakMode.Speak:
               Speaker.Speak(Text.Value, AudioSource, Speaker.VoiceForCulture(Culture.Value, Voice.Value), true, Rate, Volume);
               break;
            case SpeakMode.SpeakNative:
               Speaker.SpeakNative(Text.Value, Speaker.VoiceForCulture(Culture.Value, Voice.Value), Rate, Volume);
               break;
         }
         Finish();
      }
   }
}
// Copyright 2016 www.crosstales.com
- Jonathan

Online Playmaker Courses available at:
http://courses.jonathanoduffy.com

“I want the world to be a better place because I was here.”  -  Will Smith

laynardo

  • Junior Playmaker
  • **
  • Posts: 54
    • View Profile
Re: put a string variable into an Action without that option
« Reply #4 on: May 22, 2016, 06:15:18 PM »
it worked! I emailed it to the dev as well.

joduffy

  • Full Member
  • ***
  • Posts: 121
  • Here to help
    • View Profile
    • Online Playmaker Courses
Re: put a string variable into an Action without that option
« Reply #5 on: May 22, 2016, 09:25:45 PM »
Sweet.
Glad it worked and that I could help you out.

Good luck with the rest of the project dude.
- Jonathan

Online Playmaker Courses available at:
http://courses.jonathanoduffy.com

“I want the world to be a better place because I was here.”  -  Will Smith