337 |
return 1; |
return 1; |
338 |
} |
} |
339 |
|
|
340 |
|
static int |
341 |
|
en_add_scramble(lua_State *L) |
342 |
|
{ |
343 |
|
int x = int(lua_tonumber(L, 1)); |
344 |
|
int y = int(lua_tonumber(L, 2)); |
345 |
|
const char *dir = lua_tostring(L,3); |
346 |
|
const char *allowed = "wsen"; |
347 |
|
char *found = strchr(allowed, dir[0]); |
348 |
|
|
349 |
|
if (found && found[0]) { |
350 |
|
world::AddScramble(GridPos(x,y), enigma::Direction(found-allowed)); |
351 |
|
} |
352 |
|
else { |
353 |
|
lua_error(L, "AddScramble: Third argument must be one character of \"wsen\""); |
354 |
|
} |
355 |
|
|
356 |
|
return 0; |
357 |
|
} |
358 |
|
|
359 |
|
static int |
360 |
|
en_set_scramble_intensity(lua_State *L) |
361 |
|
{ |
362 |
|
world::SetScrambleIntensity(int(lua_tonumber(L, 1))); |
363 |
|
return 0; |
364 |
|
} |
365 |
|
|
366 |
static CFunction luafuncs[] = { |
static CFunction luafuncs[] = { |
367 |
{en_set_attrib, "SetAttrib"}, |
{en_set_attrib, "SetAttrib"}, |
368 |
{en_get_attrib, "GetAttrib"}, |
{en_get_attrib, "GetAttrib"}, |
381 |
{add_rubber_band, "AddRubberBand"}, |
{add_rubber_band, "AddRubberBand"}, |
382 |
{lua::FindDataFile, "FindDataFile"}, |
{lua::FindDataFile, "FindDataFile"}, |
383 |
{get_ticks, "GetTicks"}, |
{get_ticks, "GetTicks"}, |
384 |
|
{en_add_scramble, "AddScramble"}, |
385 |
|
{en_set_scramble_intensity, "SetScrambleIntensity"}, |
386 |
{0,0} |
{0,0} |
387 |
}; |
}; |
388 |
|
|