randomly's Recent Forum Activity

  • I think, your option is easier, but since saving to LocalStorage, saving a dictionary as JSON takes less time since it only saves one Local Storage item instead of multiple.

    No offense, just trying to figure out what's more efficient.

  • You can return Arrays and Dictionaries as JSON.

    You would then use two LocalStorage keys.

    One for the level you are on/the number you finished and one for the dictionary with the scores as JSON.

    (Dictionary.AsJSON)

    When you want to get the scores from LocalStorage,simply load the Dictionary from the JSON in the LocalStorage value.

  • Yes, this is possible.

    You will use the system action "Canvas snapshot" for this.

    There is one inevitable downside though:

    snapshots take a short time to be done.

    This doesn't take more than some ticks, but you may have some frames rendered before the snapshot is done.

    To take the snapshot in your case, you would want to do the following steps:

    • hide the layers that you don't want to be visible on the snapshot
    • Take a snapshot with the system action snapshot canvas
    • Add an event "On Canvas snapshot"
    • Now, you can load a Sprite's image from the URL "System.CanvasSnapshot"

    Of course, you will have to add a Sprite first.

    You would make that Sprite as big as the layer you want the screenshot displayed on.

    Make sure to put it on the appropriate layer.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Got it to work now.

    Download .capx

    (The only thing that isn't perfect yet, is the way it handles recipes with the same list of ingredients as another recipe. It will produce the first one in the XML. If you need this to work too, just gimme a shout.)

    Concerning 99Instances2Go 's version:

    I didn't look at the .capx, but Arrays are (probably?) more complicated to setup, but easier to handle than XML's.

    It's probably more sensible to go with the Arrays. 99Instances2Go does quality work, I have experiences that myself already, haha.

  • Actually, I'm quite familiar with XML now, so most of the XML-related stuff shouldn't be much of a problem.

    The issue is:

    We can't use a dictionary to store the items the are dropped on the input.

    Why?

    Because dictionaries don't allow multiple keys with the same name.

    So what we need is a way to differentiate between multiple instances of the same object or to merge multiple instances into one dictionary entry.

    If we got this to work, then there wouldn't be any problem whatsoever.

    Actually, I have difficulties understanding the ID system you tried to explain.

    What do you mean by ID? Based on what pattern do you want to generate it?

    What do you mean by Creation? Do you mean the output of a crafting process? Do you want to backtrack after crafting something?

    _______________________________

    [quote:1hbgiadr]check the Item count with the current picked to where if we have two stone dictionary a counted for and two item it would know to use them both. Would we use a loop here something like Loop 1-(count(//Item)

    If you explained this to me a bit more detailed, we could surely come to a solution.

    (As I said, the XML parsing shouldn't be much of a problem)

    _______________________________

    I think, I found a solution, just need to test it.

    This is what I think of:

    When adding the items on the crafting table ("Input") to the dictionary, we could simply check whether a same key already exists.

    If it does, we add 1 to its value, if it doesn't, we create a new one.

    I'll post a new reply if it works. It should.

  • [quote:3fkvm5ld]But when would I send this message ? If someone joins after the message was sent, this peer won't have a timer.

    Earlier, you said that the timer is to give each player a timelimit on how long he can take to make a pick.

    I would generally say that you start the game no earlier than when all players joined a room (room is full).

    This will prevent you from needing to synchronize the timer every second or so.

    If a player disconnects during a game, I wouldn't let him join until the current round is over. That makes the whole process easier-

    _______________________________

    [quote:3fkvm5ld]I will need to be sure everyone send their answers upon host's signal

    Alright, that's quite a requirement.

    I would take the following approach:

    Since you are playing over LAN, latency shouldn't be much of an issue.

    This means that the timer's current times wouldn't be very different for each peer anyways.

    Do this:

    • When the round starts, the host gives each player the signal to start the timer
    • the timer for the peers is used to control the displayed timelimit only.

    That means that they will have visual feedback on their time left. (You probably wanted to do that anyways)

    But when the peer's timer reaches 0, they won't send their message yet.

    They will wait until the host broadcasts a message, that his timer is over.

    This will probably cause a slight difference delay the peer's visual timer reaching 0 and the host's message arriving, but this will guarantee that each player sends his message at the same time.

    Long story short:

    • The peer's timer is started at the same time as the host's timer
    • The peer's timer is only used for displaying the time left, not to send the message when the timer reaches 0
    • When the host's timer reaches 0, he broadcasts a message (e.g. "timer"). When the peers receive this message, they send their answer (synchronized)

    __________________________________

    [quote:3fkvm5ld]I tried to do that after including "int(value)", but it stills doesn't work for the group value. The peer never gets their message upon connection, so there must be a problem on host side.

    Alright.

    Try to set the "Send message" Peer ID to Multiplayer.PeerIDAt(Multiplayer.PeerCount-1).

    (I'll explain that if it actually works)

  • You are actually right. I was mistaken.

    I used the Multiplayer object in many games, but never encountered this issue...

    Anyways, let's solve this with the host then.

    If you want to message a peer, you will need to add his ID to the message you are sending to let the host know who has to receive the message.

    There are multiple ways to do this:

    Option 1 | Adding the ID to the message:

    Add the ID after the message and separate them with escaping character.

    The host would then need to parse that message (e.g. with Regex) and send the appropriate message to the peer.

    This could look like this:

    Peer who wants to PM:

    Send message "pm":  [message] & "//" & [recipientID] (to host)[/code:16mfd0o6]
    [b]Host:[/b]
    The host needs to parse the message.
    [code:16mfd0o6]On peer message "pm":
    --- Send message {
    ----------- Peer ID:     RegexMatchAt(Multiplayer.Message, "\d+\D+\/{2}(\d+\D+)","",0)
    ----------- Message:  RegexMatchAt(Multiplayer.Message, "(\d+\D+)\/{2}\d+\D+","",0)
    --- }[/code:16mfd0o6]
    (I won't explain Regex to you, there are many tutorials out there, if you want to learn it. If you don't want to learn it or dislike Regex in general, see Option 2)
    
    [u]Option 2, using a Dictionary[/u]
    This option uses a simple 2-key dictionary that contains the recipient's ID and the message in two separate keys.
    The peer will send this dictionary as JSON to the host who will then load the JSON into his own dictionary to easily parse its contents to send the PM.
    
    This could look like this:
    
    [b]Peer who wants to PM:[/b]
    [code:16mfd0o6]Dictionary "pm": Clear
    Dictionary "pm" : Add key "ID" with value "[recipientID]"
    Dictionary "pm": Add key "msg" with value "[message]"
    Send message tag "pm" with content [Dictionary]pm.AsJSON (to host)[/code:16mfd0o6]
    [b]Host:[/b]
    [code:16mfd0o6]On message "pm":
    -- Dictionary "pm": Load from JSON [Multiplayer.Message]
    -- Send message  {
    -------- ID: [Dictionary]pm.Get("ID")
    -------- Message: [Dictionary]pm.Get("msg")
    -- }[/code:16mfd0o6]
    
    ___________________________________
    
    I'm not 100% sure about the Regex method, it [i]should[/i] work though.
    The dictionary method will definitely work, if executed correctly.
  • [quote:3m3sgb9r]I want players to be synchronized on that and the timer to be displayed for them.

    I would just have the host broadcast one single message that will start a timer for the peers.

    Just use the "timer" behavior and start that when receiving the host's message.

    Of course, this will be client-dependant but less tedious than regularly sending a variable.

    You could also start a "timer" behavior for the host and use the "duration" expression minus the "currentTime" expression to broadcast the remaining time.

    That would make the dictionary obsolete.

    _________________________________

    [quote:3m3sgb9r]And here is the latest .capx : https://www. dropbox.com/s/i9d67roqu2jtql6/ChatProject.capx?dl=0

    Link doesn't work for me. 404.

    (Yes, I removed the blank space)

    ______________________________________

    [quote:3m3sgb9r]Arf, actually it doesn't work with the "Group" value. I think I am doing something wrong with the "send message" action.

    Actually, I think that this

    For peer : On peer message, tag "Group", set "Group" to "Multiplayer.Message"[/code:3m3sgb9r]
    is the issue.
    Try changing the "group" value to [i]int(Multiplayer.Message)[/i].
    See my previous post:
    
    This will convert numbers or anything else to a string so you can e.g. send it via Multiplayer.
    [b]Just remember to convert it back when receiving a message if needed.[/b]
    
    
    Btw, as a future tip:
    try to test whether messages are actually received with a simple debugging text object before changing the actions/methods.
    (Just add a text object and change it to "Multiplayer.Message" on Peer message to check whether the host or peer is the issue)
    
    ___________________________________
    
    [quote:3m3sgb9r]And since that did not work, I tried to first save "Multiplayer.FromID" in a global variable or in a dictionary and sending to that value instead, but it doesn't work either.
    
    Chuck that. Isn't really necessary since the expression already works as a global variable of some sort.
  • Yeah the thing is, the whole system uses XML, so I can't just simply use a variable since I would have to combine the variable with the XML which would be quite tedious.

    What I can do though, is add a dictionary that counts the amount of every text object and combine that with the rest.

    Though I still think that my solution isn't very effective, but it was the only thing I could come up with.

  • [quote:2hrs6vvv] I'm keeping it very simple right now and using twelve 50 by 50 px sprites filled with dark grey stacked on top of each other to create the vertical bar.

    Actually, this is very ineffective.

    I'd recommend using a Tiled Background or a 9-patch and scale it instead of using separate Sprites.

    That will also make the height-definition easier and more fluent.

    Anyways, if you still want to use your Sprite version after reading this, just give me a shout and I'll figure sth. out.

  • [quote:2zk2tulv]OK, I found that if I disable uBlock Origin it works. Is there anything I can do about this in my game to make sure it works for uBlock users?

    Huh, that's awkward. I use uBlock too....

    And as I mentioned, I don't have any issues on either sites..

    I probably can't help you anymore here, since I just know stuff about C2, but not about browsers...

  • The simplest option would be to not send it to the host but rather to the peer you actually want to PM.

    To do this, you need to know the Peer's ID. But the ID is easy to get if you know his Multiplayer Alias.

    Just use Multiplayer.PeerIDFromAlias(PeerName).

    Now you just need to add an event to the peer group that handles messages with the tag "private" as private messages.

randomly's avatar

randomly

Member since 26 Sep, 2016

Twitter
randomly has 1 followers

Trophy Case

  • 8-Year Club
  • Email Verified

Progress

9/44
How to earn trophies