Possible method of arrays?
BeyondtheTech
Member Posts: 809
As I sat on my throne today (yes, that one), I had a revelation... what if you could dynamically change the keyword for the Save/Load Attribute Action?
For instance, if you set up a keyword called "Enemy" and had a range of, say, 1-50 and used `"Enemy" .. game.ArrayIndex`, could you use that in the Action to Save an Attribute into a bunch of unique keywords? That way, you can store and access a bunch of values and load it into a particular Attribute.
I am not in front of my setup to try it, but if anyone could test the theory before I get home, I would appreciate it!
For instance, if you set up a keyword called "Enemy" and had a range of, say, 1-50 and used `"Enemy" .. game.ArrayIndex`, could you use that in the Action to Save an Attribute into a bunch of unique keywords? That way, you can store and access a bunch of values and load it into a particular Attribute.
I am not in front of my setup to try it, but if anyone could test the theory before I get home, I would appreciate it!
Comments
Oh I am so sorry... did I went to far... lol It sounded funny in my head...
Please delete my comment if it is to much...
enemyIndex =
enemyHealth(integer) =
enemyStrength(integer) =
and on a blank enemy actor
Rule Attribute game.enemyIndex = #
........[Change Image]
........[Change Attributes] (for enemyHealth; enemyStrength; etc.)
looks like lots of work...but if you have a [Note] on the actor with all the changes/index#...
and name the Rules for each index #
and option+drag down...it easy to type in the changes for 10 or so.
I think of an Index as a 1-column array! (is that an oxymoron?!)
I like to use them for image display...
MH
PS @BTT what you wrote made perfect sense to me! I seriously thought you were on to something there...and, interesting that you take care of your business at work...
I had the same revelation laying on the floor today. You are correct, Save Attribute and Load Attribute can be used as a make shift array. I have it working in a game that I'm making.
Steps to make it work:
1. Create an actor
2. Add attributes Array (as text), Index (as integer), and Data (as text, or whatever you need)
Array is the name of the array. Then to add items to array:
3. Change Attribute self.Data to: <<your 1st data>>
4. Change Attribute self.Index to: 1
5. Save Attribute self.Data key: self.Array..self.Index
6. Change Attribute self.Data to: <<your 2nd data>>
7. Change Attribute self.Index to: 2
8. Save Attribute self.Data key: self.Array..self.Index
9. etc.
Reading values is the same in reverse.
10. Load Attribute Key: self.Array..self.Index Attribute: self.Data
The .. is the concatenate operator. So if self.Data was "weapons" and self.Index 1, the key would become weapons1.
You can use timer loops as shown elsewhere to step through array if necessary.
I imagine there may be performance issues in some use cases.
Oh, and my 2 cents: everyone is asking for arrays, but what we really should want are collections.
Please feel free to comment.
Karo