forked from chplanty/MineCraftMakeCodeExtension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.blocks
1 lines (1 loc) · 4.37 KB
/
main.blocks
1
<xml xmlns="https://developers.google.com/blockly/xml"><block type="pxt-on-start" id="^WOtYB;Zzn?zh;8Y*rsg" x="0" y="0"><statement name="HANDLER"><block type="typescript_statement" id="|;XhhDIr2!tyYZd7{(vo" editable="false"><mutation xmlns="http://www.w3.org/1999/xhtml" line0="namespace castles {" line1=" function drawRectangle(length: number, width: number, blockType: number) {" line2=" for (let index = 0; index < 2; index++) {" line3=" builder.mark()" line4=" builder.move(FORWARD, length - 1)" line5=" builder.tracePath(blockType)" line6=" builder.turn(LEFT_TURN)" line7=" builder.mark()" line8=" builder.move(FORWARD, width - 1)" line9=" builder.tracePath(blockType)" line10=" builder.turn(LEFT_TURN)" line11=" }" line12=" }" line13="" line14=" function drawAlternatingRectangle(length: number, width: number, blockType: number) {" line15=" function drawAlternatingLine(l: number, placeAtStart: boolean) {" line16=" let putBlock = placeAtStart;" line17=" for (let index2 = 0; index2 < l - 1; index2++) {" line18=" builder.move(FORWARD, 1)" line19=" if (putBlock) {" line20=" builder.place(blockType)" line21=" }" line22=" putBlock = !(putBlock)" line23=" }" line24=" return putBlock" line25=" }" line26="" line27=" builder.place(blockType)" line28=" for (let index3 = 0; index3 < 2; index3++) {" line29=" let putBlock2 = drawAlternatingLine(length, false)" line30=" builder.turn(LEFT_TURN)" line31=" drawAlternatingLine(width, putBlock2)" line32=" builder.turn(LEFT_TURN)" line33=" }" line34=" }" line35="" line36=" //% block" line37=" export function buildCastleWall(width: number = 3, length: number = 13, height: number = 6) {" line38=" let BlocType = COBBLESTONE" line39=" builder.place(CYAN_STAINED_GLASS)" line40=" // builder.teleportTo(pos(0, 0, 0))" line41=" // builder is at the center of the tower - shift it to a corner" line42=" builder.shift(-Math.floor(width / 2), 0, -Math.floor(width / 2))" line43=" // build 2 walls from bottom to top (up to WallHeight)" line44=" for (let index4 = 0; index4 < height - 1; index4++) {" line45=" drawRectangle(length, width, BlocType)" line46=" builder.move(UP, 1)" line47=" }" line48=" drawAlternatingRectangle(length, width, BlocType)" line49=" // mov builder to center on other wall's end ( added -1 as hotfix :/ )" line50=" builder.shift(length - Math.floor(width / 2) - 1, 1 - height, Math.floor(width / 2))" line51=" // verify it's ok" line52=" builder.place(CYAN_WOOL)" line53=" }" line54="" line55=" //% block" line56=" export function buildCastleTower(width: number = 5, height: number = 8) {" line57=" let BlockType = 0" line58="" line59=" BlockType = COBBLESTONE" line60=" width = 5" line61=" height = 8" line62=" // builder.teleportTo(pos(0, 0, 0))" line63=" // builder is at the center of the tower - shift it to a corner" line64=" builder.shift( - Math.floor(width / 2), 0, - Math.floor(width / 2))" line65=" // let posX = Math.sin(3.14159265*2) // will need this for circular tower's base" line66=" // build 4 walls from bottom to top (up to TowerHeight)" line67=" for (let height2 = 0; height2 <= height; height2++) {" line68=" // add 4 walls" line69=" drawRectangle(width, width, BlockType);" line70=" builder.move(UP, 1)" line71=" }" line72=" // build the upper part, larger by 1" line73=" // shift in diagonal by 1 block" line74=" builder.shift(-1, 0, -1)" line75=" for (let height22 = 0; height22 <= 2; height22++) {" line76=" // add 4 walls" line77=" drawRectangle(width + 2, width + 2, BlockType)" line78=" builder.move(UP, 1)" line79=" }" line80=" // mov builder back to center" line81=" builder.shift(Math.floor(width / 2) + 1, 0 - (height + 4), Math.floor(width / 2) + 1)" line82=" // verify it's ok" line83=" builder.place(GLASS)" line84=" }" line85="}" numlines="86"></mutation></block></statement></block></xml>