Skip to content

Commit

Permalink
Return nil on empty get_area() (#4508)
Browse files Browse the repository at this point in the history
  • Loading branch information
James Stevenson authored and Zeno- committed Sep 9, 2016
1 parent c0cd7aa commit 403dada
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/lua_api.txt
Expand Up @@ -2886,6 +2886,7 @@ chosen for you.
#### Methods
* `get_area(id, include_borders, include_data)`: returns the area with the id `id`.
(optional) Boolean values `include_borders` and `include_data` control what's copied.
Returns nil if specified area id does not exist.
* `get_areas_for_pos(pos, include_borders, include_data)`: returns all areas that contain
the position `pos`. (optional) Boolean values `include_borders` and `include_data` control
what's copied.
Expand Down
3 changes: 3 additions & 0 deletions src/script/lua_api/l_areastore.cpp
Expand Up @@ -111,6 +111,9 @@ int LuaAreaStore::l_get_area(lua_State *L)
const Area *res;

res = ast->getArea(id);
if (!res)
return 0;

push_area(L, res, include_borders, include_data);

return 1;
Expand Down

0 comments on commit 403dada

Please sign in to comment.