If you are requesting technical assistance with Twine, please specify:
Twine Version: 2.3.14
Story Format: Sugarcube 2.34.1
I’m trying to make a basic dynamic descriptor system that will fill out an appearance description based on the value of certain descriptor variables. I currently have it working correctly with the following code as well as having it set to redirect to another passage when any of the variables go over a certain value.
setup.test = function()
{
var text
if(State.variables.test == 0)
{
text = “Placeholder”
}
else if(State.variables.test > 0 && State.variables.test <= 2)
{
text = “Placeholder”
}
else if(State.variables.test > 2 && State.variables.test <= 4)
{
text = “Placeholder”
}
else if(State.variables.test > 4 && State.variables.test <= 6)
{
text = “Placeholder”
}
else if(State.variables.test > 6 && State.variables.test <= 8)
{
text = “Placeholder”
}
else if(State.variables.test > 8 && State.variables.test <= 10)
{
text = “Placeholder”
}
else if(State.variables.test > 10 && State.variables.test <= 12)
{
text = “Placeholder”
}
return text
}
var oneThreshold = 13;
// Force the player to the “Too Much blank” passage if they let the variable get too high.
Config.navigation.override = function (dest) {
var sv = State.variables;
if (sv.test1 >= oneThreshold) {
return "Too Much test";
}
if (sv.test2 >= oneThreshold) {
return "Too Much test";
}
if (sv.test3 >= oneThreshold) {
return "Too Much test";
}
if (sv.test4 >= oneThreshold) {
return "Too Much test";
}
};
However For the more detailed descriptions I’d like to use That would mean taking up a LOT of space in that code with just raw text. So i was trying to figure out how i could, instead, just write the descriptions i want in standalone twine passages and have the javascript Print those passages wherever I’m telling it to print that particular variable.
so instead of it printing text in the [text = “Placeholder”] space in the code, it would call up and print the content in a [[Description One]] passage. That way i don’t have to have a bunch of raw text in the code itself.
however I’m a total noob at javascript and barely know how to minorly edit code other people give to me to copy paste, lol. So I’m unsure exactly how to do it. Any advice would be appreciated.