John Cutter's Forum Posts

  • 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".

  • Before I started working on my Facebook Instant game I played a bunch of them on my laptop. They almost all had the same pixel dimensions: 503x894. So that's the resolution I chose for my game.

    Yesterday I played a couple of games on my iPad and almost all of them filled the screen in both portrait AND when rotated to landscape mode. I've skimmed the Facebook documentation and it looks like I can take advantage of "Fluid Layout" in the settings menu. Am I correct in assuming that this will handle the scaling for me? So I just need to make sure my aspect ratio is correct? Is that right?

  • [quote:1odtnfeh]Sprite:DragDrop is dragging -> Sprite: Set position to Touch.X - 32, Touch.Y - 32

    I thought I already tried that, but perhaps I did it wrong. Thanks for the reply!

  • Implementing dragging and dropping manually isn't difficult, but it's always a pain in the **** -- so I was really excited the first time I found the "drag and drop" behavior in Construct. So easy!

    That said, is there any way to do an offset? On mobile, for example, most games will offset the item being dragged so it isn't blocked by the player's finger. Is this possible (without rolling my own D&D code)?

  • [quote:fxfw6m52]What sort of randomness do you need? Do you just a seeded random number or perlin style coherent noise?

    Thanks for getting back to me, Nepeo!

    I don't think I need Perlin noise, I just want to make the random elements of my game deterministic, so all players get the same experience. I've found that this also helps with game testing.

    As I mentioned, my Facebook Instant game uses randomly generated word puzzles. If I could set a random seed then all players would get the same puzzle at each level of the game. (From 1 to infinity!) This is important because I want to have leaderboards and maybe some sort of challenge feature.

  • [quote:2cl6reav]The problem is your json file. Did you edit it manually? The length is set to 13570. It should be 13569.

    If you run with the Console up, you'll see an exception is thrown. That's why the later code is not run - it is crashing.

    Yikes! Yes, I generate the .json file from an Excel spreadsheet. Looks like I need to fix my VBA code. Thanks, blackhornet!

    When you say "run with the console up" do you mean the debug console? I've never noticed any error messages...

  • blackhornet

    I tried isolating the events into a very small file and I'm still seeing the problem.

    My program:

    Here's a picture of my events sheet:

    And here's a picture of my functions sheet:

    When I click the button my first function is called but the code never reaches the second one. (The text changes to "Button Clicked" and not "Function 2".)

    NOTE: If I reverse the order and call "Change Text" first, the text changes to "Function 2".

    Here's a link to my .c3p if you want to play around with it:

    https://nofile.io/f/uhcGvKUwwuR/Race+Test.c3p

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for being so helpful, Asmodean!

    What you proposed is basically what I wound up doing. I wasn't sure how to tell when my "For each element" loop was finished so I am simply checking to see if array_all_words Current value = "agria" (Which is the last word in my array.) Is there a better way to do that?

    Ugh. My code is now full of all sorts of crazy kludges that I didn't actually need. I wonder if there is anything Scirra could do to make it more obvious when this "race" situation is happening? It's not intuitive at ALL.

  • I've really been struggling with my code this weekend and I'm not sure why. Even fairly simple things are not working and I'm starting to suspect that I'm encountering timing issues in the event flow. Like some events are taking so long that following events are not being called at all. Has anyone else encountered this?

    For example, when players push a button in my game I call two different functions. The first checks through a giant array to look for valid words. That works great. The second function does a variety of things and it isn't working. To debug it I started disabling events until I was left with a single one that simply changes text in a visible string. Nothing happens, it's like the second function call is being skipped.

    Here's what my code basically looks like:

    [the player clicks on a button][ul]	[li]Function call "score_words" (this works great!)[/li]
    	[li]Function call "final_score" (this doesn't work at all)[/li]
    [/ul]
    Function On "score_words"
    [ul]
    	[li]For each X element (there are 13,000+ values in my array)[/li]
    [/ul]---- array_all_words Current Value = array_player.at(0) --> set score_1 to array_all_words(arr_all_words.CurX,1)
    
    Function On "final_score" ---> txt_debug Set text to "HERE!"
    [/code:2tyz0h2w]
    
    My debug message never gets updated to "HERE!" I've tried adding a Wait(0) between the two function calls but that doesn't seem to help.
    
    Any other suggestions? (Thanks!)
  • Thank you, Asmodean! That worked like a charm!

  • I've been using Construct 2 casually for years and recently upgraded to Construct 3 (so I could work on a Facebook Instant game). I'm not a power user, but I haven't noticed it being limited at all. Though, I guess it may not have as many addons as C2.

    To be honest, I thought the whole "runs in the browser" thing was kind of gimmicky but the work Scirra has done on this is damn impressive. And the other night I was doing some work before bed and right after I climbed under the covers I thought, "Oh, wait. I think I know how to fix that problem I was working on!" I pulled out my iPad, launched Construct 3, fixed the bug, and saved it. Worked like a charm!

    My only real concern about Construct 3 was the yearly fee. I tend to use these kinds of tools for a few months and then not at all for half a year or more. But I got a C2 discount on the first year so I decided to give it a try. So far so good. And the new faster runtime Ashley is working on should be great! (That's a C3 exclusive, I believe.)