programs/nesting.toby
author Ryan C. Gordon <icculus@icculus.org>
Tue, 18 Mar 2008 02:05:22 +0000
changeset 499 96e88f292dc8
parent 1 d7cb562e4e24
permissions -rw-r--r--
Updated Lua from 5.1.1 to 5.1.3.
//--------------------------------------------------------
// nesting.toby -- A program to test nested FORs and IFs.
//
// This program will draw boxes increasingly large, and
//  in many colors, to test if Toby can handle some
//  nested FORs and IFs. It should look like a square
//  with different colored lines pulsing, and in the
//  end, four squares, moving in different directions
//  should be drawn.
//
// There are cleaner ways to write this program, but
//  we wanted to nest stuff.
//
// Copyright (c) 1999 Lighting and Sound Technologies
//  Written by Ryan C. Gordon.
//--------------------------------------------------------

function main() returns nothing
	number totalIterations
    number boxSize
	number boxLoop
	number color
	number direction

	hideTurtle()

	for direction = 1 to 4
		color = 0
		for totalIterations = 1 to 5
			for boxSize = 1 to 100
				color = color + 1
				if (color > 15)
					color = 0
				endif
				setPenColor(color)
				for boxLoop = 1 to 4
					goForward(boxSize)
					turnLeft(90)
				endfor
			endfor
		endfor
		turnRight(90)
	endfor

endfunction