Howdy, Stranger!

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

Remove selector problem.

Sugarcube 2.11.0

I'm sorry, I did try and I've made what sense I can of the documents.

I want to have the sentence: "Among the debris, though, a lone sparkplug" (where sparkplug is a link).

On click, I want the whole of that line to disappear and be replaced with: "Sparkplug taken."

This is what I've managed to botch up, but on running it the replacement sentence just says: "Sparkplug"

For the life of me I can't understand why the word 'taken' isn't being displayed.
The inside has been wrecked. Rubble, broken glass and shelving is strewn everywhere.

<span id="plug">Among the debris, though, a lone </span><<link "sparkplug">><<remove "#plug">><br>Sparkplug taken.<</link>>

Comments

  • edited November 2016
    Jud_Casper wrote: »
    Sugarcube 2.11.0

    I'm sorry, I did try and I've made what sense I can of the documents.

    I want to have the sentence: "Among the debris, though, a lone sparkplug" (where sparkplug is a link).

    On click, I want the whole of that line to disappear and be replaced with: "Sparkplug taken."

    This is what I've managed to botch up, but on running it the replacement sentence just says: "Sparkplug"

    For the life of me I can't understand why the word 'taken' isn't being displayed.
    The inside has been wrecked. Rubble, broken glass and shelving is strewn everywhere.
    
    <span id="plug">Among the debris, though, a lone </span><<link "sparkplug">><<remove "#plug">><br>Sparkplug taken.<</link>>
    

    I'm not sure if you want the "Sparkplug Taken" to be a Link, or not, but - here's an updated version of your code that works.
    @
    

    The way this code works, it sets up the 'span' id of plug - and encases that whole text you want to 'disappear', and replaces it with the "Sparkplug Taken". It's in the formatting Markup of Sugarcube documentation. It took me a few tries before I figured out how to use this properly.
  • edited November 2016
    Thank you very much - that's exactly what I wanted.

    I'd never have found that, even though you say it's there. I think half the time the problem is I don't know what I need to be looking for in the first place.

    I'd got as far as realising I needed to be encasing the <<linkreplace>> in there, but it wasn't replacing the sentence with the 'Sparkplug taken'.

    @# to set the span id? I've never seen its use before.

    Thanks again, that was driving me mad.

    Ah! Just realised I was using 'remove #plug' and not 'replace'.
  • edited November 2016
    Basically this is how I found out - http://twinery.org/forum/discussion/6517/passage-help-hiding-some-text-in-a-long-passage-then-replacing-the-visible-with-the-hidden-text (I created a post where I was trying to find out how to get a long passage trimmed into smaller chunks for people to read at one time. I'm wordy. ;))

    And this is the direct link to the markup documentation: http://www.motoslave.net/sugarcube/2/docs/markup.html

    It's near the bottom under Custom Markup

    @'s with #name; becoming the equivalent of <span id = "">, but it's a condensed way of doing it, and much easier imho. Plus you need to have closing macros in the right order, like <<link>> content <<replace "#name">> <</replace>> <</link>>.
Sign In or Register to comment.