Use the characters in ink
You can associate a Pixi’VN character with a dialogue in ink. To do this, you need to create a or more characters in Typescript and, after that, in the ink script, you can use following syntax:
character_id
+ :
+ SPACE
+ text
=== start ===
egg-head: Hello, I'm Egg.
-> DONE
Use Character Emotions in ink
You can use the Pixi’VN Character Emotions in ink. To use the character emotions in ink, you need to create a or more characters with an emotion in Typescript and, after that, in the ink script, you can use following syntax:
character_id
+ @
+ emotion
For example, you can associate this character with a dialogue using the following syntax:
character_id
+ @
+ emotion
+ :
+ SPACE
+ text
=== start ===
liam_id@happy: Hello, I'm Liam and I'm happy.
-> DONE
Use Character how variable in ink
Having the ability to rename a character and use their name in dialogues greatly simplifies the development of a Visual Novel. Since the character is an object based on a customizable model, it is not possible to use the character as a variable simply with the {}
syntax.
But you can take advantage of the possibility of replacing portions of text and customizing hashtag scripts to implement this feature.
Use character name in dialogues
To use the character name in dialogues, you can take advantage of the possibility of replacing portions of text. For example, you can use the following method:
import { onReplaceTextAfterTranslation } from '@drincs/pixi-vn-ink'
import { getCharacterById } from "@drincs/pixi-vn";
onReplaceTextAfterTranslation((key) => {
let character = getCharacterById(key)
if (character) {
return character.name
}
// if return undefined, the system will not replace the character id
return undefined
})
Edit character name in dialogues
To edit the character name in dialogues, you can take advantage of the possibility of customizing hashtag scripts. For example, you can use the following method:
import { onInkHashtagScript } from '@drincs/pixi-vn-ink'
onInkHashtagScript((script, convertListStringToObj) => {
if (script[0] === "rename" && script.length === 3) {
let character = getCharacterById(script[1])
if (character) {
character.name = script[2]
}
return true
}
return false
})