In v2 the monogatari.run("") function will invoke monogatari actions. You can see an example of this in action in this demo game I've made for you.
https://newrem.com/monogatari/helpExamples/monogatariDotRun/index.html
The script.js file : https://newrem.com/monogatari/helpExamples/monogatariDotRun/js/script.js
monogatari.script ({
// The game starts here.
'Start': [
`y In Monogatari, you can invoke actions using the monogatari.run() method.`,
{'Function':{
'Apply': function () {
monogatari.run("y Take a look at the script.js file for this game to see an example!");
return false;
},
'Reverse': function () {
monogatari.run("y Take a look at the script.js file for this game to see an example!");
return false;
}
}},
`y Remember to return false in any function that runs a line of dialog! Failing to do this will make the function just immediately jump ahead to the next line and it will feel like it skipped it.`,
`y I hope you make a great game with that tip!`,
]
});
For this example we used a reversible function so that if the player clicks the "back" key, they can go back. If we just used a basic anonymous function(){} it would always go forward on that line.
This is, of course, quite flexible. You can make some elaborate functions to do things. You can also make infinite loops where you jump back to the start of a label that just contains the function and the jump, and then have that function be really complex and do all sorts of things with an ultimate condition that escapes the label, such as if you wanted to make a battle minigame that uses the basic monogatari text box, or something cool like that. Get creative!
Hope that helped!