Return nil on empty get_area() (#4508)
authorJames Stevenson <everamzah@users.noreply.github.com>
Fri, 9 Sep 2016 15:47:13 +0000 (11:47 -0400)
committerZeno- <kde.psych@gmail.com>
Fri, 9 Sep 2016 15:47:13 +0000 (01:47 +1000)
doc/lua_api.txt
src/script/lua_api/l_areastore.cpp

index da9ebb9f1f8bc485d183040194b1c8f7a1afb065..c4bc06695f507dcb2a7f105753ece450bd194a53 100644 (file)
@@ -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.
index 20e7875c7a4a0164f1eda851962cfe734fb05507..0912e2ab0bbc9f878275356ed8fef24797f44ab5 100644 (file)
@@ -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;