Building a wordlist database in Construct 2

0 favourites
  • 6 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • I've tried using the Dictionary, but I have to add all the keys to the database manually (as I do not know how to use JSON to load them into the game, and manually editing a wordlist created for JSON to fit Construct 2 is a MONUMENTAL task).

    I wish there was a way I could import a txt with all the words in it, and have Construct 2 be able to "search" for that list, compare the word, and allow an event to run if the word exists.

  • Ashodin

    The XML plugin is your friend here, but the file could be a lot bigger than just a text file.

    Have you tried to just import a txt file, load it via AJAX, and do a "for Each" on the tokens if you use a "," as separator ? Something like this. You can then store it in whatever you want, an array could be nice.

  • hmmm I'm not sure what you exactly want, but if you can somehow generate a word list using php/python/java

    You just have to follow this structure:

    {
       "c2dictionary":true,
       "data":{
          "key1":"value1",
          "key2":"value2",
          "key3":"value3"
       }
    }

    It's rather straightforward, you have a "c2dictionary" key which is just for c2 to check that it's supposed to be a JSON for a dictionary object, and a "data" key which holds the list of key/value pairs.

    Now if you have to do it by hand, it's still easier to build such list using a text editor than to create all the "add key" action in construct.

    Now to use such thing, you just have to put that in a file, import it in the file folder of your project tree (in the project panel)

    And then using the AJAX plugin, you request the file, and "on request completed" you load the AJAX.LastData value into a dictionary object.

  • hmmm I'm not sure what you exactly want, but if you can somehow generate a word list using php/python/java

    You just have to follow this structure:

    {
       "c2dictionary":true,
       "data":{
          "key1":"value1",
          "key2":"value2",
          "key3":"value3"
       }
    }

    It's rather straightforward, you have a "c2dictionary" key which is just for c2 to check that it's supposed to be a JSON for a dictionary object, and a "data" key which holds the list of key/value pairs.

    Now if you have to do it by hand, it's still easier to build such list using a text editor than to create all the "add key" action in construct.

    Now to use such thing, you just have to put that in a file, import it in the file folder of your project tree (in the project panel)

    And then using the AJAX plugin, you request the file, and "on request completed" you load the AJAX.LastData value into a dictionary object.

    With this, I could just add the words manually in that format? Sounds awesome.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashodin

    usually if you want to know the format of the JSON used by a plugin, you just have to do

    on start of layout
       -> add data in object
       -> add data in object
       -> add data in object
       -> download JSON

    you'll get a file with something like what I posted (but in one line)

    it works with the array, dictionary and my polygon plugin.

  • Ashodin

    Great example.

    Is there a way to search for a specific 'word' within the words.txt file? I'm trying to figure out the best way to search a database using a TextBox.

    This is what Iv experimented with capx

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