solution for ignoring the empty tags
Closed this issue · 0 comments
allaze-eroler commented
hello, i managed to add a small snippet code that will help the main.js ignore the class tags who don't have any contents when creating new paragraphs.
you need to add these directly after the CLEAR and RESTART tags like this:
// CLEAR - removes all existing content.
// RESTART - clears everything and restarts the story from the beginning
else if( tag == "CLEAR" || tag == "RESTART" ) {
removeAll("p");
removeAll("img");
// Comment out this line if you want to leave the header visible when clearing
setVisible(".header", false);
if( tag == "RESTART" ) {
restart();
return;
}
}
}
/* ------------ important part of code ------------ */
// Check if paragraphText is empty
if (paragraphText.trim().length == 0) {
continue; // Skip empty paragraphs
}
this way, each time the script check the details from the story.js, it will simply and ignore and skip all the empty tags
here the results:
this is before the added code:
as you can see, you will be able to use your own CSS styling without clashing with the other classes. otherwise, it would use the last class used for css styling. i hope it will help you out!