Skip to content

How use Rakugo Variables

Rakugo Variables are called RkVar for short. They are global, and accessible from both RkScript and GDScript.

RakuScript

You can define var in RakuScript file, like this:

player.life = 10
You can access it in any RakuScript:
narrator "You have <player.life> life points left"

GDScript

In GDScript you can define RkVars like this:

Rakugo.set_variable("player.life", 10)
You can access it in any RakuScript:
Rakugo.get_variable("player.life")
You can change it:
var life = Rakugo.get_variable("player.life")
life += 5
Rakugo.set_variable("player.life", life)
You can display text with RkVar using Label like this:
expand Label

func update_text():
    var life =  Rakugo.get_variable("player.life")
    text = ("You have %d life points left" % life)

To auto-update text in label using sg_variable_changed signal:

expand Label

func _ready():
    Rakugo.sg_variable_changed.connect(update_text)

func update_text(var_name:String, value):
    if var_name == "player.life":
        text = text = "You have %d life points left" % value