Debian Codegraph @

src/gengine/ScriptAgent.cpp

raw
1 /*
2 * Copyright (C) 2004 Ivo Danihelka ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9 #include "ScriptAgent.h"
10
11 #include "ScriptState.h"
12 #include "StringMsg.h"
13 #include "UnknownMsgException.h"
14
15 #include "options-script.h"
16
17
18 //-----------------------------------------------------------------
19 void
20 ScriptAgent::own_init()
21 {
22 registerFunc("sendMsg", script_options_sendMsg);
23 registerFunc("setParam", script_options_setParam);
24 registerFunc("getParam", script_options_getParam);
25 }
26 //-----------------------------------------------------------------
27 void
28 ScriptAgent::registerFunc(const char *name, lua_CFunction func)
29 {
30 m_script->registerFunc(name, func);
31 }
32 //-----------------------------------------------------------------
33 /**
34 * Messages:
35 * - dostring("input") ... run string
36 *
37 * @throws UnknownMsgException
38 */
39 void
40 ScriptAgent::receiveString(const StringMsg *msg)
41 {
42 if (msg->equalsName("dostring")) {
43 scriptDo(msg->getValue());
44 }
45 else {
46 throw UnknownMsgException(msg);
47 }
48 }
49
50