Building a wordlist database in Construct 2

Get help using Construct 2

Post » Wed Jul 10, 2013 8:45 pm

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.
B
17
S
3
Posts: 225
Reputation: 2,358

Post » Wed Jul 10, 2013 9:15 pm

@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.Guizmus2013-07-10 21:16:02
B
17
S
8
G
4
Posts: 461
Reputation: 6,097

Post » Wed Jul 10, 2013 10:48 pm

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:
[code]{
   "c2dictionary":true,
   "data":{
      "key1":"value1",
      "key2":"value2",
      "key3":"value3"
   }
}[/code]
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.Yann2013-07-10 22:50:15
B
64
S
22
G
14
Posts: 1,482
Reputation: 16,457

Post » Thu Jul 11, 2013 12:29 am

[QUOTE=Yann] 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:
[code]{
   "c2dictionary":true,
   "data":{
      "key1":"value1",
      "key2":"value2",
      "key3":"value3"
   }
}[/code]
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.[/QUOTE]

With this, I could just add the words manually in that format? Sounds awesome.
B
17
S
3
Posts: 225
Reputation: 2,358

Post » Thu Jul 11, 2013 7:12 am

@Ashodin
usually if you want to know the format of the JSON used by a plugin, you just have to do
[code]on start of layout
   -> add data in object
   -> add data in object
   -> add data in object
   -> download JSON[/code]
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.
B
64
S
22
G
14
Posts: 1,482
Reputation: 16,457

Post » Wed Jan 15, 2014 5:52 pm

@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
B
15
S
6
G
3
Posts: 87
Reputation: 4,304


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, ColombageEnPLS, rustomatic and 2 guests