Hello, I am sending data with json but I think it is not receiving, where is my mistake? Can you hel

Not favoritedFavorited Favorited 0 favourites
  • 7 posts
From the Asset Store
The soundstage is set for an immersive listening experience sending your audience adrift.
  • Hello, I am sending data with json but I think it is not receiving, where is my mistake? Can you help me? google translate

    {"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"on-message","objectClass":"WebSocket"},{"id":"compare-two-values","objectClass":"System","parameters":{"first-value":"JSON.Get(\"command\")","comparison":0,"second-value":"\"spawnTNT\""}}],"actions":[{"id":"create-object","objectClass":"System","parameters":{"object-to-create":"spawnTNT","layer":"0","x":"0","y":"0","create-hierarchy":false,"template-name":"\"\""}},{"id":"wait","objectClass":"System","parameters":{"seconds":"1","use-timescale":true}},{"id":"parse","objectClass":"JSON","parameters":{"data":"WebSocket.MessageText"}},{"id":"create-object","objectClass":"System","parameters":{"object-to-create":"usernameText","layer":"0","x":"spawnTNT.X","y":"spawnTNT.Y","create-hierarchy":false,"template-name":"\"\""}},{"id":"set-text","objectClass":"usernameText","parameters":{"text":"JSON.Get(\"user\")"}}]}]}
    
  • Hey there.

    It looks like you're trying to access the data before parsing the WebSocket message. The parse needs to come first.

  • Hey there.

    It looks like you're trying to access the data before parsing the WebSocket message. The parse needs to come first.

    Thank you very much for your answer. I am trying to do it with the help of artificial intelligence, I think the parsing you mentioned is there, but it still does not write data, or it does not pass at all. If it were coming, do you think this is correct? google translate

    	{"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"on-start-of-layout","objectClass":"System"}],"actions":[{"id":"connect","objectClass":"WebSoket","parameters":{"url":"\"ws://127.0.01:8080/\"","protocol-optional":"\"\""}}]},{"eventType":"block","conditions":[{"id":"on-message","objectClass":"WebSoket"},{"id":"compare-two-values","objectClass":"System","parameters":{"first-value":"JSON.Get(\"message\")","comparison":0,"second-value":"\"spawnTNT\""}}],"actions":[{"id":"parse","objectClass":"JSON","parameters":{"data":"WebSoket.MessageText"}},{"id":"set-text","objectClass":"usernameText","parameters":{"text":"JSON.Get(\"user\")"}},{"id":"set-text","objectClass":"usernameText","parameters":{"text":"WebSoket.MessageText"}},{"id":"set-from-json","objectClass":"debugText","parameters":{"json":"WebSoket.MessageText"}}]}]}
    
  • {"is-c3-clipboard-data":true,"

    You know that we can't paste your code without adding all the same objects first? Next time please post screenshots.

    Try this:

  • > {"is-c3-clipboard-data":true,"

    You know that we can't paste your code without adding all the same objects first? Next time please post screenshots.

    Try this:

    Thanks for the reply. Is this done correctly? If it is, I guess I can't send data. The text is not updated.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • > > {"is-c3-clipboard-data":true,"

    >

    > You know that we can't paste your code without adding all the same objects first? Next time please post screenshots.

    >

    > Try this:

    >

    >

    >

    >

    >

    Thanks for the reply. Is this done correctly? If it is, I guess I can't send data. The text is not updated.

    I noticed my mistake here, I corrected it but I still couldn't get it to work. If the layout is correct, I guess I can't send data. Thank you for your answers.

  • "debugText Set from JSON" is incorrect! Use "debugText Set Text" action.

    After you fix that, if nothing appears in the debugText, this means the Websocket doesn't receive any text data. You can also press F12 and check for errors in the console.

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)