-
Notifications
You must be signed in to change notification settings - Fork 13
/
floor.py
51 lines (44 loc) · 1.7 KB
/
floor.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from commands import add, admin
import buildbox
import cbc
# requires buildbox.py script in the /scripts folder
@admin
def floor(connection):
if connection.flooring > 0:
connection.flooring = 0
return 'Floor generator cancelled'
else:
connection.flooring = 1
return 'Place first corner block'
add(floor)
def apply_script(protocol, connection, config):
protocol, connection = cbc.apply_script(protocol, connection, config)
class FloorMakerConnection(connection):
def __init__(self, *arg, **kw):
connection.__init__(self, *arg, **kw)
self.flooring = 0
self.floor_x = 0
self.floor_y = 0
self.floor_z = 0
def on_block_build(self, x, y, z):
if self.flooring == 2:
self.flooring = 0
if self.floor_z != z:
self.send_chat('Surface is uneven! Using first height.')
buildbox.build_filled(self.protocol
, self.floor_x, self.floor_y, self.floor_z
, x, y, self.floor_z
, self.color, self.god, self.god_build)
if self.flooring == 1:
self.floor_x = x
self.floor_y = y
self.floor_z = z
self.send_chat('Now place opposite corner block')
self.flooring = 2
return connection.on_block_build(self, x, y, z)
class FloorMakerProtocol(protocol):
def on_map_change(self, map):
for connection in self.clients:
connection.flooring = 0
protocol.on_map_change(self, map)
return FloorMakerProtocol, FloorMakerConnection