Expose last key pressed to scripts
This commit is contained in:
2 files changed
+11
-7
No files matched your search
@@ -158,14 +158,14 @@ class ScriptTreeGenerator {
|
||||
};
|
||||
|
||||
case 'argument_reporter_string_number': {
|
||||
if (!this.isProcedure) {
|
||||
return {
|
||||
kind: 'constant',
|
||||
value: 0
|
||||
};
|
||||
}
|
||||
const name = block.fields.VALUE.value;
|
||||
if (!this.procedureArguments.includes(name)) {
|
||||
if (!this.isProcedure || !this.procedureArguments.includes(name)) {
|
||||
// Not final.
|
||||
if (name === 'last key pressed') {
|
||||
return {
|
||||
kind: 'tw.lastKeyPressed'
|
||||
};
|
||||
}
|
||||
return {
|
||||
kind: 'constant',
|
||||
value: 0
|
||||
|
||||
@@ -277,6 +277,10 @@ class ScriptCompiler {
|
||||
case 'sensing.username':
|
||||
return new TypedInput('ioQuery("userData", "getUsername")', TYPE_STRING);
|
||||
|
||||
case 'tw.lastKeyPressed':
|
||||
// Not final.
|
||||
return new TypedInput('ioQuery("keyboard", "getLastKeyPressed")', TYPE_STRING);
|
||||
|
||||
case 'var.get':
|
||||
return new TypedInput(`${this.referenceVariable(node.variable)}.value`, TYPE_UNKNOWN);
|
||||
|
||||
|
||||
Reference in new issue
Block a user