|
//* comment *//
|
|
|
|
Copyright (C) 2015 Ignacio Rodríguez
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//* globals *//
|
|
|
|
//* flow:setturtlename *//
|
|
var cblk = logo.blocks.blockList[blk].connections[1];
|
|
var sourceName = args[0];
|
|
var targetName = args[1];
|
|
var thisTurtle = null;
|
|
var foundTurtle = false;
|
|
for (var i = 0; i < turtles.turtleList.length; i++) {
|
|
thisTurtle = turtles.turtleList[i];
|
|
if (sourceName == thisTurtle.name) {
|
|
thisTurtle.name = targetName;
|
|
foundTurtle = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!foundTurtle) {
|
|
logo.errorMsg('Could not find turtle ' + sourceName, blk);
|
|
}
|
|
|
|
//* block:xturtle *//
|
|
var getxTurtleBlock = new ProtoBlock('xturtle');
|
|
getxTurtleBlock.palette = palettes.dict['extras'];
|
|
blocks.protoBlockDict['xturtle'] = getxTurtleBlock;
|
|
getxTurtleBlock.staticLabels.push(_('turtle x'));
|
|
getxTurtleBlock.adjustWidthToLabel();
|
|
getxTurtleBlock.oneArgBlock();
|
|
getxTurtleBlock.dockTypes[1] = 'anyin';
|
|
getxTurtleBlock.defaults.push('0');
|
|
|
|
//* block:yturtle *//
|
|
var getyTurtleBlock = new ProtoBlock('yturtle');
|
|
getyTurtleBlock.palette = palettes.dict['extras'];
|
|
blocks.protoBlockDict['yturtle'] = getyTurtleBlock;
|
|
getyTurtleBlock.staticLabels.push(_('turtle y'));
|
|
getyTurtleBlock.adjustWidthToLabel();
|
|
getyTurtleBlock.oneArgBlock();
|
|
getyTurtleBlock.dockTypes[1] = 'anyin';
|
|
getyTurtleBlock.defaults.push('0');
|
|
|
|
//* block:startTurtle *//
|
|
var startTurtleBlock = new ProtoBlock('startTurtle');
|
|
startTurtleBlock.palette = palettes.dict['extras'];
|
|
blocks.protoBlockDict['startTurtle'] = startTurtleBlock;
|
|
startTurtleBlock.staticLabels.push(_('start turtle'));
|
|
startTurtleBlock.adjustWidthToLabel();
|
|
startTurtleBlock.oneArgBlock();
|
|
startTurtleBlock.dockTypes[1] = 'anyin';
|
|
startTurtleBlock.defaults.push('0');
|
|
|
|
//* block:stopTurtle *//
|
|
var stopTurtleBlock = new ProtoBlock('stopTurtle');
|
|
stopTurtleBlock.palette = palettes.dict['extras'];
|
|
blocks.protoBlockDict['stopTurtle'] = stopTurtleBlock;
|
|
stopTurtleBlock.staticLabels.push(_('stop turtle'));
|
|
stopTurtleBlock.adjustWidthToLabel();
|
|
stopTurtleBlock.oneArgBlock();
|
|
stopTurtleBlock.dockTypes[1] = 'anyin';
|
|
stopTurtleBlock.defaults.push('0');
|
|
|
|
//* block:setturtlename *//
|
|
var setTurtleName = new ProtoBlock('setturtlename');
|
|
setTurtleName.palette = palettes.dict['extras'];
|
|
blocks.protoBlockDict['setturtlename'] = setTurtleName;
|
|
setTurtleName.staticLabels.push(_('turtle name'));
|
|
setTurtleName.staticLabels.push(_('source'));
|
|
setTurtleName.staticLabels.push(_('target'));
|
|
setTurtleName.adjustWidthToLabel();
|
|
setTurtleName.twoArgBlock();
|
|
setTurtleName.dockTypes[1] = 'anyin';
|
|
setTurtleName.dockTypes[2] = 'anyin';
|
|
setTurtleName.defaults.push('0');
|
|
setTurtleName.defaults.push('Yertle');
|