diff --git a/src/nhlua.c b/src/nhlua.c index ab5ccc694..dafee5753 100644 --- a/src/nhlua.c +++ b/src/nhlua.c @@ -487,6 +487,20 @@ nhl_getmap(lua_State *L) nhl_error(L, "Incorrect arguments"); return 0; } + if (g.in_mklev) { + /* xstart and ystart are set by the des.map() command to give + * coordinates relative to the 0,0 of that map. It can be quite useful + * to check what terrain is on a given space. But without compensating + * for the change in xstart and ystart here, this will lead to results + * like des.terrain(4,6,'L') and then nh.getmap(4,6) not being lava. + * + * Only valid during mklev, because xstart and ystart are not saved + * with the level and can change during the level creating process when + * additional des.map() are executed. They will not necessarily be the + * same later. */ + x += g.xstart; + y += g.ystart; + } x = (coordxy) lx; y = (coordxy) ly;