[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
  • Hash table plugin, plugin and sampe capx files are included.

    Hash table behavior, behavior.

  • Wow thanks for this!! I Tried to call the twitter API, Nothing happened though :( I'll try play around with it some more later :D Thank again!!

  • smitchell

    Can you show an example JSON string and indicate what key you need?

  • Update:

    Add property for initialize hash table data (in JSON string)

  • rexrainbow

    can you explain the difference between Hash.At and Hash.Entry expressions? Also, are all key/value pairs stored as strings?

    thanks,

    -- cacotigon

  • Key is a string, value can be number or string.

    The parameter of "expression:Hash.At" is a fully key string. ex "a.b.c0".

    "expression:Hash.Entry" need to used with "action:Set current entry". For example, value in key string "a.b.c0" can spite to "a.b" and "c0".

    • Using "action:Set current entry" to set current entry to "a.b"
    • Using "expression:Hash.Entry" by "c0"

    "expression:Hash.Entry" might make user confused, how about deprecating it?

  • Hi Rex, some questions about hashtables

    is there a way to loop thru a hashtable or should i combine it somehow with an array

    and is a hashtable a good way to do something like a shop with tabs :

    example:

    armortab:

    heavy armor = properties: defence:4 attack:0

    medium armor = properties: defence:2 attack:0

    ...

    weaponstab:

    sword = prop: def:1 atk:6

    dagger= prop: def:0 atk:2

    ...

    how would i write something like this?

    {"armor"{"heavy_armor"{"def":4}, "medium_armor"{"def":2,"atk":2} }, "weapons "{"sword"{"def":1,"atk":6} "dagger"{"def":0,"atk":2}           }}

    ?

    thanx for any advice you can give..

  • vtrix

    If you want to set some initial definition, try CSV plugin. You can create readable table in excel (or something else)

    I'll try to implement "loop thru a hashtable". BTW, CSV has a loop retrieve condition.

  • Update:

    Add version to 0.5

  • Update:

    Add condition: for each. expression: CurKey, CurValue

    For example, hash table =

    { 
     "a":{ 
           "b":1, 
           "c":2 
         },  
     "d":3 
    }

    for each "a" will get

    key = "b" , value = 1

    key = "c" , value = 2

    for each "" ("" is root) will get

    key = "d" , value = 3

    ( There are two keys "a" and "d" in root, but value at key "a" is not a number or string, only get key "d")

  • Update:

    Add "action: remove value" to remove item in this hash table

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Nice plugin, thanks for sharing :)

    Question: for keys with object values, is it possible to get the key on each item? This is crucial for me because I have a list of items with keys for item id, something like:

    { 
      "SWORD-000" : { "name": "rusty sword", "stat": { "DMG": 100 } }, 
      "SWORD-001" : { "name": "dull blade", "stat": { "DMG": 200 } }, 
      "SWORD-002" : { "name": "iron blade", "stat": { "DMG": 300 } } 
    } 
    

    thanks

  • I made a small modification on my own, the current purpose is to just show that the value is an object, so I can add a sub-event to detect and handle it properly

                this.exp_CurKey = key; 
                this.exp_CurValue = value; 
     
                if ((typeof value != "number") && (typeof value != "string")) 
      this.exp_CurValue = "[!OBJECT]"; 
    
  • Soybean

    This plugin support "for each key", see this post

    scirra.com/forum/plugin-hash-table_topic47637_post322689.html

    And thanks, I will add a condition to check if the key is existed.

  • Yeah, the problem is, in my data, root keys all have object values, so this will look like an error (nothing to show)

    I'd also like to have a conditional to check if curKey has object value.. this would be helpful, so I can store the ids on an array and fetch the data directly from HashTable.

    thanks!

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