Random posts

How to use JavaScript arrays in Twine

An array is essentially an ordered list of data values, such as strings or number expressions. You can declare a Twine variable to be an array using just the set macro.

*To create an empty array called $inv: <<set $inv = [] >>
*To create an array called $inv containing the string "Dagger": <<set $inv = ["Dagger"] >>
*To create an array called $inv containing "Dagger", "Shield" and "Potion" in that order: <<set $inv = ["Dagger", "Shield", "Potion"] >>

To examine or change the values inside an array, a number of methods are available that can be used in the set, if and print macros. Here are some examples.

Examining arrays and their contents

*To print the entire contents of an array in order (usually for debug purposes): <<print $inv >>
*To see if the value "Magic Knife" is inside an array: <<if $inv.indexOf("Magic Knife") gte 0>>
*To get the number of values inside an array: <<set $size = $inv.length >>
*To get the first value inside an array: <<set $first = $inv[0] >>
*To get the last value inside an array: <<set $first = $inv[$inv.length - 1] >>

Changing values in arrays

*To add the value "Magic Knife" to the end of an array: <<set $inv.push("Magic Knife")>>
*To add the values "Blunt Axe", "Key" and $item to the end of an array: <<set $inv.push("Blunt Axe", "Key", $item)>> (push() can insert many values at once.)
*To add the value "Weird Pear" to the start of an array: <<set $inv.unshift("Weird Pear")>>
*To add the values "Blunt Axe", $item, 2, and $weapon to the start of an array: <<set $inv.unshift("Blunt Axe", $item, 2, $weapon)>> (unshift() can also insert many values at once.)
*To remove the value "Weird Pear" from an array: <<set $inv.splice($inv.indexOf("Weird Pear"),1)>>
*To sort an array alphabetically: <<set $inv.sort()>>
*To reverse an array: <<set $inv.reverse()>>
*To remove the first value from an array: <<set $inv.shift()>>
*To remove the last value from an array: <<set $inv.pop()>>
*To remove the first value from an array and set $item to it: <<set $item = $inv.shift()>>
*To remove the last value from an array and set $item to it: <<set $item = $inv.pop()>>

TheCube's picture

Knytt Stories Last Hurrah Collab!

Sat, Dec 01 2012 12:00 AM
12/01/2012 - 00:00
12/06/2012 - 23:59
Etc/GMT-7

Remember the Pirate Kart Knytt Stories Collaboration Level? I thought that was pretty awesome. In fact, best Knytt collaboration level ever, right?

Well, Knytt Underground is supposed to come out before the end of the year, which signals the end of an era - an era where Knytt Stories was the only game, ever. I figure that we need to send it out in style with ANOTHER BADASS COLLABORATION from the Trainwrecks Friendship and Drinking club (Drinking Optional) (TM). It might very well be the last collaboration level for Knytt Stories before Knytt Underground.

So, here's the guidelines, as copied from the last Knytt collab (Thanks EffBee/EffEminate!)

-Each participant takes turns making a section of the level
-Only one section per participant (although this is flexible. I want to see everyone who wants to participate go at least once before we start seeing duplicate participants though)
-Make your section between ten and twenty screens long (more of a guideline really)
-Please don't edit someone else's section (unless you have a really good idea)
-Add a sign message to your first screen stating that you made the section
-First person should start the level off with the Run and Climb abilities. Feel free to introduce the other abilities but try to be gradual about it.
-When you've finished your section, upload it as a packed file.
-Whoever is working on the next section should say so, just so that we don't have two people trying to make section X and thus conflicting with each other.

Submit WIP versions as an attachment to COMMENTS, not as a new game. That way, we don't clutter up the site or the Twitter feed. We'll attach the final version as the real game so there's no confusion.

Since we have some time before the event begins, feel free to share your ideas in the comments and get excited! And send it to your friends!


Games made for Knytt Stories Last Hurrah Collab!

qrleon's picture

Roguelikes

Last night, I dreamt of a Roguelike where the only enemies were fellow looters: looters that entered the labyrinth before you and have had time to amass equipment, and looters that entered after you with poorer inventories overall. All looters attack each other, but may gang up temporarily against a strong looter.

Does a Roguelike with sparse-but-brutal encounters like this exist?

clyde's picture

Shadow Doctors

shadow.gif

Credits:
Made in October of 2016 for Halloween.

Angry Birds Tutorial by Роман Рафиков
https://www.youtube.com/watch?v=tUKbaVv-eUw

Before I found out you could import .gif directly into Clickteam Fusion, I used:
Convert .gif to spritesheet in Gimp
http://registry.gimp.org/node/20943
Import sprite-sheet as animation into Clickteam
http://www.create-games.com/article.asp?id=2261

Clouds:
http://www.publicdomainpictures.net/pictures/20000/velka/dark-clouds-1300642988AuA.jpg

Skull gif
http://bestanimations.com/Humans/Skulls/Skulls2.html

Haunted House Pic
https://commons.wikimedia.org/wiki/File:A_haunted_house_like_church_in_kurseong.jpg

Bat Gif
http://www.animatedimages.org/img-animated-bat-image-0063-50698.htm#infos

moon pic
http://www.publicdomainpictures.net/pictures/10000/velka/381-1233891708GdW7.jpg

Beetle gif
http://www.animatedimages.org/img-animated-insect-image-0141-57634.htm

Eye gif
http://www.animatedimages.org/img-animated-eye-image-0007-40053.htm

Flying skulls:
http://giphy.com/gifs/spooky-macabre-wtfchrisstuff-qjszOEgCFuB6o

Birds gif:
http://rebloggy.com/post/scary-gif-beauty-death-black-and-white-cool-hell-birds-b-w-halloween-night-dark/99120725897

Bats gif:
http://rebloggy.com/post/gif-bat-black-and-white-cool-creepy-awesome-horror-b-w-animal-crazy-nature-amazi/96603828172

Squirrel pic:
http://www.pngall.com/squirrel-png

Rattle pic:
I DID THAT!

Flame gif:
http://www.animatedimages.org/img-animated-fire-image-0015-49061.htm

-------------
Music:
Pavane
http://www.midiworld.com/midis/other/faure/pavane.mid
I put it into NanoStudio and rearranged the instrumentation.
http://www.blipinteractive.co.uk/download.php

-------------

Feedback, significant advice, and support
-Chrissy my wife.

Also thank you to the Glorious Trainwrecks community for encouraging me to use Clickteam Fusion 2.5, answering questions and pointing me towards example projects, and contributing hugely to my aesthetic.

You can contact me on twitter @cafefiction

Author: 
clyde
Made For: 
An event
sergiocornaga's picture

Schrödinger's Tamagotchi

SchrodingersTamagotchi.gif

Every time Schrödinger's Tamagotchi is opened, the tamagotchi will be either alive or dead (unless it has already died, in which case it will always be dead). While Schrödinger's Tamagotchi is not open, the tamagotchi exists in a state of quantum superposition.

In accordance with the implied rules of the event this was created for, the tamagotchi is inside a password-protected archive that I will not release the password for, so it should be impossible to look inside the box. To clarify, YOU CANNOT PLAY THIS GAME, maybe don't even bother downloading it.

Made For: 
An event

You Create The Bullet Hell!

CreateTheBulletHell 2012-03-06 01-08-34-70.png

Have you ever wondered what life was like as an everyday boss in bullet hell.

Made For: 
An event
justin_bailey's picture

The Furnace

Screen Shot 2013-02-16 at 1.38.58 PM.png

A game I was afraid to make.

Author: 
Mike Leisz
Made For: 
An event
FirecatFG's picture

Hom Alon

A thing.png
Game File: 

Based on the sega genesis Home Alone game. I think i spent more time on this than it was worth.

Made For: 
An event

Greenday ZZT

greenday.gif
Game File: 

Greenday ZZT was inspired by an old game I played back in the day and it references to chapter 1. It's a story of loss and lament, and involves a young boy and his troubles with being unable to attend the band's concert. Originally a 1 scene 2 frame game, I have added 4 extra paths and some title pages, incorporated some new gameplay and added a tight but simple story.

I've included the Lyon library for those who have trouble running ZZT with sound and without crashes.

The chapter selector is on the title screen and after a chapter is over the game must be reloaded to access other chapters (limits of zzt on the engine) pressing O

Space for info on the title screen is a farce, but just hold down shift+direction and you'll get the info provided.

The adventure is short but I feel it has enough depth, laughter and overall tones of lament and acceptance that I feel it is a good tone for this month, so I've resurrected this oldie but goodie as a red herring, but hopefully it's a good one others will enjoy, or overlook. So feel free to run it in zzt, lyon (included) or the execution of your choice.

Thanks go to Newt, Mew, ERI, the GT crew, Saxxonpike, mno, smedis, linhat, spindley or inspiration and whatnot..

Event Created For: 
Made For: 
An event
Syndicate content
pensive-mosquitoes