Scripting in Lua

Getting the best out of Lua requires some effort, obviously. However I am progressing nicely with a “near” object oriented script interface for the world/map configuration. Now it is possible to write things like:

envMap = AddCubeTexture("data/sky.tga")
mesh01 = AddMesh("data/model1.md2");
skin01 = AddTexture("data/model1.tga")
obj = AddStaticObject(mesh01, skin01, 0, 0, 0)
obj:SetEnvMap(envMap);
obj:SetReflection(0.1);
AddLight(-30.0, -50.0, 40.0, 1.0, 1.0, 1.0, 300.0)

Of course you can do nifty stuff, such as loops (create hundreds of objects sharing the same mesh - good for benchmarking). I am not really sure yet what to expose in Lua space, and how to expose it, but at least it is now contained in a single unit (scriptfun.c), that can be updated or replaced when necessary.

Leave a Reply

You must be logged in to post a comment.