playMaker

Author Topic: ArrayMaker is now available [April 2021]  (Read 176908 times)

Red

  • Hero Member
  • *****
  • Posts: 563
Re: ArrayMaker is now available
« Reply #15 on: December 23, 2011, 09:44:15 AM »
Thank ye kindly! i didn't know to check the menu (i was scouring the action browser though. ;) )

works now! now to figure out how to make it do what i hope to make it do :P

Mark_T

  • 1.2 Beta
  • Junior Playmaker
  • *
  • Posts: 72
Re: ArrayMaker is now available
« Reply #16 on: January 11, 2012, 11:55:06 AM »

Many thanks for this cool addition!
One small request though for no scripting guys like me: when you have time (:) ) some tutorials will help a lot. I tried to use the examples you provide, and I managed to do my thing, but I`m sure can do more and this addon can be very very helpful (I have a few ideas where I can use it).
Anyway, again, many thanks. I`m sure it was a bit of work there. :)

Take care,


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: ArrayMaker is now available
« Reply #17 on: January 12, 2012, 02:35:55 AM »
I know I know...

 I tried over the christmas holiday to make screencasts, but I get self aware when talking over the screencast, and talk rubbish :) it's just stupid... I need to do something about this! At the moment I am running around between the "not so" new born baby yet not giving us any sleep really, the work, the house, etc etc! so when I have time I am just not relaxed enough to do a good job at talking over screencasts...

 I'll give it a go tonight one more time! I just need to get the ball rolling with this. Doing help and tutorial is SO important, yet always such a difficult thing to manage and incorporate properly.

 bye,

 Jean


Zyxil

  • Playmaker Newbie
  • *
  • Posts: 10
Re: ArrayMaker is now available
« Reply #18 on: April 14, 2012, 11:53:13 PM »
ArrayMaker is excellent!  Thank you for releasing it to everybody.

I have an issue with an ArrayList of Materials.  I am using the Free Substances from the Asset Store and they are supposed to work exactly like a Material in Unity, they're just generated inside the editor.  The ArrayList allows adding them in the editor, but they disappear when running.

If my array is 10 elements and elements 5 and 6 are substances, then the proxy will show elements 0 through 4 and 7 through 9.  And when referenced by the Array List Get action, the action does not fail, but also does not retrieve the Substance from the array.  It works on a normal Material, even oddball ones like the Gem Shaders.

Any idea on what's going on here?

Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: ArrayMaker is now available
« Reply #19 on: April 15, 2012, 07:43:57 AM »
Hi,

 I haven never tried with the substance materials, so will give it a try and see what coud go wrong within arraymaker.

Can you confirm that if you do the same with standard materials then it works ok? if too difficult to test don't bother ( it's just that I won't be able to look at it properly until tomorrow).

 Bye,

 Jean

Zyxil

  • Playmaker Newbie
  • *
  • Posts: 10
Re: ArrayMaker is now available
« Reply #20 on: April 15, 2012, 03:47:39 PM »
It works for the Materials that Unity can make, whether from model import, made manually within the editor or imported from asset packages like the Gem Shader package.

Thanks for looking at this, Jean!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: ArrayMaker is now available
« Reply #21 on: April 16, 2012, 06:56:12 AM »
Hi,

 ok, Unity has introduce a new type of material "proceduralMaterial" for substance, so it simply has to be taken into account, you can reference a proceduralMaterial using a material, but to retrieve it, you need to qualify it properly.

I can't upload anything currently to the forum, so I have sent an email to you. Will post here when I'll be able to add attachment.

Bye,

 Jean

Zyxil

  • Playmaker Newbie
  • *
  • Posts: 10
Re: ArrayMaker is now available
« Reply #22 on: April 17, 2012, 09:24:17 PM »
Jean, I checked the ArrayListGet action and it works!

Thank you for the great support!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: ArrayMaker is now available
« Reply #23 on: April 18, 2012, 02:24:45 AM »
Hi,

 You are welcome, this is the least I can do!

The upload folder has been upgraded so here are the files in questions:

put ArrayListGet.cs in

playmaker/actions/addons/ArrayMaker/ArrayList

and HashTableGet.cs in

playmaker/actions/addons/ArrayMaker/HashTable

And then it will work for substances materials.

Bye,

 Jean

Amy

  • Playmaker Newbie
  • *
  • Posts: 36
Re: ArrayMaker is now available
« Reply #24 on: May 04, 2012, 10:10:48 PM »
People talk about arrays so much but I'm still finding them hard to understand. This is how data bases are made correct? Would this help me make an RPG? ^^

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: ArrayMaker is now available
« Reply #25 on: May 06, 2012, 02:07:30 AM »
hi,

 Array and database are two different things but they work together.

-- Arrays allow you to store a number of variables ( any ), and conveniently access them via one variable, so that you can iterate through them, organize them, sort them. Database holds a lot more power, and creates relationships between data, and allows very powerful queries with complex requirements.

 If you query a database, you will likely get the results in an array, that's how it works most of the time.

In playmaker, Array and database is not supported currently, that's why I create ArrayMaker, to support working with arrays within playmaker, and for database, monosqlite ( available on the asset store) has a solution that works with playmaker.

 Now, for an RPG, array and database will definitely help you, but first you need to really understand and grasp the concept behing database and arrays in order to use them in any kind of projects, not just RPG.

Bye,

 Jean

Jos Yule

  • Playmaker Newbie
  • *
  • Posts: 33
Randomize (shuffle) ArrayList function
« Reply #26 on: May 14, 2012, 01:07:10 PM »
Hello!

I'd love to have a "randomize" action available for the ArrayList.

My use-case is using an ArrayList as a holder for a "deck" of cards. I'd love a simple way to "shuffle" or randomize that deck.

What do you think?

Thanks
jos

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: ArrayMaker is now available
« Reply #27 on: May 14, 2012, 04:02:38 PM »
Hi,

 good idea, When I needed that I was going for a manual way, but the opposite action to "sort" seems fair enough :)

 I will work on that and post back on that thread

Bye,

 Jean

Jos Yule

  • Playmaker Newbie
  • *
  • Posts: 33
Re: ArrayMaker is now available
« Reply #28 on: May 16, 2012, 10:00:11 AM »
Great, thanks!

Jos

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: ArrayMaker is now available
« Reply #29 on: May 17, 2012, 01:28:51 AM »
Hi,

 there you go, a nice shuffling algo. I took a simple random algorithm ( the Knuth-Fisher-Yates  one), so I think it will give you satisfaction:

http://www.4guysfromrolla.com/articles/070208-1.aspx

[EDIT] now shuffling can be assigned a range to shuffle only part of the array.

I have attached the action to this post.

Code: [Select]
// (c) Jean Fabre, 2012 All rights reserved.
// http://www.fabrejean.net
//  contact: http://www.fabrejean.net/contact.htm
//
// Version Alpha 0.7

// INSTRUCTIONS
// Drop a PlayMakerArrayList script onto a GameObject, and define a unique name for reference if several PlayMakerArrayList coexists on that GameObject.
// In this Action interface, link that GameObject in "arrayListObject" and input the reference name if defined.
// Note: You can directly reference that GameObject or store it in an Fsm variable or global Fsm variable


// the shuffle routine is a Knuth-Fisher-Yates algorithm explained at : http://www.4guysfromrolla.com/articles/070208-1.aspx

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("ArrayMaker/ArrayList")]
[Tooltip("Shuffle elements from an ArrayList Proxy component")]
public class ArrayListShuffle : ArrayListActions
{
[ActionSection("Set up")]

[RequiredField]
[Tooltip("The gameObject with the PlayMaker ArrayList Proxy component to shuffle")]
[CheckForComponent(typeof(PlayMakerArrayListProxy))]
public FsmOwnerDefault gameObject;

[Tooltip("Author defined Reference of the PlayMaker ArrayList Proxy component to copy from ( necessary if several component coexists on the same GameObject")]
public FsmString reference;

[Tooltip("Optional start Index for the shuffling. Leave it to 0 for no effect")]
public FsmInt startIndex;

[Tooltip("Optional range for the shuffling, starting at the start index if greater than 0. Leave it to 0 for no effect, that is will shuffle the whole array")]
public FsmInt shufflingRange;


public override void Reset()
{
gameObject = null;
reference = null;

startIndex = 0;
shufflingRange = 0;

}


public override void OnEnter()
{

if ( SetUpArrayListProxyPointer(Fsm.GetOwnerDefaultTarget(gameObject),reference.Value) )
{
DoArrayListShuffle(proxy.arrayList);
}

Finish();
}


public void DoArrayListShuffle(ArrayList source)
{
if (! isProxyValid())
{
return;
}

int start = 0;
int end = proxy.arrayList.Count-1;

if (startIndex.Value>0)
{
start = Mathf.Min(startIndex.Value,end);
}

if (shufflingRange.Value>0)
{
end = Mathf.Min(proxy.arrayList.Count-1,start + shufflingRange.Value);

}
Debug.Log(start);
Debug.Log(end);
// Knuth-Fisher-Yates algo

// for (int i = proxy.arrayList.Count - 1; i > 0; i--)
for (int i = end; i > start; i--)
{
   // Set swapWithPos a random position such that 0 <= swapWithPos <= i
   int swapWithPos = Random.Range(start,i + 1);

   // Swap the value at the "current" position (i) with value at swapWithPos
   System.Object tmp = proxy.arrayList[i];
   proxy.arrayList[i] = proxy.arrayList[swapWithPos];
   proxy.arrayList[swapWithPos] = tmp;
}
//

}
}
}


Bye,

 Jean
« Last Edit: July 09, 2012, 04:46:28 AM by jeanfabre »