From f981e8747f9a2820a86407e06ba40e035966306e Mon Sep 17 00:00:00 2001 From: liam4 Date: Fri, 2 Sep 2016 00:48:14 -0300 Subject: [PATCH] Implement 'current' block --- src/blocks/scratch3_sensing.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/blocks/scratch3_sensing.js b/src/blocks/scratch3_sensing.js index ee75cc43a..3271990f3 100644 --- a/src/blocks/scratch3_sensing.js +++ b/src/blocks/scratch3_sensing.js @@ -16,7 +16,9 @@ Scratch3SensingBlocks.prototype.getPrimitives = function() { 'sensing_resettimer': this.resetTimer, 'sensing_mousex': this.getMouseX, 'sensing_mousey': this.getMouseY, - 'sensing_mousedown': this.getMouseDown + 'sensing_mousedown': this.getMouseDown, + 'sensing_current': this.current, + 'sensing_currentmenu': this.currentMenu }; }; @@ -40,4 +42,28 @@ Scratch3SensingBlocks.prototype.getMouseDown = function (args, util) { return util.ioQuery('mouse', 'getIsDown'); }; +Scratch3SensingBlocks.prototype.current = function (args, util) { + var date = new Date(); + switch (args.CURRENTMENU) { + case 'year': + return date.getFullYear(); + case 'month': + return date.getMonth(); + case 'date': + return date.getDate(); + case 'dayofweek': + return date.getDay(); + case 'hour': + return date.getHours(); + case 'minute': + return date.getMinutes(); + case 'second': + return date.getSeconds(); + } +}; + +Scratch3SensingBlocks.prototype.currentMenu = function (args) { + return args.CURRENTMENU.toLowerCase(); +}; + module.exports = Scratch3SensingBlocks;