Fwatch 1.15 On-Line Documentation


Using Commands

Syntax
Data Types
Error Handling
Memory Commands on a Dedicated Server
Source Directory for the FILE Commands
Source Directory for the New Commands
Game Limitations


Syntax

Fwatch can be called by any command that reads an external file (addAction, exec, loadFile or preprocessFile).

String that you pass to one of these commands begins with a backslash and a colon followed by the Fwatch command name. Subsequent phrases are treated as arguments.
\:name1 name2 argument1 argument2 argument3 argument4
for example:
loadFile "\:file write test.db foo 1"
Backslash is not obligatory but recommended because in its absence long arguments will crash the game.

All arguments are required unless stated otherwise. They must be written in the specified order.

If you want to pass string with spaces then put it into additional quotation marks. Otherwise every word is going to count as a separate parameter.
loadFile Format ["\:file read ""%1"" %2", "My File.txt", "foo"] - correct
loadFile Format [{\:file read "%1" %2}, "My File.txt", "foo"] - correct
loadFile Format ["\:file read %1 %2", "My File.txt", "foo"] - incorrect

30 new commands   (show)   feature named arguments. Each value must be preceded with a keyword and a colon. \:igse load  end:150  split:true  ""file:name with spaces.txt"" All arguments are optional. They can be written in any order. Arguments that require boolean are false by default. If you pass empty string, zero or false then the option will remain turned off. For any other value - it will be activated.

Text arguments in the new system do not need quotes. Instead they are separated by "Unit Separator" character. Hold ALT and press 0, 3, 1 on numeric keypad and release ALT. \:string compare text1:hello worldtext2:hi world It's indicated on the command page which arguments require this notation.


Data Types

All input and output data are de facto strings. However, in command reference they are treated for what they represent.

For example: :info lock returns string containing an array. _lock = loadFile ":info lock"
_lock = "[true,false,false]"
To assign that array to a variable use call command: _lock = call loadFile ":info lock"
_lock = [true,false,false]
New commands that only return a string (e.g. :string replace) do not require execution of call as it would be redundant. See example code in the command description page.


Error Handling

33 commands return detailed error description   (show)

Error information is stored in the output array. For 5 FILE commands (show) it is stored in a separate local array _fwatch_error instead (it needs to be declared beforehand).

Array contains following items:
Example: _result = call loadFile "\:IGSE LOAD  file:???"
? !(_result select 0) : hint (_result select 3)

; For FILE commands
_fwatch_error = [true, 0, 0, ""]
_variable = call loadFile "\:FILE READ  test.db  foo"
? !(_fwatch_error select 0) : hint (_fwatch_error select 3)


Memory Commands on a Dedicated Server

Only 10 mem commands will work on a dedicated server: :mem bullets
:mem getdaylight
:mem getdifficulty
:mem getrespawntype
:mem getresside
:mem getweather
:mem getworld
:mem missioninfo
:mem setdifficulty
:mem setweather
Fwatch automatically recognises whether they are executed on a client or a server.


Source Directory for the FILE Commands

FILE type commands (e.g. :file write) save to and read from fwatch\mdb\ directory. File names are converted to lowercase and all slashes and other invalid characters in it will be replaced with an underscore.


Source Directory for the New Commands

Default working directory for the CLASS, IGSE and CLIP type commands is current (unpacked) mission folder. They will return error on PBO missions.

To access game root directory start the path with ..\ \:igse load  file:..\res\bin\config.cpp
Commands that modify files are restricted from operating outside except for these hardcoded locations:
..\fwatch\idb
..\fwatch\tmp
..\in-game-script-editor
..\flashpointcutscenemaker
..\missioneditor3d
..\@addontest
fwatch\idb is a new common storage folder for save data.
fwatch\tmp is meant for temporary files and also stores data downloaded with :exe wget.

Commands that remove files actually move them to the recycle bin instead (unless the file is stored in fwatch\tmp - then it's deleted).


Game Limitations

Command format will crash the game when input text is larger than 2048 characters. Use concatenation operator to work around (it's slower, though).

Game will not create arrays with too many elements. For example: if you append 257 elements with :file awrite and then try to read it with :file read the game will display an error. To work around this issue merge smaller arrays into a big one.

Topics:
What is Fwatch?
What's new?
Download & Startup

Presence Check
Using Commands
Input Commands Info
Animation Codes
Function & Script Library
Recommended Practices

Extras
Changelog
Source
Credits

Discuss Scripting
Post Request

Fwatch 1.16 Beta
Mod Manager