Skip to content
DG Scripts

TRIGEDIT

TRIGEDIT edits trigger prototypes. MEDIT, OEDIT, and REDIT attach those prototypes to mobiles, objects, and rooms.

Source of truthEditor, save path, and shared scripts menu: src/dgscript/dg_olc.c. Oasis routing: src/olc/oasis.c.

Open or create a trigger

Builder command
trigedit <vnum>

The argument must begin with a number. If the VNUM exists, the editor opens a copy of that prototype; otherwise it initializes a new trigger. The VNUM must belong to a real zone, and non-implementors must be assigned permission for that zone.

  • You must be a connected player character in normal play state; switched or forced NPC editing is rejected.
  • Only one descriptor can edit a given trigger VNUM at a time.
  • Use a VNUM inside your assigned zone and confirm it is not already allocated with tstat or tlist.

The main menu

Rendered by trigedit_disp_menu()
Trigger Editor [<vnum>]

1) Name         : <name>
2) Intended for : Objects | Rooms | Mobiles
3) Trigger types: <selected flags>
4) Numeric Arg  : <number>
5) Arguments    : <text>
6) Commands:
<script body>
W) Copy Trigger
Q) Quit
Enter Choice :
ChoiceWhat it changesBuilder decision
1 NamePrototype name shown by OLC, lists, and stats.Include location or purpose, not only the event name.
2 Intended forSets the attach type and selects the owner-specific type list.Choose before trigger types.
3 Trigger typesToggles one or more flags from the current owner list.Combine only compatible flags.
4 Numeric ArgStores one integer, clamped by TRIGEDIT to 0-100, and interpreted by the selected hook.Chance, hour, mask, threshold, or mode.
5 ArgumentsStores event match text.Mostly Command, Speech, and Act triggers.
6 CommandsOpens the multiline command editor.Write one command or control line per line.
W Copy TriggerLoads another trigger as the working copy.Review owner, flags, and embedded VNUMs after copying.
Q QuitPrompts to save when the working copy changed.Save only after rechecking all shared fields.

Configure owner, types, and arguments

Changing Intended for changes the list presented by choice 3. The selector stops at the end of that owner's actual table: mobile triggers have 21 choices through Damage, while object and room triggers have 20. Entries explicitly marked UNUSED remain reserved and should not be selected.

Catch attachment mismatches before runtime

The attached-triggers OLC menu labels a mismatched intended owner, and wtool validate reports the bad reference. The driver contains an additional type-versus-flag diagnostic abort only in builds compiled with SCRIPT_DEBUG; normal builds must not rely on it. Fix the attachment rather than guarding around a mismatch in the body.

Before opening the command editor, write down the event contract:

  1. Which exact hook invokes this type?
  2. What does Numeric Arg mean for this hook?
  3. Does Arguments use prefix, substring, word, or phrase matching?
  4. Which event variables are guaranteed?
  5. Does the caller consume the return value?

The complete answers are in the trigger type reference.

Edit the command list

Choice 6 enters the multiline string editor. The stored command list is split into lines when the prototype is parsed. Indentation is optional to the driver but valuable for nested structure.

Builder-friendly formatting
* Trigger-local guard
if %cmd.mudcommand% == examine && walls /= %arg%
  set clue ash
  %send% %actor% A single word glows in the plaster.
else
  return 0
end
  • Pair every if with end.
  • Pair every while or switch with done.
  • Use * as the first non-space character for comments.
  • Keep command-trigger guards at the top and return false on irrelevant input.
  • Use owner-neutral pseudo-commands only when their mapped syntax is valid for this owner.

Attach the prototype in MEDIT, OEDIT, or REDIT

Open the owning entity in the appropriate OLC editor and choose S for its scripts menu:

Shared attached-triggers menu
Triggers Attached:
  1) [<vnum>] <trigger name>

N) Attach trigger
X) Detach trigger
Q) Quit

Choose N, then enter either a VNUM or position, vnum, such as 1, 11868. A VNUM by itself appends the trigger. The menu warns when the prototype's intended owner does not match the edited entity.

Choose X and select the numbered attachment entry to remove it. Save the parent MEDIT, OEDIT, or REDIT session after leaving the scripts menu.

Prototype order matters

Hooks walk the attached trigger list. Put narrow interceptors before broader command triggers when both could handle the same event, and document intentional ordering.

Save, reload, and prove the edit

TRIGEDIT saves the trigger prototype and writes its zone trigger file. When an existing prototype is saved, matching live trigger instances receive the new body and fields; their waits are canceled, locals are cleared, and depth is reset. The owner editor saves the attachment list separately, and TRIGEDIT does not rebuild each owner's attachment set, aggregate event flags, owner globals, or broader entity state. Test changed attachment or event behavior with a fresh mobile or object instance.

  • Quit TRIGEDIT and answer yes to save the prototype.
  • Attach it through the correct owner editor and save that editor.
  • Use tstat <vnum> to confirm the stored fields.
  • Reload the mobile or object, or revisit/reset the room as appropriate.
  • Exercise positive, negative, repeated, and interrupted paths.
  • Run zone validation and check the game log.

See Testing and debugging for the full sequence.

What OLC writes to disk

Use OLC for normal editing. The disk format is useful for review and recovery, but the ASCII type flags are positional and owner-specific.

Trigger record shape in lib/world/trg/<zone>.trg
#<vnum>
<name>~
<attach-type> <ASCII type flags> <numeric-arg>
<arguments>~
<command body>~
$~

Attach types are 0 mobile, 1 object, and 2 room. Mobile, object, and room prototype records store each permanent attachment on a line shaped T <trigger-vnum>.

Do not hand-invent flag strings

TRIGEDIT and the source arrays own that encoding. Hand editing can silently shift a trigger to a different event when an ASCII flag position is misunderstood.