mcrxb's Forum Posts

  • 14 posts
  • I can't edit posts but I should add that the AJAX.LastData does show the correct data when attempting to load subsequent data, that data is just not getting loaded into the dictionary. I'm not seeing any console errors in Chome or FF. When I click on the dictionary object in the Construct debugger it shows 0 keys.

  • All of my dictionaries are using the following format:

    {

    "c2dictionary":true,

    "data":

    {

    "AA":"a volcanic rock consisting of angular blocks of lava with a very rough surface [n -S]",

    ...

    "AZYMS":"AZYM; unleavened bread; also AZYME [n]"

    }

    }

    I am trying to load these into specific dictionary objects, so there is an "A" dictionary for the "A" JSON file. The first file "A" loads no problem, it's the subsequent files that don't seem to load.

  • It actually appears that this is the debugger display limit, not the actual request limit. I'll keep digging. I've tried splitting into 26 smaller JSON files but only the first will load. I use the following events:

    On Start of Layout:

    Request A.json(tag "load_A")

    On "load_A" Completed:

    Dictionary Load from JSON string AJAX.LastData

    Request B.json(tag "load_B")

    On "load_B" Completed:

    Dictionary Load from JSON string AJAX.LastData

    Request C.json(tag "load_C")

    Etc.

    This will load the content of the first request "load_A" into the dictionary. The AJAX call is returning the latest data, in this case, "load_C". But the data from "load_C" does not get added to Dictionary. I've tried this with separate dictionaries and same behavior. Am I overlooking something obvious here?

  • The limit is imposed by the browser. Firefox has a 1MB limit before truncating the JSON file and throws an improper termination error. Chrome doesn't specify the limit but from my testing it's larger than 1MB. Once you hit the limit in Chrome though you receive a generic "no response data" in the debugger. I guess I'll need to create more files and have more AJAX calls. There doesn't appear to be an event structure in Construct that will let me iterate through and load files due to the nature of the OnComplete event with AJAX; is this correct?

  • Yes, after thinking more about hard coding the events, that would balloon the size of the data significantly. I've been running tests on the AJAX calls. With the complete dictionary data (276,643 records), the AJAX call takes about 2.5 seconds to complete, which should only need to be loaded once and stored in the dictionary for the remainder of the session. The problem I'm running into now is that the dictionary doesn't seem to get any of the data. If I break the data into smaller JSON files (1 or 2MB) it works fine. Is there a limit to the number of keys that can be stored in a dictionary?

  • In C# that dictionary would be compiled, so I understand it's not an apples to apples comparison. Setting the keys as events is essentially what I'm looking to do, but without having to set them manually. 250,000 keys would take a long time to add events for. Is there a way to either:

    1. Edit the events in a source view so I can write a script that outputs the necessary code

    2. Define the dictionary by directly editing the embedded data in the Construct project file

    I don't see this as any different than setting instance variables at design time. I'm setting the keys and values of a dictionary at design time, but for a large quantity of data, so I'd prefer to not do it by hand with events.

    I've got multiple dictionaries working using AJAX to read JSON files and it does what I need to at this point, I just feel like this is a sledgehammer of a solution for data that only needs to be set once in the entire lifetime of the project.

  • I'm not dense and I've written software applications for many years. I understand that the data must be in memory at runtime, but I don't see why I can't prepopulate a dictionary.

    If I want a static dictionary in C# I don't need to read the data from a file at runtime every time to populate the dictionary. I can populate the dictionary at design time and it is then loaded into memory at runtime. This is all I'm asking to do in Construct to avoid an unnecessary file read/parse every time the application runs.

  • OK thanks. I made that quick change and it does improve performance drastically. I can easily split the files, but like I said in my previous post, why do I need to read this at runtime?

    I noticed that if I open the XML for my layout I can see the instance of the dictionary:

    <instance type="Dictionary" uid="41" />

    Can I not append my data here manually? If I can, what's the correct XML schema to follow for dictionary items?

  • I'm certainly open to those approaches but since this is static data, is there no way to populate a dictionary before runtime? I see there is an editor for Construct3 but there must be an underlying structure of the data that could be hand edited and stored in the project, circumventing the need to read a file in the first place, no?

  • I'm forcing the key to uppercase when it is loaded into local storage and also forcing my compare string to uppercase. Looks like it should be OK based on the debugger output, but it's not working. I'm sure it's something simple I'm overlooking.

    I've uploaded a copy of my capx file here:

    filehosting.org/file/details/779033/SpellQuest.capx

    Thanks again for the assistance.

  • Thanks for all of the help so far. I've successfully loaded my JSON file into local storage, though I noticed if I use my complete JSON file (250K+ records) Chrome chokes. I'll need to split the files and take multiple requests.

    Now that I have my keys loaded into local storage, I'm attempting to compare if a key exists against a string. I'm using the following:

    Local storage > compare key

    = Equal To

    String: curWord

    curWord exists and I can see it in the debugger. But this even doesn't fire, even though the key exists in local storage. I can't use a top level Key Exists event because I need this to trigger on an input, in my case a key press event.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'll look into leveraging local storage for this. Is this the best solution? Would I be better using XML and searching the XML to validate at runtime? The JSON file that I prepared to import via AJAX is around 18MB. I know most modern browsers will support at least that for local storage so I'm more worried about runtime performance.

    This game will not be able to reach the web as it will be built into a standalone arcade cabinet w/o internet access. I could host a local web server via Apache and fetch data from there if it will improve performance.

  • I'm making a Bookworm Adventure clone and need to store a large English language dictionary. I'm currently reading in a JSON file using AJAX and loading a dictionary object at startup. This seems costly to do every time the game loads. Is there a way to store a dictionary so I can load it once and freeze it across sessions?

  • 14 posts