playMaker

Author Topic: Get FSM Array Variable by String Name (Not Just by Index)  (Read 306 times)

westingtyler

  • Full Member
  • ***
  • Posts: 210
    • View Profile
    • My Oculus Rift + Touch VR Game Using Playmaker
Get FSM Array Variable by String Name (Not Just by Index)
« on: November 13, 2018, 07:59:40 PM »
Get FSM Array Variable by String Name (Not Just by Index)

This would save us having to copy over the entire array to a different fsm, just to do an Array Contains search on it.

EDIT: this is even harder than I thought. It seems we can only use Array Contains by index or exact type match (game object array contains this game object?) rather than saying "game object array contains game object named X?"

We need to be able to check ANY array type for an entry with a certain NAME, whether it's an array of prefabs, textures, strings, etc. Please help.
« Last Edit: November 13, 2018, 08:40:15 PM by westingtyler »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13635
  • Official Playmaker Support
    • View Profile
Re: Get FSM Array Variable by String Name (Not Just by Index)
« Reply #1 on: November 13, 2018, 11:05:03 PM »
Hi,

 I am confused, can you give a concrete example with proper variable names, types and fsm, the I'll be able to understand more.

 Typically though if you want FsmArray to be a central part of your game data, you are better off using ArrayMaker which by design is decentralized ( it's its own component), and they offer a lot more flexibility both with array with multiple types and more advanced features to work with the data, as well as hashtables.

Bye,

 Jean

waveform

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
Re: Get FSM Array Variable by String Name (Not Just by Index)
« Reply #2 on: November 14, 2018, 03:47:33 PM »
you mean FSM array? here is maybe something u need


westingtyler

  • Full Member
  • ***
  • Posts: 210
    • View Profile
    • My Oculus Rift + Touch VR Game Using Playmaker
Re: Get FSM Array Variable by String Name (Not Just by Index)
« Reply #3 on: November 15, 2018, 12:02:03 AM »
Thanks, I have most of those ecosystem actions, but I don't see any that can do this.

I just need to get an array's item by a string of the name of its contents, rather than by its ID. I need to check an array to see if any of its entries is called X string (even if it's NOT a string array), then get THAT index entry, whether it's a game object, a texture, etc. I'll look into ArrayMaker as well, but for now this is the only thing I need.

Here is a picture of the action I need, edited by me:
« Last Edit: November 15, 2018, 12:06:07 AM by westingtyler »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13635
  • Official Playmaker Support
    • View Profile
Re: Get FSM Array Variable by String Name (Not Just by Index)
« Reply #4 on: November 15, 2018, 12:20:48 AM »
Hi,

 sorry I just don't get it...

 could you show me the array content? to me it looks like you just need to use the ArrayContains to find the index of an array item

Bye,

 Jean

westingtyler

  • Full Member
  • ***
  • Posts: 210
    • View Profile
    • My Oculus Rift + Touch VR Game Using Playmaker
Re: Get FSM Array Variable by String Name (Not Just by Index)
« Reply #5 on: November 15, 2018, 12:44:58 AM »
I'm trying ArrayMaker, and it also seems to not be able to do this.

Here's what I'm trying to do. I find the name of the item that the player is holding. So that's now in a STRING variable. Then I want to update the Equipped Item Icon display in the HUD. So I need to find, from my ItemIconTextures arraylist, the texture that has the same name as the item the player is holding, WHEREVER it's stored in the array, regardless of its index. i'm adding new textures and prefabs all the time, so indices don't help since all I have is the name of the object being held, to use.
« Last Edit: November 15, 2018, 01:12:39 AM by westingtyler »

westingtyler

  • Full Member
  • ***
  • Posts: 210
    • View Profile
    • My Oculus Rift + Touch VR Game Using Playmaker
Re: Get FSM Array Variable by String Name (Not Just by Index)
« Reply #6 on: November 15, 2018, 01:44:06 AM »
I'm testing the EcoSystem action Array List Contains Name right now. if this works, then my request is to get this action, except for standard FSM arrays:

FSM Array Contains Name
Array Contains Name

UPDATE: I can't get it to work. It never finds anything. :(
« Last Edit: November 15, 2018, 03:26:56 AM by westingtyler »

westingtyler

  • Full Member
  • ***
  • Posts: 210
    • View Profile
    • My Oculus Rift + Touch VR Game Using Playmaker
Re: Get FSM Array Variable by String Name (Not Just by Index)
« Reply #7 on: November 15, 2018, 04:17:17 AM »
Still trying to get it to work, and are some inconsistencies and issues: I'm trying to use some Array List actions here:

In the Array List Contains Game Object one, it won't find UNLESS I specify a tag. It works, but it'd be great if it didn't need a tag (Untagged was used in this case) and could find regardless of any tag, since this Array will eventually contain objects with different tags.

In the Array List Contains Name action, I can't make it find anything at all in the referenced Texture Array List. What am I doing wrong here?

I tried editing the Array List Contains Game Object to make it a Array List Contains Texture action, but it kept telling me that either a path returned nothing (when I commented out the tag parts) or that it didn't expect a return. i don't get it, but I attached it. It'd be great to have these actions for ALL variable types, not just Game Object. That's what the action Array List Contains Name seems to be, but I can't get it to find anything, as shown in the images.
« Last Edit: November 15, 2018, 06:55:18 AM by westingtyler »

waveform

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
Re: Get FSM Array Variable by String Name (Not Just by Index)
« Reply #8 on: November 15, 2018, 09:59:39 AM »
Here is a simple action i made for get array value by string name

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13635
  • Official Playmaker Support
    • View Profile
Re: Get FSM Array Variable by String Name (Not Just by Index)
« Reply #9 on: November 15, 2018, 10:51:58 PM »
Hi,

 ok, I see, you want to search for a property of the item.

 That's really going to backfire at some point, I would definitly avoid doing that.

instead use hashtables, it's a key (string) referencing a value ( Object)

then when you want to get content for a given player you use the key to get it.

you would have several hashtable, one for texture, one for indexes, one for score, etc etc.

 you could even use the new ArrayTable and organize data this way.

Bye,

 Jean

westingtyler

  • Full Member
  • ***
  • Posts: 210
    • View Profile
    • My Oculus Rift + Touch VR Game Using Playmaker
Re: Get FSM Array Variable by String Name (Not Just by Index)
« Reply #10 on: November 16, 2018, 07:39:58 AM »
okay, can you explain why it would backfire, though?

westingtyler

  • Full Member
  • ***
  • Posts: 210
    • View Profile
    • My Oculus Rift + Touch VR Game Using Playmaker
Re: Get FSM Array Variable by String Name (Not Just by Index)
« Reply #11 on: November 16, 2018, 01:02:44 PM »
waveform, that could be a helpful action. I need to be able to search within another game object's fsm's arrays, though this action seems to only do it locally within one.

The array lists are cool, so the ideal action may instead be a modified version of the current Array List Contains Game Object that allows you to select the type of variable you are looking for (texture, game object, etc.) Would it be possible to modify that action to allow this? In a previous comment here I attached my attempt to modify the action for textures, but it kept giving errors I don't understand.

waveform

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
Re: Get FSM Array Variable by String Name (Not Just by Index)
« Reply #12 on: November 18, 2018, 04:12:42 PM »
u can simply checkout my action as example then modify array list action to fit what u need, u can also make a template and run it with Run Fsm action.

First make a copy of fsm array then seach through the array inside, after this add a Finnish Fsm action as last action, finnish fsm allow u to trigger finnish event in Run Fsm action
but in this case i really recommend use hashtable,it save a lot of perfomance.

I really dont recmmend use arraylist, because arraylist support too few of types, this is a big problem then u try to do something complex