Storage temporaneo
You can read more about temporary variables in ink on the official documentation.
Sometimes a global variable is unwieldy. ink provides temporary variables for quick, local calculations. Unlike global variables (VAR), a temporary variable is discarded as soon as the story leaves the knot or stitch in which it was defined.
In the ink + Pixi'VN integration, temp variables are equivalent to temporary variables in storage.
Define
This functionality in Javascript/TypeScript corresponds to temporary variables in storage.
Declare a temporary variable with the temp keyword inside a ~ logic line:
~ temp myTemp = 42You can use any type that ink supports: integer, floating point, boolean, or string.
=== near_north_pole ===
~ temp number_of_warm_things = 0
{ blanket:
~ number_of_warm_things++
}
{ ear_muffs:
~ number_of_warm_things++
}
{ gloves:
~ number_of_warm_things++
}
{ number_of_warm_things > 2:
Despite the snow, I felt incorrigibly snug.
- else:
That night I was colder than I have ever been.
}The variable number_of_warm_things is created when the knot is entered and thrown away when it is left.
Imposta
This functionality in Javascript/TypeScript corresponds to storage.set.
After the initial declaration you can reassign a temporary variable with the same ~ syntax (without repeating the temp keyword):
~ temp score = 0
~ score = score + 10
~ score++Ottieni
To get a temporary variable, use the normal storage.get function.
Inside ink itself, you read a temporary variable exactly the same way as any other variable – by using its name in an expression, inline print, or condition:
~ temp duration = 3
The duration is: {duration}
{ duration > 2:
It's a long scene.
- else:
It's a short scene.
}