summaryrefslogtreecommitdiff
path: root/src/scripting
diff options
context:
space:
mode:
authorFreeyorp <Freeyorp101@hotmail.com>2010-12-03 17:56:39 +1300
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-12-08 00:18:44 +0100
commit0cad65eb467b2a8833949b42d21fa8737ec14a97 (patch)
tree5478268f2a08e4b16a43b40c9d3dab5687d809bb /src/scripting
parentb0ecb15a2167afefd9ac39cc478e2e707a223faf (diff)
downloadmanaserv-0cad65eb467b2a8833949b42d21fa8737ec14a97.tar.gz
manaserv-0cad65eb467b2a8833949b42d21fa8737ec14a97.tar.bz2
manaserv-0cad65eb467b2a8833949b42d21fa8737ec14a97.tar.xz
manaserv-0cad65eb467b2a8833949b42d21fa8737ec14a97.zip
Minor cleanup in a number of script functions
Reviewed-by: Bertram
Diffstat (limited to 'src/scripting')
-rw-r--r--src/scripting/lua.cpp36
1 files changed, 6 insertions, 30 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 72d20a66..61d98357 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -323,11 +323,11 @@ static int chr_warp(lua_State *s)
{
int c = 50;
LOG_INFO("chr_warp called with a non-walkable place.");
- do {
+ do
+ {
x = rand() % map->getWidth();
y = rand() % map->getHeight();
- c--;
- } while (!map->getWalk(x, y) && c);
+ } while (!map->getWalk(x, y) && --c);
x *= map->getTileWidth();
y *= map->getTileHeight();
}
@@ -655,8 +655,6 @@ static int being_walk(lua_State *s)
const int x = luaL_checkint(s, 2);
const int y = luaL_checkint(s, 3);
- lua_pushlightuserdata(s, (void *)&registryKey);
- lua_gettable(s, LUA_REGISTRYINDEX);
Being *being = getBeing(s, 1);
being->setDestination(Point(x, y));
@@ -689,7 +687,9 @@ static int being_say(lua_State *s)
if (being && message[0] != 0)
{
GameState::sayAround(being, message);
- } else {
+ }
+ else
+ {
raiseScriptError(s, "being_say called with incorrect parameters.");
return 0;
}
@@ -758,9 +758,6 @@ static int being_heal(lua_State *s)
*/
static int being_get_attribute(lua_State *s)
{
- lua_pushlightuserdata(s, (void *)&registryKey);
- lua_gettable(s, LUA_REGISTRYINDEX);
-
Being *being = getBeing(s, 1);
if (being)
@@ -787,9 +784,6 @@ static int being_get_attribute(lua_State *s)
*/
static int being_get_name(lua_State *s)
{
- lua_pushlightuserdata(s, (void *)&registryKey);
- lua_gettable(s, LUA_REGISTRYINDEX);
-
Being *being = getBeing(s, 1);
if (being)
@@ -806,9 +800,6 @@ static int being_get_name(lua_State *s)
*/
static int being_get_action(lua_State *s)
{
- lua_pushlightuserdata(s, (void *)&registryKey);
- lua_gettable(s, LUA_REGISTRYINDEX);
-
Being *being = getBeing(s, 1);
if (being)
@@ -825,9 +816,6 @@ static int being_get_action(lua_State *s)
*/
static int being_set_action(lua_State *s)
{
- lua_pushlightuserdata(s, (void *)&registryKey);
- lua_gettable(s, LUA_REGISTRYINDEX);
-
Being *being = getBeing(s, 1);
int act = lua_tointeger(s, 2);
@@ -846,9 +834,6 @@ static int being_set_action(lua_State *s)
*/
static int being_get_direction(lua_State *s)
{
- lua_pushlightuserdata(s, (void *)&registryKey);
- lua_gettable(s, LUA_REGISTRYINDEX);
-
Being *being = getBeing(s, 1);
if (being)
@@ -865,9 +850,6 @@ static int being_get_direction(lua_State *s)
*/
static int being_set_direction(lua_State *s)
{
- lua_pushlightuserdata(s, (void *)&registryKey);
- lua_gettable(s, LUA_REGISTRYINDEX);
-
Being *being = getBeing(s, 1);
int dir = lua_tointeger(s, 2);
@@ -885,9 +867,6 @@ static int being_set_direction(lua_State *s)
*/
static int posX(lua_State *s)
{
- lua_pushlightuserdata(s, (void *)&registryKey);
- lua_gettable(s, LUA_REGISTRYINDEX);
-
int x = getBeing(s, 1)->getPosition().x;
lua_pushinteger(s, x);
@@ -899,9 +878,6 @@ static int posX(lua_State *s)
*/
static int posY(lua_State *s)
{
- lua_pushlightuserdata(s, (void *)&registryKey);
- lua_gettable(s, LUA_REGISTRYINDEX);
-
int y = getBeing(s, 1)->getPosition().y;
lua_pushinteger(s, y);