Script Editor
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
- Left pane, three tabs.
- Explorer: the folders of your mod(s) on disk. Click a file to open it. The filter box narrows the files by name, the + button creates a script, the link button opens the mod in an external editor (VS Code by default). Right-click a file or a folder for New script, New folder, Open in external editor, Rename and Delete (Delete asks for a second click).
- Vanilla: the tree of the game's scripts, read from the game's
scripts.pbo. "Vanilla" means the unmodified game. Files open read-only. - Symbols: a search over every class, method, field and enum of the game and of your mod. Type at least two characters; a click opens the file at the declaration. The line under the box says whether the script index is ready.
- The ? at the right of the tabs opens this help (F1 does the same).
- File tabs (top of the middle): one tab per open file. A dot marks unsaved edits; game files carry "read-only". Close with the cross or a middle click.
- Path line: the path of the active file, the cursor position, the language, and the Save button.
- Read-only banner (game scripts only): says the file cannot be changed and offers Copy into my mod.
- Editor: the code. Problems are underlined; breakpoints are set in the gutter left of the line numbers.
- Bottom panel (collapsed to one bar until you click it):
- Problems: errors and warnings of all open files, then the script errors found in the game's newest script log or RPT. A click opens the file at the line.
- References: the uses of a symbol, after Shift+F12 in the editor.
Dmarks a declaration,Ra use. - Debug: the script debugger (listener, Continue and Step buttons, call stack, variables, and a console that runs Enforce Script in the game).
- Outline (right, when a file is open): the classes of the file and their members. Click one to go to it.
First steps
- Open the page and click the Vanilla tab.
- Under
scripts, open4_World,Entities,ManBaseand clickPlayerBase.c. It opens read-only. - 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.
- Click the Symbols tab, type
MissionServerand click the class: another game file opens at the declaration. - 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.
- 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
- In the Explorer, click + (or right-click the folder the file should go to, then New script).
- Choose the script module (
3_Game,4_Worldor5_Mission), type the file name, choose the content: amodded class(change a game class), aclass(a new class) or an empty file. - 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)
- Find the class with the Symbols tab and open it.
- Read the method you want to change and note its signature.
- 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 classin front of the class), or create a new script with the "modded class" content and the same class name. - Write the
overrideof the method; callsuper.<Method>(...)when the original must still run. - Save, then check the Problems list.
Take the tour of this task (in the app)
Find where something is defined or used
- Put the cursor on a name. F12 or Ctrl+Click goes to its definition (in the game's scripts too).
- Shift+F12 lists every use in the References tab of the bottom panel.
- For a name you do not have on screen, use the Symbols tab.
Fix the script errors of the last game run
- Run the game or the server with your mod (Launcher page).
- 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.
- 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
- Open the Debug tab of the bottom panel and click Listen (default port 41001).
- Start the diagnostic build of the game, DayZDiag, with
-debuggerPort=<port>, or use "Attach script debugger" in the Launcher. The badge turns to "connected". - 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.
- F5 continues, F10 steps over, F11 steps into, Shift+F11 steps out.
- "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
- PlayerBase: the player (in the app): the class of every survivor and the most modded
class of the game. Look at how long it is, and use the Outline to reach
OnConnectorEEKilled. - MissionServer: what the server does (in the app):
OnInit, the client events (OnClientNewEvent,InvokeOnConnect,InvokeOnDisconnect), andCreateCharacter/StartingEquipSetup, which decide what a fresh spawn wears. - Canteen: a small item class (in the app):
class Canteen extends Bottle_Base, a handful ofoverridemethods returning sound set names, andCanPutInCargocallingsuperfirst. - ActionDrink: a player action (in the app): the constructor sets the callback class, the
animation command and the text;
CreateConditionComponentssets the conditions on the item and the target; the callback class sets the duration.
Concepts
- Enforce Script: the scripting language of DayZ, in
.cfiles (it is not C). Classes, single inheritance,override,super, typed variables. Reference: Enforce Script Syntax. - Script modules: the game compiles its scripts in five layers,
1_Core,2_GameLib,3_Game,4_World,5_Mission, in that order. Code of a module sees the classes of its own and of the lower modules only. A mod adds files to3_Game,4_Worldand5_Mission; a modded class must live in the module of the class it changes. - Modded class:
modded class PlayerBase { ... }adds members to an existing class or replaces its methods, without editing the game's file. Several mods can mod the same class; eachsupercall reaches the previous one in load order. - config.cpp and CfgMods: the
config.cppof a mod declares the mod (CfgPatches) and, inCfgMods, aclass defsblock with one entry per script module (gameScriptModule,worldScriptModule,missionScriptModule) naming the folder to compile. A folder that is not declared there is ignored by the game. See Modding Basics. - PBO: the archive format the game loads. The game's scripts are in
dta/scripts.pbo; your mod is packed into a PBO by the PBO Packer. This page reads PBOs and never writes them. - DayZDiag: the diagnostic executable shipped with the game. The script debugger of this page
listens on a port and DayZDiag connects to it when started with
-debuggerPort=<port>.
Pitfalls
- Trying to edit a game script: the file is read-only and Save is disabled. Use Copy into my mod or a modded class.
- Leaving a whole copied game file in the mod: the game then finds every class twice. After
Copy into my mod, keep only the classes you change, as
modded class. - Putting a modded class in the wrong module (a
4_Worldclass modded from5_Mission): Copy into my mod keeps the module of the game file; in the New script dialog, pick it yourself. - Forgetting to declare a script module in
config.cpp: the page adds the entry when it creates a script, and warns when the file has noCfgMods/class defsblock to add it to. - An override whose signature differs from the original: read the Problems list before packing.
- Editing the same file in VS Code and here: files changed outside are reloaded; when the tab has unsaved edits a banner asks Reload from disk or Keep my version, and Save waits for the choice.
- Old scripts that are not UTF-8 are opened as Latin-1 and saved back the same way; characters
outside Latin-1 become
?(a warning says so when the file opens). - The Problems list covers the open files only. Check the whole mod with
script_check, or read the game log after a run.
For agents
Tools of dzt that do the same work without the window:
script_symbols: fuzzy search of classes, methods, fields, enums and globals in the game's scripts and the mod workspaces (Class.membersearches members). Same index as the Symbols tab.script_class: one class in full: where it is declared, base classes, modded declarations, subclasses, members with signatures. Use it before writing an override.script_grep: regular expression search in the game's scripts and the mod folders (callers, string literals).script_check: syntax errors and semantic warnings of every script of a mod folder. Run it after editing, before packing.vfs_search,vfs_read: find and read a game file by virtual path (for examplescripts/4_world/entities/manbase/playerbase.c).config_check: diagnostics of aconfig.cpp(the page runs the same checks on an open config).file_read,file_edit,file_write,file_move,file_delete: the mod's own files.mod_new: a new mod from the template.logs_tail,fix_scan: the game's logs and their errors.debug_listen,debug_status,debug_set_breakpoints,debug_wait,debug_control,debug_variables,debug_exec,debug_recompile,debug_log: the script debugger.
Files the page reads and writes:
- Reads: the workspace folders (Settings), the game's PBOs through the virtual file system
(
dta/scripts.pbofor the Vanilla tab), the newestscript_*.logor.RPTof the game's profile folders. - Writes: only inside a workspace folder: the script you save (same encoding as read), new
scripts and folders, renames and deletions, and the
CfgModsentry added to the mod'sconfig.cpp. Game files are never written. - A document is identified by its path on disk, or by
vfs:<virtual path>for a game file. An open request with avfs:path opens that game file read-only.
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
- Config (CfgConvert): convert and check config files.
- Layout Editor: the UI files your scripts load; How DZML works.
- PBO Packer: pack the mod once the scripts are clean.
- Launcher: run the game or a local server with the mod, attach the debugger.