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()>>

gisbrecht's picture

Chistmas Leftovers + Gravity Curtain

gravityCurtainScreen.png
Game File (Linux): 
Game File (Mac): 

Chistmas Leftovers + Gravity Curtain

Okay I had two ideas for Chistmas sekret santa before settling on Comedy of the Chimera and I thought I might as well share them...!

First idea was a game with games within... two puzzlescript games were made. The game masters wanted to challenge to Chimera.

Challenge 1: Match 3 blocks of each color. Push red blocks and pull blue blocks.

Challenge 2: Reworking of scrapped SokoBoby idea: You and the rocks move at the same time. Get all rocks in the hole and dont get squished by the rocks!

Standard Puzzlescript Controls: arrow keys,x to action, z to undo, r to restart.

Second idea: Gravity Curtain basically had the story of the Comedy but the Chimera has the power to manipulate gravity. Watch out for spikes. It was a pain to individually place every save point and spike.

Controls: WASD, arrow keys to move. R to restart from save point. U and I to activate the gravity curtain!

Credits:
Sound clips from "The Phantom Planet" (1961), Link: The Faces of Evil (1993) and Zelda: The Wand of Gamelon (1993).
Background image is Whistlejacket by George Stubbs

Author: 
MarikenG
Made For: 
An event

Slimes Unfinished

slimes.png

Battle the slimes. Death is nonexistent.

Event Created For: 
Made For: 
An event
gisbrecht's picture

Snake Oil Shrinking

Screenshot_2020-07-10_13-53-09.png

clark stanley has sold snake oil contaminated with shrink ray energy! will jogger be able to report this to the judge in time?

press R to reset game.

Music is Rave On by Masafumi Takada and Jun Fukuda

For Grid 1 Online Chat Room + Snake Oil Hawker + Shrink Ray

Event Created For: 
Made For: 
An event

taxi 5imulator

tx1.jpg

Enjoy a taxi ride!

Author: 
Jake Clover
Made For: 
An event
avery's picture

long time no see, linhat

Screenshot 2016-03-22 01-28-03.png

ive been away but im here again for a while hello world

well, im ok mostly, im still alive and getting through life. my external hard drive which originally had KNP and all my source files on there died early last year and as such i no longer after any of my leftover projects or any games which never got to be released whoops i done fucked the pooch on that one huh

luckily i backed up the last iteration of the game that me and mno are working on,,,,we're resuming progress on it slowly, working out little intricate details about the game. it'll be here soon, we promise.

in the meanwhile enjoy this klikart i created just now, it may become the title screen to something.

~pico

Healy's picture

Mommy I don't want to make a KotM game today

lazykotm_screen.png
Game File: 

ugh I feel so lazy today

Anyway here is game. You'll need an interpreter like Windows Frotz or Zoom for the Mac to play.

Made For: 
Klik of the Month Klub #33 (Mar 2010)
Terry's picture

Horse Melting Game

horse.png
Game File: 

Horse Melting Game

Made For: 
Pirate Kart 2
dessgeega's picture

LET'S ALL GO TO THE IGF!

Fri, Oct 14 2011 04:13 PM
10/14/2011 - 16:13
10/17/2011 - 23:59
US/Pacific

DOWNLOAD THE 2012 IGF PIRATE KART

we're putting together a compilation of games to submit to the INDEPENDENT GAMES FESTIVAL! someone has offered to cover the entry fee, so this is your chance to be part of it!

have you made klik of the month games, text adventures, visual novels, adventure game toolkit games, anything? or feel free to make something new, right now!

EXCITEMIKE is generously compiling all of the games into a single compilation! send your games to him at MIKE AT MEYERMIKE DOT COM. the deadline is monday at midnight, but please don't wait to the last minute! RESPECT MIKE'S RIGHTS

if you have the multimedia fusion flash games exporter, please volunteer to convert some klik and play games to flash! it'd help a lot!

some discussion has already gone on in this thread.


Games made for LET'S ALL GO TO THE IGF!

SpindleyQ's picture

SECRET PROJECT UPDATE FINAL

Last night I decided that my SECRET PROJECT is being shelved indefinitely in favour of small, fun projects that don't resemble my job so much and can be finished in a reasonable amount of time without ruining my life.

To help with the crushing disappointment surely felt by all of you, I will announce the working codename of the (non-KotMK) project I am working on next:

MIKE TYSON'S JUNGLE BEAT

Oh, yes. I see the gears turning in your mind.

Syndicate content
pensive-mosquitoes