/[enigma]/enigma/src/lua.cc
ViewVC logotype

Diff of /enigma/src/lua.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by dheck, Sun Jun 15 10:38:19 2003 UTC revision 1.13 by ant_39, Sat Jun 21 18:37:53 2003 UTC
# Line 42  using namespace lua; Line 42  using namespace lua;
42  using namespace std;  using namespace std;
43    
44  using world::GridPos;  using world::GridPos;
45    using world::ForceField;
46    
47  namespace lua  namespace lua
48  {  {
49      lua_State *state = 0;       // global Lua state      lua_State *state = 0;       // global Lua state
50      int object_tag;             // Lua tag for `Object's      int object_tag;             // Lua tag for `Object's
51        ForceField *cff = 0;        // constant force field for levels
52  }  }
53    
54  //----------------------------------------------------------------------  //----------------------------------------------------------------------
# Line 287  int lua::FindDataFile(lua_State *L) Line 289  int lua::FindDataFile(lua_State *L)
289  static int  static int
290  add_constant_force(lua_State *L)  add_constant_force(lua_State *L)
291  {  {
292        if (cff) {
293            world::RemoveForceField(cff);
294            delete cff;
295            cff = 0;
296        }
297    
298      px::V2 v;      px::V2 v;
299      v[0] = lua_tonumber(L, 1);      v[0] = lua_tonumber(L, 1);
300      v[1] = lua_tonumber(L, 2);      v[1] = lua_tonumber(L, 2);
301      world::AddForceField(new world::ConstantForce(v));  
302        cff = new world::ConstantForce(v);
303        world::AddForceField(cff);
304    
305      return 0;      return 0;
306  }  }
307    
# Line 421  lua::Init() Line 432  lua::Init()
432    
433      // Register all functions      // Register all functions
434      RegisterFuncs(luafuncs);      RegisterFuncs(luafuncs);
435        cff = 0;
436  }  }
437    
438  void lua::Shutdown()  void lua::Shutdown()
# Line 428  void lua::Shutdown() Line 440  void lua::Shutdown()
440      if (state) {      if (state) {
441          lua_close(state);          lua_close(state);
442          state = 0;          state = 0;
443            if (cff) {
444                delete cff;
445                cff = 0;
446            }
447      }      }
448  }  }

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26