pull request #744 - specifying items in lua files
Pull request #744 from vultur-cadens: the object specification supported by des.object() was ambiguous for items whose name in objects[] doesn't include the object class name. For instance ring and spellbook of protection are just named "protection" (unlike "cloak of protection" which has its full name). Fixes #744 The commit message for pull request #743 misidentified it as #744, so didn't get marked closed properly. Do that now... Closes #743
This commit is contained in:
@@ -32,7 +32,7 @@ des.stair("up", 39,10)
|
||||
des.non_diggable(selection.area(00,00,40,11))
|
||||
-- Objects
|
||||
des.object({ id = "quarterstaff", x=20, y=06, buc="blessed", spe=0, name="The Staff of Aesculapius" })
|
||||
des.object("lightning", 20, 06)
|
||||
des.object("wand of lightning", 20, 06)
|
||||
des.object()
|
||||
des.object()
|
||||
des.object()
|
||||
|
||||
@@ -41,7 +41,7 @@ des.stair("down")
|
||||
-- Non diggable walls
|
||||
des.non_diggable(selection.area(00,00,75,20))
|
||||
-- Objects
|
||||
des.object({ id = "teleportation", x=11, y=18, buc="cursed", spe=0 })
|
||||
des.object({ id = "scroll of teleportation", x=11, y=18, buc="cursed", spe=0 })
|
||||
des.object()
|
||||
des.object()
|
||||
des.object()
|
||||
|
||||
@@ -148,7 +148,7 @@ des.object({ id = "chest", trapped = 0, locked = 1, coord = loc ,
|
||||
});
|
||||
-- Prevent monsters from eating it. (@'s never eat objects)
|
||||
des.engraving({ coord = loc, type="burn", text="Elbereth" })
|
||||
des.object({ id = "scare monster", coord = loc, buc="cursed" })
|
||||
des.object({ id = "scroll of scare monster", coord = loc, buc="cursed" })
|
||||
-- The treasure of the lord
|
||||
des.object("chest",37,08)
|
||||
-- Traps
|
||||
|
||||
@@ -93,8 +93,8 @@ des.object({ id = "statue", contents=0 })
|
||||
for i=1,8 do
|
||||
des.object()
|
||||
end
|
||||
des.object("blank paper",48,18)
|
||||
des.object("blank paper",48,18)
|
||||
des.object("scroll of blank paper",48,18)
|
||||
des.object("scroll of blank paper",48,18)
|
||||
--
|
||||
des.trap("rust")
|
||||
des.trap("rust")
|
||||
|
||||
@@ -81,15 +81,15 @@ des.non_diggable(selection.area(53,14,61,14))
|
||||
des.engraving({12,03}, "engrave",
|
||||
"You are now entering the Gnome King's wine cellar.")
|
||||
des.engraving({12,04}, "engrave", "Trespassers will be persecuted!")
|
||||
des.object("booze", 10, 07)
|
||||
des.object("booze", 10, 07)
|
||||
des.object("potion of booze", 10, 07)
|
||||
des.object("potion of booze", 10, 07)
|
||||
des.object("!", 10, 07)
|
||||
des.object("booze", 10, 08)
|
||||
des.object("booze", 10, 08)
|
||||
des.object("potion of booze", 10, 08)
|
||||
des.object("potion of booze", 10, 08)
|
||||
des.object("!", 10, 08)
|
||||
des.object("booze", 10, 09)
|
||||
des.object("booze", 10, 09)
|
||||
des.object("object detection", 10, 09)
|
||||
des.object("potion of booze", 10, 09)
|
||||
des.object("potion of booze", 10, 09)
|
||||
des.object("potion of object detection", 10, 09)
|
||||
-- Objects
|
||||
-- The Treasure chamber...
|
||||
des.object("diamond", 69, 04)
|
||||
|
||||
@@ -107,11 +107,11 @@ des.object({ id = "tallow candle", coord = place[4], quantity = math.random(1,2)
|
||||
-- go ahead and leave a lamp next to one corpse to be suggestive
|
||||
-- and some empty wands...
|
||||
des.object("oil lamp",place[2])
|
||||
des.object({ id = "striking", coord = place[1], buc="uncursed", spe=0 })
|
||||
des.object({ id = "striking", coord = place[3], buc="uncursed", spe=0 })
|
||||
des.object({ id = "striking", coord = place[4], buc="uncursed", spe=0 })
|
||||
des.object({ id = "magic missile", coord = place[4], buc="uncursed", spe=0 })
|
||||
des.object({ id = "magic missile", coord = place[5], buc="uncursed", spe=0 })
|
||||
des.object({ id = "wand of striking", coord = place[1], buc="uncursed", spe=0 })
|
||||
des.object({ id = "wand of striking", coord = place[3], buc="uncursed", spe=0 })
|
||||
des.object({ id = "wand of striking", coord = place[4], buc="uncursed", spe=0 })
|
||||
des.object({ id = "wand of magic missile", coord = place[4], buc="uncursed", spe=0 })
|
||||
des.object({ id = "wand of magic missile", coord = place[5], buc="uncursed", spe=0 })
|
||||
|
||||
-- the Orcish Army
|
||||
|
||||
|
||||
@@ -105,5 +105,5 @@ else
|
||||
buc="not-cursed", achievement=1 });
|
||||
end
|
||||
des.engraving({ coord = pt, type = "burn", text = "Elbereth" });
|
||||
des.object({ id = "scare monster", coord = pt, buc = "cursed" });
|
||||
des.object({ id = "scroll of scare monster", coord = pt, buc = "cursed" });
|
||||
|
||||
|
||||
@@ -107,4 +107,4 @@ else
|
||||
buc="not-cursed", achievement=1 });
|
||||
end
|
||||
des.engraving({ coord = pt, type = "burn", text = "Elbereth" });
|
||||
des.object({ id = "scare monster", coord = pt, buc = "cursed" });
|
||||
des.object({ id = "scroll of scare monster", coord = pt, buc = "cursed" });
|
||||
|
||||
@@ -84,8 +84,8 @@ des.trap("pit",06,10)
|
||||
des.trap("pit",07,10)
|
||||
|
||||
-- A little help
|
||||
des.object("earth",02,11)
|
||||
des.object("earth",03,11)
|
||||
des.object("scroll of earth",02,11)
|
||||
des.object("scroll of earth",03,11)
|
||||
|
||||
-- Random objects
|
||||
des.object({ class = "%" });
|
||||
|
||||
@@ -54,8 +54,8 @@ des.trap("pit",05,08)
|
||||
des.trap("pit",06,08)
|
||||
|
||||
-- A little help
|
||||
des.object("earth",01,09)
|
||||
des.object("earth",02,09)
|
||||
des.object("scroll of earth",01,09)
|
||||
des.object("scroll of earth",02,09)
|
||||
|
||||
-- Random objects
|
||||
des.object({ class = "%" });
|
||||
|
||||
@@ -44,7 +44,7 @@ des.object({ id = "chest", coord = place[6],
|
||||
});
|
||||
des.object("water walking boots",place[7])
|
||||
des.object("crystal plate mail",place[8])
|
||||
des.object("invisibility",place[9])
|
||||
des.object("spellbook of invisibility",place[9])
|
||||
-- Walls in the tower are non diggable
|
||||
des.non_diggable(selection.area(00,00,14,10))
|
||||
|
||||
|
||||
28
src/sp_lev.c
28
src/sp_lev.c
@@ -3271,11 +3271,37 @@ find_objtype(lua_State *L, const char *s)
|
||||
if (s) {
|
||||
int i;
|
||||
const char *objname;
|
||||
char class = 0;
|
||||
|
||||
/* In objects.h, some item classes are defined without prefixes (such
|
||||
* as "scroll of ") in their names, making some names (such as
|
||||
* "teleportation") ambiguous. Get the object class if it is
|
||||
* specified, and only return an object of the matching class. */
|
||||
struct {
|
||||
const char *prefix;
|
||||
char class;
|
||||
} class_prefixes[] = {
|
||||
{"ring of ", RING_CLASS},
|
||||
{"potion of ", POTION_CLASS},
|
||||
{"scroll of ", SCROLL_CLASS},
|
||||
{"spellbook of ", SPBOOK_CLASS},
|
||||
{"wand of ", WAND_CLASS},
|
||||
{NULL, 0}
|
||||
};
|
||||
for (i = 0; class_prefixes[i].prefix; i++) {
|
||||
const char *p = class_prefixes[i].prefix;
|
||||
if (!strncmpi(s, p, strlen(p))) {
|
||||
class = class_prefixes[i].class;
|
||||
s = s + strlen(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* find by object name */
|
||||
for (i = 0; i < NUM_OBJECTS; i++) {
|
||||
objname = OBJ_NAME(objects[i]);
|
||||
if (objname && !strcmpi(s, objname))
|
||||
if ((!class || class == objects[i].oc_class) &&
|
||||
objname && !strcmpi(s, objname))
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user