User Tag List

Results 1 to 6 of 6

Thread: Associative Array

  1. #1
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,717
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)

    Associative Array

    Associative Array

    With the Associative array you can save and load character positions, directions, current stats, or just about any value you need. It can, when made global, also share these values over frames and sub-applications, which is really handy for inventories, maps and other things. The beauty of this array is the use of plain english "Keywords", which can be followed by a number or string such as:

    NivramsOxygen=480
    or
    NivramsLevel=duffus

    You can also retrieve data of counters, alterable values, global values, characters, enemies, Associative Array, or just about anything.

    This makes it simple, along with good comments, to keep track of what is happening within your game or application. Use the Modify/Add a Value or Modify/Add a String to set the value at a Key.

    Nivram overlaps Garlic
    +Only one action when event loops
    Associative Array: Set Value at Key "GARLIC" to 1
    Garlic: Destroy

    To retrieve the data (Key) from the Associative Array, Compare Two General Values:

    "GARLIC"=1
    +Only one action when event loops<BR>
    Garlic:destroy

    When you save your game using the Associative Array, the Key is saved. When you load the game, the Key GARLIC will be equal to 1. The garlic will be destroyed and Nivram will still have the garlic. If you desire, when the Key GARLIC=1 you can place a garlic icon in an inventory slot somewhere.

    So, how do we save our game?
    Let's say we have a Save Button and want to save the array in the game directory:
    Player clicks on Save Button
    Associative Array: Save Associative Array file apppath$+"nivram.dat" (you can use any name and file ext you want like: duffus.sav)

    So, how do we load our game?
    Let's say we have a Load Button and want to load the array from our game directory:
    Player clicks on Load Button
    Associative Array: Load Associative Array file apppath$+"nivram.dat"

    I also want to let you know that for some value loadings, such as position of the character, you must put in a second event for clicking on the Load Button. The loading of the array needs to be first, before calling up values. If the values, such as character postion, is called before loading the actual array, the character position will not be loaded.

    The Associative Array can find an instance of a word or string. So you can load in a vocabulary and see if the word exists without looping. Instead of having numerous List Objects for Shops in an RPG, you could use just one Associative Array. With it you can list the item and price and call it up for any Shop your player enters. Very good if your player changes levels. You load up the Associative Array, then all you have to do is take a couple of items and their prices, and put them into the Shop.

    A couple of notes for you:
    You can disable the pop up for this extension by unchecking "Remind me later"
    My thanks goes out to Click Team, the developer of this extension, and forum members for their help and understanding.
    ​458 TGF to CTF 2.5+ Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  2. #2
    No Products Registered

    Join Date
    Jan 2009
    Location
    Usa
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Associative Array

    lol a good tut. for those who dont know how to use the extension

    too bad i cant get it though.....


    btw can someone get me an idea on when MMF3 is coming out for beta?

  3. #3
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,717
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)

    Re: Associative Array

    Thanks for the comment. I have seen no date for MMF3.
    ​458 TGF to CTF 2.5+ Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleSWF Export Module
    FGRaptor's Avatar
    Join Date
    Aug 2011
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Associative Array

    I already know how to use it pretty much, but I wanted to say that it is a useful tutorial.

    Also, could you talk a bit more about this part?

    Quote Originally Posted by nivram
    The Associative Array can find an instance of a word or string. So you can load in a vocabulary and see if the word exists without looping. Instead of having numerous List Objects for Shops in an RPG, you could use just one Associative Array. With it you can list the item and price and call it up for any Shop your player enters. Very good if your player changes levels. You load up the Associative Array, then all you have to do is take a couple of items and their prices, and put them into the Shop.
    I don't really understand your connection between lists and looking for a string. For that matter, how does it help me to look if a word exists? Do you mean for the values or for the keys?

  5. #5
    Clicker Fusion 2.5Android Export ModuleSWF Export Module
    EE's Avatar
    Join Date
    Sep 2009
    Posts
    194
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Nice article!
    The "Garlic=1 destroy garlic" was a real pearl! For anyone dabbling in metroidvanias this can be an awesome asset in controlling pick-ups and secret entrances!

  6. #6
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,717
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Thanks EE Things are changing so quickly I should probably check to make sure everything still works

    I love the extension.

    Marv
    ​458 TGF to CTF 2.5+ Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

Similar Threads

  1. Save associative array in another directory
    By EE in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 7th November 2012, 06:19 PM
  2. associative Array
    By ffomega in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 31st October 2010, 10:12 AM
  3. associative array
    By iammfa in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 5th April 2009, 03:00 PM
  4. Associative Array
    By scottige in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 11th June 2007, 08:50 PM
  5. Associative Array 1.21
    By Jeff in forum Released Extensions
    Replies: 0
    Last Post: 22nd September 2006, 12:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •