Author: simast
Author Website:

Requirements: No addons required

Version: 0.6
Signed: No

Short description: This addon adds JavaScript scripting support for ARMA addons and missions.

Date: 2013-07-07 18:16

Comments: (0)


JavaScript [ALPHA]


This addon adds JavaScript scripting support for ARMA addons and missions. The JavaScript language is powered by the very (very) speedy Google’s V8 Engine. V8 implements ECMAScript as specified in ECMA-262, 5th edition.

This is a preview release. I encourage you to test it, run some performance tests and simply report any issues you encounter. Not all the planned features are implemented yet (see TODO section). I haven't signed this with multiplayer bikeys's yet as this preview release is intended for a client side testing only.

Be aware of the following limitations:
  • You cannot use and call SQF commands from within JavaScript context. This is a limitation of the [FONT=Courier New]callExtension[/FONT] DLL interface/API.
  • Linux dedicated server is not supported at the moment (according to Wiki the [FONT=Courier New]callExtension[/FONT] does not support Linux shared libraries (.so). I would love to implement a native Linux port if the BIS would add the required [FONT=Courier New]callExtension[/FONT] support).
  • The return value of [FONT=Courier New]JS_fnc_exec[/FONT] has a hard buffer limit (max 10kb output) – a limitation of the [FONT=Courier New]callExtension[/FONT] interface. You may have issues returning large strings or large arrays from JavaScript. Technically, I think I know how to bypass this limitation and make it transparent, so this issue is temporary and will be resolved in the upcoming updates. At the moment if you hit the output buffer limit - SQF will throw a "[OOB]" exception so you can still handle the issue with SQF code.
Since you cannot directly call SQF commands from JavaScript – the main idea of this addon is to use JavaScript to offload complex algorithms and computations that require fast execution and do not depend on ARMA/SQF state. Also, you get the following native JavaScript language features for free:
The following functions are provided by this addon:
  • JS_fnc_exec - Execute JavaScript code and return the result.
  • JS_fnc_spawn - Execute JavaScript code in parallel (non-blocking mode, separate thread).
  • JS_fnc_terminate - Terminate (abort) a spawned JavaScript script (not implemented yet).
  • JS_fnc_done - Check if a spawned JavaScript script is done/finished (not implemented yet).
  • JS_fnc_version - Get addon and JavaScript engine version information.

Extract into the ArmA 3 Directory, by default this is located in:
32-Bit - C:/Program Files/Steam/Steamapps/Common/ArmA 3/
64-Bit - C:/Program Files (x86)/Steam/Steamapps/Common/ArmA 3/
After extraction it should look like this:
Steam/Steamapps/Common/ArmA 3/@your_mod_folder_name

You can also use the "Arma 3 Alpha" folder in your "My Documents" folder. Your folder setup could than look like for example this:
mydocuments\Arma3 Alpha\@your_mod_folder_name\
mydocuments\Arma3 Alpha\@your_mod_folder_name\
mydocuments\Arma3 Alpha\@your_mod_folder_name\

You'll also need to add a Launch Parameter to Steam, in order to do so right-click on ArmA 3 Alpha and click Properties and then Set Launch Options. In the window that opens enter in -mod=@your_mod_folder_name
For using multiple mods you would then do so like this:

You can also use -nosplash to get rid of the splash art and intro videos.

And of course you can also enable and disable community made addons and mods through the in-game Options Expansions menu if you do not want to mess with startup parameters!

When the above information still does not provide you with enough to learn how to install custom addons and mods you can always ask in our Guide On Installing Mods.

Included files:

Refer to the information and examples in this post. The documentation is still to be done!

To do:
- Implement the workaround around callExtension output buffer limitation.
- Add JavaScript uiSleep() function.
- Add global property/accessor as alias for JavaScript global object.
- Add JavaScript log() function to allow logging to ARMA RPT file directly from JavaScript context.
- Detect when ARMA is paused (suspend background scripts and use v8::V8::IdleNotification() internally).
- Consider adding two additional functions: JS_fnc_compile and JS_fnc_run that would work directly with V8 script handles and would allow you to skip repeated compilations.
- Double check everything and do a final review of the code.

This addon is open source with code available under GPL 3.

- Updated V8 to 3.20.2.
- Implemented background script handles (returned by JS_fnc_spawn).
- Implemented JS_fnc_done and JS_fnc_terminate functions.
- Added sleep(seconds) JavaScript function.
- Added a common header file (#include "\JS\API.hpp") with JS(code) macro.
- PBO and extension DLL files are now signed with bikeys (server-side key is included).
- Other internal tweaks and optimizations.

Forum topic:
- BI forums

Enable javascript to be able to download from Armaholic please!

Tags: Javascript