playMaker

Author Topic: Set Enum value via string/index?[SOLVED]  (Read 4843 times)

craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 234
    • Haven Made
Set Enum value via string/index?[SOLVED]
« on: February 12, 2018, 10:10:19 AM »
Wasn't sure if there currently was a way to do this or not...

I'm looking for a way to save current enum values, and best I can find to do is save the index/int for the enum. But then I realized there's no way to actually SET an enum by any value other than an enum.

Could have an int-switch tied to set-enum but that seems like a bit of a workaround. *shrugs* just wasn't sure if there was a better way?

best,

craigz
« Last Edit: February 22, 2018, 01:17:32 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Enum value via string/index?
« Reply #1 on: February 20, 2018, 01:46:19 AM »
Hi,

 Good point. Made an action for this on the Ecosystem. Search for "ConvertIntToEnum"



 bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Enum value via string/index?
« Reply #2 on: February 20, 2018, 01:53:58 AM »
Hi,

 and the second one: ConvertStringToEnum



 Bye,

 Jean

craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 234
    • Haven Made
Re: Set Enum value via string/index?
« Reply #3 on: February 21, 2018, 06:39:55 PM »
BOOM!

As usual Jean, thank you!

You rock :D

-craigz

craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 234
    • Haven Made
Re: Set Enum value via string/index?[SOLVED]
« Reply #4 on: February 28, 2018, 01:15:19 AM »
So a follow up question, that I feel you might have answered else, couldnt remember if it was a Unity limitation or not.

But would some sort of a 'FSM Enum Switch' or 'FSM Enum Test' action be possible? (similar to how the FSM Bool Test action tests the bool on another without having to have a local data variable made on the object thats doing the testing)

I find myself needing to test if the enum on other game objects is a certain one. And things have been getting cluttered from making duplicate variables on the manager type gameobject just for the purpose of doing 'Get FSM Enum' then followed by 'Enum Switch' etc :)

-craigz

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Enum value via string/index?[SOLVED]
« Reply #5 on: March 01, 2018, 03:55:09 AM »
Hi,

 yes, I'll see if I can work on this action, it should feasible. Can you bump me mis next week if I haven't delivered?

 Bye,

 Jean

craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 234
    • Haven Made
Re: Set Enum value via string/index?[SOLVED]
« Reply #6 on: March 01, 2018, 10:17:41 AM »
Excellent! :D Thanks Jean! Will do :)

-craigz

craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 234
    • Haven Made
Re: Set Enum value via string/index?[SOLVED]
« Reply #7 on: March 06, 2018, 07:18:52 PM »
Just an almost mid-week bump ;D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Enum value via string/index?[SOLVED]
« Reply #8 on: March 07, 2018, 04:33:41 AM »
thanks :)

on it!

Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Enum value via string/index?[SOLVED]
« Reply #9 on: March 07, 2018, 04:48:55 AM »
Hi,

 ok, done, it's called 'FsmEnumSwitch'

the only bad thing is that you have to manually define the enum type for all your case as there is no mechanism built action to match the type this way.

 Let me know how it works for you.

 Bye,

 Jean

craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 234
    • Haven Made
Re: Set Enum value via string/index?[SOLVED]
« Reply #10 on: March 07, 2018, 10:34:44 PM »
You rock Jean! :D

This is working perfect! No worries about having to manual set them, still saves a ton of time :D

Thanks for cranking this out, it means a lot to me! :)

-craigz