[Solved] Hash Table Named Keys Randomness

This forum is currently in read-only mode.
From the Asset Store
Random Maze Generator with Door & Key System - tutorial capx
  • I Have been trying now for a very long time to create a system that loads information from a .txt file (called "Dwarf.txt" in the example) and adds it into a Hash table.

    How

    The .txt file is made so that each line represents a value, ex:

    Race

    Dwarf

    Agility

    100

    Strength

    105

    Intelligence

    100

    Charisma

    90

    and so on...

    I have successfully added all even line number values to 1 ListBox object, and all Odd line number values to another ListBox object. This has created 2 lists, one with the name of the attribute, and one with the value of that number (so to speak).

    I Now Play a loop 27 times,

    Each Time the loop plays, I

    Insert a key equal to ListBox1's Line Text on the Line equal to LoopIndex. That Key is given the value of ListBox2's Line Text on the Line equal to Loopindex.

    Now I don't find anything wrong with the events/actions, and keys are added as I said.

    <font color=red>THE PROBLEM</font>] is that the keys are all messed up. Several keys may be OK, but some of them are really strange, named after all sort of code and other keys...

    I Included a .cap and a .txt object for testing. Its .Zip

    yourfilelink.com/get.php

  • What about using the INI object/file instead? Its kinda setup for this sorta thing.

    Add the INI object to your layout, and make it global. Then you will need to Set the INI file to be loaded from.

    [Dwarf]

    Race=Dwarf

    Agility=100

    Strength=105

    Intelligence=100

    Charisma=90

    Then use an INI.ItemString (for letters/strings) or INI.ItemValue (for Numbers)

    So just to load the values above you would do the following:

    INI.ItemString("Dwarf", "Race")

    INI.ItemValue("Dwarf", "Agility")

    INI.ItemValue("Dwarf", "Strength")

    INI.ItemValue("Dwarf", "Intelligence")

    INI.ItemValue("Dwarf", "Charisma")

    This way rather than a file for each race, you could have a file for all of the races, just put them into a different group. With an INI file the keys should never be messed up.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the response Sandcrawler, I have thought about using an INI file. I have never done so, but figured it wouldn't be a problem to learn. The thing is though that I have a very hard time to let go of a problem that is unsolved, and that I believe can be solved. If its a bug then fine, I will move on. But if it's not and Im just doing something wrong, well the thought of that frustrates me beyond description. I feel that I need to solve this problem or I will never use Hash tables again. With is sad...

  • The keys appear to be fine to me. Each name has the correct value. What language do you use with windows? If the language uses 2 bytes per letter then perhaps the listbox is causing the corruption?

    This cap doesn't use the listbox object:

    http://dl.dropbox.com/u/5426011/examples6/txtToHash.cap

    run in debug mode to see the populated hashtable.

  • The keys appear to be fine to me. Each name has the correct value. What language do you use with windows? If the language uses 2 bytes per letter then perhaps the listbox is causing the corruption?

    This cap doesn't use the listbox object:

    http://dl.dropbox.com/u/5426011/examples6/txtToHash.cap

    run in debug mode to see the populated hashtable.

    Thanks R0J0hound

    Well, that application sure worked a lot smoother. <img src="smileys/smiley4.gif" border="0" align="middle"> Seams Im using Swedish. (though not sure how Windows figured that one out as absolutely nothing in the system is displayed in Swedish) Never the less, the explanation that its the system (and not I) who messed up is very comforting. Ill just have to work around the Listbox object as a means of storing data in any manner and just use it for displaying.

    That's some brilliant coding there by the way. Ill need to customize it a lot, but I will use it to fall back to if something happened. Thanks again for the help. Now (soon) I can finally start working with the actual game and not just the engine for it. <img src="smileys/smiley36.gif" border="0" align="middle">

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