コード例 #1
0
  void LoadScriptFromFile(std::string const &aFilename)
  {
    SLB::Script script;
    LUAFILECHECK()

    script.doString(mScripts.find(aFilename)->second.c_str());
  }
コード例 #2
0
int main(int, char**)
{
	const char *lua_code = 
		"print('print SLB functions:')\n"
		"for k,_ in pairs(SLB) do print('SLB.'..k) end\n" 
		"print('---------------')\n";

	// Custom SLB::SCript, a simplification to use SLB
	SLB::Script s;
	s.doString(lua_code);

	/* but you can include SLB features on any lua_State */
	// Create a lua State, using normal lua API
	lua_State *L = luaL_newstate();
	// load default functions (the current example uses print)
	// and by default, SLB::Script does this.
	luaL_openlibs(L);
	// Register SLB inside the lua_State, calling the SLB::Manager
	// that handles bindings, default functions, default values...
	SLB::Manager::getInstance().registerSLB(L);
	// No call lua API to execute the same code as above
	luaL_dostring(L, lua_code); // execute code

	return 0;
}
コード例 #3
0
void ActionLua::doAction( GameEntity *entity )
{
    BK_ASSERT( entity != 0, "entity must not be 0." );

    SLB::Script s;
    s.doString( "SLB.using(SLB)" );
    s.set( "entity", entity );
    s.set( "action", this );
    s.set( "source", source() );

    try {
        s.doFile( m_path );
    } catch ( exception &e ) {
        BK_DEBUG( e.what() << ": make sure the file " << m_path << " is available." );
        BK_ABORT();
    }
}
コード例 #4
0
 void LoadScriptFromString(std::string const &aString)
 {
   SLB::Script script;
   script.doString(aString.c_str());
 }