summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dat/clua
diff options
context:
space:
mode:
authorEnne Walker <ennewalker@users.sourceforge.net>2009-10-18 16:32:37 -0400
committerEnne Walker <ennewalker@users.sourceforge.net>2009-10-18 16:52:02 -0400
commitdf0b2a5165b84d52d9c43d76d14adea095b671c8 (patch)
tree6e1587fae77a2c020b8c7e5498e5eb8caab88cdf /crawl-ref/source/dat/clua
parent52fce0a7785eccba94e59c7ec8375019780eddcc (diff)
downloadcrawl-ref-df0b2a5165b84d52d9c43d76d14adea095b671c8.tar.gz
crawl-ref-df0b2a5165b84d52d9c43d76d14adea095b671c8.zip
Lua map improvements.
The previous dungeon layout.des functions all apply directly to the grid and so are unsuitable for use in vaults. This aims to correct that by providing lua functions that can manipulate maps (of glyphs). grd[x][y] in a .des file can now be used to get and set glyphs in the current map. This should allow for less cumbersome map variations than what you can do with just SUBST and SHUFFLE. To support that, map_def no longer batches up transforms--it applies them all immediately. This resulted in a good bit of refactoring. FTILE/RTILE map commands now support setting the tile for multiple features at once. There are also a small number of new lua functions that apply to maps (map_octa_room, map_smear, and map_extend). Ideally, these will eventually replace the existing builder funcs that work on grd.
Diffstat (limited to 'crawl-ref/source/dat/clua')
-rw-r--r--crawl-ref/source/dat/clua/dungeon.lua24
1 files changed, 15 insertions, 9 deletions
diff --git a/crawl-ref/source/dat/clua/dungeon.lua b/crawl-ref/source/dat/clua/dungeon.lua
index 5d178b891d..b1cc8de795 100644
--- a/crawl-ref/source/dat/clua/dungeon.lua
+++ b/crawl-ref/source/dat/clua/dungeon.lua
@@ -75,6 +75,10 @@ function dgn_map_meta_wrap(map, tab)
return crawl.err_trace(val, map, ...)
end
end
+
+ -- Convenience global variable, e.g. grd[x][y] = 'x'
+ meta['grd'] = dgn.grd_table(map)
+
meta['_G'] = meta
meta.wrapped_instance = map
return meta
@@ -89,19 +93,21 @@ function dgn_set_map(map)
g_dgn_curr_map = map
end
-function dgn_run_map(prelude, main)
- if prelude or main then
+function dgn_run_map(prelude, map, main)
+ if prelude or map or main then
local env = dgn_map_meta_wrap(g_dgn_curr_map, dgn)
+ local ret
if prelude then
- local fn = setfenv(prelude, env)
- if not main then
- return fn()
- end
- fn()
+ ret = setfenv(prelude, env)()
+ end
+ if map then
+ ret = setfenv(map, env)()
+ dgn.normalise(g_dgn_curr_map)
end
if main then
- return setfenv(main, env)()
+ ret = setfenv(main, env)()
end
+ return ret
end
end
@@ -387,4 +393,4 @@ dgn.good_scrolls = [[
w:5 scroll of vorpalise weapon /
w:5 scroll of immolation /
w:5 scroll of vulnerability
- ]] \ No newline at end of file
+ ]]