playMaker

Author Topic: Arraymaker Scripting help  (Read 3612 times)

LauraNL

  • Playmaker Newbie
  • *
  • Posts: 2
Arraymaker Scripting help
« on: December 19, 2013, 10:24:07 AM »
Hey,

I've been using playmaker for a while now and recently started delving into arraymaker. The problem I'm having is that I want to be able to insert and remove from an array list via a c# script.

There is a catch though, I want to be able to input an integer which corresponds to an item within the array list (so I assume I'd need to do something like a compare but I've found that compare requires a string to be compared whereas I have an integer). Then with this newly found array item I'd like to be able to insert (above or below the specified array list item) and remove the specified item via buttons.

So far I've been able to add and remove array list items, but only if I define the integer of the variable assigned to the integer input.

I hope this explanation makes some kind of sense, all I really need to know is how to compare a user inputted integer against an existing arraymaker array list and then use the array list item found to either remove that item or insert another item. Did I mention I want to do this in script?  ;D

Any help or advice would be much appreciated, if needed I can show what I currently have but I'm holding back as I've never posted in this forum before :/


Andy22

  • Junior Playmaker
  • **
  • Posts: 99
Re: Arraymaker Scripting help
« Reply #1 on: December 19, 2013, 11:04:06 AM »
Its actually hard to understand what u want to-do?
Can u exemplify the logic by using c# List<> and/or Linq code?

This way its more clear what u want to-do and if it can be translated to arraymaker.

bye Andy

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Arraymaker Scripting help
« Reply #2 on: December 19, 2013, 01:23:01 PM »
As Andy has mentioned this is a little mystifying in that I'm not 100% certain what it is you're hoping to do... But, if what you're hoping to do is to have a system that will take objects from the array based on their slot (location in the array) then I am thinking that a hash-table might be a better use... At least for determining what integer value to use to determine what object you want.

How I'd do this would be to have the array that is the inventory... but having the hash-table being the "index."

It might be confusing but from what I have been able to tell, a hash-table is basically a listing of objects themselves with specific "indexes" whereas an array is more dynamic and isn't limited to just one kind of object.

This might also be do-able with an XML "chart" but I'm not yet skilled enough to say if this IS the way to go or not.

So, to start out, I'd probably have the hash-table set up with the listing of the objects... So, to help visualize it:

1: Bow
2: Sword
3: Bola
4: Health Potion

Each of these would be referencing the objects as a prefab by name so if you have them instantiated and they have that "(clone)" section added to it, you might benefit from finding a way to re-name it so as to remove the "(clone)" part of the name (everything I've found tells me that this "(clone)" is purely cosmetic and the engine doesn't need it there per-se... it's more for the user to know what's been instantiated and what's in the scene naturally... I could be wrong here so if anyone has better information on that aspect please toss in your two cents.)

So, when you click the button to "insert" an object, if it's a specific object (such as an interactive point that will "give" the player a "Sword") then you can then tell the system to check for the identifier of the sword, fetch the pertinent data from the hash table and use that data to insert into the array the object you want... in the case of "removing" an object, if it's a button that "take X from inventory" you can have it set with the int, it checks the value and then you use the value you've taken from the hash table to iterate through the array and find the object you want and then do what you need (in this case, removing it from the array and placing it in the scene somewhere.)

It might sound like it's making the process overly complicated but arrays are actually pretty quick (I've been putting together resources for some tutorials on ArrayMaker and I have found that it's fast enough on my computer that I don't notice any slowing down... and one of the systems I have has multiple arrays on each object and can have quite a lot of objects with those two arrays on them.)

Is this in any way helpful?

LauraNL

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Arraymaker Scripting help
« Reply #3 on: December 24, 2013, 03:49:28 AM »
Quote
So, when you click the button to "insert" an object, if it's a specific object (such as an interactive point that will "give" the player a "Sword") then you can then tell the system to check for the identifier of the sword, fetch the pertinent data from the hash table and use that data to insert into the array the object you want... in the case of "removing" an object, if it's a button that "take X from inventory" you can have it set with the int, it checks the value and then you use the value you've taken from the hash table to iterate through the array and find the object you want and then do what you need (in this case, removing it from the array and placing it in the scene somewhere.)

This sounds like exactly the functionality I need! The only problem I'm having is writing these functions in C#. I can't seem to find any reference/or help to comparing the user inputted integer to the hashtable (or array table) so that clicking either button adds or removes the user inputted integer from the list. hmph :/ Either I'm missing something really obvious (which is more than likely!) or I'm looking in the wrong place.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Arraymaker Scripting help
« Reply #4 on: December 26, 2013, 06:25:06 AM »
Hi,

 ArrayMaker has this example:

look into the sample for the scene: PlayMaker ArrayMaker/Samples/Inventory/

This will be a good base for you to work on.

bye,

 Jean