playMaker

Author Topic: How to set arraymaker-hash value in script?[SOLVED]  (Read 4170 times)

weilies

  • Junior Playmaker
  • **
  • Posts: 74
How to set arraymaker-hash value in script?[SOLVED]
« on: July 22, 2015, 07:48:44 PM »
I have a character gameobject, it's assigned with a PM hash table,
Reference: ref
Key: HP
Value: 100

How could I change the value via Cscript?

Thanks for the help
« Last Edit: July 24, 2015, 08:03:13 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to set arraymaker-hash value in script?
« Reply #1 on: July 23, 2015, 12:45:15 AM »
Hi,

The ArrayMaker Hashtable proxy is a regular component and it exposes the hashtable as a public variables.

If you open HashTableAdd.cs you'll see how it's accessed:

proxy in the code below is a pointer to the PlayMakerHashtableProxy component.
Code: [Select]
proxy.hashTable.Add(...)

Bye,

 Jean

weilies

  • Junior Playmaker
  • **
  • Posts: 74
Re: How to set arraymaker-hash value in script?
« Reply #2 on: July 23, 2015, 01:28:37 AM »
sorry Jean,

I am hardcore programmer, you mean this?

GetComponent<PlaymakerHashTableProxy>.hashTable.get(MYKEY) = NEW_VALUE

is it?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to set arraymaker-hash value in script?
« Reply #3 on: July 23, 2015, 04:19:57 AM »
yep :)

weilies

  • Junior Playmaker
  • **
  • Posts: 74
Re: How to set arraymaker-hash value in script?
« Reply #4 on: July 23, 2015, 05:51:26 PM »
yep :)


Error out

Assets/Resource/scripts/DragDropSelectChar.cs(38,84): error CS1061: Type `PlayMakerHashTableProxy' does not contain a definition for `get' and no extension method `get' of type `PlayMakerHashTableProxy' could be found (are you missing a using directive or an assembly reference?) :(


i think there is no 'get' function
Debug.Log (GetComponent<PlayMakerHashTableProxy>().get("hp"));

any API link i can refer? i am not quite understand the existing script files (too complex)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to set arraymaker-hash value in script?
« Reply #5 on: July 24, 2015, 02:06:56 AM »
Hi,

 I see, I did not pay attention to how you worked with the hashtable, The right line would be:

Code: [Select]
GetComponent<PlaymakerHashTableProxy>.hashTable[MYKEY] = NEW_VALUE

Study the link below to understand how to work with hashtables.

http://www.dotnetperls.com/hashtable

Bye,

 Jean

weilies

  • Junior Playmaker
  • **
  • Posts: 74
Re: How to set arraymaker-hash value in script?
« Reply #6 on: July 24, 2015, 06:52:19 AM »
i have my code below

Debug.Log (GetComponent<PlayMakerHashTableProxy>().hashTable[hp]);

and it return error
Assets/Resource/scripts/DragDropSelectChar.cs(39,94): error CS0103: The name `hp' does not exist in the current context

i also attach my hashtable as screenshot

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to set arraymaker-hash value in script?
« Reply #7 on: July 24, 2015, 07:23:18 AM »
Hi,

 hp MUST be a string variable, like so:

Code: [Select]
string my_key = "hp";
Debug.Log (GetComponent<PlayMakerHashTableProxy>().hashTable[my_key]);


else if you want to directly get the key "hp", then put that as a litteral string like so:

Code: [Select]
Debug.Log (GetComponent<PlayMakerHashTableProxy>().hashTable["hp"]);
Bye,

 Jean

weilies

  • Junior Playmaker
  • **
  • Posts: 74
Re: How to set arraymaker-hash value in script?
« Reply #8 on: July 24, 2015, 07:41:22 AM »
Very thankful, Jean!