Howdy, Stranger!

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

(Solved) Updating variables and/or redisplaying links without moving

edited July 2014 in Help! with 1.x
Hi there,

I'm trying to create a passage where some links move to other passages (as usual), while others simply update a variable or run a script without moving the character. Ideally I'd want the links of the current room to then be redisplayed.

I'd also like links that just print text and then refresh the links, again without moving.

So, as an example, you're in a spaceship outside the door to the bridge. There's the room description as normal:
"You're outside the bridge bulkhead, which is firmly shut. An access panel is here."

Go back down the corridor
Use the panel
Access the bridge
The corridor link is a normal link.
The bridge link should test if $bulkheadLocked is true or false. If true, it should print a quick message ("The bulkhead is sealed."), and then the three links should be redisplayed without redisplaying the description. If false, it should act like a normal link to the bridge passage.
The use panel link should toggle $bulkheadLocked, display a confirmation message ("The panel clicks in response and the door locks/unlocks".), and as before redisplay the three links without moving the player.

Does anyone know how to achieve this result? I can't seem to find any way to have a link that doesn't move the player into a different room. Many thanks in advance!

Comments

  • I don't see using the built-in macros will be of use here, you may need to use JavaScript to this. Assign each link with a a href and id like so:

    <div id="content">"You're outside the bridge bulkhead, which is firmly shut. An access panel is here."</div>

    <a id="corridor" href="#">Link 1</a>
    <a id="panel" href="#">Link 2</a>
    Then using a different passage, try the following:

    //requires jquery
    $('#panel').click(function(e) {
    $('#content').html('Here, I am replacing this content with ' + myVariable + ' this variable.');
    });
    Play around with that. Your second passage needs to have the word 'script' in the tags for it to function.
  • The SugarCube story format has the click macro.

    It looks like a link but can be used to modify the contents of the existing passage if combined with the append / replace / remove macros.

    A simple example can be found here
  • Thank you both, the click macro looks like exactly what I'm after!
Sign In or Register to comment.