Skip to content

Commit

Permalink
Bring setRoomEnv's error messages up to standard (Mudlet#3089)
Browse files Browse the repository at this point in the history
  • Loading branch information
vadi2 authored Sep 15, 2019
1 parent 2a0d5c0 commit 93b6835
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/TLuaInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4301,26 +4301,28 @@ int TLuaInterpreter::setRoomEnv(lua_State* L)
{
int id, env;
if (!lua_isnumber(L, 1)) {
lua_pushstring(L, "setRoomEnv: wrong argument type");
lua_error(L);
return 1;
lua_pushfstring(L, "setRoomEnv: bad argument #1 type (room id as number expected, got %s!)", luaL_typename(L, 1));
return lua_error(L);
} else {
id = lua_tonumber(L, 1);
}
if (!lua_isnumber(L, 2)) {
lua_pushstring(L, "setRoomEnv: wrong argument type");
lua_error(L);
return 1;
lua_pushfstring(L, "setRoomEnv: bad argument #2 type (environment id as number expected, got %s!)", luaL_typename(L, 2));
return lua_error(L);
} else {
env = lua_tonumber(L, 2);
}
Host& host = getHostFromLua(L);
TRoom* pR = host.mpMap->mpRoomDB->getRoom(id);
if (pR) {
pR->environment = env;
lua_pushboolean(L, true);
return 1;
} else {
lua_pushnil(L);
lua_pushfstring(L, "room %d doesn't exist", id);
return 2;
}

return 0;
}

// Documentation: https://wiki.mudlet.org/w/Manual:Lua_Functions#setRoomName
Expand Down

0 comments on commit 93b6835

Please sign in to comment.