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:
99
x.lua
Normal file
99
x.lua
Normal file
@@ -0,0 +1,99 @@
|
||||
|
||||
-- s = string.format("(%i,%i),[%i,%i,%i]", u.ux, u.uy, u.dx, u.dy, u.dz);
|
||||
-- nh.pline(s);
|
||||
|
||||
|
||||
nh.test({ x = 3, y = 7, name="foo" });
|
||||
|
||||
local l = nh.getmap(u.ux, u.uy);
|
||||
|
||||
nh.pline(string.format("map(%i,%i): glyph=%i, typ=%i, lit=%i, candig=%i",
|
||||
u.ux, u.uy,
|
||||
l.glyph, l.typ, l.lit, l.candig));
|
||||
|
||||
-- nh.pline("lit: " .. x.lit .. ". ")
|
||||
|
||||
-- str = nh.getlin("What do you call it?");
|
||||
-- nh.verbalize("Hello, this is " .. str .. " speaking");
|
||||
|
||||
|
||||
-- nh.pline("COLNOxROWNO=(" .. nhc.COLNO .. "x" .. nhc.ROWNO .. ")")
|
||||
|
||||
|
||||
-- local opts = { a = "valinta a", b = "bbbbb", c = "option c" }
|
||||
-- local ret = nh.menu("Chooooooose one", "a", "one", opts)
|
||||
-- nh.pline("You chose: '" .. ret .. "', that is: '" .. opts[ret] .. "'");
|
||||
|
||||
|
||||
-- nh.pline("makeplural: " .. nh.makeplural("zorkmid"));
|
||||
-- nh.pline("makesingular: " .. nh.makesingular("zorkmids"));
|
||||
|
||||
|
||||
-- local opts = {
|
||||
-- { key = "a", text = "valinta a" },
|
||||
-- { key = "b", text = "bbbbb" },
|
||||
-- { key = "c", text = "option c" }
|
||||
-- }
|
||||
--local ret = nh.menu("Choose one (1)", nil, nil, opts)
|
||||
--nh.pline("You chose: '" .. ret .. "'")
|
||||
|
||||
|
||||
--local ret = nh.menu("Choose one (2)", opts)
|
||||
--nh.pline("You chose: '" .. ret .. "'")
|
||||
|
||||
--[[
|
||||
|
||||
nh.level_init({
|
||||
style = "none", -- or "fill", "grid", "mines", "rogue"
|
||||
filling = "tree",
|
||||
init_present = 1,
|
||||
padding = 1,
|
||||
fg = "floor",
|
||||
bg = "wall",
|
||||
smoothed = 0,
|
||||
joined = 1,
|
||||
lit = -1,
|
||||
walled = 0,
|
||||
icedpools = 0
|
||||
});
|
||||
|
||||
nh.level_flags({"noteleport", "hardfloor"});
|
||||
|
||||
nh.message("What a strange feeling!");
|
||||
|
||||
nh.map({horiz = "center",
|
||||
vert = "center",
|
||||
map = "
|
||||
.....
|
||||
.L.L.
|
||||
.....
|
||||
" });
|
||||
|
||||
nh.monster({
|
||||
class = "V",
|
||||
typename = "vampire",
|
||||
coord = {5, 10},
|
||||
name = "Phil",
|
||||
attitude = "peaceful",
|
||||
alertness = "asleep",
|
||||
alignment = "lawful",
|
||||
-- appearance = ...?
|
||||
female = 1,
|
||||
invisible = 1,
|
||||
cancelled = 1,
|
||||
revived = 1,
|
||||
avenge = 1,
|
||||
fleeing = 23,
|
||||
blinded = 23,
|
||||
paralyzed = 23,
|
||||
stunned = 1,
|
||||
confused = 1,
|
||||
seentraps = { "pit", "magic trap" }, -- could be "all"
|
||||
-- how to add inventory for this monster?
|
||||
-- should be able to just directly set struct monst fields
|
||||
});
|
||||
|
||||
nh.object({
|
||||
});
|
||||
|
||||
-- ]]
|
||||
Reference in New Issue
Block a user