Changes between Version 3 and Version 4 of ScriptSystem
- Timestamp:
- 09/27/07 21:20:05 (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ScriptSystem
v3 v4 32 32 33 33 // return if a wrong number of arguments were passed 34 if (args.size() <= 1){ 35 return ScriptResult(std::string("someClass.scriptFunc(arg1) : wrong parameter count")); 34 if (args.size() <= 1) 35 { 36 return ScriptResult(std::string("someClass_scriptFunc(arg1) : wrong parameter count")); 36 37 } 37 38 … … 53 54 54 55 // register new functions 55 Engine::sScriptEngine()->add("someClass .scriptFunc", someScriptFunction, param);56 Engine::sScriptEngine()->add("someClass_scriptFunc", someScriptFunction, param); 56 57 } 57 58 … … 60 61 SomeClass::~SomeClass() 61 62 { 62 Engine::sScriptEngine()->del("someClass .scriptFunc");63 Engine::sScriptEngine()->del("someClass_scriptFunc"); 63 64 } 64 65 … … 66 67 67 68 69 When a new method is registered the engine will send an '''ScriptRegisterFunctionEvent''' on which the connected script wrappers should react to add this new function into their environment. After this a simple call of (example showed in lua): 70 {{{ 71 function run () 72 result = someClass_scriptFunc(5) 73 end 74 }}} 75 will be linked with the real implementation of the script function. Of course you have to know how to react on the provided arguments. The 'result' variable will contain either a result or an error message. 68 76 69 See also: ["ManualPage"], ["ResourceManagment"], ["LuaPlugin"] 77 Since all the communication is done by strings a wrapper plugin has to know how to interpret the strings into the appropriate message or value. The scripting glue code has also to know how to translate the results given back to the script environment back. ["LuaPlugin"] is a simple glue plugin giving you access to the [http://www.lua.org/ lua] language within the engine. 78 79 See also: ["ManualPage"], ["ResourceManagment"], ["LuaPlugin"], ["EventSystem"]