Skip to content

Commit

Permalink
Create vars.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Mistium authored Aug 6, 2024
1 parent c1a882c commit 4d33a1b
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions files/compiler_data/vars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
blocks = ["Variables",
{
opcode: "getVariableIdByName",
text: "get Sprite Variable ID of [A]",
blockType: "REPORTER",
code: 'Object.values(vm.editingTarget.variables).filter(variable => variable.name === [A] && variable.type !== "list")[0]?.id ?? ""',
returns: "STRING",
arguments: {
A: { type: "STRING", defaultValue: "my variable" },
},
},
{
opcode: "getSpriteListIdByName",
text: "get Sprite List ID of [A]",
blockType: "REPORTER",
code: 'Object.values(vm.editingTarget.variables).filter(variable => variable.name === [A] && variable.type === "list")[0]?.id ?? ""',
returns: "STRING",
arguments: {
A: { type: "STRING", defaultValue: "my variable" },
},
},
"---",
{
opcode: "getStageVariableIdByName",
text: "get Stage Variable ID of [A]",
blockType: "REPORTER",
code: 'Object.values(vm.runtime.getTargetForStage().variables).filter(variable => variable.name === [A] && variable.type !== "list")[0]?.id ?? ""',
returns: "STRING",
arguments: {
A: { type: "STRING", defaultValue: "my variable" },
},
},
{
opcode: "getStageListIdByName",
text: "get Stage List ID of [A]",
blockType: "REPORTER",
code: 'Object.values(vm.runtime.getTargetForStage().variables).filter(variable => variable.name === [A] && variable.type === "list")[0]?.id ?? ""',
returns: "STRING",
arguments: {
A: { type: "STRING", defaultValue: "my variable" },
},
},
{
opcode: "setSpriteVariableById",
text: "set var/list in Sprite (id: [A] value: [B])",
blockType: "COMMAND",
code: 'vm.editingTarget.variables[[A]].value = [B]',
arguments: {
A: { type: "STRING", defaultValue: "variable id" },
B: { type: "STRING", defaultValue: "1" },
}
},
{
opcode: "setStageVariableById",
text: "set var/list in Stage (id: [A] value: [B])",
blockType: "COMMAND",
code: 'vm.runtime.getTargetForStage().variables[[A]].value = [B]',
arguments: {
A: { type: "STRING", defaultValue: "variable id" },
B: { type: "STRING", defaultValue: "1" },
}
},
]

0 comments on commit 4d33a1b

Please sign in to comment.