Possible method of arrays?

BeyondtheTechBeyondtheTech Member Posts: 809
edited November -1 in Tech Support
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!

Comments

  • ORBZORBZ Member Posts: 1,304
    you can't
  • LordTarantorLordTarantor Member, PRO Posts: 890
    Only one thing can come out when you are in the throne...
    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...
  • BeyondtheTechBeyondtheTech Member Posts: 809
    I believe the correct phrase, now that I'm in front of my Mac and determined it isn't currently possible, is being able to use an Expression for a Keyword. That would have basically enabled rudimentary arrays or indexed values. Oh well, one can dream.
  • MotherHooseMotherHoose Member Posts: 2,456
    think you could do a parallel array...where a game attribute is an index type.
    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... ;)
  • JGary321JGary321 Member Posts: 1,246
    I take care of all my business at work. Saves money, ya know? Stick it to the man!!
  • karokaro Member Posts: 1
    BeyondtheTech,

    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
Sign In or Register to comment.