Scripts

Since v.84, Magic DOSBox supports simple scripting. It’s possible write java script, which can be executed with Combo/Deadly strike action.
Defined script must be bound to Deadly Strike / Combo through action.
Supported methods
•void setKeyboardVisibility(boolean show);
•boolean isKeyboardVisible();
•boolean setLayer(String layerID);
•void setLayerVisibility(boolean show);
•int getPixelTriggerState(String triggerID);
•void showToast(String message);
Keyboard methods
setKeyboardVisibility and isKeyboardVisible methods serves for manipulating with Magic Dosbox’s in-built keyboard.
Layer methods
setLayer(layerID) finds and sets layer for execution. setLayerVisibility(show) will be applied to the layer set by setLayer method.
Pixel Trigger Methods
int getPixelTriggerState(triggerID) can return values -1, 0, 1. It returns the current Pixel Trigger state.
•-1 - Pixel Trigger was not found by ID
•1 - Pixel Trigger is active
•0 - Pixel Trigger is not active
This method must be used only in the combo widget executed by Pixel Trigger and script action must be used before “wait/rest” combo action. In other case the state is not guaranteed.
Messaging Methods
showToast(message) - displays simple popup message

Examples

Example 1: Find and set layer by id. Then display it and at the end display simple message.
function main() {
  thiz.setLayer('3652830b-451e-4f34-a9bb-c1b053d14011');
  thiz.setLayerVisibility(true);
  thiz.showToast('Menu activated');
  return 0;
}
Example 2: Script is executed by Pixel Trigger. We check another Pixel Trigger in the script. If both matches then we display specific layer. Return value 1 stops all next combo actions from execution.
function main() {
 if (thiz.getPixelTriggerState('3652830b-451e-4f34-a9bb-c1b053d14011') == 1) {
  thiz.setLayer('11041d350b1c-bb9a-43f4-e154-b0382563');
  thiz.setLayerVisibility(true);
  return 0;
 }
 return 1;
}

How to get IDs for methods

•Layer – in design mode click on layer item, click on pencil and on dialog press the dragon icon
•Pixel Trigger – in the pixel trigger menu, open change name dialog and press the dragon icon
ID will be copied to clipboard, notification will be shown.
If it does not work, then check the game profile/Scripts directory for an error file. Every function must start with “thiz”.