====== Script Law — Objects ====== How to put a Beanshell SpecProc on an **object prototype**. Classic ''oedit'' script fields / dg object scripts are not the Neo path: create ''@proc item'', then ''@item proc '' on the item prototype you built in Creation. Hub: [[immortal:scriptlaw|Script Law]]. Build first: [[immortal:creationlaw:objects|Creation Law — Objects]]. Shell method detail: [[immortal:scriptlaw:items|Script Law — Items]]. ===== Objects vs items (script side) ===== * **Objects (this page)** — workflow: create item SpecProc → attach on ''@item'' → save → spawn-test. * **Items ([[immortal:scriptlaw:items|scriptitems]])** — what you can call on ''var.item'' (''isWeapon'', ''purge'', ''createMobile'', …) and item ''Var'' fields. Neo still has no separate ''@object'' verb; procs are ''@proc item'' / ''@item proc''. ===== Why this order ===== The prototype only stores the **name** of a SpecProc. The Beanshell text lives in the SpecProc table. If you ''@item proc my_sword_proc'' before ''@proc item new/script my_sword_proc'', you attach a dangling name and runtime looks broken. Create → write → examine/index → attach → examine → save → spawn. ===== Order of operations ===== - [ ] Object prototype exists (descr + stats + item linked) — [[immortal:creationlaw:objects|Objects]] - [ ] ''@proc item new '' + ''@proc item script '' - [ ] ''index proc_item'' / ''@proc item examine '' - [ ] ''@load item '' → ''@item proc '' → ''@examine item'' → ''@save item'' - [ ] ''create item '' / ''load item'' and exercise the trigger ===== Create an item SpecProc ===== > @proc item new my_sword_proc Okay. > @proc item script my_sword_proc (writer opens — paste Beanshell, finish) > @proc item examine my_sword_proc > @proc item matrix my_sword_proc 0.0 Okay. > index proc_item sword > Pattern: ''@proc item [delete|examine|new|matrix|rename|script] ''. Names: lowercase, alphabetic/underscore, length 3–16 (''SpecProc.MIN_NAME_LEN'' / ''MAX_NAME_LEN''). Rename when the name was a draft: > @proc item rename my_sword_proc blade_hum Okay. > Then update any prototype that still says ''my_sword_proc'' (''@load item'' → ''@item proc blade_hum'' → ''@save item''). Personal writer option: > script item list > script item write > ===== Attach on the prototype ===== > @load item 3100 Okay. > @item proc my_sword_proc Okay. > @examine item (confirm proc field) > @save item Okay. > create item 3100 You create a tempered shortsword. > If ''@load item'' errors because a draft is open, ''@examine item'' then ''@save'' or ''@clear''. After editing script text later, ''purge'' the old instance and ''create'' again (or ''zone reset'' if the zone loads it). ===== Cautious first stub ===== Until you know which STATEs your item proc receives, keep the stub loud and harmless: if (var.STATE == var.STATE_SCRIPT) { if (util.chance(100)) { // rare pulse — replace with real logic later } } return false; Then expand using APIs from [[immortal:scriptlaw:items|Script items]]. Prefer copying from ''@proc item examine'' on a live proc over inventing calls. ===== Object-proc workflow with Creation ===== Full path from nothing: > @new item_descr 3100 … strings … > @save item_descr > @new item_stats 3100 > @item_stats type weapon > @item_stats flags wear take > @item_stats flags wear wield > @save item_stats > @new item 3100 > @item description 3100 > @item stats 3100 > @examine item > @save item > @proc item new my_sword_proc > @proc item script my_sword_proc (paste stub that branches on var.STATE, return false) > @load item 3100 > @item proc my_sword_proc > @examine item > @save item > create item 3100 > ===== Matrix note ===== ''@proc item matrix '' stores builder metadata. It is **not** combat power (combat matrix is ''Matrix.calculate'' / ''Mobile.matrix()''). Live procs often leave ''0.0''. ===== Compiled vs Beanshell ===== Free-form scripts use ''@item proc''. Hard-coded Java item specials use ''SpecItem'' on ''@item_stats attrs'' ([[immortal:creationlaw:items|Items]], Script Law hub). Pick one model per behavior; do not assume both fire the same way. ===== Common mistakes ===== * Attaching before the proc row exists * ''@save'' forgotten after ''@item proc'' * Editing the script but testing an old instance * Renaming a proc without updating prototypes * Putting give-quest logic only on the item when the mobile event is what fires ([[immortal:scriptlaw:items|Script items]], [[immortal:scriptlaw:mobiles|Script mobiles]]) ===== Related ===== * [[immortal:scriptlaw:items|Script items]] — APIs and patterns * [[immortal:creationlaw:objects|Creation objects]] — three-layer build * [[immortal:scriptlaw:mobiles|Script mobiles]] — often paired (give/wield reactions) * [[immortal:scriptlaw|Script Law]] — hub