playMaker

Author Topic: Arrays or Lists  (Read 5705 times)

MitchStan

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
Arrays or Lists
« on: April 22, 2011, 06:02:38 PM »
Any timetable as to when Arrays or Lists will be part of Playmaker variables?  Really need this ASAP!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14035
  • Official Playmaker Support
    • View Profile
Re: Arrays or Lists
« Reply #1 on: April 24, 2011, 10:52:49 PM »
Hi,

 You can already do that.

 Check these actions:
https://hutonggames.fogbugz.com/default.asp?W442
https://hutonggames.fogbugz.com/default.asp?W442

Check the test lab for "RandomTeleport" for an example.

If you need a specific usage, mention it and let's see what's possible.

 Bye,

 Jean

Murcho

  • 1.2 Beta
  • Junior Playmaker
  • *
  • Posts: 54
    • View Profile
Re: Arrays or Lists
« Reply #2 on: April 26, 2011, 01:36:23 AM »
I think Mitch is talking about having variables available as arrays.  And if so I second that.

At the moment if you're trying to deal with a set of data across multiple actions you need to hard code the values to individual variables which is very annoying and not very flexible.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14035
  • Official Playmaker Support
    • View Profile
Re: Arrays or Lists
« Reply #3 on: April 27, 2011, 06:24:23 AM »
Hi,

Just a proof of concept to define and use an array within fsm. This is definitly not ideal and it would of course a lot better to have it built in the variable section. Basically just for the fun of it.

 I have built a special action that let you define an vector3 array. This action treat this array given some accessor, index and inject value. I could not come up with something nicer sorry... But now you simply build Events around that and make it into its own fsm and you have a way to define, get and set variable from an array, all of it only with fsm.

Here is a screencast showing a demo fsm using this action. Again not something for a real world project as is, you would likely fire the get and set events from outside this fsm and inject events infos some other more flexible way obviously. and you would need a more versatile action to allow for adding, removing, counting, stepping and iterating.

http://www.screencast.com/t/chttWZ1B

Here is the action for reference:

Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Vector3)]
[Tooltip("Proof of concept for an array accessor")]
public class Vector3Array: FsmStateAction {


public Vector3[] test;


[UIHint(UIHint.Variable)]
public FsmString accessor; // "GET" or "SET"

[UIHint(UIHint.Variable)]
public FsmInt index;


[UIHint(UIHint.Variable)]
public FsmVector3 storeResult;

[UIHint(UIHint.Variable)]
public FsmVector3 injectValue;


public override void Reset()
{
accessor = null;
test = null;
index = 0;
storeResult = null;
}

public override void OnEnter()
{

if (accessor.Value == "GET"){
storeResult.Value = test[Mathf.Max(0,Mathf.Min(test.Length,index.Value))];
}else if (accessor.Value == "SET"){
test[Mathf.Max(0,Mathf.Min(test.Length,index.Value))] = injectValue.Value;
}
}

}
}

MitchStan

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
Re: Arrays or Lists
« Reply #4 on: May 21, 2011, 08:56:58 AM »
I think Mitch is talking about having variables available as arrays.  And if so I second that.

At the moment if you're trying to deal with a set of data across multiple actions you need to hard code the values to individual variables which is very annoying and not very flexible.

Yes, thank you for clarifying that.  The existing actions are for setting up an array and setting weights for random selection.  I am asking for support for a List or array as a variable type to be used in other actions.

Duffdaddy

  • Junior Playmaker
  • **
  • Posts: 54
    • View Profile
Re: Arrays or Lists
« Reply #5 on: May 21, 2011, 03:00:39 PM »
I'll second that request!

Kardend

  • 1.2 Beta
  • Playmaker Newbie
  • *
  • Posts: 8
    • View Profile
Re: Arrays or Lists
« Reply #6 on: June 22, 2011, 10:28:22 AM »
Yeah I'd like to have arrays or lists too. I am trying to read a text file and load it into an string[] to keep it in memory and do some processing over it depending on what's happening in the game..
Had to do it with my own custom action but it is so customized that I cannot use it anywhere else.

qholmes

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 509
    • View Profile
Re: Arrays or Lists
« Reply #7 on: August 08, 2011, 08:30:13 AM »
i would love to have the ability to create list of objects and then be able to use that list to apply actions too... so if i want to say scale a set of objects then i would set up a group of them and then use that group or list name in the scale action..

If i get organized i will attempt to write this myself but it means creating a whole new type in the pM main structure i expect so that it will automatically cycle through them properly.

Q

qholmes

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 509
    • View Profile
Re: Arrays or Lists
« Reply #8 on: August 16, 2011, 09:20:39 AM »
I think i am going to try Jeans idea... I am just heading into a section of my project that is going to get quite repetitious because i need to use lists.. So i think i will attempt to do exactly what Jean did.

I will have several different sets built the way that is already possible and when called with a global event they will cycle through their lists one at a time performing actions on them... i think this is going to work quite well for me..... i just realized that because of how i just modified my code i only need one action that is multi object to make it work.... so i will not spend my time on this right now i guess....

Q

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14035
  • Official Playmaker Support
    • View Profile
Re: Arrays or Lists
« Reply #9 on: August 16, 2011, 10:14:06 PM »
Hi,

 If you need help or needs some clarifications, don't hesitate,

 Bye,

 Jean

qholmes

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 509
    • View Profile
Re: Arrays or Lists
« Reply #10 on: August 16, 2011, 10:22:56 PM »
Thanks Jean...  I may come back to this eventually but one custom Action and i was able to solve my problems and kill about 6 control objects etc... just thinking a new way gives clarity some times.

Q

Red

  • Hero Member
  • *****
  • Posts: 563
    • View Profile
Re: Arrays or Lists
« Reply #11 on: October 22, 2011, 05:21:26 PM »
I know i'm necroposting, but a list/array action set would be really awesome and i'd love to toss in my "yes please!" to the pile!

though, i would wager that one action to rule them all in this respect might be a programming nightmare, maybe two (or three) one to create the array/list... one to modify the array/list and one to access the array/list?

and having a hard-coded variable in the number of entries seems limiting, maybe be able to make it such that you can drop in an int variable to determine the number of entries it would have (though i would imagine that if you did a "get" run through with too many, it'd bog down the system every time you accessed it)

for instance, say you had a list so that you could tally up the number of "Player" tagged items in the scene, go through the list and give an index entry for each. maybe also add in a column type thing where you can give them a value (such as experience, points, health, etc) i am not 100% on the game-lingo as to what that's called but i think the math name is matricies... maybe the game lingo is database? dunno... i am the eternal newb ;)

i.e.

Index...Object type....Health....Name......Status
1.          Player           50%     Roger         OK
2.          Player           89%     Johnny    poisoned
3.          Player          100%    Sue        paralyzed
4.          Player           20%     Tommy       OK
5.          Placeholder   100%   -Empty-      OK
same for enemies

Index. Object type... health... aggro.....aggroTargetIndex.....status
1.       Enemy            30%       70%            1                   Pursuing
2.       Enemy            100%      0%             5                     Idle
3.       Enemy             70%      100%          2                     Attacking

that kind of thing...? i can imagine a couple different ways to manage that sort of information using FSMs on empty game objects using global actions (now that i know how to use them ;) ) to tell each object what to do and how to behave in response to the players on the game-field.
« Last Edit: October 22, 2011, 05:27:02 PM by Red »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14035
  • Official Playmaker Support
    • View Profile
Re: Arrays or Lists
« Reply #12 on: October 23, 2011, 02:30:13 AM »
I am about to release a full set of actions and tools to do just that :) i planned originnaly to release it in the asset store, but i have to be realist, i lack of time to properly deal with this so i think it will go out as is ontne forum and playmaker wiki sometimes next week

Also in your example, i would seriously consider a database system or a proper class representation of your player, and unity has this near perfect with components. Tho with playmaker, i agree it requires a little more thinking to get a proper convenient way to manage such set if data, and what i have been working on could be an easy way out of this if you really want to miaintain data in arrays.

Bye,

Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14035
  • Official Playmaker Support
    • View Profile
Re: Arrays or Lists
« Reply #13 on: October 28, 2011, 12:42:06 AM »
Hi,

 ArrayMaker is now out. you can check it out from here:

http://hutonggames.com/playmakerforum/index.php?topic=835.0

Bye,

 Jean