Skip to content

how to call a passage with parameters

jackdarker edited this page Apr 10, 2021 · 1 revision

Sometimes you would like to reuse a passage in a way that requires to hand it over some parameters, f.e. a character-inspector-passage that you want to reuse for different characters.
There is no built-in way to call passages with parameters. A simple approch is to create window.story.state.args = [] on initGame and use it to store data there just before the passage is called:
:: PartyScreen
<a href='javascript:void(0)' onclick='window.story.state.args=["Eric"];window.story.show(CharScreen);'> Eric </a> </br>
<a href='javascript:void(0)' onclick='window.story.state.args=["Detlev "];window.story.show(CharScreen);'> Detlev </a> </br>

:: CharScreen
<%=window.story.state.args[0]%>'s Health is <%=window.story.state.[window.story.state.args[0]].health%>
<!--this should print "Eric's Health is 40" and requires window.story.state.Eric.health to exist-->

Clone this wiki locally