Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Could use some help with the replace command.

edited February 2016 in Help! with 2.0
So I am trying to make a basic text game involving combat. I am doing this on Sugarcube.
I am currently trying to get a working combat menu but it is being difficult.
I will have a basic scene description at the top and then have the combat system linked from other pages below. I have the combat system on other pages so I can use it for future combat sections, to save having to retype it needlessly.
I have been trying to achieve this with the replace command.

Firstly I tried this:
<span id="miniscene"></span>
<<replace "#miniscene">><<display "Combat Commands">><</replace>>
However turns out that wont trigger on page load which is what I wanted.

Next I combined it with a click command:
<span id="miniscene"></span>
<<click "Start Combat Round.">><<replace "#miniscene">><<display "Combat Commands">><</replace>><</click>>

This works and brings up my "Combat Commands" scene which in turn has :
<<click "Attack">><<replace "#miniscene">><<display "Attack Selection">><</replace>><</click>>
at the moment. I plan on adding defend and run, but they will work in a similar way.

When I click on Attack it replaces the Combat Commands scene that was displayed with the Attack scene like I want it to.

The problem is the Start Combat Round clickable link remains and isn't replace at any point, so it stays there. Is there any way to get the clickable link for Combat Round replaced by the Combat Command scene like I want it to?


  • edited February 2016
    Try changing your first example to the following, it will insert the contents of the Combat Commands passage between the miniscene span's open and close tags:
    <span id="miniscene"><<display "Combat Commands">></span>
    ... now you won't need your second example and your third example should just work.

    The <<replace "#miniscene">> macro call can only replace content that is between the miniscene span's open and close tags, so if you still want your second example you will need to change it to something like:
    <span id="miniscene"><<click "Start Combat Round.">><<replace "#miniscene">><<display "Combat Commands">><</replace>><</click>></span>
  • That sorted it out nicely. Thank you!
Sign In or Register to comment.