|
1 #!/usr/bin/env lua5.1 |
|
2 |
|
3 local parser = require "scansion.parser"; |
|
4 |
|
5 io.input(arg[1]); |
|
6 local script_data = io.read("*a"); |
|
7 |
|
8 local script = assert(parser.parse(script_data)); |
|
9 |
|
10 local c = 0; |
|
11 for name, object in pairs(script.objects) do |
|
12 local o = require("scansion.objects."..object.type); |
|
13 object.handler = o; |
|
14 o._validate(object); |
|
15 c = c + 1; |
|
16 end |
|
17 |
|
18 print("Script defines "..c.." objects, and "..#script.actions.." actions"); |
|
19 |
|
20 for _, action in pairs(script.actions) do |
|
21 local object = script.objects[action.object_name]; |
|
22 local handler = object.handler; |
|
23 assert(handler[action.action], "Objects of type '"..object.type.."' do not support action '"..action.action.."'"); |
|
24 |
|
25 handler[action.action](object, action.extra); |
|
26 end |