The plan would be to fully embed it into our source so it is not added to our runtime or compile time dependencies. It's small enough to justify that. We'd strip more addons, of course; the core source is about 250 kb bzipped. Lua would be smaller than that, but it seems to be harder to wrap C++ objects in Lua.
A goal of adding scripting to AA would be that everyone, including as of yet non-programmers, should be able to change simple things in the behavior of game objects. We currently have no TnA around to test Io's beginner appeal, so would one of the listening players without or with little programming experience volunteer for testing? We'll try to hold your hand while you do, and see what docs we can write to help those that follow you.
A simple minded introduction to Io follows. It assumes you are using the interactive mode of Io so that results are printed right away; in a script file, you'll have to occasionally enclose the given code in a writeln(...).
1. Variables, assignments and expressions
Io knows about numbers and can do calculations:
Code: Select all
Io> 1+1
==> 2
Code: Select all
Io> (2+2)*3
==> 12
Io> 4 sqrt
==> 2
Code: Select all
Io> 2 pow(5)
==> 32
You can assign results of calculations to variables for later use. If you want to define a new variable, you use the := operator; for overwriting an already set variable, you can use the = operator.
Code: Select all
Io> pi := 0 acos * 2
==> 3.141593
Io> pi * 2
==> 6.283185
Io> x := 0
==> 0
Io> x = 1
==> 1
Io> y = 2
Exception: Slot y not found. Must define slot using := operator before updating.
==> nil
2. Functions
Repeatedly used pieces of code can be put into functions so they don't have to be typed every time. A function is defined like this:
Code: Select all
Io> f := method(t, t - t * t)
==> method(t, t -(t *(t)))
Code: Select all
Io> f(0)
==> 0
Io> f(1)
==> 0
Io> f(2)
==> -2
Functions can have any number of arguments, including zero. The general syntax is "method(arg1, arg2, ..., argn, body) where arg1 to argn are the arguments and body the expression(s) you want to evaluate on these arguments.
Keen minds will have noticed that a function with zero arguments doesn't sound all that useful. All it can do is return a constant value, right? No arguments, no meaningful calculation. Well, not quite: in the function body, you have access to variables defined earlier (or later):
Code: Select all
Io> x := 2
==> 2
Io> y := 3
==> 3
Io> f := method(x*y)
==> method(x *(y))
Io> f()
==> 6
Io> x = 3
==> 3
Io> f()
==> 9
You can write arbitrary commands inside a function body. You can define variables, use them, define new functions, whatever you want. If it is legal outside of a function, it is legal inside. The one thing you need to know is that all variable definitions in the function body are local; that means that, just like the parameter t in our first function, they will vanish once the function exits. They won't be restored on the next usage of the function either; they're gone.
----
This is getting too simple minded for a post in the development subforum


The four small drawbacks I see with Io:
- No release, we'll have to freeze the darcs repository ourselves and pull bugfixing patches
- The official documentation is pretty thin
- It's bigger than Lua both in code size and binary size
- It's purely OO, meaning it may be hard to pick up. But note that my introduction attempt above doesn't use the word "Object" once and pretends that Io is a procedural language. I think that for the simple customization tasks in AA, the ones that can be done with functions alone, we can keep up that illusion.
- I really would prefer sin(2) over 2 sin. Of course, "Object sin := method( x, x sin )" fixes that

Edit: updated attachment to fix the bug reported by wrtl.