helpers.registerVariable, variable blocks

This commit is contained in:
Loren Norman 2025-08-01 16:22:34 -04:00
parent 52c77e93dc
commit fdabcd552e
3 changed files with 4 additions and 0 deletions

View file

@ -1,3 +1,4 @@
/** @type {import('#types').BlockDefinitionRaw} */
export default { export default {
type: 'io_variables_get', type: 'io_variables_get',
bytecodeKey: "getVariable", bytecodeKey: "getVariable",

View file

@ -1,3 +1,4 @@
/** @type {import('#types').BlockDefinitionRaw} */
export default { export default {
type: 'io_variables_set', type: 'io_variables_set',
bytecodeKey: "setVariable", bytecodeKey: "setVariable",
@ -36,6 +37,7 @@ export default {
const const
defaultedValue = value defaultedValue = value
? JSON.parse(value) ? JSON.parse(value)
// TODO: is this !== 0 check superfluous?
: (value !== 0 && value !== null) && null, : (value !== 0 && value !== null) && null,
blockPayload = JSON.stringify({ blockPayload = JSON.stringify({
setVariable: { setVariable: {

View file

@ -48,6 +48,7 @@
* @typedef {object} BlockRegeneratorHelpers * @typedef {object} BlockRegeneratorHelpers
* @property {function} expressionToBlock * @property {function} expressionToBlock
* @property {function} arrayToStatements * @property {function} arrayToStatements
* @property {function} registerVariable
*/ */
/** /**