[Suggestion] Auto convert numbers to strings

0 favourites
  • 3 posts
From the Asset Store
A collection of a mix of percussion and orchestral string loops, including 20 musical sketches.
  • Hi. When I tried to send numbers via a Multiplayer.SendMessage action or when I try to GoToLayout.ByName and use a integer/number variable nothing happens. I have to add "str(VARNAME)" to make it work. Do you think it would be possible and/or better to auto convert such numbers to a string if a string is needed by the action and vice versa? If a number is needed a string could become a number so the math or other code works.

    Some coding environments I used in the past have such a system and made it very easy to use variables with the "wrong" format and it can save you some time.

    Or are there any disadvantages or problems with this?

  • Having experience creating (multiplayer) plugins I can say that certain input expressions need to be explicitly in a certain format (string,int,etc) so as not to break the functionality of the object. The plugin parameter types are a predefined by the creator of the plugin as to what it will accept "paramAny, paramNumber, paramString" usually for a reason. In the case of multiplayer message (where i have a lot of experience) the problem you would have is that if you try to send a number it will always have to be converted to a string before being sent by the plugin. So when its received on the other end you will get a string in stead of the int you sent any way. You would have to convert it back to an int on the other end regardless.

    The best method for maintain data types for string transmission is JSON. With out any 3rd party plugins the easiest way to pass data is to load it into a dictionary, send the dictionary AsJSON and then when the peer receives it that load that JSON back into a dictionary and act on the data. By doing it this way you can maintain data types and can send complex instructions all in a single transmission. I can say with certainty that its just as fast and completely reliable as i do all of my multiplayer data transmission in this format.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here you go

    var = "string" & 1337

    C2 uses "&" for concatenation rather than "+"

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