Playmaker Forum

PlayMaker Updates & Downloads => Pre-release Discussion => Topic started by: Duffer on March 07, 2017, 10:25:52 AM

Title: "Collections" Actions[SOLVED]
Post by: Duffer on March 07, 2017, 10:25:52 AM
Hi All,

Not sure if this is the right forum board to ask this.... but I see that 'Collections' actions are in planning.

What sorts of actions (and variables) would Collections actions cover?  Where can I find out about them and what they are planned to do/accomplish?

When / what version are they slated to be introduced in?
Title: Re: "Collections" Actions
Post by: jeanfabre on March 09, 2017, 01:36:45 AM
Hi,

 can you paste the link where you see this is stated?

 Currently, ArrayMaker is available on the Ecosystem and wiki and covers collection using Hashtables, with string keys. It's already enabling quite a lot, but maybe not as flexible as Collections.

Bye,

 Jean
Title: Re: "Collections" Actions
Post by: Duffer on March 09, 2017, 02:11:31 AM
Damn.  Doesn't sound likely then... ;)

Here is the link:-  in Action Reference section of Manual:-  https://hutonggames.fogbugz.com/default.asp?W529

Ive always wanted a neat way for Playmaker to work well with or effectively interrogate public Lists in GOs.  I am not sure the Get/Set Property actions get me there...
Title: Re: "Collections" Actions
Post by: jeanfabre on March 09, 2017, 09:28:18 AM
Hi,

 yes, you are better off creating custom actions to access this component data.

Where did you get this component?

 Bye,

 Jean
Title: Re: "Collections" Actions
Post by: Duffer on March 09, 2017, 12:08:51 PM
I regularly append public lists or arrays in mono classes to GO.  From what you are saying the Action References link to Collections actions is a red herring?
Title: Re: "Collections" Actions
Post by: jeanfabre on March 10, 2017, 04:53:19 AM
Hi,

 If you are ok with scripting, no it's totally fine, you create the proper custom actions to access this list either per item, or direclty saving the content into an FsmArray.

The actions references link is simply a pending task, I am not sure when this is going to be adressed, I would not wait on this, and use either ArrayMaker or make your own custom actions to access your scripts. If you need a kick start let me know, send me one of your component and I'll show you how to create related custom actions, it's very easy.

 Bye,

 Jean
Title: Re: "Collections" Actions
Post by: Duffer on March 10, 2017, 07:16:04 AM
Hi Jean,

I'll be honest.  I could do with some help for the script for the custom action to grab values from say a public array of strings and, for the sake of simplicity a List of strings too, in a monobehaviour class linked to a GO.

Pretend the following mono class is sitting as a component on the same GO:-

Code: [Select]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class RPGBaseInfo : MonoBehaviour {

    public bool template = false;
    public bool hidden = false;

    public string title = "default name";

    public string[] descriptors;

    public List<string> knicknames = new List<string>();
}

What would the Custom Action scripts look like to access both values in the Array and then in the List?

[edit] ignore bit about Arrays... can now see how to do that with Get Property action.  More interested in Lists...

Title: Re: "Collections" Actions
Post by: jeanfabre on March 15, 2017, 03:48:10 AM
Hi,

 here we go:

(http://i.imgur.com/nw6ddq5.png)

and the action is :

Code: [Select]
using System;
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("RPG")]
public class GetRPGInfoItem : FsmStateAction
{
[RequiredField]
[CheckForComponent(typeof(RPGBaseInfo))]
[Tooltip("The GameObject with the RPGBaseInfo component")]
public FsmOwnerDefault gameObject;

public FsmInt index;

public FsmString name;

public bool everyFrame;

RPGBaseInfo _info;

public override void Reset()
{
index = 0;
name = null;
everyFrame = false;
}

public override void OnEnter()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null)
{
return;
}

_info = go.GetComponent<RPGBaseInfo> ();

DoGetRPGInfoItem();

if (!everyFrame)
Finish();
}

public override void OnUpdate()
{
DoGetRPGInfoItem();
}

void DoGetRPGInfoItem()
{

if (_info == null) {
return;
}

name.Value = _info.knicknames [index.Value];

}
}
}

 so, once you understand how to declare Fsm Variables and work with them within an action, the rest is regular c#

Bye,

 Jean
Title: Re: "Collections" Actions
Post by: Duffer on March 16, 2017, 03:21:51 AM
@Jean,

Excellent.  Thanks.
Title: Re: "Collections" Actions[SOLVED]
Post by: MauriceZaiss on May 16, 2022, 10:00:56 AM
List of strings too, in a monobehaviour class linked to a GO!