Import global variables from external source

Get help using Construct 2

Post » Wed Jul 03, 2013 5:30 pm

Is there anyway for me to import a large group of global or local variables into Construct as a CSV or something? I have an array of 100+ variables and I'd like to use identifiers for my code but still be able to move stuff around easily.

Example:

Global variables I want to set below so I can call ItemArray.at(PlayerDamage), PlayerArray.at(PlayerDamage), SpellArray.at(PlayerDamage), etc. If I later want to insert PlayerDefense at 2 and shift everything down.. doing it manually would be quite the pain if they are global variables in Construct vs. very easy in traditional code + copy paste from Excel.

PlayerDmg 0
PlayerLife 1
SlayerEnemyTypeA 2
SlayerEnemyTypeB 3
SlayerEnemyTypeC 4
SlayerEnemyTypeD 5
SlayerEnemyTypeE 6
ResistMagicA 7
ResistMagicB 8
ResistMagicC 9
ResistMagicD 10
ResistMagicE 11

etc.
B
9
S
2
Posts: 58
Reputation: 1,416

Post » Wed Jul 03, 2013 6:23 pm

It would be better to use a global array or dictionary for this.
Scirra Founder
B
378
S
220
G
84
Posts: 23,871
Reputation: 188,157

Post » Wed Jul 03, 2013 6:33 pm

Global array doesn't seem to help since it's the problem I'm trying to fix. Not familiar with importing from a CSV/JSON to Dictionary, however I found another one of RexRainbow's awesome plugins will fix this here:
http://www.scirra.com/forum/plugin-hash-table_topic47637_page1.html

JSON formatted import to hash table and then I can call the value at any time!
B
9
S
2
Posts: 58
Reputation: 1,416

Post » Wed Jul 03, 2013 6:47 pm

[QUOTE=Agni]
JSON formatted import to hash table and then I can call the value at any time! [/QUOTE]

That is pretty much what dictionary does.. :)

B
24
S
8
G
7
Posts: 756
Reputation: 7,242


Return to How do I....?

Who is online

Users browsing this forum: Kyatric, oosyrag and 2 guests