155 |
|
|
156 |
const tools::Value *v = obj->get_attrib(key); |
const tools::Value *v = obj->get_attrib(key); |
157 |
if (!v) { |
if (!v) { |
158 |
lua_error(L, "Get_Attrib: unknown attribute"); |
lua_error(L, "GetAttrib: unknown attribute"); |
159 |
lua_pushnil(L); |
lua_pushnil(L); |
160 |
} |
} |
161 |
else |
else |
163 |
return 1; |
return 1; |
164 |
} |
} |
165 |
|
|
|
enum ObjType { FLOOR, ITEM, STONE }; |
|
|
|
|
166 |
static int |
static int |
167 |
en_set_floor(lua_State *L) |
en_set_floor(lua_State *L) |
168 |
{ |
{ |
272 |
} |
} |
273 |
|
|
274 |
static int |
static int |
275 |
|
add_rubber_band (lua_State *L) |
276 |
|
{ |
277 |
|
using namespace world; |
278 |
|
|
279 |
|
Actor *a1 = dynamic_cast<Actor*> (to_object(L, 1)); |
280 |
|
Object *o2 = to_object(L, 2); |
281 |
|
Actor *a2 = dynamic_cast<Actor*>(o2); |
282 |
|
Stone *st = dynamic_cast<Stone*>(o2); |
283 |
|
double strength = lua_tonumber(L, 3); |
284 |
|
double length = lua_tonumber(L, 4); |
285 |
|
|
286 |
|
if (!a1) |
287 |
|
lua_error(L, "AddRubberBand: First argument must be an actor\n"); |
288 |
|
else if (!a2 && !st) |
289 |
|
lua_error(L, "AddRubberBand: Second argument must be actor or stone\n"); |
290 |
|
else { |
291 |
|
if (a2) |
292 |
|
world::AddRubberBand (a1, a2, strength, length); |
293 |
|
else |
294 |
|
world::AddRubberBand (a1, st, strength, length); |
295 |
|
} |
296 |
|
return 0; |
297 |
|
} |
298 |
|
|
299 |
|
static int |
300 |
get_ticks(lua_State *L) |
get_ticks(lua_State *L) |
301 |
{ |
{ |
302 |
lua_pushnumber(L, SDL_GetTicks()); |
lua_pushnumber(L, SDL_GetTicks()); |
317 |
{en_name_object, "NameObject"}, |
{en_name_object, "NameObject"}, |
318 |
{en_get_named_object,"GetNamedObject"}, |
{en_get_named_object,"GetNamedObject"}, |
319 |
{add_constant_force, "AddConstantForce"}, |
{add_constant_force, "AddConstantForce"}, |
320 |
|
{add_rubber_band, "AddRubberBand"}, |
321 |
{find_data_file, "FindDataFile"}, |
{find_data_file, "FindDataFile"}, |
322 |
{get_ticks, "GetTicks"}, |
{get_ticks, "GetTicks"}, |
323 |
{0,0} |
{0,0} |