player object script block
This commit is contained in:
parent
6c3e1ae64e
commit
93e127b2f7
|
|
@ -15,7 +15,7 @@ Blockly.Blocks['physics_apply_impulse_action'] = {
|
||||||
this.setInputsInline(true)
|
this.setInputsInline(true)
|
||||||
this.setPreviousStatement(true, null);
|
this.setPreviousStatement(true, null);
|
||||||
this.setNextStatement(true, null);
|
this.setNextStatement(true, null);
|
||||||
this.setTooltip('Push me to a position');
|
this.setTooltip('Push me in a direction');
|
||||||
this.setColour(150);
|
this.setColour(150);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,4 @@ export * from './position';
|
||||||
export * from './direction';
|
export * from './direction';
|
||||||
export * from './objectById';
|
export * from './objectById';
|
||||||
export * from './directionToPosition';
|
export * from './directionToPosition';
|
||||||
|
export * from './playerObject';
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import * as Blockly from "blockly";
|
||||||
|
import { javascriptGenerator, Order } from "blockly/javascript";
|
||||||
|
|
||||||
|
Blockly.Blocks['player_object_value'] = {
|
||||||
|
init(this: Blockly.Block) {
|
||||||
|
this.appendEndRowInput()
|
||||||
|
.appendField('Player');
|
||||||
|
this.setInputsInline(false)
|
||||||
|
this.setOutput(true, 'Object');
|
||||||
|
this.setTooltip('Returns object that is controlled by player');
|
||||||
|
this.setColour(315);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
javascriptGenerator.forBlock['player_object_value'] = function (_block, _generator) {
|
||||||
|
return ['(scene.playerObjectId?scene.objects[scene.playerObjectId]:undefined)', Order.ATOMIC];
|
||||||
|
};
|
||||||
|
|
||||||
|
export { };
|
||||||
|
|
@ -36,6 +36,7 @@ const TOOLBOX: Blockly.utils.toolbox.ToolboxDefinition = {
|
||||||
{ kind: 'block', type: 'dpos_value' },
|
{ kind: 'block', type: 'dpos_value' },
|
||||||
{ kind: 'block', type: 'direction_to_position_value' },
|
{ kind: 'block', type: 'direction_to_position_value' },
|
||||||
{ kind: 'block', type: 'object_by_id_value' },
|
{ kind: 'block', type: 'object_by_id_value' },
|
||||||
|
{ kind: 'block', type: 'player_object_value' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue