[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
  • Update:

    • Add "condition: key exists" to check a key is existed or not.
    • Add second parameter at "expression: At", the second parameter is a default value returned when key is not existed. For example
    Hash.At("a.c", 20)

    if Hash[a][c] does not exist return 20 , else return Hash[a][c]

    It might have a better way to do that, I will think it again.

  • Thanks! Both updates would be very useful :)

    About my initial idea, instead of checking the value type (esp if it's an object), how about an action to list keys per 'layer' to an Array?

    Let's say for data

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

    The action works something like:

    If 'listKeys("", Array.X)' will insert "a" and "d" to Array, and if 'listKeys("a", Array2.X)' will insert "b" and "c" to Array2?

    Thanks again :)

  • Good idea, I will implement it in this weekend.

  • Update:

    Add "action:pick keys", to pick keys into an array object. See sample capx.

    This action will set array size to (0,1,1), then push keys into array. Using "array condition: for each element X" to pick them.

    Here it is.

  • awesome! thanks!

  • Hi rexrainbow,

    Want to ask another thing, is it possible to 'for each item' of an array value?

    For data something like:

        { "type": "weapon", "id": "SWORD-0000", "amount": 1 },
        { "type": "material", "id": "ORE-0000", "amount": 10 },
        { "type": "potion", "id": "HEAL-0000", "amount": 20 }

    I found that using "At" works if I include the index of array on the key:


    shows the correct entry ('material').

    I also notice that for each item works if I include the index of array:

    For each item in "equip.2"

    Puts out the correct key and value.

    But if I try:

    For each item in "equip"

    Nothing shows.


  • Oh.. nevermind.. I found that PickKeys "equip" works, and inserts the indexes to an Array... AWESOME!

  • Yes, this feature comes from your previous requirement.

  • Would it be useful if hash table have a tree traversal for "for each item"?

  • Hi rexrainbow,

    Do you mean something like JSONPath (http://goessner.net/articles/jsonPath/)? That would be great.. :D

  • Uh, I could not implement XPath. I mean, travel all leaf nodes in a root.

    For example:

        { "type": "weapon", "id": "SWORD-0000", "amount": 1 },
        { "type": "material", "id": "ORE-0000", "amount": 10 },
        { "type": "potion", "id": "HEAL-0000", "amount": 20 }

    Will get all string and number value if root is ""

    key="equip.0.type", value="weapon"

    key="equip.0.id", value="SWORD-0000"

    key="equip.0.amount", value=1

    key="equip.1.type", value="material"

    key="equip.1.id", value="ORE-0000"

    key="equip.1.amount", value=10


  • Wow.. that would be awesome too :D

  • hi, can you tell me what I might be doing wrong here screenshot

    I originally had the for each stuff nested below the system=>ajaxData!="" stuff.. moved it down just to try something else.. the disabled append there under that system=>ajaxData!="" works btw; data is there.

         "cards": {
              "general`s sword 8": {
                   "faction": "universal",
                   "ready": "6",
                   "type": "Equipment",
                   "ability0": "Command All N",
                   "ability0_rank": "2",
                   "ability1": "",
                   "ability1_rank": "",
                   "show": "1",
                   "attack": "",
                   "health": "",
                   "class": "",
                   "image": "general_s_sword_8",
                   "name": "General`s Sword"
              "battle speech 4": {
                   "faction": "universal",
                   "ready": "2",
                   "type": "Special",
                   "ability0": "Gain Morale N",
                   "ability0_rank": "6",
                   "ability1": "Demoralize N",
                   "ability1_rank": "3",
                   "show": "1",
                   "attack": "",
                   "health": "",
                   "class": "",
                   "image": "battle_speech_4",
                   "name": "Battle Speech"


    • Cecil
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I usually put the for each item of hashtable as a sub-event for ajax on complete.. haven't tried hash on created, so not sure if that's the problem.

  • crhatfield

    Just like said. Using "for each item" after "on create" might be strange -- hash table is empty when creating.

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