inkle / inky

An editor for ink: inkle's narrative scripting language
http://www.inklestudios.com/ink
2.36k stars 289 forks source link

solution for ignoring the empty tags #490

Closed allaze-eroler closed 1 month ago

allaze-eroler commented 10 months ago

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: msedge_FJUxZERSbj

this is after the added code: msedge_6vPX1kjOwS

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!