gplar's Forum Posts

  • Which just goes to prove that C2 and its users are flexible in approaches to a challenge.

  • Which was just what I ended up doing.

    solved, I think.

    There is nothing obvious about retrieving data from webstorage outside a project, so I worked around it.

    The way to get 32000 words into an array is:

    1. read the data from a text file with newline as separator into an array using:

    Import the text file into the project.

    AJAX request the file.

    repeat tokencount(AJAX.Lastdata,newline) times

    Array push back tokenat(AJAX.LastData,loopindex,newline) on X axis.

    (this will take close to a minute)

    2. Use NodeWebKit and run preview with NodeWebkit as selected browser.

    Save (on click of a button or whatever) to file , with Array.AsJson as content.

    3. This gives a txt file, correctly json-formatted, which can now be imported into project, AJAX requested and loaded directly into the Array. (Remember to use "AJAX on completed" before attempting a load into Array with

    Array Load from Json string AJAX.lastdata.

    And this only takes a second.

    Well, I learned a bit from this, and thanks to codah and zenox98 for nudging me along.

  • I'm getting closer.

    I found out how to read the data from a text file into an array, which takes 45 seconds.

    After that searching the 32000 cells is pretty much instant.

    I can also save the array as json to webstorage once, and then in subsequent runs read it back from webstorage, which is also pretty much instant.

    What I'm banging my head against now is:

    I want to find the saved array in json form, which webstorage has buried somewhere, and include it as a project file to avoid the timeconsuming conversion, which I can not expect users to have patience with.

    So my question is where Webstorage has saved the file? So I can get at it outside the editor.

  • Clever! I can save an Array to JSon using WebStorage (and reload it). Bu I'm having a hard time finding out where it is stored as a file. Any ideas?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Now that´s instant! Thanks!

    Do you, by any chance, have any idea of how to read a 32000 line txt file into an Array?

    It should be possible if it´s converted to a JSon format, but I don´t really know how to make that.

    I tried the method I mentioned above, reading tokenat but it´s too slow.

  • That´s interesting, I may have been going about it clumsily. Array is clearly the best way, because it searches for the full and correct instance of a word. My find(ListText,Word) is flawed by the fact that if it finds any suggested combination of letters it returns true. E.g. "XPLAI" would be found, being part of EXPLAINED, Boggle enthusiasts would shudder in disgust.

    But how did you get the list into the Array quickly? I tried to read from the string using

    for ReadList 0 to 33000

    MyArray(loopindex)= tokenat(ListText,loopindex,";")

    and it took quite a while, 35 seconds, and then crashed....

  • 'yes, but as far as I can tell a Dictionary is not a dictionary, it's more like a set of named variables.

  • Just thought I¨d share my discovery.

    I tried to put a list of 33000 words into an array and search for a specific word. (For a word game)

    This was rather sluggish , so, not thinking it would work, I put the entire word list into a string (a Global Text), separated by ";".

    Using find(MyList, "WORD") is instant, and solved the whole problem.

    If the WORD is not in the string it returns -1, also instantly, which is sufficient info for a word making game.

    So if you just need to check if a word is valid, this is the way to go.

    And way to go, Construct team. You make my work a joy!

  • VMWare fusion works great! Wouldn´t go for 11" screen, though, if you want to work comfortably in Construct2. A small screen easily gets annoying.

  • Thanks! Interesting read.

    Am I correct in concluding that I need to get my list formatted like this:

    {

    "c2array":true,

    "size":[6000,1,1],

    "data":[ ["word1"],

    ["word2"],

    ["word3"],

    ["word4"]

    ]

    }

    and save the file as words.json to import it?

    Looked for converters but nothing useful showed up. Guess I´ll try Word and Notepad to get it right.

    What about the search speed? Anybody experienced these?

  • I´m making a learning tool, and I have a 6000 word list as a txt file, the words separated by newline.

    1. How do I read it into an array? I know it should be in a Json format, but I can´t seem to find pointers as to how to edit the list to the correct format. (Hoping for a search and replace job on the list.)

    2. Is searching a 6000 element array fast enough to check for the existence of a word?

    By this I mean that when the user suggests a word I want to run it through the array using "contains value" to see if it is correct, without making the user wait.

    Any help would be appreciated.

  • Wow, thanks cvp! Perfect!

    My balloons fly away most elegantly.

  • I have a sprite (a balloon) set up with bullet behavior.

    I want it to, on touch, to move towards the top right corner (1366,0) and shrink on the way,

    to give the effect of disappearing up and right.

    I can't find settings to set angle towards a point, or to shrink a sprite over a given time.

    Anybody done this?

  • Thanks, both of you! Tiled Bkg did the trick.

    I forgot that x of sprite is centre.

  • I need a time progress bar, a red line which reduces its length every second.

    I searched in vain for a Draw function, so can anybody help.

    I tried to make a line sprite and decrease width, which works, but it won´t stay in place, even if i did this:

    Timeline sprite is at start 900 pixels wide and TimeLeft starts at 300.

    Do every second

    Timeline.width = TimeLeft*3

    Timeline.X = 675 (which should keep it in place, but it still shortens at both ends)

    Drawing a line every Tick would do the trick, I think.

    Anybody?