playMaker

Author Topic: [SOLVED] Using a string value as a variable name?  (Read 2489 times)

bfd

  • Playmaker Newbie
  • *
  • Posts: 21
[SOLVED] Using a string value as a variable name?
« on: February 13, 2016, 05:33:10 PM »
I'm trying to set the value of a number of float variables at the same time. The number of variables I need to set is not consistent. I've got my floats named:
  • 0_chance_f
  • 1_chance_f
  • 2_chance_f
  • 3_chance_f
I'm trying to use an int to represent the current float being changed, then increment that as I work through the floats to be changed. What I had hoped to do was:
  • Convert int to string
  • Build string using int+"_chance_f"
  • Set the value of the float corresponding to the new string
  • Increment the int value
  • Goto 1
But the 'set float value' action only lets me choose from a list of existing float variables, there's no option to choose a string and use that as a variable name. I imagine it's fairly simple to do in code - but I'm using Playmaker because I don't know how to code ;D

Is this something that can be done in Playmaker currently and I'm just missing the 'how' or if not: is it functionality that can be added fairly easily?
« Last Edit: February 14, 2016, 11:00:47 AM by Alex Chouls »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Using a string value as a variable name?
« Reply #1 on: February 13, 2016, 05:43:54 PM »
You can use Set Fsm Variable:
https://hutonggames.fogbugz.com/default.asp?W1251

Keep GameObject as UseOwner.
Set the Fsm Name if there is more than one FSM on the GameObject.
Use the variable name you built and set the type to Float.

bfd

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Using a string value as a variable name?
« Reply #2 on: February 14, 2016, 07:24:28 AM »
Awesome! Thanks heaps. I figured there had to be a way to do this.