Function on setup object to get passage's wikified text

- Posted in Coding by

setup.getWikifiedText = function(passageName){

  if(Story.has(passageName)){
      var passage = Story.get(passageName);
      return "<wiki>" + passage.text + "</wiki>";
  }else{
   return ""; 
  }
};

Speech functions I created for "A Campfire Tale"

- Posted in Coding by

I use these two functions to format speech in my current WIP, "A Campfire Tale":

Ways to use a single Twine passage repeatedly

- Posted in Coding by

We can use a passage repeatedly by incrementing a story variable that is used with a <<switch>> to select what the passage should display.

The way I do this is to define a widget like so (be sure the passage in which you define the following widget has a widget tag:

<<widget lb>>
<<goto $p>>
<</widget>>

Then, in special passage PassageDone I put this code:

<<set $p to passage()>>

The above sets story variable $p to the name of the most recently rendered passage.

Using the above, we can then do the following in the passage we want to repeatedly use (assume the passage name is MyPsg):

<<switch visited()>>
<<case 1>>
     Case 1 text goes <<link here>><<lb>><</link>>.
<<case 2>>
     Case 2 text goes <<link here>><<lb>><</link>>.
<<case 3>>
     Case 3 text goes <<link here>><<lb>><</link>>.
<<default>>
     Text for after the third passage visit.
<</switch>>

Here's another way you can accomplish this (I prefer the method used above):

<span id="start">
This text will be displayed when the passage is first loaded.
</span>

<<set _count to 0>>

<<link "Continue">>
  <<set _count++>>
  <<replace "#start">>
    <<switch _count>>
      <<case 1>>
      This text will be displayed when the "Continue" Link is clicked the first time.
      <<case 2>>
      This text will be displayed when the "Continue" Link is clicked the second time.
      <<case 3>>
      This text will be displayed when the "Continue" Link is clicked the third time.
    <</switch>>
  <</replace>>
<</link>>

Sunday May 18th Update on my Twine WIP

- Posted in Coding by

 work in progress image'

On 5/19/2025, I added about another 5Kb, a mixture of prose/twinescript.


As of 18th May, 2025: I gave updates previously the 16th and the 17th of this month. Progress is strong on my current WIP, A Campfire Tale. This evening, I broke 10,000 words and we're at 48 passages. A lot of those passages contain considerable prose, twinescript, or a mixture of both.

This afternoon and evening I've spent time fleshing out inventory manipulation. It's semi-puzzlely in that you most combine some items to create new items, and then must make use of some of those new items to escape the initial chamber in which you were deposited after the alien ship tractor-beamed you.

Altogether today, I increased the game contents by about 10 Kb.

A Campfire Tale - WIP updated 17 May 2025

- Posted in Coding by

 work in progress image

Yesterday, I reported on my progress coding my current game. This morning, I spent a couple hours working on this, and finished coding all item combinations of objects paired with water from the MC's canteen.

This added a few more Kb to story-text and twinescript, and brought total words just north of 9300. You can click the inline image above to view a higher resolution screenshot in another browser tab.

I likely should have forged ahead at that point, but I wound up reading another chapter in a book, then took a nap. And this evening, we're going to a benefit auction — just about an hour from now, in fact.

Something I've noticed: if you need a block of Twinescript involving only plain text, links and story variables, you can store it in a setup function. The real benefit in doing so would be if you're going to use that block in different places in your twinework:

An update on my WIP Twinework in Sugarcube

- Posted in Coding by

 work in progress image

I recently reported on my blog about my WIP, A Campfire Tale. That was two days ago. Since then, I've made significant progress. In the past two days, I've added about 7Kb of a combination of narrative and Twinescript.

The last forty-eight hours' work has been on I guess what could be called my first puzzle of the game (and, indeed, or anything I've ever coded). Basically, I'm trying to set up some inventory-manipulation to make the player feel clever while advancing the story.

So far, I've implemented examining items, and I'm working on item combination logic.

A Campfire Tale as of Mid-May 2025

- Posted in Coding by

I'm at 41 passages on my Twine WIP, "A Campfire Tale", and currently I'm spending some time building an Action/Object system in passage EscapeFrom.

Here is some code from that passage. To date, I've got it working to show appropriate long descriptions for objects that I select with a hyperlink click:

Setting a brevity toggle in Sugarcube

- Posted in Coding by

In A Campfire Tale, early on I got a little implementor-happy (as in trigger-happy) and implemented a brevity toggle. Below, I show the toggle (from the JS section of our story), and then an example of using this in a passage:

A Sugarcube Widget to Display Debug-Mode Message

- Posted in Coding by

Here's a widget I wrote on 5/8/25 to display helpful developer messages during the development phase:

Obviously, this widget relies upon a story variable, $releaseVersionOfGame, because it checks this boolean. Ideally, this boolean would be set in passage StoryInit in your Sugarcube game.

Then, whenever you want to show a message in a passage (for instance, to reassure yourself that $inventory has the contents you think it has), you do something like this:

Sugarcube Permit Saves Only in Checkpoint Passages

- Posted in Coding by

To permit save-games to be created only in passages tagged checkpoint, add the following to your game's CSS:

Page 1 of 67