In TyranoScript, you can use variables.
A variable is essentially a container that stores something.
That "something" can be, for example:
・The protagonist’s name entered by the player
・A character's affection level
・Flag management
These are just a few examples. The phrase "a flag is raised" has become fairly common in games and storytelling.
TyranoScript allows you to use the following three types of variables:
Let’s take a look at some actual code:
;Assign a number to a game variable
[eval exp="f.flag1 = 1000"]
;Assign a string to a system variable
[eval exp="sf.variable1 = 'string'"]
;Assign a value to a temporary variable
[eval exp="tf.flag1 = f.flag2"]
[iscript]
f.flag1 = 1000
sf.variable1 = 'string'
tf.flag1 = f.flag2
[endscript]
In TyranoScript, you can freely assign names to variables. However, please follow the rules below:
・Variable names can include alphanumeric characters, full-width characters, and underscores (_).
(Example) f.flag_test, sf.your_name_3
・Variable names cannot start with a number.
(Example) × f.3name is not allowed
If you want to perform calculations:
[eval exp="f.flag1 = f.flag1 + 1"]
[eval exp="f.flag1 = f.flag1 + f.flag2 * f.flag3"]
The result of f.flag2 multiplied by f.flag3 is added to f.flag1 and stored in f.flag1.
[eval exp="f.flag2 = 'hoge'"]
[eval exp="f.flag3 = 'une'"]
[eval exp="f.flag1= f.flag2 + f.flag3"]
To delete a variable, use `delete variable_name`. For example, to delete `f.flag1`, write:
[iscript]
delete f.flag1;
[endscript]
If you want to display the value of a variable in your scenario, use the [emb] tag.
For example:
[cm]
[eval exp="f.num=200"]
[eval exp="f.mojiretu='Hello there'"]
Contents of f.num : [emb exp="f.num"][l][r]
Contents of f.mojiretu : [emb exp="f.mojiretu"][l][r]
The entity feature allows you to substitute variable values into other tag attributes.
To do this, prefix the variable name with an `&` symbol within the attribute value.
;Assign text to a temporary variable
[iscript]
tf.title = "This is a test"
[endscript]
;Use the assigned variable as the value for the text attribute — "This is a test" will be displayed on screen
[ptext layer=1 page=fore text=&tf.title size=30 x=180 y=150 color=red ]