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
@@ -80,8 +80,7 @@ themerooms = {
|
||||
if (percent(25)) then
|
||||
local mintime = 1000 - (nh.level_difficulty() * 100);
|
||||
local ice_melter = function(x,y)
|
||||
local ax,ay = nh.abscoord(x,y);
|
||||
nh.start_timer_at(ax,ay, "melt-ice", mintime + nh.rn2(1000));
|
||||
nh.start_timer_at(x,y, "melt-ice", mintime + nh.rn2(1000));
|
||||
end;
|
||||
ice:iterate(ice_melter);
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user