[EXAMPLE/TIPS] - HashTable Object.

This forum is currently in read-only mode.
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hi There is a couple of examples and tips about usage of HashTable Object.

    * Sometimes you asked, how to create dynamic vars or local vars, well there is a way to do that. Right with hashtable object.

    The first you need will be an Function object, obviously from where to call your routines and where to put the local vars.

    At start of your 'on function' condition, using the 'Checks if exist key' condition but negated, you ensure the new var or 'key' isn't being used, once this checks availability, then create the new var with 'insert key' action, giving name and initial value. Afterwards you may use your local as you desire.

    At the end of the function, if you dont like save locals then use the 'delete all keys' action to clear the locals Hashtable.

    Picture below shows how looks the event sheet.

    <img src="http://dl.dropbox.com/u/74660811/Tutoriales/hashtables/hashtable1.png" border="0">

    This is useful when you don't desire to have a lot of globals.

    * Other particular usage for hashtables what i recently applied is, when trying to do a techtree system. this is a cheaper techtree system what i designed, using hastable.

    Well, first i do need is to clearify my concept about techtree. this is, techtree i could define it as a set of abilities or skills inside the game those player gets access when reached some requirements, lets see the example below:

    <img src="http://dl.dropbox.com/u/74660811/Tutoriales/hashtables/techtree_example.png" border="0">

    In the picture you may notice my idea of a techtree, in that sense, we could say, experienced skill needs medium skill 1 at level 4 and medium skill 3 at level 2, in order to player gets access to that skill.

    Well, we may define for each skill, item or key a 'key' inside the hashtable, in this case i called it 'Playerdata' the hashtable, too i stored a key with the name list of each skills this with access purpose later. We'll need too an extra 'key' for requirements for each skill 'key'

    Next, we need a function to call for check the techtree, every time a new skill is granted we need to check for the techtree unlocks, lets see the event sheet to try better understanding.

    <img src="http://dl.dropbox.com/u/74660811/Tutoriales/hashtables/techtree_example_eventsheet01.png" border="0">

    <img src="http://dl.dropbox.com/u/74660811/Tutoriales/hashtables/techtree_example_eventsheet02.png" border="0">

    I espect this be useful... any question post it


    EDIT: After some fixing here is the .cap if you want give it a try... get fun.

    The .cap

  • It's a shame, you don't get any comments. Not only is it a fine example of using the hashtable object, but also something, many people wanted to have an example for. (This and hashtable/array-based inventory)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey, thank you for that, looks really advanced <img src="smileys/smiley1.gif" border="0" align="middle" />

    For the inventory array thing, I got a really cool array based example from the russian construct site. Looks like diablo inventory :P

  • Hi guys tulamide, zyblade, thanks for comments, well I just want to share with community my examples, I have a lots still to share, this one is been used in my current project "Deep Space"... while this can be useful comments may lacks, but I'll thanks any comments... espect community appreciate this...



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