-
Get the SDK
Unzip
xScal-SDK.zipanywhere, for exampleC:\xscal-sdk. Inside is ansdkfolder withinclude,cmake,binandtemplate. -
Get a certificate
xScal only loads plugins that are signed with a certificate from the xScal maintainers.
- Run
sdk\bin\xscal-sign.exe keygen dev.key dev.pub(on Linux, under Wine).dev.keyis your private key: keep it to yourself and do not commit it.dev.pubis public. - Send
dev.puband the plugin ID prefix you want, for exampleacme_, to the xScal maintainer. - You get back
dev.xcert. It is not secret.
Set the environment variables
XSCAL_SIGNING_KEYandXSCAL_SIGNING_CERTIFICATEto the full paths ofdev.keyanddev.xcertbefore you run CMake. Without them the build still works, but the DLL is unsigned and xScal will not load it. - Run
-
Copy the template
Copy
sdk\templateto a new folder for your plugin, for exampleC:\MyPlugin. It holds two files:CMakeLists.txtandplugin.cpp. -
Rename things in
CMakeLists.txtexample_plugin→ your project name.OUTPUT_NAME ExamplePlugin→ the DLL name, for exampleMyPlugin.
-
Rename things in
plugin.cpp.id = "example_plugin"→ something unique that starts with your certificate prefix, such as"acme_myplugin"(at most 63 bytes). xScal rejects a plugin whose ID does not start with the prefix..name = "Example Plugin"→ the name shown inxscal.log."ExamplePlugin.IsEnabled"→"MyPlugin.Whatever". Every call name starts with your plugin name so it does not clash with xScal or other plugins.- The option texts
"Enabled","Example Plugin"and"Enable the example feature".
-
Add your code
- Startup code goes in
load(). Return0there to refuse loading. - Each function your SWF calls is a callback like
isEnabled, plus one line in thescaleformCallbackslist. - Write to the log with
xscal::log(host, "text %d", number);
The comments in
sdk\include\xscal\plugin_api.hdescribe every structure and callback. - Startup code goes in
-
Build it
Windows
Install Visual Studio with the “Desktop development with C++” workload and CMake 3.25 or later, then run:
cmake -S C:\MyPlugin -B C:\MyPlugin\build -A x64 -DxScalPlugin_DIR=C:\xscal-sdk\sdk\cmake cmake --build C:\MyPlugin\build --config ReleaseLinux (cross-compile)
Install CMake 3.29 or later, Ninja, LLVM (
clang-cl,lld-link,llvm-lib,llvm-ml,llvm-mt,llvm-rc) and xwin. Download the Windows SDK and C runtime once:xwin --accept-license --arch x86_64 --variant desktop splat --output ~/.xwinThen build with the toolchain file that ships in the SDK:
cmake -S ~/MyPlugin -B ~/MyPlugin/build -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_TOOLCHAIN_FILE=$HOME/xscal-sdk/sdk/cmake/toolchains/xwin-clang.cmake \ -DXWIN_ROOT=$HOME/.xwin \ -DxScalPlugin_DIR=$HOME/xscal-sdk/sdk/cmake cmake --build ~/MyPlugin/buildThe DLL is written to
build\Release\Data\XSCAL\Plugins\MyPlugin.dll. When the signing variables are set, the build also writesMyPlugin.dll.signext to it. Each rebuild replaces the.sig; a.sigfrom an older build no longer matches the DLL. -
Install it
Copy
MyPlugin.dllandMyPlugin.dll.sigtoData\XSCAL\Plugins\in the game folder. Give other people both files too. xScal (dxgi.dll) must already be installed there. -
Check that it loaded
Start the game and open
xscal.log.Loaded:xScal module 'acme_myplugin' (My Plugin): loadedRejected:xScal plugin '…': <reason>. The reason says what to fix, for examplemissing signature fileorfile does not match signature(the DLL was rebuilt after it was signed). -
Call it from your SWF
try { var result:* = __SFCodeObj.call("MyPlugin.Whatever"); } catch (error:Error) { // xScal or the plugin is not installed. }For everything else you can call from a SWF, see the Movie API guide.
MyPlugin.dll_disabled to turn it off. Restart the game after adding, removing or renaming a plugin.