Show pageOld revisionsBacklinksBack to top You've loaded an old revision of the document! If you save it, you will create a new version with this data. Media Files ====== 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 <name>'' on the item prototype you built in Creation. Hub: [[scriptlaw|Script Law]]. Build first: [[creationobjects|Creation Law — Objects]]. Shell method detail: [[scriptitems|Script Law — Items]]. ===== Objects vs items (script side) ===== * **Objects (this page)** — workflow: create item SpecProc → attach on ''@item'' → save → spawn-test. * **Items ([[scriptitems|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) — [[creationobjects|Objects]] - [ ] ''@proc item new <name>'' + ''@proc item script <name>'' - [ ] ''index proc_item'' / ''@proc item examine <name>'' - [ ] ''@load item <vid>'' → ''@item proc <name>'' → ''@examine item'' → ''@save item'' - [ ] ''create item <vid>'' / ''load item'' and exercise the trigger ===== Create an item SpecProc ===== <code mud> > @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 > </code> Pattern: ''@proc item [delete|examine|new|matrix|rename|script] <name>''. Names: lowercase, alphabetic/underscore, length 3–16 (''SpecProc.MIN_NAME_LEN'' / ''MAX_NAME_LEN''). Rename when the name was a draft: <code mud> > @proc item rename my_sword_proc blade_hum Okay. > </code> Then update any prototype that still says ''my_sword_proc'' (''@load item'' → ''@item proc blade_hum'' → ''@save item''). Personal writer option: <code mud> > script item list > script item write > </code> ===== Attach on the prototype ===== <code mud> > @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. > </code> 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: <code mud> if (var.STATE == var.STATE_SCRIPT) { if (util.chance(100)) { // rare pulse — replace with real logic later } } return false; </code> Then expand using APIs from [[scriptitems|Script items]]. Prefer copying from ''@proc item examine'' on a live proc over inventing calls. ===== Object-proc workflow with Creation ===== Full path from nothing: <code mud> > @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 > </code> ===== Matrix note ===== ''@proc item matrix <name> <double>'' 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'' ([[creationitems|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 ([[scriptitems|Script items]], [[scriptmobiles|Script mobiles]]) ===== Related ===== * [[scriptitems|Script items]] — APIs and patterns * [[creationobjects|Creation objects]] — three-layer build * [[scriptmobiles|Script mobiles]] — often paired (give/wield reactions) * [[scriptlaw|Script Law]] — hub SavePreviewCancel Edit summary Note: By editing this page you agree to license your content under the following license: CC Attribution-Share Alike 4.0 International scriptobjects.1790178414.txt.gz Last modified: 2026/09/23 15:46(external edit)