playMaker

Author Topic: Add variable to FSM with custom action[SOLVED]  (Read 2662 times)

Martin

  • Playmaker Newbie
  • *
  • Posts: 4
Add variable to FSM with custom action[SOLVED]
« on: March 15, 2013, 02:23:59 PM »
I'm writing a custom action and was looking for a way to check if a FSM has a variable, and if not to create it. Is that possible?
« Last Edit: March 20, 2013, 02:40:00 AM by jeanfabre »

memetic arts

  • Full Member
  • ***
  • Posts: 141
Re: Add variable to FSM with custom action
« Reply #1 on: March 20, 2013, 12:45:15 AM »
I have a similar question, but just for adding variables via script, so am bumping this.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3999
  • Official Playmaker Support
    • LinkedIn
Re: Add variable to FSM with custom action
« Reply #2 on: March 20, 2013, 01:16:12 AM »
Fsm variables can be found here:

Code: [Select]
FsmComponent.Fsm.Variables
Each variable type has its own array:

Code: [Select]
FsmComponent.Fsm.Variables.FloatVariables[]
FsmComponent.Fsm.Variables.IntVariables[]
...

Do you want to add variables at edit time or run time?

Most editor stuff is done by an FsmBuilder class, but this is not documented. You would have to poke around to figure out how it works...

If you're talking runtime, you could make a new variable and add it to the array yourself:

Code: [Select]
var myFloatVariable = new FsmFloat("myFloatVariable");

memetic arts

  • Full Member
  • ***
  • Posts: 141
Re: Add variable to FSM with custom action
« Reply #3 on: March 20, 2013, 02:38:15 AM »
I was looking for the latter, adding variables at runtime, and the info you provided is exactly what I needed to know, thanks very much!