All files / src/lib/events eventInputScriptSet.js

90% Statements 9/10
100% Branches 0/0
50% Functions 1/2
90% Lines 9/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 701x   1x 1x   1x           1x                                                                           1x 1x 1x               1x                    
const l10n = require("../helpers/l10n").default;
 
const id = "EVENT_SET_INPUT_SCRIPT";
const groups = ["EVENT_GROUP_INPUT"];
 
const autoLabel = (fetchArg) => {
  return l10n("EVENT_SET_INPUT_SCRIPT_LABEL", {
    input: fetchArg("input"),
  });
};
 
const fields = [
  {
    key: "input",
    label: l10n("FIELD_BUTTON"),
    description: l10n("FIELD_BUTTON_DESC"),
    type: "input",
    defaultValue: ["b"],
  },
  {
    key: "override",
    type: "checkbox",
    label: l10n("FIELD_OVERRIDE_DEFAULT_BUTTON_ACTION"),
    description: l10n("FIELD_OVERRIDE_DEFAULT_BUTTON_ACTION_DESC"),
    defaultValue: true,
  },
  {
    key: "__scriptTabs",
    type: "tabs",
    defaultValue: "press",
    values: {
      press: l10n("FIELD_ON_PRESS"),
    },
  },
  {
    key: "true",
    label: l10n("FIELD_ON_PRESS"),
    description: l10n("FIELD_ON_PRESS_DESC"),
    type: "events",
    allowedContexts: ["global", "entity", "prefab"],
    conditions: [
      {
        key: "__scriptTabs",
        in: [undefined, "press"],
      },
    ],
  },
];
 
const compile = (input, helpers) => {
  const { inputScriptSet, event } = helpers;
  inputScriptSet(
    input.input,
    input.override !== false,
    input.true,
    event.symbol
  );
};
 
module.exports = {
  id,
  description: l10n("EVENT_SET_INPUT_SCRIPT_DESC"),
  autoLabel,
  groups,
  fields,
  compile,
  editableSymbol: true,
  allowChildrenBeforeInitFade: true,
};