Nilom's Forum Posts

  • Thank you very much!

    Still figuring this out. But now I have new hope to get it to work.

  • Thank you!

    But is it not possible natively? Because I can not know how reliable external plugins will work after several Construct or Browser updates.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey there!

    How do I get the users Facebook Access Token after signing in to Facebook through the Facebook plugin?

    I have a hard time figuring out how I can let the user sign up a new account with Facebook and then let the User/Client use API calls to MongoDB Realm with its implemented Facebook authentication.

    So I thought I could maybe use the Access Token which I send to MongoDB Realm via API call.

  • That's an interesting idea. I will look into this if I need it.

    For now I just load Base64 into an ImageMemory library.

  • Hello!

    I came across this topic https://www.construct.net/en/forum/construct-3/how-do-i-8/load-binarydata-dictionary-151643.

    dop2000

    You can store different images in BinaryData under different tags, which is very similar to the dictionary.

    Can someone please tell me how to do this? Or was this feature removed? I'm not able to find the place where I can define tags for the binary object.

    I need this for loading images from local storages binary data. Otherwise I would need to use a dictionary and store the data as Base64.

    Or maybe use JSON if it is able to hold binary data (is it?).

  • Hello there!

    I have a big issue.

    I'm building a deck editor. I'm using a websites API to load the card images. The owners of the website state that they will ban and blacklist people who download/request too many images per second.

    For this reason I want to create an image cache for these images and only request them if they are not found in the local storage as binary data.

    But the whole thing ends up with a lot of synchronisation issues because of the asynchronous local storage and load image from url (binary data). All cards images always get the same, even with different animation frames set.

    .

    Because the process is complicated I will try to describe the event page as detailed as possible:

    1. On start of layout the online card database version will be checked and compared with the local one. If outdated or missing it will be redownloaded.

    .

    2. The first time the database is downloaded all the data is rearranged in a new json with the card id's being the paths. (Because loaded decklists only contain the cards id)

    .

    3. When a deck is imported the decks card id's are read and for every one of them a sprite instance is spawned with the id as a local variable.

    .

    4. While spawning the sprite (the card) the local storage is searched for a key named like the id of the card. For example 53439220. If it is found then the binary data will be read and the image will be loaded from binary url. (problem: all cards will always get the last image -_-)

    .

    5. If no key with the cards id is found in local storage the sprite will be loaded from image url (from the online api) and this binary data will then be stored as the cards id as a key name to the local storage.

    I tried so many things.

    - Using functions

    - Without functions

    - Setting different animation frames based on object count, loop_index, incrementing

    - Looping through all objects, comparing their id and then setting image from url after Local Storage get is complete

    - Much more that I can not even remember

    .

    Here is what I have so far. I rearranged and changed it a lot so there are many events disabled. But I think you can see what I tried there and what I want to do.

    Any ideas on how this can be solved?

    I just want to be able to load image from url individually for each sprite. =(

    Thank you in advance!

  • Hey there!

    Currently I have a problem with load image from url.

    I have many instances of the same sprite object and want to load different images from url for each of them.

    The very inpractical problem is, that load image from url ignores instance picking. I don't even know why it was designed that way.

    Anyway so when I load an image from url all of the instances will get the same image.

    I read from an old post, that I could use different frames, one for each image. But the problem is that there are a maximum of over 11.000 images and I would need to copy and paste that many frames manually in the editor.

    Isn't there just an easy way like the whole rest of construct is designed around picking instances and only have them manipulated?

  • Hello there!

    I use Ajax to access a servers API. The problem is that I do not receive the data as JSON but as an array.

    It looks like this:

    {"data":[{"id":543422,"name":"This is a name","type":"Normal"}]}

    Maybe I'm stupid but I have a hard time figuring out how I can access for example JSON.Get(".id"). How can I access the JSON data?

    (PS: I hate arrays and love JSON >:O)

    Edit:

    After a lot of testing I figured it out.

    "data.0.id" will access the id in this case.

  • Unfortunately the peer id is a string and not a number and will not be synced.

    I believe that this is the order of things to get it synced correctly:

    1. Host and peer both define the objects that need to be synced.

    2. Host creates the objects that need to be synced or their variables that need to be synced with its owners (players) multiplayer index in a local variable (not id). You get a joining players index with Multiplayer.PeerCount-1 or you loop through every peer and check if the id is matching and the index will be the loop index -1.

    3. Peer: On (synced) object created send a message to the host with this objects local multiplayer index, basically asking the host for information about the player with the given index.

    4. The host then uses this index to get and send all of the information back to the peer. The easiest way to do so would be to use JSON.set all of the information and then JSON.ToCompactString.

    .

    5. When the peer receives this message it will loop through all of the objects and check for the local index variable. If it matches the one from the message it can paste all of the data like id, name, level or whatever you just sent to the objects local variables. Do not forget to parse the JSON data from the message. Then use JSON.Get("").

    .

    This is a bit of a back and forth. If somebody knows a more efficient way please let me know. :D

  • Thank you both for your replies!

    Yesterday while laying in the bed I realized that I need to do this the other way around to have the right order of things happening.

    basically what you said. But not when a peer detects another peer but when it detects the creation of a player frame. This way it is ensured that it will not fire too early as it is the case right now.

    oosyrag Yes I know I should be very considerate with syncing. I sync the player stats so that I do not need to worry about sending all these messages. I think with only up to 5 players it shouldn't be an issue bandwidth wise.

  • Hi there.

    Currently I have a lot of hassle. I have to rewrite all of the unit frames creation because of the limitation of syncing variables to numbers only.

    My workaround was to store the players multiplayer index (multiplayer.peerCount-1) in a local variable on the object that I want to sync. They are basically the players character frames where you see their name, hp, mana and so on. After the local variable with the index is created the host will then broadcast a message to the players containing a JSON with alle the information, as well as which player has which index (as I discovered that the players multiplayer index will not be the same between peers).

    The problem now is that When the peers receive this message the sync objects are not created yet. So again it will not work.

    Now I'm having a headache on how to sync all of this. I just want to create a player frame when someone connects.

    I think I might drop all of this and just look into techniques of converting text to a number (double should be enough), just sync it and re-convert it to text on the peers side.

    Any ideas? Thank you in advance!

  • I was about to ask another question about the syncronisation of variables when I saw this topic.

    I had a similar issue just 2 days ago. Just scroll down to my last reply.

    I don't know if it will help you but what did the trick for me is to set the sync object and sync variable events on the host side as well as on peers side too. Before it didn't work for me, but after this it works now.

    Either the syncing must be initialized on both sides or I did something wrong. But either way the documentation is a bit confusing and needs some more clarification or an example on how to set this proper up.

    Also it is kinda sad that syncing variables doesn't work for strings.. .

  • oosyrag When I put the sync initialization events in the common group (active on host and peer) then on random either the host or the peer will have 2 SyncObjects and the other one will have one. Even when I only drag and drop one SyncObject on the layout inside the editor.

    I can further troubleshoot that later but maybe someone already sees the solution.

    eleanorjmorel About the date.now yeah I could possible do that but I need a working SyncObject anyway for other stats so I will just focus on finding a solution for syncing local variables. But thank you for the advice. Always good to know alternatives.

    .

    Edit:

    Okay I got it to work.

    For everyone having the same issue:

    You must set the multiplayer sync object events on both the host and the peer side, even if that seems counter-intuitive and the documentation doesn't mention this. I thought the multiplayer object would be smart enough to tell the peers which objects to sync if it sends them updates of their states. After I set that up I was able to create the SyncObject object with the eventing system and it was then created on the peers side and everything is working now.

  • Hello there!

    For my game, after the host pressing start in the lobby I want to have a 5 second countdown so the players can prepare for the game to start.

    To not get out of sync I do not just use a multiplayer message for the timer to start, but instead I use an invisible sprite object that I named SyncObject. It will have instance variables that I want to keep in sync with all of the, up to 4, other peers with the sync instance variable feature.

    The first problem I face is that this SyncObject object will not be created on the peers side If I create that object on the host side. It will only be created if I drag and drop the SyncObject inside the editor on the layout, but not if I create it inside the eventing system with create object.

    The second problem is that although I drag and drop the SyncObject and it will be created on the peers side the instance variable will just not sync.

    When the timer is started I set the timer variable of the SyncObject to 5 on the host side and after every 1 second I substract 1 from it. But it remains 0 on the peer for the whole duration.

    What am I doing wrong? As always, thanks in advance!

  • Thank you for your detailed reply.

    Maybe I overcomplicated my question with too much detail.

    My wish:

    Please mark strings in the Debugger with " " like in the editor or programming languages. That would make troubleshooting easier.

    But you are right it is not a bug and I will instead request it as an idea/feature in the thread you linked.