[Plugin] Hash table

0 favourites
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • rexrainbow Thanks, but I found an way to do what I needed using your plugin. I used the following:

    For "" from 1 to Hash.ItemCnt("")

         do something with Hash.At((loopindex - 1) & ".id")

         do other things with Hash.At((loopindex - 1) & ".name")

  • mchulet Check my previous post on this thread, I think you can use:

    For "" from 1 to Hash.ItemCnt("Question")

        do something with Hash.At("Question." & (loopindex - 1) & ".Sentence")

  • RedDragon

    Great! I forgot that.

    It is not design for list object, never mind, it could be used in this case, cool.

  • Update

    Now expression:ItemCnt will return list length directly.

    Here is a sample capx to iterate a list object.

    The content of this list is provided by RedDragon

  • That worked for me, Thanks RedDragon,rexrainbow.

  • Hello, I'm having trouble with arrays using the HashTable. I basically want to take an array from my JSON file which I load from an external URL, and place all the items in an array in construct2. My array from my JSON file looks like this:

    {

       "en": ["word1", "word2", "word3", "word4", ... "word103"]

    }

    From the trial and error i've done, when I set my debug text to HashWords.ItemCnt("en") it appears as 103, so it's noticing that there's 103 items in the JSON array. However, I don't know how to get those words, and put them into an array in construct, all on the X-axis.

    Thank you for any help.

  • Rogalog

    To put array into array object, see this and this.

  • rexrainbow

    Awesome, thanks dude. Turns out I was using CurKey, instead of CurValue which was my main problem.

  • Update

    Support save/load system (r124)

  • How can I append a hash table. I have two tables one that has the loaded ajax call and another that's the stored table. As I want to check the server every few mins for updates and push them into the stored table.

    I have tried to use the merge but that's not giving me the correct results as it overwrites current keys rather than appending them.

    Also tried to use set value and ussing itemkeycount to get last root key and set value from loaded hash table but I get \ in the json.

  • labithiotis

    Reference

    How about 2. "Merge new keys from hash table B" ?

  • I want the keys to extend, in that example only D was added becuase it was new.

    I have done it by hacking the json data like so:

    Ajax on "Complete" | DataLoaded | Load hash from JSON string Ajax.LastData
    
    var text appendData = ""
    
    System : dataLoaded.itemcnt("") > 0 
    
      System for "" from 0 to DataLoaded.ItemCnt("")-1 | Add DataLoaded.at (str(loopindex) to appendData
    
           System append =! "" && loopindex < dataLoaded.itemCnt("")-1 | Add "," to appendOrders
    
      System DataAll.itemCnt("") = 0 | System : set appendData to "[" & appendData & "]"
    
                                     | dataAll Load hash table from JSON string appendData
    
    

    I want to do this :

    Table A (Loaded) : [ 1:"A", 2:"B" ]

    Table B (All) : [ 1:"X", 2:"Y" ]

    Result after merging/appending A with B : [ 1:"A", 2:"B", 3:"X", 4:"Y"]

    with the current merge that result is : [ 1:"X", 2:"Y" ] has it has merge the indexes.

    Note- the root is blank from my server and I can't change that:

    [
     {
       "ID": 129,   
       "X": X
     },
     {
       "ID": 130,   
       "X": X
     },
     {
       "ID": 131,   
       "X": X
     }
    ]
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I've tweaked it further because of an issue with additional appends.

    <img src="https://dl.dropboxusercontent.com/u/2175584/Construct2Examples/Append.JPG" border="0" />

  • labithiotis

    Oh, I understand. Your requirement is so special. I'm afraid that hash table could not support this. You could do this at event sheet, or functionext plugin if you like javascript.

  • Hello rexrainbow,

    I have a question for you, I,m new with Construct2.

    Would it be possible to get JSON data from an outside weather source and parse it with Hash Table?

    If yes, do you think that functionality can be supported to a CocoonJS export to an iPhone app?

    Thank you!

    I'm trying to get an answer for that before investing time and money in my project!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)