License from €75
DE EN FR ES IT CZ

Printing string values

This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials

  1. · 7 years ago
    I'm making a first few baby steps into scripting and ended up in front of a wall.
    I'd like to print a string value in a line of displayed text, which, according to the wiki, shouldn't be much different from printing an integer:
    < vs=string_I'd_linke_to_print >

    (spaces before and after brackets intentional, as I suspect the forum to interpret it as code otherwise)
    What I haven't figured out yet is how to create the value in the first place and how to change it to contain the string I'd like it to have.
    My copy/paste experiments from what I found on the site and in the forum led to something like this to set up the value:
    val:setValue(VValueString, "string_I'd_like_to_print")
    And this to change the string:
    Values["string_I'd_like_to_print"].String = "String content to be printed"
    However, this only results in a "?" being printed.
    Could someone more capable than me please point me in the right direction? :-/
  2. Working on a game?

    The free version covers up to 25 scenes per project. For more scenes and to sell your game, you need a license.

    See licenses Try it for free
  3. · 7 years ago
    You can create values anywhere inside of the editor that has a values tab. You should always try to give them unique names. You can specify a default string value when you create a value in the editor, but if you want to edit the value while the game is running then you have to do that via script.

    Ok, so let's say you in the values tab belonging to a scene that you create a value & call it "example", & you set the string value as "hello world".

    So now to access that inside of a display text you would do...
    <vs=example>

    Quick note #1: names are case sensitive.

    To update the string belonging to the value, you need to create an execute a script action part somewhere, then you can insert something like this into it (again names are case sensitive) ...

    Values["example"].String = "the mouse ran up the clock"


    or if the value belongs to the current scene you could direct access it with game.CurrentScene, like so...
    
    
    game.CurrentScene.Values["example"].String = "the mouse ran up the clock"



    Quick note #2: always use unique names otherwise you might prevent yourself from being able to globally access things as the engine will get confused about which thing to access if more than one instance with the same name exists unless you directly link to it.
  4. · 7 years ago
    Thanks a lot; I didn't understand that you have to specifically create a value in the tab and can handle this as an integer as well as a string. Works fine now. :-)
  5. · 7 years ago
    <v=example> returns the integer (number part of a value)
    <vs=example> returns the string (text part of a value)

This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.

New thread

Really delete this post?