lincolnsalles's Forum Posts

  • hmm, thanks, I'll try that. But anyway I'm going to have to save this array when I exit the game, so would it be more productive if I always save in jason and reload in the array, or just at the end of the level save all changes in jason and then in local storage? But anyway I thank you, I think you already solved the question, thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You do not have permission to view this post

  • Note that you must leave the animation speed at 0 (inside the animation editor).

    The example file is also attached.

    https://drive.google.com/file/d/10QBXo0lUKxun404SFW7bGD6QBMEw2kOw/view?usp=share_link

  • Hello, thanks for the replies. I think I found the problem, but I don't know how to solve it. I forgot to mention that this array I included using json. So every time I change something in this array, when I enter another layout, it reloads the original json data into the array. So I believe that when I change something in the array, I need to save it in the json first, so that when I enter another layout it will download the already changed json to the array. To do this, I think you have to use local storage, right? I will send the file.https://drive.google.com/drive/folders/1Gf0PN-ucJylsJnP9VVvtTGQzVUTnwRCx?usp=share_link

  • Yes it is an array and it is marked as global. I really don't understand why it's not holding the value when I change layout. I don't have layout start events changing array. But thanks for answering, I'm definitely missing something, because I create other examples of changing the array and when I change the layout the value always changes in any new example that I do.

    But at the same time I always create a global variable and also write the value to it. In the global variable even when I change the layout it records the value as expected, but the array does not.

  • No. I made another example to test in a new file that I created, and the same thing happens. It normally changes the matrix, but when I change the layout it returns to the value that was in the matrix. As I'm new to matrix maybe I'm missing something. I want to change the value in the array and it stays changed as long as I stay in the game. It's like a global variable, but I don't understand why it's not keeping it.

  • Summary: I can change the array value, but when I change the layout the array value returns to what it was before.

    In this code here in the photo, if I press Enter on the button option called Right : a variable called Record_keycode becomes True and the sprite font blinks for 5 seconds. At that time in another event, if I press any key on the keyboard it writes that keycode of the pressed key to a specific location in the array called Button_map at (2,54). The problem is that when I leave the menu layout and go to another layout, the array value returns to what it was before, it is not being recorded. I'm not talking about exiting the game (which I'm going to save to local storage), I'm talking about changing layouts. Then I created a test variable called Right_test and also recorded this value in it. The value was saved in the variable. I started messing with array and dictionay a little while ago and found this problem...

  • You were amazing. It's hard to believe, you gave me both examples, I saw the code, well summarized, very clear. This will help me a lot, I didn't know the expression "SRT", although it's in the documentation, there's always something there to see. It's the kind of thing I'm going to study for a few days, practicing different examples of this to better memorize. I thank you very much for donating your time to this. Thank you very much, God bless you.

  • Here's my imaginary Json I made for this example here, which is nothing more than these keys and values in the construct's own visual dictionary editor. All the keys are numbers (the keycodes) and the values are the keys.

    What I wanted was that when the player pressed any key, the corresponding key appeared in a sprite font. In fact, I already managed to do this yesterday without a variable, without a dictionary or json, just with: Keyboard.StringFromKeyCode(Keyboard.LastKeyCode)

    I didn't know that there was this expression in the keyboard object called StringFromKeyCode, I only knew the LastKeyCode, that's why I tried to do it like this. But let's assume that I had to do this by json, would you know how to look for the keycode corresponding to the last key pressed by the keyboard in that json and return the value of that key?

    {

    "c2dictionary": true,

    "data": {

    "9": "TAB",

    "13": "ENTER",

    "17": "CTRL",

    "18": "ALT",

    "32": "SPACE",

    "37": "LEFT",

    "38": "FORWARD",

    "39": "RIGHT",

    "40": "BACKWARD",

    "41": "\\",

    "45": "-",

    "48": 0,

    "49": 1,

    "50": 2,

    "51": 3,

    "52": 4,

    "53": 5,

    "54": 6,

    "55": 7,

    "56": 8,

    "57": 9,

    "61": "=",

    "65": "A",

    "66": "B",

    "67": "C",

    "68": "D",

    "69": "E",

    "70": "F",

    "71": "G",

    "72": "H",

    "73": "I",

    "74": "J",

    "75": "K",

    "76": "L",

    "77": "M",

    "78": "N",

    "79": "O",

    "80": "P",

    "81": "Q",

    "82": "R",

    "83": "S",

    "84": "T",

    "85": "U",

    "86": "V",

    "87": "W",

    "88": "X",

    "89": "Y",

    "90": "Z",

    "91": "[", "93": "]",

    "97": 1,

    "98": 2,

    "99": 3,

    "100": 4,

    "101": 5,

    "102": 6,

    "103": 7,

    "104": 8,

    "105": 9,

    "106": "*",

    "107": "+",

    "108": "L",

    "109": "-",

    "110": ",",

    "111": "/",

    "180": "´",

    "188": ",",

    "190": ".",

    "191": ";",

    "192": "'",

    "193": "/",

    "194": ".",

    "199": "Ç",

    "222": "~",

    "231": "Ç"

    }

    }

  • I used the json dictionary object because it's easier to edit so many keys manually. And it is also possible to retrieve key values directly from json, without having to pass to a dictionary. But I can retrieve values in that json, but I can't parse the whole json looking for the numeric key I want.

  • I have a Json file that was created within construct 3 with the dictionary's native plugin in the "files" folder. It's like a dictionary, but I know that those files created in the file folder are actually Json files, correct?

    What I want to do is the following:

    Start of layout / Request file.json('tag")

    Ajax on "tag" completed / Parse json string Ajax.lastData

    So far so good. I uploaded the Json file.

    All the keys in my Json file are numbers. But what I want to do is parse all the keys looking for a specific number, until I find that number.

    When it finds the key that matches the number I want, I want it to return the value of that key. And then I want to show that value in a text object. How could I do this? I'm breaking my head because I'm a beginner at this.

    Tagged:

  • With the result like that you don't really need the dictionary. You can access the same data from JSON.

    For example:

    JSON.Get("Skills.Double Strike.Mana")

    will return the same value as

    Dictionary.Get("Skills.Double Strike.Mana")

    Hello. But would I be able to save the information directly from json to local storage? Or would I need to bake for a dictionary like he did?

  • Thanks for all the answers, they helped me a lot.

  • Here is an alternate way. It checks the value with all the other values and if any match it randomizes the number again and re-does the check.

    https://www.dropbox.com/s/z0an316nusgc6nu/unique_random_list.capx?dl=1

    If you were only concerned with the values 1 through 6 you could do something simpler like this too.

    https://www.dropbox.com/s/mb9he4ke03d7r23/unique_random_list2.capx?dl=1

    R0J0hound

    Thank you very much, I confess that your example was too advanced for me lol. I still don't deal very well with loops, but I'll save it to study this more calmly later on. Thank you for that.

  • Using the permutation table is quite easy. You initialize it with a length and a starting value, and it'll automatically randomize itself.

    Problem is, you need to create a visual pseudo-shuffling animation. To that end you can still use a normal random call, but when it's time to pick a final number, you do so using the permutation table at the correct index.

    Here's your modified example implementing what I explained :

    https://drive.google.com/file/d/1HkqVTyFrRjg0AvcsHcTZXT25oTs_D_89/view?usp=sharing

    Dude was really worth it. You showed me that I was making a mistake I was never going to guess, that index 1 of the permutation table is actually 0. How was I supposed to guess? So I was calling the index 1 from 1, when it's actually 0. And apart from that, I just changed your example by putting the table to generate not at the beginning of the layout, otherwise it would always be the same when clicking on the button, but I put it to generate when press the button and the variable is not starting.

    Thanks for all the replies. Many told me that I would have to use matrix for this. Glad you won't need it. This forum is really good.