Add timeAndDate block.
This commit is contained in:
parent
5482589da7
commit
64fb52699c
1 changed files with 15 additions and 0 deletions
|
@ -29,6 +29,8 @@ SensingPrims.prototype.addPrimsTo = function(primTable) {
|
||||||
primTable['distanceTo:'] = this.primDistanceTo;
|
primTable['distanceTo:'] = this.primDistanceTo;
|
||||||
|
|
||||||
primTable['getAttribute:of:'] = this.primGetAttribute;
|
primTable['getAttribute:of:'] = this.primGetAttribute;
|
||||||
|
|
||||||
|
primTable['timeAndDate'] = this.primTimeDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
SensingPrims.prototype.primTouching = function(b) {
|
SensingPrims.prototype.primTouching = function(b) {
|
||||||
|
@ -206,6 +208,19 @@ SensingPrims.prototype.primGetAttribute = function(b) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SensingPrims.prototype.primTimeDate = function(b) {
|
||||||
|
var dt = interp.arg(b, 0);
|
||||||
|
var now = new Date();
|
||||||
|
if (dt == 'year') return now.getFullYear();
|
||||||
|
if (dt == 'month') return now.getMonth()+1;
|
||||||
|
if (dt == 'date') return now.getDate();
|
||||||
|
if (dt == 'day of week') return now.getDay()+1;
|
||||||
|
if (dt == 'hour') return now.getHours();
|
||||||
|
if (dt == 'minute') return now.getMinutes();
|
||||||
|
if (dt == 'second') return now.getSeconds();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
SensingPrims.prototype.mouseOrSpritePosition = function(arg) {
|
SensingPrims.prototype.mouseOrSpritePosition = function(arg) {
|
||||||
if (arg == "_mouse_") {
|
if (arg == "_mouse_") {
|
||||||
|
|
Reference in a new issue