Item-shell scripting detail for new creators. This page assumes you can already create and attach an item SpecProc (Script objects) and that the object prototype exists (Objects).
If you only remember one teaching point: many “item quests” are really mobile scripts that inspect var.item. Put behavior on the entity whose event actually fires. This page documents what you can do when the item proc runs, and the item-side primitives mobile scripts call.
Hub: Script Law.
> @proc item new my_sword_proc Okay. > @proc item script my_sword_proc (paste Beanshell that branches on var.STATE; end with return false;) > @load item 3100 > @item proc my_sword_proc > @examine item > @save item > create item 3100 >
Full attach pedagogy: Script objects.
Item procs receive an ItemEvent.Var. Fields you will read or branch on:
STATE, state — trigger kind and a free mutable script state integeritem — the SpecProc owner shell (ItemScript / item shell)mobile, room, victim, victims, items — context when the event provides themcommand, args — when interpreter / post-interpreter hooks firem, it, rm, s, n where the Var exposes them
Always branch on var.STATE (or named constants like var.STATE_POST_INTERPRETER). Return false unless you mean to block the triggering command.
Why branching matters: the same script text can be invoked for different STATEs. A stub that only chatters on STATE_SCRIPT will look “broken” if you were testing a give/drop path that never hits that STATE.
Scripts call methods on shells rather than inventing verbs. From code and live world usage, item shells expose (illustrative — not an exhaustive javadoc dump):
isWeapon, isKey, and related is… helpers present on ItemShellpurge() — remove this item instancevid() — prototype / instance identity checks in quest scriptscreateMobile / fill helpers — where the shell provides them
Every eval also binds util: roll, chance, limit, max, min, getPosInt, tokenizerNoFill, …
Rule for new creators: before you invent a call, run @proc item examine <existing> or index proc_item and copy a pattern that already works. Only methods on ItemShell / script subclasses are legal. Fabricating var.item.doSomethingCool() will fail at eval time.
Use when ambient item logic should only run for weapons (or keys, …):
if (var.STATE == var.STATE_SCRIPT) {
if (var.item.isWeapon()) {
// weapon-only flavor — keep it cheap
}
}
return false;
If an is… method is missing at eval time, you invented it — examine a live proc or shell source; do not guess.
Quest turn-ins typically live on the mobile (see thanksgiving on Script mobiles). The item-side primitives those scripts rely on:
var.item.vid() — compare to the quest prototype VID you built in Creationvar.item.purge() — consume the turned-in instancecreateItem (or equivalent shell helper) — grant the rewardTeaching checklist when something “eats the give” wrong:
stat item, Creation notes)true only when you intend to consume/block the givepurge leftover rewards and re-create the quest itemgive, say, sayto, socials, combat involving the NPC@item proc and expected a shopkeeper to thank you for a give, move the quest logic to @npc proc> @proc item script my_sword_proc (revise Beanshell, finish writer) > purge sword > create item 3100 (exercise the trigger again) >
If a zone loads the object, @save the script then zone reset so you are not staring at an old mental model of “stale instances.” Script text lives on the SpecProc row; the prototype must still @item proc that name.
EvalError caught; when the proc name matches a player, that player may receive the error textEventable.MAX_LAG_TIME) are loggedSpecProc — leave no leftover globals; runtime unsets var / util after each eval@proc item delete only after prototypes stop naming the procgive (that is usually the mobile)return false;index proc_item cannot find