Howdy, Stranger!

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

[Harlowe]Have I Not Placed The (stop:) Macro In The Correct Places?

Hi. I have made this for the start of my game. It uses (live:) macros, and I thought I places the (stop:) macros in the right place. Basically, I just want the text to show, then go on to the next bit of text. I don't know why this isn't working. Here's my code. If anyone was kind enough to look through it and give me a version with the (stop:) macros in the right place then that would be awesome!
{
(print: "<script>$('html').removeClass(\)</script>")
(if: (passage:)'s tags's length > 0)[
(print: "<script>$('html').addClass('" + (passage:)'s tags.join(' ') + "'\)</script>")
]
}|newGame>[I was born at sea.]
(live: 2s)[(replace: ?newGame)[I was born at sea for a reason.
(live: 2s)[(replace: ?newGame)[I was born at sea, to live at sea.
(live: 2s)[(replace: ?newGame)[To fight at sea.
(live: 2s)[(replace: ?newGame)[To rule the sea...
(live: 3s)[(replace: ?newGame)['Oh, he's a lovely young boy, isn't he!' exclaimed your mother.(live: 2s)[
'Yes, he most certainly is.' agreed your father, looking down at you as a baby and smiling, just as your mother did. (link: "'But what to call him is the question.'")[(replace: ?newGame)[(color: "red")[
{(link: "(either: 'Daniel','Francis','Charles')")[(set: $name to (prompt: "Please Enter A First Name:"))]}

{(link: "(either: 'East','Kenway','Drake')")[(set: $sname to (prompt: "Please Enter A Surname:"))]}

{(link: "(either: 'Ruler of Seas','Killer of Kings','The Champion','Death','Ruler of Seas','Killer of Kings','The Champion','Death','Ruler of Seas','Killer of Kings','The Champion','Death','Ruler of Seas','Killer of Kings','The Champion','Death','Ruler of Seas','Killer of Kings','The Champion','Death','Ruler of Seas','Killer of Kings','The Champion','Death','The Black Pearl')")[(set: $ship to (prompt: "Please Name Your Ship:"))]}]
(if: $name is 0)[](else:)[(if: $sname is 0)[](else:)[(if: $ship is 0)[](else:)[
[[Accept ->Story]]]]]]]](stop:)]](stop:)]](stop:)]](stop:)]](stop:)]](stop:)

Comments

  • Some basic background information:

    1. The <script> related code you have at the start (first five(ish) lines) of your example looks like it may of come from the Basic Harlowe Passage Tag Based Styling thread, it is not meant to be used within a standard passage, it is meant to be used within a header tagged special passage. You should remove it from this passage.

    2. A (stop:) macro must be used within the associated hook of the (live:) macro it is stopping.
    (live: 1s)[
    	(stop:)
    ]
    

    3. It is generally not a good idea to have multiple (live:) macros on a single page/passage, a better way to implement the effect you want is to use a single (live:) macro and to use (if:)/(else-if:) macros to check how much 'total time' has passed.
    (set: $tick to 0)
    (live: 1s)[
    	(set: $tick to it + 1)
    	
    	(if: $tick is 2)[First action]
    	
    	(elseif: $tick is 4)[Second action]
    
    	(elseif: $tick is 6)[Third action]
    
    	(elseif: $tick is 8)[Forth action]
    
    	(elseif: $tick is 11)[Fifth action]
    
    	(elseif: $tick is 13)[
    		Sixth action
    		(stop:)
    	]
    ]
    

    4. The (prompt:) macro returns an empty String value if the Reader/Player does not enter their own value. The following test can be used to check this, just leave the field empty and click on either the Ok, Cancel or little X button to close the prompt dialog.
    {
    (set: $var to (prompt: "some input"))
    (if: $var is 0)[The variable equals zero]
    (else-if: $var is "")[The variable equals an empty String]
    (else:)[The Reader/Player actually entered a value: $var]
    }
    

    ** The next two points are semi-related to each other and to point 4.

    5. Don't use an (if:) macro with an empty associated hook combined with an (else:) macro to test if a condition is not true (false), that is what the not Boolean operator is for.
    {
    (set: $var to (prompt: "some input"))
    (if: not ($var is ""))[The Reader/Player actually entered a value: $var]
    }
    

    6. You can use the b]and[/b] Boolean operator to test multiple conditions one after another.
    {
    (set: $name to (prompt: "Please Enter A First Name:"))
    (set: $sname to (prompt: "Please Enter A Surname:"))
    (set: $ship to (prompt: "Please Name Your Ship:"))
    
    (if: not ($name is "") and not ($name is "") and not ($ship is ""))[name: $name, sname: $name, ship: $ship]
    (else:)[You need to enter a value for all three prompts]
    }
    

    7. An (if:)/(else-if:) macro is not automatically re-evaluated if the associated variable is changed, this means that you need to do that yourself manually.

    So based on the above information a possible solution could look something like the following, it is made up of two passages.

    A. Your story's first passage:
    {
    (set: $name to (either: 'Daniel','Francis','Charles'))
    (set: $sname to (either: 'East','Kenway','Drake'))
    (set: $ship to (either: 'Ruler of Seas','Killer of Kings','The Champion','Death','Ruler of Seas','Killer of Kings','The Champion','Death','Ruler of Seas','Killer of Kings','The Champion','Death','Ruler of Seas','Killer of Kings','The Champion','Death','Ruler of Seas','Killer of Kings','The Champion','Death','Ruler of Seas','Killer of Kings','The Champion','Death','The Black Pearl'))
    
    }|newGame>[I was born at sea.]
    {
    (set: $tick to 0)
    (live: 1s)[
    	(set: $tick to it + 1)
    	
    	(if: $tick is 2)[
    		(replace: ?newGame)[I was born at sea for a reason.]
    	]
    	(elseif: $tick is 4)[
    		(replace: ?newGame)[I was born at sea, to live at sea.]
    	]
    	(elseif: $tick is 6)[
    		(replace: ?newGame)[To fight at sea.]
    	]
    	(elseif: $tick is 8)[
    		(replace: ?newGame)[To rule the sea...]
    	]
    	(elseif: $tick is 11)[
    		(replace: ?newGame)['Oh, he's a lovely young boy, isn't he!' exclaimed your mother.]
    	]
    	(elseif: $tick is 13)[
    		(stop:)
    		(append: ?newGame)[<br>'Yes, he most certainly is.' agreed your father, looking down at you as a baby and smiling, just as your mother did.<br>
    (link: "'But what to call him is the question.'")[
    	(replace: ?newGame)[(display: "Choose Name and Ship")]
    ]
    ]
    	]
    ]
    }
    

    B. The Choose Name and Ship passage, this is where the 'tricky' stuff happens. lol

    The first three (if:) macros are catering for the case where the Reader/Player does not enter a value for a prompt, this would cause nothing to be shown for the related link which would make it difficult to click on.
    {
    (if: $name is "")[(set: $name to "click here")]
    (if: $sname is "")[(set: $sname to "click here")]
    (if: $ship is "")[(set: $ship to "click here")]
    
    }(color: "red")[\
    First Name: (link: $name)[
    	(set: $name to (prompt: "Please Enter A First Name:"))
    	(replace: ?newGame)[(display: "Choose Name and Ship")]
    ]
    
    Surname: (link: $sname)[
    	(set: $sname to (prompt: "Please Enter A Surname:"))
    	(replace: ?newGame)[(display: "Choose Name and Ship")]
    ]
    
    Ship's Name: (link: $ship)[
    	(set: $ship to (prompt: "Please Name Your Ship:"))
    	(replace: ?newGame)[(display: "Choose Name and Ship")]
    ]
    
    {
    (if: not ($name is "" or $name is "click here") and not ($name is "" or $sname is "click here") and not ($ship is "" or $ship is "click here"))[ [[Accept ->Story]]]
    (else:)[''Please supply values for each of the above.'']
    }
    ]
    

    If you need anything explained, just ask.
  • greyelf wrote: »
    Some basic background information:

    1. The <script> related code you have at the start (first five(ish) lines) of your example looks like it may of come from the Basic Harlowe Passage Tag Based Styling thread, it is not meant to be used within a standard passage, it is meant to be used within a header tagged special passage. You should remove it from this passage.

    2. A (stop:) macro must be used within the associated hook of the (live:) macro it is stopping.
    (live: 1s)[
    	(stop:)
    ]
    

    3. It is generally not a good idea to have multiple (live:) macros on a single page/passage, a better way to implement the effect you want is to use a single (live:) macro and to use (if:)/(else-if:) macros to check how much 'total time' has passed.
    (set: $tick to 0)
    (live: 1s)[
    	(set: $tick to it + 1)
    	
    	(if: $tick is 2)[First action]
    	
    	(elseif: $tick is 4)[Second action]
    
    	(elseif: $tick is 6)[Third action]
    
    	(elseif: $tick is 8)[Forth action]
    
    	(elseif: $tick is 11)[Fifth action]
    
    	(elseif: $tick is 13)[
    		Sixth action
    		(stop:)
    	]
    ]
    

    4. The (prompt:) macro returns an empty String value if the Reader/Player does not enter their own value. The following test can be used to check this, just leave the field empty and click on either the Ok, Cancel or little X button to close the prompt dialog.
    {
    (set: $var to (prompt: "some input"))
    (if: $var is 0)[The variable equals zero]
    (else-if: $var is "")[The variable equals an empty String]
    (else:)[The Reader/Player actually entered a value: $var]
    }
    

    ** The next two points are semi-related to each other and to point 4.

    5. Don't use an (if:) macro with an empty associated hook combined with an (else:) macro to test if a condition is not true (false), that is what the not Boolean operator is for.
    {
    (set: $var to (prompt: "some input"))
    (if: not ($var is ""))[The Reader/Player actually entered a value: $var]
    }
    

    6. You can use the b]and[/b] Boolean operator to test multiple conditions one after another.
    {
    (set: $name to (prompt: "Please Enter A First Name:"))
    (set: $sname to (prompt: "Please Enter A Surname:"))
    (set: $ship to (prompt: "Please Name Your Ship:"))
    
    (if: not ($name is "") and not ($name is "") and not ($ship is ""))[name: $name, sname: $name, ship: $ship]
    (else:)[You need to enter a value for all three prompts]
    }
    

    7. An (if:)/(else-if:) macro is not automatically re-evaluated if the associated variable is changed, this means that you need to do that yourself manually.

    So based on the above information a possible solution could look something like the following, it is made up of two passages.

    A. Your story's first passage:
    {
    (set: $name to (either: 'Daniel','Francis','Charles'))
    (set: $sname to (either: 'East','Kenway','Drake'))
    (set: $ship to (either: 'Ruler of Seas','Killer of Kings','The Champion','Death','Ruler of Seas','Killer of Kings','The Champion','Death','Ruler of Seas','Killer of Kings','The Champion','Death','Ruler of Seas','Killer of Kings','The Champion','Death','Ruler of Seas','Killer of Kings','The Champion','Death','Ruler of Seas','Killer of Kings','The Champion','Death','The Black Pearl'))
    
    }|newGame>[I was born at sea.]
    {
    (set: $tick to 0)
    (live: 1s)[
    	(set: $tick to it + 1)
    	
    	(if: $tick is 2)[
    		(replace: ?newGame)[I was born at sea for a reason.]
    	]
    	(elseif: $tick is 4)[
    		(replace: ?newGame)[I was born at sea, to live at sea.]
    	]
    	(elseif: $tick is 6)[
    		(replace: ?newGame)[To fight at sea.]
    	]
    	(elseif: $tick is 8)[
    		(replace: ?newGame)[To rule the sea...]
    	]
    	(elseif: $tick is 11)[
    		(replace: ?newGame)['Oh, he's a lovely young boy, isn't he!' exclaimed your mother.]
    	]
    	(elseif: $tick is 13)[
    		(stop:)
    		(append: ?newGame)[<br>'Yes, he most certainly is.' agreed your father, looking down at you as a baby and smiling, just as your mother did.<br>
    (link: "'But what to call him is the question.'")[
    	(replace: ?newGame)[(display: "Choose Name and Ship")]
    ]
    ]
    	]
    ]
    }
    

    B. The Choose Name and Ship passage, this is where the 'tricky' stuff happens. lol

    The first three (if:) macros are catering for the case where the Reader/Player does not enter a value for a prompt, this would cause nothing to be shown for the related link which would make it difficult to click on.
    {
    (if: $name is "")[(set: $name to "click here")]
    (if: $sname is "")[(set: $sname to "click here")]
    (if: $ship is "")[(set: $ship to "click here")]
    
    }(color: "red")[\
    First Name: (link: $name)[
    	(set: $name to (prompt: "Please Enter A First Name:"))
    	(replace: ?newGame)[(display: "Choose Name and Ship")]
    ]
    
    Surname: (link: $sname)[
    	(set: $sname to (prompt: "Please Enter A Surname:"))
    	(replace: ?newGame)[(display: "Choose Name and Ship")]
    ]
    
    Ship's Name: (link: $ship)[
    	(set: $ship to (prompt: "Please Name Your Ship:"))
    	(replace: ?newGame)[(display: "Choose Name and Ship")]
    ]
    
    {
    (if: not ($name is "" or $name is "click here") and not ($name is "" or $sname is "click here") and not ($ship is "" or $ship is "click here"))[ [[Accept ->Story]]]
    (else:)[''Please supply values for each of the above.'']
    }
    ]
    

    If you need anything explained, just ask.

    Thank you so much! That's really important.

    note: This is what I use to change the background colour, font and stuff like that along with a tag. It works perfectly.
    {
    (print: "<script>$('html').removeClass(\)</script>")
    (if: (passage:)'s tags's length > 0)[
    (print: "<script>$('html').addClass('" + (passage:)'s tags.join(' ') + "'\)</script>")
    ]
    }
    
  • Deadshot wrote: »
    note: This is what I use to change the background colour, font and stuff like that along with a tag. It works perfectly.
    I wrote the original version of that code so I do understand what it does. *smile*

    When that code is placed within a header tagged passage it will allow you to do Tag Based Styling on every/any navigable passage in your story. If you use that code like you have (placing it within a navigable passage) then it only works in the passages you have placed a copy of the code in, which is an inefficient way to use that code.
  • greyelf wrote: »
    Deadshot wrote: »
    note: This is what I use to change the background colour, font and stuff like that along with a tag. It works perfectly.
    I wrote the original version of that code so I do understand what it does. *smile*

    When that code is placed within a header tagged passage it will allow you to do Tag Based Styling on every/any navigable passage in your story. If you use that code like you have (placing it within a navigable passage) then it only works in the passages you have placed a copy of the code in, which is an inefficient way to use that code.

    Please, when will you write your twine book? :smile:
Sign In or Register to comment.