function runscript()
	-- Make the player invisible, as this is a cutscene.
	hideplayer();
	
	-- The same level is used in both the beginning and ending sequences, so a flag (FLAG_REACHED_END) is tested to see
	-- which of these sequences will play.
	
	if (getflag(FLAG_REACHED_END) == FLAG_OFF) then
		-- INTRODUCTION CUTSCENE
		
		-- For dramatic purposes, we start the cutscene with a black screen.
		fadeoutinstant();
		wait(100)
		say("In a pretty empty and lonely house,| somewhere||.||.||.")
		
		-- Then we fade into Buddy's house.
		fadein();
		wait(100)
		
		-- Set the speaking character's graphic to Buddy's face.
		speaker("buddy");
		say("Hrm...")
		wait(100)
		
		-- Set the animation to Buddy's sleep animation.
		sound("hurt", CHAN_SCRIPTED)
		setanim("buddy", 0, 4, 2, 20, 1)
		wait(100);
		say("||||Z|z|z|z|z|...")
		
		-- Fade out because Buddy is sleeping now.
		fadeout();
		wait(50);
		
		-- Make the player visible again before changing the level.
		showplayer();
		changelevel("buddy_1")
	else
		-- ENDING CUTSCENE
		
		-- Buddy should be sleeping when the level starts (since the last time we saw him, he was asleep)
		setanim("buddy", 0, 4, 2, 20, 1)
		wait(100);
		fadeout();
		wait(100);
		say("Buddy had a pretty good night.")
		wait(50);
		say("...The end.")
		
		-- Restart the game.
		restartgame()
	end
end