19 lines
624 B
TypeScript
19 lines
624 B
TypeScript
import * as Blockly from "blockly";
|
|
import { Order } from "blockly/javascript";
|
|
import type { BlockDef } from "../toolbox";
|
|
|
|
export const playerObjectValue: BlockDef = {
|
|
category: 'Values',
|
|
block: {
|
|
init(this: Blockly.Block) {
|
|
this.appendEndRowInput().appendField('Player');
|
|
this.setInputsInline(false);
|
|
this.setOutput(true, 'Object');
|
|
this.setTooltip('Returns object that is controlled by player');
|
|
}
|
|
},
|
|
code(_block, _generator) {
|
|
return ['(scene.playerObjectId?scene.objects[scene.playerObjectId]:undefined)', Order.ATOMIC];
|
|
}
|
|
};
|