Skip to content

Commit

Permalink
Update scratch3_procedures.js
Browse files Browse the repository at this point in the history
  • Loading branch information
SharkPool-SP authored Aug 17, 2024
1 parent 68a90f7 commit cf2f7de
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/blocks/scratch3_procedures.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Scratch3ProcedureBlocks {
return {
procedures_definition: this.definition,
procedures_call: this.call,
procedures_set: this.set,
argument_reporter_string_number: this.argumentReporterStringNumber,
argument_reporter_boolean: this.argumentReporterBoolean
};
Expand Down Expand Up @@ -68,6 +69,21 @@ class Scratch3ProcedureBlocks {
}
}

set(args, util) {
const contain = util.thread.blockContainer;
const block = contain.getBlock(util.thread.isCompiled ? util.thread.peekStack() : util.thread.peekStackFrame().op.id);
if (!block) return;
const thread = util.thread;
const param = contain.getBlock(block.inputs.PARAM?.block);
if (param) {
try {
const curParams = thread.stackFrames[0].params;
if (curParams !== null) thread.stackFrames[0].params[param.fields.VALUE.value] = args.VALUE;
else thread.stackFrames[0].params = { [param.fields.VALUE.value]: args.VALUE }
} catch { /* shouldn't happen */ }
}
}

argumentReporterStringNumber(args, util) {
const value = util.getParam(args.VALUE);
if (value === null) {
Expand Down

0 comments on commit cf2f7de

Please sign in to comment.