playMaker

Author Topic: Extending playmaker functionality - Fsm variables  (Read 3850 times)

SimonMillard

  • Playmaker Newbie
  • *
  • Posts: 4
Extending playmaker functionality - Fsm variables
« on: February 27, 2013, 05:28:31 AM »
Hi!

I've got a few questions regarding Fsm variables and extending the PlayMaker functionality.

1) Is it possible to create your own Fsm variable types (like FsmString, etc.)?

2) In C# you can have nullable variables using f.x. float? - this means the float value can be null. Is it possible to have nullable Fsm variables? I tried FsmFloat?, but that gives an error, and I guess what I really want is the FsmFloat.Value to be nullable.
The reason I'm asking is because I would like to have float, int, etc. fields which the user can leave empty. Then I would check for f.x. FsmFloat.IsNone in my FsmStateAction script to find out if the user has set a value for the float or not. Also, using float? instead of FsmFloat? doesn't work either (and then of course I would lose the advantages of using a Fsm variable).

Any information is much appreciated - thanks!

/Simon

Jake

  • Junior Playmaker
  • **
  • Posts: 61
    • Fluffy Underware
Re: Extending playmaker functionality - Fsm variables
« Reply #1 on: February 27, 2013, 06:21:27 AM »
Hi,

1.) I guess no, but the author may prove me wrong.
2.) Why do you need nullable variables? Fsm variables have a defined null state. The user can either enter a fixed value or a reference and you can consider an empty reference to be a null value, can't you? E.g.

Code: [Select]
public FsmVector3 position;

public override void OnUpdate()
{
   if (!position.isNone)...
   ...
}

public override void Reset()
{
            position = new FsmVector3() { UseVariable = true }; // much like null
}

Jake

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Extending playmaker functionality - Fsm variables
« Reply #2 on: February 27, 2013, 06:54:07 AM »
Hi,

 Jake is right,

 by forcing the variable to "UseVariable" you can then check if the user has indeed inputed something, be it a simple value or a pointer to a variable.

check using IsNone() on that variable and then you know if the user left that field to "none" or not.

Check the action "addForce" for an example of this.

bye,

 Jean

SimonMillard

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Extending playmaker functionality - Fsm variables
« Reply #3 on: February 27, 2013, 06:57:07 AM »
Brilliant! Thanks guys, I didn't think of that. I would still really like to know if there is a way of making your own Fsm variable types though :)

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Extending playmaker functionality - Fsm variables
« Reply #4 on: February 27, 2013, 08:15:55 AM »
Wow, I wanted to ask the same thing. Right now I'm using FsmObject variable wrappers for many variables in my Playmaker-Astar bridge, but it would be so much nicer to have them at least show up directly in the same list as the FsmInt, FsmVector3 etc. Is such a thing possible?
Best,
Sven

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Extending playmaker functionality - Fsm variables
« Reply #5 on: March 15, 2013, 10:33:18 AM »
Hi,

 playmaker now lets you create a variable that allows the user to select its type. I am not sure if this is what you need, but that's really powerful.

bye,

 Jean

Jake

  • Junior Playmaker
  • **
  • Posts: 61
    • Fluffy Underware
Re: Extending playmaker functionality - Fsm variables
« Reply #6 on: March 15, 2013, 10:47:51 AM »
Hi,

can you elaborate on this? I found nothing in the docs/release notes about this topic.

Thanks
Jake

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Extending playmaker functionality - Fsm variables
« Reply #7 on: March 18, 2013, 04:08:54 AM »
Hi,

 look at the "format string" action, it feature this new type of interface

you can select the variable type, before that wasn't possible, hence for exampel why with arrayMaker I had to give ALL possible solution... now I wiull be able to make very simple action interface with great flexibilities.

bye,

 Jean