Lua Scripting for Ecotect

Instructor: Matthew M. Burke
Summer 2008

Lesson 3: Exercises

  1. This first exercise is a warm-up to get used to thinking of different ways of accessing data in tables. The task is to count how many times each word appears in a particular text. You can use this text, or one of your own choosing. This script will get you started. Feel free to elaborate on this assignment. For example, print the list in order of frequency, or alphabetically by word.

  2. In this next exercise, we will build a simple object using data in a table. This script gets the job done, but is not a very effective means of going about it. Instead, modify it so that given this description, the script creates the object.

  3. Finally, we can improve on the ideas in the previous exercise by making use of Lua syntax to make the description of Ecotect entities more self-documenting. This script defines several zones which will be created in the Ecotect model. Note by making use of string keys for the table elements, you do not need to remember a particular order to list parameters. Using the ideas from this script, come up with a similar approach to create objects.


Copyright 2008 Matthew M. Burke. All rights reserved.
Modified: 28 June 2008