and actually do so in the lua files.
Before this, it was not possible to specify (for example) "scroll of
teleportation" in des.object() because there is actually no object
defined in objects.h named "scroll of teleportation", so
find_objtype() failed to find it. Instead, one had to request
"teleportation", but that is ambiguous, and find_objtype() would find
the first defined item with that name instead (ring of teleportation).
In cases of ambiguity, I referred to the des files from 3.6.6 (before
the lua conversion).
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()
-- 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()
});
-- 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
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")
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)
-- 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
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" });
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" });
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 = "%" });
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 = "%" });
});
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))
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;
}