-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.html
33 lines (33 loc) · 955 Bytes
/
api.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<div class="title">API</div>
<div>The 'cc' and 'codingcraft' is same objects. To see the result of the code, you might need to play the game</div>
<ul>
<li>cc.setBlock(1, 1, 1, BLOCK.diamond);</li>
<li>cc.removeBlock(1, 1, 1);</li>
<li>cc.getBlock(1, 1, 1);</li>
<li>cc.getCurrentBlock();</li>
<li>cc.getTargetPosition();</li>
<li>cc.getNormalVector();</li>
<li>cc.move(1, 0, 0);</li>
<li>cc.moveTo(0, 20, 0);</li>
</ul>
<div>Examples.</div>
<pre>// Pole.
var pos = cc.getTargetPosition();
var blk = cc.getCurrentBlock();
var vec = cc.getNormalVector();
if (pos) {
for (var i = 0; i < 5; i++) {
cc.setBlock(pos.x + vec.x*i, pos.y + vec.y*i, pos.z + vec.z*i, blk);
}
}</pre>
<pre>// Big ball.
for (var i = -10; i < 10; i++) {
for (var j = -10; j < 10; j++) {
for (var k = -10; k < 10; k++) {
if ((i*i + j*j + k*k) < 10*10) {
cc.setBlock(i, j+10, k, BLOCK.diamond);
}
}
}
}
cc.moveTo(0, 20, 0);</pre>