Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)

Hello Yuna, it's easy to do, but you'll have to use a call function to set the name.

First, the characters have two names, an id, which is used in the script, and a name that will be shown in the name box. The id can never change, so if you have a character that represents the player, you can use, for example, "player" as the id. What you need to do is change the name property of the character so that when you make them talk, the new name will appear in the name box, instead of "player".

The characters are their own object, and the property for the display name is called "name". The characters are all stored in a map, accessible from the Character Manager (RenJS.chManager.characters), and you access each one indexed by their id. On the other hand, the variables are stored also in a map, in the Logic Manager (RenJS.logicManager.vars). Knowing this, it's easy to make a custom function to change a character name.

I'll give you an example with the Quickstart. The character with id "deuzi" has a displayName property defined in the setup as "Deuzilene".

Setup.yaml

characters:
  deuzi:
    displayName: Deuzilene
    speechColour: "#ca90cf"
    looks:
      normal: assets/characters/Char3Normal.png
      happy: assets/characters/Char3Happy.png

Story.yaml

start:
  - play morningBGM:
  - show room: WITH FADE CONTINUE
  - show deuzi: happy AT CENTER WITH FADE
  - var username: Sandrine
  - deuzi says: I prefer to be called by my middle name, {username}.
  - call changeName:
      character: deuzi
      name: username
  - deuzi says happy: That's much better!

In this case I just used a normal variable to store the new name, but you will use the one obtained from the input. The new name will appear only after calling the function changeName, with two parameters, the character id (deuzi), and the variable where we have the new name (username). In this way, you can change any name you want. Finally, let's see what's inside the changeName function:

CustomContent.js

RenJS.customContent = {
    //put here your own functions
    changeName: function (params) {
        //params is a map with {character,name}
        //lookup of the character with "character" id
        var character = RenJS.chManager.characters[params.character];
        //lookup the content of the variable with "name" id
        var newName = RenJS.logicManager.vars[params.name];
        //change the character name property
        character.name = newName;
        //continue with the game
        RenJS.resolve();
    }
}

Hope you can make it work, and let me know if there's more I can help you with.

Cheers!

Luna

Hello Luna

It worked, I'm really happy !

Thank you very much Luna for your fast help and also for developping RenJS. I always wanted to make my own visual novel and i really enjoy using this.

Yuna ~