-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtablecontainer.lua
More file actions
127 lines (116 loc) · 3.68 KB
/
tablecontainer.lua
File metadata and controls
127 lines (116 loc) · 3.68 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
-- Container object is the representation of a Docker
-- container in the Minecraft world
-- NewTableRecordContainer returns a Container object,
-- representation of a container in
-- the Minecraft world
function NewTableRecordContainer()
c = {
displayed = false,
x = 0,
y = 0,
z = 0,
name="",
id="",
init=TableRecordContainer.init,
setInfos=TableRecordContainer.setInfos,
destroy=TableRecordContainer.destroy,
display=TableRecordContainer.display,
addGround=TableRecordContainer.addGround
}
return c
end
TableRecordContainer = {
displayed = false,
x = 0,
y = 0,
z = 0,
name="",
id=""
}
-- TableRecordContainer:init sets Container's position
function TableRecordContainer:init(x,z)
self.x = x
self.z = z
self.displayed = false
end
-- TableRecordContainer:setInfos sets Container's id, name, imageRepo,
-- image tag and running state
function TableRecordContainer:setInfos(id,name,content)
self.id = id
self.name = name
self.content = content
end
-- TableRecordContainer:display displays all Container's blocks
-- Blocks will be blue if the container is running,
-- orange otherwise.
function TableRecordContainer:display()
local metaPrimaryColor = E_META_WOOL_LIGHTBLUE
local metaSecondaryColor = E_META_WOOL_BLUE
local level = 0
if self.name == "column"
then
LOG("!!!!!!!!!!!!!!!!!!!!")
LOG(self.x)
LOG(self.z)
TABLE_SIGNAL_OFFSET = 0
metaPrimaryColor = E_META_CONCRETE_GRAY
metaSecondaryColor = E_META_CONCRETE_GRAY
for i=1, table.getn(self.content)
do
-- add a block and add a sign to the blocks
setBlock(UpdateQueue,self.x+i,GROUND_TABLE_LEVEL + 1,self.z,E_BLOCK_WOOL,metaPrimaryColor)
setBlock(UpdateQueue,self.x+i,GROUND_TABLE_LEVEL + 1,self.z - 1,E_BLOCK_WALLSIGN,E_META_CHEST_FACING_ZM)
updateSign(UpdateQueue,self.x+i,GROUND_TABLE_LEVEL + 1,self.z - 1,"", self.content[i], "", "",0)
end
elseif self.name == "query"
then
TABLE_SIGNAL_OFFSET = 0
local level = tonumber(self.id)
metaPrimaryColor = E_META_WOOL_GREEN
for i=1, table.getn(self.content)
do
-- add a block and add a sign to the blocks
setBlock(UpdateQueue,self.x+i,GROUND_TABLE_LEVEL + 1 + level,self.z,E_BLOCK_WOOL,metaPrimaryColor)
setBlock(UpdateQueue,self.x+i,GROUND_TABLE_LEVEL + 1 + level,self.z - 1,E_BLOCK_WALLSIGN,E_META_CHEST_FACING_ZM)
updateSign(UpdateQueue,self.x+i,GROUND_TABLE_LEVEL + 1 + level,self.z - 1,"", self.content[i], "", "",0)
end
else
LOG("??????")
LOG(self.x)
LOG(self.z)
TABLE_SIGNAL_OFFSET = 0
local level = tonumber(self.name)
for i=1, table.getn(self.content)
do
-- add a block and add a sign to the blocks
setBlock(UpdateQueue,self.x+i,GROUND_TABLE_LEVEL + 1 + level,self.z,E_BLOCK_WOOL,metaPrimaryColor)
setBlock(UpdateQueue,self.x+i,GROUND_TABLE_LEVEL + 1 + level,self.z - 1,E_BLOCK_WALLSIGN,E_META_CHEST_FACING_ZM)
updateSign(UpdateQueue,self.x+i,GROUND_TABLE_LEVEL + 1 + level,self.z - 1,"", self.content[i], "", "",0)
end
end
self.displayed = true
end
-- TableRecordContainer:addGround creates ground blocks
-- necessary to display the container
function TableRecordContainer:addGround()
local y = GROUND_TABLE_LEVEL
local max_x = GROUND_TABLE_MAX_X
if GROUND_TABLE_MIN_X > self.x - 2
then
max_x = GROUND_TABLE_MIN_X
GROUND_TABLE_MIN_X = self.x - 2
min_x = GROUND_TABLE_MIN_X
end
local min_x = GROUND_TABLE_MIN_X
for x= min_x, max_x
do
for z=GROUND_TABLE_MIN_Z,GROUND_TABLE_MAX_Z
do
setBlock(UpdateQueue,x,y,z,E_BLOCK_GRASS,0)
for sky=y+1,y+6
do
setBlock(UpdateQueue,x,sky,z,E_BLOCK_AIR,0)
end
end
end
end