Squiffy templates

I was just thinking - I wonder if maybe the squiffy community should provide a set of JS functions for the absolute newbies. You know, all the things that squiffy doesn't provide. First would be a random number generator. What else would be included. Inventory control? Color/text functions? Sound functions?

What can we provide to the new users that could be easily C&P into the basic squiffy sheet?


I made annotations to explain and remind myself of what each thing in the css does. I really think that should have been done by Alex Warren.


mrangel has made editions to the story.template.js that (1) makes randomizers easy, (2) makes nesting more universal, (for example, (a) passages in the master section become universally accessible and (b) @ttributes can nest other @ttributes) and (3) it automatically turns inputs into @ttributes.


I'd like to make both available online somewhere, but I have no idea how to "fork it on GitHub"

They should learn about [[]]: @clear. It would be beneficial for newbies to make it very clear that it's a possibility. It keeps the games really nice and clean and allows you to do more with your stuff.

Also, I believe that a score tracker should be good. If you play my newest work in progress THE WORLD ENDS TODAY, I THINK...(selfless plugin, I know. I need playtesters btw), there's a score thing that I made through a nice little trick in my squiffy code. If anyone is interested, I can share how it works. What it achieves is whenever you find a new ending, you get points. But when you revest that same ending, it won't give you points.

Another thing that I use in THE WORLD ENDS TODAY, I THINK... is a timer. It's one of my favorite elements in making gamebooks, and I believe it keeps the pace at a very entertaining rate.

These are the things that I had to scour the forums for but ended up being my most valued coding treasures. I hope this helps.

Also, here's a link to the game if you want to check it out :)

http://textadventures.co.uk/games/view/gaer7ugua0qqh1z1wcdf8w/the-world-ends-today-i-think


Here are some I use all the time.

  • squiffy.story.go("some_section"); and squiffy.story.passage("some_passage");

  • setTimeout(() => squiffy.story.go("some_section"), ?000);

  • squiffy.getRndInteger = function(min,max){return Math.floor(Math.random() * (max - min + 1) ) + min;

  • set("coin", (Math.random() > 0.5) ? 'heads' : 'tails');

  • html <input id="attribute_title"> [[next]] followed by JSset("attribute_title", jQuery("#attribute_title").val());

I just really like C&P one-liners, I guess.


Hi, Bluevoss. I'm just bumping this with out adding anything because I think it's a great idea. I was so hoping to steal some of your templates. Please?


I second IFforClassroom.


Okay, this is my alltime favorite, a bit of code that will make your text dialog different each time you read it. It also produces a random number (from the value passed in) and six booleans for you to use. Here is the code:

    //RANDOM STORY TELLING PATHS    
    squiffy.randomPath = function(numPath) {

    var path=Math.ceil(Math.random()*squiffy.get("numPath"));
    squiffy.set("path",path);

    var p1=Math.ceil(Math.random()*6);
    squiffy.set("p1",p1);
    
    var p2=Math.ceil(Math.random()*6);
    squiffy.set("p2",p2);

    var p3=Math.ceil(Math.random()*6);
    squiffy.set("p3",p3);

    var p4=Math.ceil(Math.random()*6);
    squiffy.set("p4",p4);

    var p5=Math.ceil(Math.random()*6);
    squiffy.set("p5",p5);
    
    var p6=Math.ceil(Math.random()*6);
    squiffy.set("p6",p6);

    squiffy.set("f1",false);
    squiffy.set("f2",false); 
    squiffy.set("f3",false); 
    squiffy.set("f4",false); 
    squiffy.set("f5",false); 
    squiffy.set("f6",false);
    
    if (Math.ceil(Math.random()*2)==1){set("f1",true);}
    if (Math.ceil(Math.random()*2)==1){set("f2",true);}
    if (Math.ceil(Math.random()*2)==1){set("f3",true);}
    if (Math.ceil(Math.random()*2)==1){set("f4",true);}
    if (Math.ceil(Math.random()*2)==1){set("f5",true);}
    if (Math.ceil(Math.random()*2)==1){set("f6",true);}
    };

And here is an example of its use in my game "StoreyMinus".

You see some water in
{if p1=1:a stagnant}
{if p1=2:a scummy}
{if p1=3:an algae-crusted}
{if p1=4:an oily}
{if p1=5:a crystal-clear}
{if p1=6:a shimmering}
{if p2=1:pool.}
{if p2=2:puddle.}
{if p2=3:trickling stream.}
{if p2=4:runnel.}
{if p2=5:flow.}
{if p2=6:water-filled pothole.}

Every time the player comes to this spot in the game, it will describe. Usually I'll either use sentence fragments or perhaps and entire sentence (in six versions) to write this out. It makes all the rooms feel a little different.

And if you need a point toss, you have the six f* variable (f1-f6) to use. And path, which you can set to whatever max value you'd like.

Here is that code in use in my game:

https://textadventures.co.uk/games/view/dmo-xkger0arz5csjfra8g/storeyminus


I will also mention that once this is in, I use this as a template for every section in my game. This is in a txt file which I cut and paste into each new section.

    squiffy.set("numPath",100); 
    squiffy.randomPath ("numPath");
	

{if p1=1:}
{if p1=2:}
{if p1=3:}
{if p1=4:}
{if p1=5:}
{if p1=6:}

{if p2=1:}
{if p2=2:}
{if p2=3:}
{if p2=4:}
{if p2=5:}
{if p2=6:}

{if p3=1:}
{if p3=2:}
{if p3=3:}
{if p3=4:}
{if p3=5:}
{if p3=6:}

{if p4=1:}
{if p4=2:}
{if p4=3:}
{if p4=4:}
{if p4=5:}
{if p4=6:}

{if p5=1:}
{if p5=2:}
{if p5=3:}
{if p5=4:}
{if p5=5:}
{if p5=6:}

{if p6=1:}
{if p6=2:}
{if p6=3:}
{if p6=4:}
{if p6=5:}
{if p6=6:}


{if debug:-debug- 

}

You will notice the section at the end - I can put whatever statuses I need to check, or special path sections, or whatever I'd like. At the first line of the game, I have a debug value that I set to TRUE or FALSE and that turns the debugs on and off.

This this, you can write sections just as fast as you can come up with descriptors for them.


Thanks, Bluevoss!


Log in to post a reply.

Support

Forums