Use lua for special level files

Game is playable, and should compile on linux and Windows.
Assumes you have a lua 5.3 library available.

Removes level compiler and associated files.
Replaces special level des-files with lua scripts.
Exposes some NetHack internals to lua:
 - des-table with commands to create special levels
 - nh-table with NetHack core commands
 - nhc-table with some constants
 - u-table with some player-specific data (u-struct)
 - selection userdata

Adds some rudimentary tests.

Adds new extended command #wizloadlua to run a specific script,
and #wizloaddes to run a specific level-creation script.

nhlib.lua is loaded for every lua script.

Download and untar lua:
  mkdir lib
  cd lib
  curl -R -O http://www.lua.org/ftp/lua-5.3.5.tar.gz
  tar zxf lua-5.3.5.tar.gz

Then make nethack normally.
This commit is contained in:
Pasi Kallinen
2019-05-10 21:11:50 +03:00
parent 3e029d2900
commit fd55d9118e
189 changed files with 16653 additions and 27346 deletions

View File

@@ -14,7 +14,6 @@ STATIC_DCL void FDECL(mksink, (struct mkroom *));
STATIC_DCL void FDECL(mkaltar, (struct mkroom *));
STATIC_DCL void FDECL(mkgrave, (struct mkroom *));
STATIC_DCL void NDECL(makevtele);
STATIC_DCL void NDECL(clear_level_structures);
STATIC_DCL void NDECL(makelevel);
STATIC_DCL boolean FDECL(bydoor, (XCHAR_P, XCHAR_P));
STATIC_DCL struct mkroom *FDECL(find_branch_room, (coord *));
@@ -354,6 +353,14 @@ register struct mkroom *aroom;
register int tmp;
int i;
if (aroom->doorct) {
for (i = 0; i < aroom->doorct; i++) {
tmp = aroom->fdoor + i;
if (g.doors[tmp].x == x && g.doors[tmp].y == y)
return;
}
}
if (aroom->doorct == 0)
aroom->fdoor = g.doorindex;
@@ -573,7 +580,7 @@ makevtele()
* special) but it's easier to put it all in one place than make sure
* each type initializes what it needs to separately.
*/
STATIC_OVL void
void
clear_level_structures()
{
static struct rm zerorm = { cmap_to_glyph(S_stone),
@@ -637,6 +644,14 @@ clear_level_structures()
xdnladder = ydnladder = xupladder = yupladder = 0;
g.made_branch = FALSE;
clear_regions();
g.xstart = 1;
g.ystart = 0;
g.xsize = COLNO - 1;
g.ysize = ROWNO;
if (g.lev_message) {
free(g.lev_message);
g.lev_message = (char *) 0;
}
}
STATIC_OVL void