Script Editor

Tutorial · 3:11

The Script Editor is where you write the Enforce Script code of a mod (the .c files) and its config.cpp, and where you read the game's own scripts to learn how something is done. It checks the code while you type, completes names, shows the declaration of what you hover, and jumps to any class or method of the game or of your mod. You need a mod folder (a "workspace") to write code, and the DayZ folder set in Settings to browse the game's scripts; reading the game's scripts works without any mod.

The screen

First steps

  1. Open the page and click the Vanilla tab.
  2. Under scripts, open 4_World, Entities, ManBase and click PlayerBase.c. It opens read-only.
  3. In the Outline, click a method to go to it. Hover a type name to see its declaration; press F12 (or Ctrl+Click) on a name to jump to where it is defined.
  4. Click the Symbols tab, type MissionServer and click the class: another game file opens at the declaration.
  5. Go back to Explorer. If it says there is no workspace, add your mod folder or create a mod from the template. Then click +, keep "modded class", type a file name and create it.
  6. Type some code, watch the Problems bar at the bottom, and save with Ctrl+S.

Take the tour (in the app)

Common tasks

Create a script in your mod

  1. In the Explorer, click + (or right-click the folder the file should go to, then New script).
  2. Choose the script module (3_Game, 4_World or 5_Mission), type the file name, choose the content: a modded class (change a game class), a class (a new class) or an empty file.
  3. Check the path shown at the bottom of the dialog, then Create.

The file goes to Scripts/<module>/<mod id>/<name>.c of the mod (existing folder spellings are kept). If the module is not declared in the CfgMods block of the mod's config.cpp, the page adds it and tells you; without that declaration the game does not load the folder.

Change a game class (modded class)

  1. Find the class with the Symbols tab and open it.
  2. Read the method you want to change and note its signature.
  3. Either click Copy into my mod in the read-only banner (the copy goes to the same script module of your mod; then keep only what you change and write modded class in front of the class), or create a new script with the "modded class" content and the same class name.
  4. Write the override of the method; call super.<Method>(...) when the original must still run.
  5. Save, then check the Problems list.

Take the tour of this task (in the app)

Find where something is defined or used

  1. Put the cursor on a name. F12 or Ctrl+Click goes to its definition (in the game's scripts too).
  2. Shift+F12 lists every use in the References tab of the bottom panel.
  3. For a name you do not have on screen, use the Symbols tab.

Fix the script errors of the last game run

  1. Run the game or the server with your mod (Launcher page).
  2. Come back here and open the bottom panel: under your files' problems, the section "Game log" lists compile errors and script exceptions of the newest log, each with its count.
  3. Click one: the file of your mod opens at the faulty line. Fix, save, run again.

Warnings of the log are listed only for files of your own mod.

Debug a script with breakpoints

  1. Open the Debug tab of the bottom panel and click Listen (default port 41001).
  2. Start the diagnostic build of the game, DayZDiag, with -debuggerPort=<port>, or use "Attach script debugger" in the Launcher. The badge turns to "connected".
  3. Click left of a line number (or press F9) to set a breakpoint. When the game reaches it, the line is highlighted and the call stack and variables fill in.
  4. F5 continues, F10 steps over, F11 steps into, Shift+F11 steps out.
  5. "Hot reload on save" recompiles a saved script in the running game (the game must be started with -filePatching).

Start from a recipe

With no file open, the empty state lists the recipes for this page as chips (New mod, Teleport new players, New crafting recipe…): a click starts one in Beans Assistant, which asks a few questions, proposes a plan and works step by step with checks. All recipes opens the whole catalogue. The help panel (F1) lists them too.

Examples

Concepts

Pitfalls

For agents

Tools of dzt that do the same work without the window:

Files the page reads and writes:

What the page tells the assistant (its page context): the active file (path or vfs: key), the cursor line, the number of open tabs, whether the file has unsaved edits, and its problems as line N: severity message. With no file open the context is empty. It offers one action: review the open file.

See also