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 |
//---------------------------------------------------------------------- |
//---------------------------------------------------------------------- |
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 |
|
|
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() |
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 |
} |
} |