Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- engine.storyName = "CYS JavaScript engine demo";
- variables({
- vase_alive: true,
- vase_quest: false,
- vase_ask_more: false,
- glass_count: 0,
- snail_location: "yard",
- hunger: 0,
- mosaic: null,
- idleChoices: [0, 1, 2, 3]
- });
- function addHunger() {
- if (++hunger >= 6)
- jumpLink("", ">end", "^You tried to do it, but died of starvation.");
- }
- addScene("intro", "Damn! Your head hurts. <ln> You open your eyes, move your hands and realize that you are lying on a dusty floor. <ln> You can't remember anything.",
- "stand up", ">room");
- addScene("room", function() {
- ln("You are standing in a room with a single open doorway.");
- if (mosaic) {
- ln("There is an image of " + mosaic + " made out of glass on the floor.");
- }else if(vase_alive) {
- ln("A big glass vase is standing on the floor.");
- link("pick up the vase ###", "", "You can't pick up the vase, it is too heavy.");
- link("kick the vase", {vase_alive:false},
- "With a mighty kick you make the vase fall and shatter to many small pieces.");
- if (vase_quest)
- link("talk to the vase #", "", "The vase does not answer.");
- }else {
- ln("Shattered glass is scattered around.");
- link("make a mosaic out of glass on the floor", ">choose image");
- link("pick up a piece of glass", "{glass_count++}",
- "You manage to pick up " + (glass_count ? "another" : "a") + " piece of glass.");
- }
- if (snail_location == "room")
- ln("A snail is crawling on the floor.");
- if (vase_quest && snail_location == "pocket") {
- if (vase_alive)
- link("put the snail into the vase", ">wish");
- else
- link("put the snail near the remains of the vase", {snail_location:"room"});
- }
- link("look around ###", "", "There are no windows. The room is very dusty.");
- link("exit the room", ">yard", "^You came out of the room.");
- });
- addScene("choose image", function() {
- if (state == "") {
- ln("What do you want to depict?");
- link("a skull");
- link("a flower");
- link("a cute elephant", "an ugly elephant");
- }else {
- mosaic = state;
- ln("Making the fine mosic took several hours.");
- addHunger();
- link("next", "<");
- }
- });
- addScene("yard", function() {
- ln("The small shed stands in a yard surrounded by high walls. The yard is covered in grass.");
- link("examine the shed ###", {vase_quest:true},
- "There is a dusty sign above the door. It says: \"I like snails. Bring me one and I'll grant you one wish. Sincerly yours, the Magical Vase.\"");
- link("search for an exit ##", addHunger,
- "You carefully examie every inch of the walls. It seems there is no exit.");
- link("try to climb the walls ###", "",
- "You have tried and failed. There is no way you can climb these walls.");
- if (vase_quest) {
- link("search for snails", addHunger, function() {
- text = "You spend several hours searching in the grass ";
- if (snail_location == "yard") {
- text += "and finally pick up a snail.";
- snail_location = "pocket";
- }else
- text += "but find no snails."
- });
- }
- link("enter the shed", ">room");
- });
- addScene("wish", function() {
- snail_location = "none";
- ln("\"Thank you staranger!\", the vase speaks. \"I am very pleased. I can't hunt for snails myself. No hands, you know...\" <ln> \"Now choose one wish and I will grant it.\"");
- link("@I want to know what is happening and why I am here.", ">room",
- "@You were teleported here by an evil wisard who has also erased your bemory by hitting your head with a stick. The wish is granted.");
- link("@Get me out of here!", ">end",
- "You were teleported to a big city. A few years later you managed to become a merchat, create a family and live happily ever after. <ln> Until the end of your life you have not learned the mystery of the dusty shed with the Magical Vase.");
- if (vase_ask_more) {
- link("@Create a snail, o mighty Vase!", ">room {snail_location='pocket'}",
- "@Your wish is granted. The new snail is in your right pocket now.");
- }else {
- link("@I wish for more snails!", {vase_ask_more:true},
- "@I'm sorry, I can create only one. Do you want me to do it?");
- }
- link("@I don't have a wish.", ">room",
- "@It's too bad. Thanks for the snail anyway. Farewell.");
- });
- addScene("do nothing", function() {
- addHunger();
- switch(pickShuffle(idleChoices)) {
- case 0: ln("You sit and do nothing for several hours."); break;
- case 1:
- ln("You sleep and have a nightmare.");
- addHunger();
- break;
- case 2: ln("You sit down and think about your miserable existence."); break;
- case 3: ln("You kill some time by thinking about a storygame you can write."); break;
- }
- }, "next", "<");
- addScene("end", function() {
- ln("This is the end.");
- },
- "try again", "RESTART",
- "rate and comment the story", "END");
- engine.afterText = function() {
- if (scene != "room" && scene != "yard") return;
- switch(hunger) {
- case 2: ln("You feel a light hunger."); break;
- case 3: ln("#o You are hungry."); break;
- case 4: ln("#r You are very hungry."); break;
- case 5:
- ln("#r The hunger is almost unbearable.");
- if (glass_count > 0)
- link("#r cut your veins with a piece of glass",
- ">end", "^You bleed to death.");
- break;
- }
- if (hunger >= 3 && (snail_location == "pocket" ||
- (scene == "room" && snail_location == "room")))
- {
- link("#g eat the snail",
- function() {
- hunger = Math.max(hunger-2, 0);
- snail_location = "none";
- },
- "You crunch the snail along with its shell. It is unexpectedly delicious.");
- }
- link("wait", ">do nothing");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement