Standardize all core and obj functions with relative coords
This is a large iteration on a previous implementation of making nh.getmap() parse its coordinates as relative to the last defined map or room rather than absolute to the entire level. Now, everything in the nh.* and obj.* functions interprets coords as relative rather than absolute. (By default; if no map or room has been defined, or if the lua code is executing after level creation is done, they will interpret the coordinates as absolute). The general motivation is basically the same - routines that use absolute coordinates are difficult to use in level creation routines, because then the designer has to remember to convert the relative coordinate to an absolute one (and that was impossible before nh.abscoord was added, particularly in themed rooms). And once nh.getmap() takes relative coordinates, it would be very strange to have all the other functions (setting timers, burying objects, etc) remain with absolute ones. In a couple places, code is changed to account for coordinates that are relative to a *room* (which uses g.coder->croom->[lx,ly] as an offset, instead of relative to a *map*, which uses [xstart,ystart]. Specifically, selection.iterate did not account for this, and without this the ice themed room timer was not being started in the proper place. All tests are updated to respect the new behavior. Most of the modified functions are not actually used anywhere in level files; the one exception is starting a timer in a themed room, and that has been adjusted. Documentation updated as well to clarify when various things are tossing around relative and absolute coordinates, both in comments and in lua.adoc.
This commit is contained in:
committed by
Pasi Kallinen
parent
a30a45be46
commit
f71bff3285
12
doc/lua.adoc
12
doc/lua.adoc
@@ -6,13 +6,16 @@
|
||||
|
||||
Functions exposed from the NetHack core. They are all in the `nh` table.
|
||||
|
||||
All core functions involving xy coordinates interpret these as relative to the
|
||||
last defined map or room.
|
||||
|
||||
=== abscoord
|
||||
|
||||
Convert a room-relative coordinate to map-absolute.
|
||||
Convert a room- or map-relative coordinate to absolute.
|
||||
Can accept one table with x and y keys (and in that case, returns similar),
|
||||
or two integer values (and returns two integer values)
|
||||
des-routines tend to use relative coordinates, nh and obj use absolute.
|
||||
(This mess is still very much in need of improvement.)
|
||||
des, nh, and obj routines all treat inputs as relative coordinates, but this is
|
||||
here in case an absolute one is needed for some reason (debugging?).
|
||||
|
||||
Example:
|
||||
|
||||
@@ -385,6 +388,9 @@ Example:
|
||||
|
||||
Functions for creating special levels. They are in the `des` table.
|
||||
|
||||
All special level functions involving xy coordinates interpret these as relative
|
||||
to the last defined map or room.
|
||||
|
||||
=== altar
|
||||
|
||||
Create an altar of certain type and alignment.
|
||||
|
||||
Reference in New Issue
Block a user