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

50
dat/tower3.lua Normal file
View File

@@ -0,0 +1,50 @@
-- NetHack 3.6 tower.des $NHDT-Date: 1432512784 2015/05/25 00:13:04 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $
-- Copyright (c) 1989 by Jean-Christophe Collet
-- NetHack may be freely redistributed. See license for details.
--
des.level_init({ style = "solidfill", fg = " " });
des.level_flags("mazelevel", "noteleport", "hardfloor", "solidify")
des.map({ halign = "half-left", valign = "center", map = [[
--- --- ---
|.| |.| |.|
---S---S---S---
|.S.........S.|
-----.........-----
|...|.........+...|
|.---.........---.|
|.|.S.........S.|.|
|.---S---S---S---.|
|...|.|.|.|.|.|...|
---.---.---.---.---
|.............|
---------------
]] });
-- Random places are the 10 niches
local place = { {05,01},{09,01},{13,01},{03,03},{15,03},
{03,07},{15,07},{05,09},{09,09},{13,09} }
des.levregion({ type="branch", region={02,05,02,05} })
des.ladder("up", 05,07)
-- Entry door is, of course, locked
des.door("locked",14,05)
-- Let's put a dragon behind the door, just for the fun...
des.monster("D", 13, 05)
des.monster({ x=12, y=04 })
des.monster({ x=12, y=06 })
des.monster()
des.monster()
des.monster()
des.monster()
des.monster()
des.monster()
des.object("long sword",place[4])
des.trap({ coord = place[4] })
des.object("lock pick",place[1])
des.trap({ coord = place[1] })
des.object("elven cloak",place[2])
des.trap({ coord = place[2] })
des.object("blindfold",place[3])
des.trap({ coord = place[3] })
-- Walls in the tower are non diggable
des.non_diggable(selection.area(00,00,18,12))