John Cutter's Recent Forum Activity

  • A tag is just a name you can assign to help Construct identify things. It's almost like a variable name, which means it can be anything you like.

    For example, when you use AJAX to "request" a project file you can add a tag like: "zebra_yoghurt". Then your next line would be:

    AJAX --> On "zebra_yoghurt" completed -- Dictionary --> Load from JSON string AJAX.LastData

    Another place where I use tags is with audio. When you play a music file, for example, you can assign it an optional tag. Again, it can be any name you want. By giving it a tag you can then do things like check to see if music with that tag is playing.

  • For a bit more help, check out my recent thread here:

    Here's a quick overview:

    1. Right click on Files and select New --> Dictionary

    2. Edit your dictionary with keys and values (do NOT include quotes for text)

    3. Add AJAX to your project

    4. One of your first events should use AJAX to Request a Project File

    5. When it's loaded (AJAX "On [tag] Completed") then the Action for your Dictionary object should be "Load"

    6. You can then load AJAX.LastData into your Dictionary

    7. Now you can use keys to retrieve information from your dictionary

    8. If you created an array then you can do things like: Array.At(index) or Array Contains Value "Text"

  • Your project should work fine in Construct 3. In fact you can probably try it with the free version. (Just click on the Construct 3 link above.)

    That said, if you SAVE your project using Construct 3 you will no longer be able to load it in Construct 2. At least, this is my understanding.

  • [quote:1blze4vj]If this is for C3, why post in the C2 section?

    Yeah, sorry about that. I initially posted in the C2 section because more people seem to read that section. When I realized my problem was specific to C3 I posted again there, then found out it was too late for me to delete this thread. Can you do that for me? Thanks!

  • Update: blackhornet provided the solution to my problem! When I entered the data in the JSON file (using Construct 3 I was able to type values into a table) I was using quotation marks for strings. Apparently, this isn't necessary. When I removed them everything worked correctly.

    In case anyone else runs into this issue in the future I made a quick illustration:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • [quote:34y3482z]You don't need the quotes in the JSON file. Get rid of all of them, and it works.

    That did the trick! Thank you very much, blackhornet. That was driving me nuts.

    For anyone else who might run into this same issue in the future I made a quick diagram:

  • That sounds amazing, oosyrag! When I get some time I'll check it out!

  • I started this thread in the Construct 2 General Discussion board, but I think the problem may be specific to Construct 3 so I'm recreating it here.

    I was trying to learn about the Dictionary object the other day and I created a simple test:

    1. I started a new project

    2. I added a dictionary object, AJAX, a button, and a text object.

    3. I right clicked on "Files" and picked New --> Dictionary

    4. I made size = 4 and I created four sample keys:

    "Name" = "John"

    "Age" = 56

    "last_played" = 0

    "puzzles_lost" = 0

    Then I created a few events that looked like this:

    To my surprise, clicking the button on my layout did NOT change my text string to "John" as I expected. It changed to "0". When I looked at the debug panel the dictionary appeared to have the correct information, though when I looked at the string for AJAX.LastData it looked like this:

    {
       "c2dictionary": true,
       "data": {
          "\"Name\"": "\"John\"",
          "\"Age\"": 32,
          "\"last_played\"": 0,
          "\"puzzles_lost\"": 0
       }
    }[/code:1b28gtnl]
    
    Are the back slashes normal? I didn't edit the JSON data, I just had C3 make it for me...
    
    As a test I added some keys to my dictionary object using "Add Key" and everything worked as intended.
    
    [img="http://i68.tinypic.com/2s1m2rq.jpg"]
    
    I'm stumped. Is this a bug in Construct 3? Or is it, [b][i]once again[/i][/b], something stupid I'm doing wrong? 
    
    Here's my .c3p file:
    [url]https://ufile.io/hk7a1[/url]
  • [quote:2dwry3bw]Post a CAPX.

    As I mentioned, I built my dictionary test using Construct 3. (But the file is small enough for people with the FREE version to view.)

    dictionary_test.c3p

    https://ufile.io/hk7a1

    UPDATE:

    I just tried adding keys to my dictionary manually, and that worked as intended. Here's the code:

    So I seem to be having an issue when I use Construct 3 to generate my dictionary file. I'll put up a new post in the Construct 3 area.

  • Try this: forget about the form for now, try to directly print Dictionary.Get("Name") to the console after loading the dictionary.[/code:3d55xobx]
    
    To be honest, I'm not sure how to do that. I need a plugin, right?
    
    As a test I just started completely over with fresh code and tried setting a Global String variable to Dictionary.Get("Name"). I tried triggering this based on a button press (the debugger says the value of the variable was still "O"), then I moved it below the line where the dictionary loads AJAX.LastData. The debugger still says "O".
    
    I'm stumped.
  • Thank you for the reply, Zed!

    Here is the JSON string from Ajax.LastData:

    {
    	"c2dictionary": true,
    	"data": {
    		"\"Name\"": "\"John\"",
    		"\"Age\"": 32,
    		"\"last_played\"": 0,
    		"\"puzzles_lost\"": 0
    	}
    }[/code:zs15n2r5]
    
    I created the json file within Construct 3. I right clicked on the "Files" button and chose "New" & "Dictionary". Then I just entered some values:
    
    "Name" = "John"
    "Age" = 32
    "last_played" = 0
    "puzzles_lost" = 0
  • I was doing some simple tests with the dictionary object and I immediately ran into a snag. (See image below.) When I click the button on my form the text string changes to "0". What am I doing wrong?

    NOTE: I included a picture of the debugger. The dictionary object has the correct data, I just can't seem to retrieve it using the key value "Name".