diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-06-02 15:47:36 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-06-03 22:31:01 +0300 |
commit | bf8cfce50e3f32b84c7fccf470601986d6f7913f (patch) | |
tree | 9cb99973db9cb1c83b184ff0d9fe0e8cee2fd9f5 /src | |
parent | b235e4d290e3565a2789ec5097d33b1ec9dbb5ce (diff) | |
download | minetest-bf8cfce50e3f32b84c7fccf470601986d6f7913f.tar.gz minetest-bf8cfce50e3f32b84c7fccf470601986d6f7913f.tar.bz2 minetest-bf8cfce50e3f32b84c7fccf470601986d6f7913f.zip |
Add ObjRef:is_player() and modify ObjRef:get_player_name() to always return a string to aid better inter-object compatibility of code that assumes objects to be players
Diffstat (limited to 'src')
-rw-r--r-- | src/scriptapi.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index 320a45ff9..9744aaa33 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -2683,6 +2683,15 @@ private: } /* Player-only */ + + // is_player(self) + static int l_is_player(lua_State *L) + { + ObjectRef *ref = checkobject(L, 1); + Player *player = getplayer(ref); + lua_pushboolean(L, (player != NULL)); + return 1; + } // get_player_name(self) static int l_get_player_name(lua_State *L) @@ -2690,7 +2699,7 @@ private: ObjectRef *ref = checkobject(L, 1); Player *player = getplayer(ref); if(player == NULL){ - lua_pushnil(L); + lua_pushlstring(L, "", 0); return 1; } // Do it |