Howdy, Stranger!

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

Keeping a score for replacements/removals

Hi everyone,

I'm stuck on my Twiny Jam game. The player character is a letter-censor. Every time the player removes questionable content from a letter, I want her score to increase. She won't be allowed to proceed to the next letter until a certain number of removals have been made. I can't figure out how to implement this, though. Right now I'm using the replace macro:


Administration insists that this is a refugee camp<<replace>>, but they are up to something frightening<<becomes>><<endreplace>>.


It works, kinda, but it's ugly and the score variable isn't integrated. All I want is for the player's score to increase by 1 when she removes the text ", but they are up to something frightening" so that after, say, 5 similar removals, she'll be allowed to send the letter and move on to the next one. I'm so clueless! Perhaps y'all can help?

Thanks!

Andrew

Comments

  • It's been a long time since I messed with Twine and I hardly recall how to do really much of anything with it.

    However, I jumped in there and took a look. It ended up being pretty simple, but make sure you check out my method.
    Start Passage

    Your favorite color is <<replace>>red<<set $color = "red">><<becomes>>white<<set $color = "white">><<becomes>>blue<<set $color = "blue">><<endreplace>>.

    [[Continue]]
    Continue Passage

    Your favorite color is <<print $color>>.
    I tested that and it worked. See attached files.

    Basically, just put your variable inside the <<replace>>.

    Hope that helps, but if not, let us know. :-)

  • Oh, and in case you're a bit newer to Twine than I assumed when writing the above example, instead of using "$color" or whatever, you might have a "$score" variable with code something like <<set $score += 1>>.

    So, you'd have:
    Administration insists that this is a refugee camp, <<replace>>but they are up to something frightening<<becomes>><<set $score += 1>><<endreplace>>.
    Just as a personal note, it might be more fun to have this take place on a word-by-word basis where censoring the wrong words subtracts from the score as well. Also, I'd "replace" the text not with a blank, but a "strikethrough."

    Check it out:
    Start Passage

    Administration insists that this is a refugee camp, <<replace>>but they are up to something frightening<<becomes>><strike>but they are up to something frightening</strike><<set $score += 1>><<endreplace>>.

    [[Continue]]
    Continue Passage

    Your score is: <<print $score>>.
  • Thanks, Sharpe! This is all helpful. The one thing that still eludes me: I don't want the [[Continue]] link to appear until a certain number of replacements have been made. I tried the following:

    [CODE]<<set $score to 0>>\
    Administration insists that this is a refugee camp<<replace>>, but they are up to something frightening<<becomes>><<set $score += 1>><<endreplace>>.

    <<if $score is 1>>[[Continue]]<<endif>>[/CODE]

    This doesn't work, unfortunately. Any ideas about what I might do differently?
  • Again, I want to be very clear that I'm beyond rusty with Twine and "programming" with it. I was no expert to begin.

    Like I mentioned in PM, loops will help here. See How to Create Loops in Twine.

    The trouble is, when the passage is loaded, your conditional branch returns false so it doesn't show. Your score variable increases with player clicks, but the passage isn't re-loaded and thus, neither is the conditional branch.

    Since you're on a deadline, this may not be the greatest news, but my suggestion regarding loops was meant largely as a replacement for the Replace macro. Loops will solve this problem, and they are quick, simple and legible, but this is a different method entirely than using the Replace macro so all your work, indeed every passage using this censorship method need reworked slightly.

    In a loop, each word or phrase to be censored would be a (setter) link to the same passage causing the whole passage to reload. CSS can be used to make it seamless, but . . .

    Do read my tutorial and become familiar with the process. It's not difficult to understand or implement, but I know, it's just one more thing under pressure.

    When's the deadline?
  • I think, given the fact that you're on a deadline, what you probably want to do for this is to either use SugarCube (http://www.motoslave.net/sugarcube/docs/macros.html#macros-replace) or use Harlowe in Twine 2.0 (http://twinery.org/forum/index.php/topic,2593.msg8301.html) and then increment the score, not when you try to do replace, since that doesn't work, but when the user clicks the link.

    Does that make sense? I offer these as solutions, because I suspect the <<replace>> you're using (which I assume is this: http://www.glorioustrainwrecks.com/node/5462) doesn't have any mechanism to target what you want to replace, and to the best of my knowledge even the <<revise>> macro, part of that set, can't independently act upon the passage and the [[Continue]] link below it.
  • Sharpe, is this sort of like what you had in mind? It works!

    [code]/*excerpt from "letter1"/*

    Dear Maggie,

    Administration insists that this is a refugee camp<<if $a neq 0>>.<<else>>[[, but they are up to something frightening.|letter1][$a+=1, $q+=1]]<<endif>>

    Buses<<if $b neq 0>> <<else>>[[ with secret itineraries |letter1][$b+=1, $q+=1]]<<endif>>take people away at night.

    The guards have been<<if $c neq 0>> <<else>>[[ armed, and are |letter1][$c+=1, $q+=1]]<<endif>>strictly enforcing curfew.

    /*and at the bottom, for example/*

    <<if $q gt 2>>Love,

    [[Robert|letter2]]<<endif>>[/CODE]

    Check out the attachments to see the complete (but unfancy) letter1. I'm going to try using strikes for link hover and see how it looks.

    Thank you so much! The backtracking was worth it. Twiny Jam ends tonight, but I'll have something decent, I think.

    And nicolem, thanks for weighing in. I'm too much of a Sugarcane/1.4.2 dinosaur to mess with SugarCube or Harlowe tonight, but I have been itching to do some work in Twine 2.
  • Yep! That was it, my man!  ;D

    Good luck with the jam!  :D
Sign In or Register to comment.