ComGamer's Recent Forum Activity

  • Hi,

    Is there a system action that does the same thing as runtime.getAllLayouts();

    I just want an array with all the layout-names.

    At this moment I do it this way, and it works, but I am just wondering if this can be done without using scripting:

    let larray = runtime.getAllLayouts();

    let a = runtime.objects.Array.getFirstInstance();

    a.setSize(larray.length,1,1,);

    for (let i = 0; i < larray.length; i++){

    a.setAt(larray.name,i-1);

    }

    Thanks!

    (I posted this topic in 'How do I...? and not in scripting because I have a question about doing something without scripting. )

    Wim

  • dop2000, off course, such an easy solution, I was making it much to difficult.

    There's still a small chance of getting long repetition of two of the same numbers: 1,2,1,2,1,2,3 but this doesn't seem a real problem.

    lionz: 3 times in a row is only a problem when simply picking a random number every time. Ex. 10 x choose(1,2,3) -> 3,1,2,1,3,3,3,3,1,2

    Thank you both!

  • I want 3 different enemies to appear in a random order, but never two the same after each other.

    - By choosing one at random, it often happens that the same enemy appears even three or more times in a row.

    - With an advanced random permutation table

    (-> AdvancedRandom: Create permutation with 3 values starting at 0)

    that I shuffle every 3 'appearances', I often get the same enemy two times in a row (example of a sequence: 0, 1, 2, 2, 1, 0, 0, 2, 1, 1, 2, 0).

    - So when shuffling the permutation table I check if the last enemy (of the first table) and the first enemy (of the new table) are not the same. Else I reshuffle.

    However, I feel that this is a very complex and far-fetched solution. Can it also be simpler?

    [functions]

    | Local static number index‎ = 0

    ----* On function 'getNext' → Number

    --------+ System: index < 2

    ---------> Functions: Set return value AdvancedRandom.Permutation(index)

    ---------> System: Add 1 to index

    --------+ System: Else

    --------+ System: index = 2

    ---------> Functions: Set return value AdvancedRandom.Permutation(2)

    ---------> Functions: Call randomizeTable

    ---------> System: Set index to 0

    | Local number last‎ = 0

    ----* On function 'randomizeTable'

    -----> System: Set last to AdvancedRandom.Permutation(2)

    -----> AdvancedRandom: Shuffle permutation table

    --------+ System: While

    --------+ System: last = AdvancedRandom.Permutation(0)

    ---------> AdvancedRandom: Shuffle permutation table

    Thanks!

    Wim

  • Thank Lionz, this is wat I thought and what seems logical. But why then is the 'on item get'event triggered when the item doesn't exist?

  • Does LocalStorage 'Get item' action creates the item in LocalStorage?

    I'm asking out of curiosity now, because I solved my problem with 'Check item exists' and then in 'on item exists' the action 'get item'.

    At assumed (wrongly?) that 'On item get' wouldn't be triggered when the item didn't exist already (when the user first played the game on this browser). But even in incognito-modus the 'on item get' was always triggered.

    Thanks!

    Wim

    Tagged:

  • Only possibility left is your web host server settings then.

    The main problem seemed to be a 'hidden' (I couldn't find it) cashing of files in Google Chrome, 'incognitomodus' of Chrome solved my problem.

    Thanks for your help!

    Wim

  • Like I mentioned, is most likely server side.

    Routers also have the ability to cache requests in some scenarios to save bandwidth, this may happen in a commercial or institutional setting, unlikely for home internet though.

    I'm at a home network, my router can't cache sites.

  • I tried everything to clear all data, but still Chrome keeps finding old files, for example an old version of c3runtime.js:

    - Deleted the sw.js and offline.json files from the server, to be sure Chrome doesn't save the app for offline use.

    - With Crome Dev Tools cleared all files in storage, cached-storage, ...

    - Cleared all browsing data, history, ...

    - Even changed the directory of the app on the server

    Reloaded with Ctrl+Shift+R, and still Chrome used old files that didn't exist anymore.

    But I've found the solution in the end: incognito-modus.

    + force a reload of the json file by adding ?t=" & random(1000) to the URL.

    Thank you all for your help!

    My working code:

    Wim

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Lennaert,

    Thank you for your response.

    I started with one dictionary, but added a second one, just to be sure I don't display the data from the first dictionary. So I know yes.

    Wim

  • The caching doesn't seem the (only or main) reason. I discovered where to find the cached json-file (https://developer.chrome.com/docs/devtools/storage/cache/) and deleted the json-file (and even all the other cached files). But I still get the data from the old json file. Even after closing the tab and restarting the application. I still get the old data. This old data doesn't exist anymore at this point, so where is he getting this data??

    Wim

  • This tip of oosyrag about caching seems to get me a step along the way, but I'm not there yet.

    To avoid a cached result, JQuery doesn't seem necessary, adding a unique ID to the URL should be enough if I understand the following correctly. But unfortunately it doesn't work. I still get the same result.

    w3schools.com/js/js_ajax_http_send.asp:

    In the example above, you may get a cached result. To avoid this, add a unique ID to the URL:

    xhttp.open("GET", "demo_get.asp?t=" + Math.random());

    xhttp.send();

    So I tried:

    url":"\"https://www.mysite.be/testjson/MyDictionary.json?t=" & random(1000)"

    But with no effect on the caching.

    Wim

  • Hi,

    To test and finetune a lot of properties (different speeds, strengths, powers, ...) in my game I want to be able to change them while playing the game. All the values are in a dictionary, which is loaded from a json-file. I can host the game and the file on the same webserver (to prevent cross-domain problems which I have in preview mode) and change the values in the json-file on this server.

    But when I change the values and reload the json-file in the project, the data imported from the file isn't changed. Even if I reload (ctrl + F5) the gamepage, it still loads the old data that doesn't exist anymore.

    I made a new project with a simplified version of this problem:

    Any ideas to solve this?

    Thanks!

    Wim

    Tagged:

ComGamer's avatar

ComGamer

Member since 20 Oct, 2017

Twitter
ComGamer has 1 followers

Connect with ComGamer