File: teleport.py

package info (click to toggle)
minetest-mod-pycraft 0.22-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,744 kB
  • sloc: python: 79,282; makefile: 10
file content (30 lines) | stat: -rwxr-xr-x 743 bytes parent folder | download | duplicates (3)
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
#
# Code under the MIT license by Alexander Pruss
#

from mc import *
from random import *
from time import *

mc = Minecraft()
pos = mc.player.getTilePos()

goldPieces = 0

while goldPieces < 10:
    x = pos.x + randint(-10,10)
    z = pos.z + randint(-10,10)
    if mc.getBlock(x,pos.y-1,z) != GOLD_BLOCK.id:
        mc.setBlock(x,pos.y-1,z,GOLD_BLOCK)
        goldPieces = goldPieces + 1

startTime = time()
while goldPieces > 0:
    pos = mc.player.getTilePos()
    if mc.getBlock(pos.x,pos.y - 1,pos.z) == GOLD_BLOCK.id:
        mc.setBlock(pos.x,pos.y - 1,pos.z,COBBLESTONE)
        mc.player.setPos(pos.x,pos.y + 5, pos.z)
        goldPieces = goldPieces - 1
    sleep(0.01)

mc.postToChat("You took "+str(time()-startTime)+" seconds")