Zakeru's Forum Posts

  • It works ! But the Japanese characters won't appear. I get weird symbols instead... any idea why :D ?

    By the way, I had no idea you could create all kinds of files with construct 2. That's really good to know !

  • Oh ok.

    Indeed, I don't need to load them back. I'm directly using the data in the dictionaries for my research. In short, this program helps me to create stimuli for a linguistic experiment, all I need in the end is an excel file with the list of verbs I created and their inflections.

    So now I just download them separately, open them in firefox and copy/paste in excel. That works just fine even if that may not be the most convenient way to do it.

    So thank you very much for your help !

  • Oh yeah !! It worked ! Thanks a lot !

    However, I did not manage to get everything into one file. As you said, it would be a lot more convenient. Actually I can get the file as JSON but when I try to open it on Firefox I get this error message :

    "SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 2 column 1 of the JSON data"

    The problem appears only when I try to combine several dictionaries. It works fine if I download them one by one, which is already great.

    Here is the new .capx, the file that does not work for me is the "FullList.json" :

    drive.google.com/open

  • Hello everyone,

    I am very new to programming and found myself stuck with a problem I am sure you will be able to help me solve in no time.

    As a PhD student in linguistics, I am not exactly making games but little programs that help me in my research.

    The one I am having trouble with is a "Japanese -ru verb generator". In short, it creates random (non) verbs ending in "-ru" in Japanese while respecting the basic phonotactic rules and phoneme frequencies of the language.

    The good thing is: everything works just fine on my computer when I am previewing from Construct2. I may not have programmed everything in the most elegant way, but it works ! It generates the verbs, saves everything I want to save on 5 dictionaries (the list of verbs and some of their basic inflections), and downloads those dictionaries as JSON when I click the right button.

    However, I want to share my program with some colleagues. Since I could not find a way to upload it on a server (again, I am quite a noob), I thought the best option was to export it as a desktop app. So I downloaded and installed the NW.js support to do that. But if I run the game from the desktop app, when I click the "save" button, the downloading of the dictionaries doesn't work. Instead, 5 blank pages pop up (one for each dictionary).

    What did I do wrong ?

    By the way, here is the .capx file :

    drive.google.com/open

  • Ooooooh now I understand what you mean.

    The game will be translated and played only in Japanese. So capital letters won't be a problem since it doesn't exist. I already thought about it .

  • Oh I see. But maybe that would be more convenient the other way around :

    When host get an "answer" message from peer, he adds a key "CreatureCount//Multiplayer.message" with value "1". Or add +1 to the value if the key already exists.

    Then peers score if "HostAnswerList" has key "CreatureCount//Answer".

    At the end of the game, the "HostAnswerList" dictionnary should look something like that :

    1//blablabla 3

    1//bliblibli 2

    1//blobloblo 5

    ...

    2//blebleble 7

    2//blublublu 2

    2//blyblybly 1

    ...

    Which would be cool to analyse.

  • Yeap, dictionnaries for life lol. My first idea was to use families though. Something like creating 30 sets of 3 items (at the beginning, only "?" would appear) : a sprite, a "answer" text and a "score" text. Put the 3 items in 3 different families with an instance variable (corresponding to the creature count). When timer reaches 0 :

    Pick sprite (currently a question mark picture) by instance variable = creature count => Replace with sprite of current creature

    Pick "answer" text (currently a question mark) by instance variable = creature count => Replace it with Answer.Text

    Pick "score" text (currently a question mark) by instance variable = creature count => Replace it with "HostAnswerList.get(Answer.Text)-1"

    Do you think I can do something along those lines ?

    [quote:1hkiznfi]Don't know whether you added this yet or not, but it may be sensible to catch the case that every player submits an empty answer, by accident.

    So that it doesn't display "", but "No answer given" for example.

    I don't understand what would be the problem if everybody submit an empty answer. So far, empty answer = you don't send anything to host and you don't score anyway when getting the answer list.

    Also, I notice a little problem with the way the scoring system works now : if someone always answer the same thing, like "ZZZZZ" for example, even if it is nonsense, it will add 1 to "ZZZZZ" value every round. So this player would score round number-1 every round. I should find a way to prevent previous rounds to influence later ones. I thought about 2 solutions :

    • Reset HostAnswerList every round => cool, but a complete list of all answers could have been interesting data to analyze for my research, so I'd rather not.
    • Learning to use array, then I can have x = Answer (text), y = Value for this answer, z = round number. And players would score y points only if there Answer.Text = x and round number = z. => I have to learn how to use array T_T
  • Hey ! No problem, I was on holydays too.

    Actually, I will be quite busy with other stuffs until the middle of february, so I may have to put the game aside for a while. But I think it is already in good shape (thanks to your good advices).

    The next thing I will have to think about is this : the "previous creatures" hint.

    I want it to be a page that appears when "previous creatures" button is clicked. It would show the previous creatures sprite (in reduced size) + the answer given by the player and the points he got for that round. I am sure there is a quite simple way to do this. I just haven't had time to think about it yet. If you have any advice...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oh ok I get it. (Well it's still weird that ".FromID" doesn't work though).

    Well I actually managed to implement the scoring system too and changed the way the "timer" works to what you explained earlier. So now I could say the game is "fully operational". Here is the .capx : https://www. dropbox.com/s/gv08nlsdwl1xbcx/ChatProject.capx?dl=0

    There is still place for improvement though, here is how it works now :

    • When the peercount = "the number of player I want", host broadcasts his timer, then everybody substract 1 every second (it's only visual for peers).
    • When host's timer reaches 0, he broadcasts "timer0" to everyone. He also registers his answer (if not empty) on a dictionary with value 1. And puts "timer" back to 10 seconds.
    • When peers get "timer0", they send their answers to host (if not empty, tag "Answer"). They put their "timer" to 10 seconds too.
    • When host gets "Answer", he adds this to the dictionary (either a new key with value 1 or +1 to an already existing key).
    • When host's "timer" is 9, he checks if the dictionary has a key corresponding to his "Answer.Text". If so, add key value -1 to your score (you don't get a point for yourself). He then broadcasts the dictionary as JSON and peers do the same.

    Note that everybody saves their own answers only with the "Spawn" value for later analyzes purposes. But this has nothing to do with the scoring system.

    My problem here is the last step has to happen at host's timer = 9, which is already 1 second in the next round (so there is a delay between the end of the round and the actual scoring). But when trying with timer=10, it seemed that the host did not have time to get the peers' "Answer" messages. Which is weird, since this should happen at timer = 0, thus, one frame earlier than timer = 10. Also, this would be a problem for scoring the last round (well, it's not really hard to solve that). Do you think this is actually just because it takes time to exchange all those messages ? Do you have a better idea to improve that ? I thought about asking the host to count the answers he gets and set timer to 10 only when that number reaches peercount-1. But then I should allow peers to send empty answers and find another way to exclude those from the dictionary, so nobody get points for not answering.

  • [quote:2z500p6m]Try to set the "Send message" Peer ID to Multiplayer.PeerIDAt(Multiplayer.PeerCount-1).

    (I'll explain that if it actually works)

    It does work . So what is the difference between "Multiplayer.PeerIDAt(Multiplayer.PeerCount-1)" and "Multiplayer.FromID" ?

  • [quote:tpjbgdmw]I would just have the host broadcast one single message that will start a timer for the peers.

    But when would I send this message ? If someone joins after the message was sent, this peer won't have a timer. And for the scoring system I will need to be sure everyone send their answers upon host's signal (on the precise tick when timer reaches 0). Well anyway, this part is working for now. So that's not the most important.

    [quote:tpjbgdmw]try to test whether messages are actually received with a simple debugging text object before changing the actions/methods.

    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.

    Another try with the .capx: https://www. dropbox.com/s/palq7rp46p2k687/ChatProject.capx?dl=0

  • Thank you again for your answer.

    [quote:3mbk4f6l]Also, why don't you just broadcast the variable directly?

    Why does it have to be in the dictionary first?

    It was just an alternative solution I wanted to try because I already tried and failed with sending the variable directly. I also already tried with "int(variable)" but the peers always get 0 (the same problem happened in the thread I sent on my previous message). I will try with "str(variable)" this time, hopefully that will work.

    The "timer" is here so that everybody as X seconds to answer (probably 90 seconds for each creature). I want players to be synchronized on that and the timer to be displayed for them. The first round will be empty of creature, just so players have time to connect and synch with host and exchange a few messages with other players in their group. Then, every 90 seconds the content of "AnswerText" is sent to host and then comes the scoring system (not yet implemented).

    Concerning the dictionnaries, thank you for this simple example, this is what I thought but I wasn't sure. I did not have time to test a lot of stuff and everything failed so far, so I supposed I was doing something wrong.

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

    On the debug, I can see the "Spawn" variable changine exactly as I want to, so I don't think that is the problem. But I may be wrong ^^

    Edit randomly : YEEAAAAAAHHHH !!! The str(variable) worked ! I can't believe I spent so much time on such a trivial thing ! But I guess that is what we call "learning" lol. Thank you ! Next : the scoring system. I will try something and send a new .capx.

    • Arf, actually it doesn't work with the "Group" value. I think I am doing something wrong with the "send message" action. I tried :

    For host : On peer connected >> send message, ID : Multiplayer.FromID, tag : "Group", message "str(GroupGenerator.Next)

    For peer : On peer message, tag "Group", set "Group" to "Multiplayer.Message"

    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.

    "Timer" works fine because I use the "broadcast message" action instead of "send message".

  • Hey ! No problem, it's very cool that you keep answering and helping me <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

    So, concerning the synchronization of global values, this is pretty much the same idea I had (found in this thread : https://www. scirra.com/forum/how-do-i-sync-global-variables-over-multiplayer_t101878). The problem is that the peer always gets a NaN value for the timer. Apparently, there is a problem with sending a variable as a message. The guy in the thread had the same problem and found an alternative solution which is not clearly explained, so I am stuck here.

    I will try the other stuff too and come back. (Just mentioning "randomly" in my edit will give you a notification ?)

    Edit randomly : Concerning the use of families. I looked at your .capx and I understand quite clearly how this work, but still, I can't think of a way to spawn my creatures according to my "Spawn" variable. As you can see in my .capx, I already have a "Creatures" family with all the sprites in it, and I have several events using this like : on start of layout > delete "Creatures" (and that's convenient). I also have the "index" instance variable set accordingly for each sprite, as you explained me. But I don't know how to say to the game "you have to spawn the creature who's "Index" value is egal to the current "Spawn" value". I tried your idea of "picking "Creature" by evaluating "Index = Spawn" but that did not work. That's the only detail that I am stuck with.

    • Concerning the smart random "next" expression. After some testing, it appears to be more simple than what you explained. "Start" expression always give you the lowest possible value in the range (useless in my case), but "next" actually starts from the first value of the sequence. Proof is in this .capx : https://www. dropbox.com/s/5l7ztd8kndlsov8/Next.expression-test.capx?dl=0

    Notice that the two first value you get are always different, which proves they belong to the same loop, thus the first time you click on "next" you really get the first value in the sequence. If you started at the second value, skipping the first one, then you would start at the edge of a loop and have a 50% chance that the first value of the next loop is the same.

    Illustration : with a sequence like 2-1 / 1-2 / 1-2 / 2-1 / ...

    The two first value you get using only "next" is this : 2-1 / 1-2 / 1-2 / 2-1 / ...

    And never : 2-1 / 1-2 / 1-2 / 2-1 / ...

    Which is what I want anyway. So that's cool. Now I have to think of the way to always send the "next" value to every peer upon connection. Of course, I tried "upon peer connected" > send message, tag "Group", message "Groupgenerator.Next". But that wouldn't work since "Groupgenerator.Next" is a number and not a string (damn, that limitation is troublesome).

    Here is another idea I just tried, but it failed (too bad! I was confident this time ah ah) : I created a "GlobalValues" dictionnary. The host task is to add a "Timer" key every second with the value "Timer" (global variable's current value), and add a key "Group" on peer connected, with the value "GroupGenerator.Next". Then, broadcast a message every second, tag "Timer", message "GlobalValues.Get(Timer)" and send a message on peer connected, ID "Multiplayer.FromID", tag "Group", message "GlobalValues.Get(Group)". For the peers : on peer message, tag "Timer"/"Group", set "Timer/Group" (Global variable) to "Multiplayer.message".

    And of course, it doesn't work for both : "Timer" gets a NaN value and "Group" doesn't change at all.

    • Concerning dictionnaries, I think I have a hard time understanding how the informations can be transmitted from host to peer. It seems the "AsJSON" expression is the key, but I don't really get it. For example, I suppose I could send the "GlobalVariables" Dictionnary as JSON and make the peer load it somehow and then set their global values accordingly. But I have troubles with this whole "host transforms into JSON > send to peers > Peers transform back to dictionnary objet" process. I think I would need a concrete example on that one.
  • Hey ! Sorry for the double post, but I have done a lot of changes to the game so I wanted to post the new .capx : https://www. dropbox.com/s/tqpq5zedfi9iw1f/ChatProject.capx?dl=0

    Thanks to your explanations and some testing, this whole multiplayer thing is getting quite clear. I now have a license and two computers connected in LAN to do some testing.

    There are two points with which I am struggling :

    • I can't find a way to synchronize the "timer" global value. Everybody should have the host "timer", but I see no way to broadcast a number value.
    • I can't find a way to send to each peer, upon connection, the next value in the smart random to set there "Group" value.

    And a less important one :

    • Is there a way to simplify the list of 30 events for spawning creatures using family ?

    I feel like dictionnaries and arrays will come in handy here, but I am not yet familiar with those. Anyway, next step will be implementing the scoring system, so I will have to learn about it quite soon.

  • [quote:2vr3wg1l]In case one player disconnects, he simply has to login again with the same alias. The host will then assign the player the group number that is stored under his name in the dictionary.

    Well, actually I don't want them to have an alias since I don't want them to recognize each other in the actual room and try to communicate not using the chat. I deleted that option and made everybody's alias "player" so they will just be called "playerX". But actually, if anybody gets disconnected, then that player just has to connect back several times until he falls back in the right group (they will be informed of which group they are in). With the smart random set like this, it will take at most 3 tries to get back to the right group, so it's not a major problem.

    Concerning the multiplayer, I think some things are a little more clear now, I will try a few things and send another capx soon so you can give me your opinion about it (well, if you want, of course).

    Edit : - Just a naive question on the way smart random works. I see no way to ask for the "first" value in the meaning of "the first of the randomly generated string of value" but only in the meaning "lowest possible value (the opposite of end value)". So I suppose asking for the "next" value for the first time will actually give the first value in the string (and then the second for second time you ask for the "next" and so on). I don't know if I am being clear, but basically, I just want to be sure not to skip the first value everytime I use smart random just because I overlooked something.

    • I know I haven't put every creature sprites in a family yet, but for now I put another smart random on the "spawn" value. So it changes from 1 to 30 (using all values only once before going to game over) as I wanted, but I still have no idea why my ugly big black numbers that I use as sprite for now dont want to appear. Any idea ?

    I simply wanted to create something similar to what is shown here, but I can't figure out what I'm doing wrong : https://www. scirra.com/forum/create-random-object-every-x-seconds_t63037

    ==> Problem solved. I did a long list of 30 conditions to create the 30 sprite at the same time XD. I actually had to just separate them in different events. Yeaaaaah one fewer problem!

    • Actually I have trouble now I am using families (I could get the license, yay !) :

    [quote:2vr3wg1l]Try this:

    Add a family containing all the sprites, e.g."Sprites"

    Add a family instance variable, e.g. "index"

    Edit that variable for every Sprite and set it to the Sprite's number (don't set it in the event sheet, set it in the object properties)

    Delete that long chain of conditions you referred to (Spawn=X, Spawn=Y,...) and replace it by this:

    Image

    ____________________________________________________________

    This does not seem to work, or maybe I am doing something wrong...