Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 7b1752f

Browse files
author
Dave Tucker
committed
Format Lua code
The lua code was a mess of mixed indentation and trailing spaces. Using ZeroBraneStudio correct indentation and vim, this is now fixed. We should aspire to keep it tidier Signed-off-by: Dave Tucker <dt@docker.com>
1 parent 6b4c865 commit 7b1752f

File tree

6 files changed

+471
-472
lines changed

6 files changed

+471
-472
lines changed

Docker/container.lua

Lines changed: 130 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -10,191 +10,191 @@ CONTAINER_STOPPED = 2
1010
-- representation of a Docker container in
1111
-- the Minecraft world
1212
function NewContainer()
13-
c = {
14-
displayed = false,
15-
x = 0,
16-
z = 0,
17-
name="",
18-
id="",
19-
imageRepo="",
20-
imageTag="",
21-
running=false,
22-
init=Container.init,
23-
setInfos=Container.setInfos,
24-
destroy=Container.destroy,
25-
display=Container.display,
26-
updateMemSign=Container.updateMemSign,
27-
updateCPUSign=Container.updateCPUSign,
28-
addGround=Container.addGround
29-
}
30-
return c
13+
c = {
14+
displayed = false,
15+
x = 0,
16+
z = 0,
17+
name="",
18+
id="",
19+
imageRepo="",
20+
imageTag="",
21+
running=false,
22+
init=Container.init,
23+
setInfos=Container.setInfos,
24+
destroy=Container.destroy,
25+
display=Container.display,
26+
updateMemSign=Container.updateMemSign,
27+
updateCPUSign=Container.updateCPUSign,
28+
addGround=Container.addGround
29+
}
30+
return c
3131
end
3232

3333
Container = {displayed = false, x = 0, z = 0, name="",id="",imageRepo="",imageTag="",running=false}
3434

3535
-- Container:init sets Container's position
3636
function Container:init(x,z)
37-
self.x = x
38-
self.z = z
39-
self.displayed = false
37+
self.x = x
38+
self.z = z
39+
self.displayed = false
4040
end
4141

42-
-- Container:setInfos sets Container's id, name, imageRepo,
42+
-- Container:setInfos sets Container's id, name, imageRepo,
4343
-- image tag and running state
4444
function Container:setInfos(id,name,imageRepo,imageTag,running)
45-
self.id = id
46-
self.name = name
47-
self.imageRepo = imageRepo
48-
self.imageTag = imageTag
49-
self.running = running
45+
self.id = id
46+
self.name = name
47+
self.imageRepo = imageRepo
48+
self.imageTag = imageTag
49+
self.running = running
5050
end
5151

52-
-- Container:destroy removes all blocks of the
52+
-- Container:destroy removes all blocks of the
5353
-- container, it won't be visible on the map anymore
5454
function Container:destroy(running)
55-
local X = self.x+2
56-
local Y = GROUND_LEVEL+2
57-
local Z = self.z+2
58-
LOG("Exploding at X:" .. X .. " Y:" .. Y .. " Z:" .. Z)
59-
local World = cRoot:Get():GetDefaultWorld()
60-
World:BroadcastSoundEffect("random.explode", X, Y, Z, 1, 1)
61-
World:BroadcastParticleEffect("hugeexplosion",X, Y, Z, 0, 0, 0, 1, 1)
62-
63-
-- if a block is removed before it's button/lever/sign, that object will drop
64-
-- and the player can collect it. Remove these first
65-
66-
-- lever
67-
digBlock(UpdateQueue,self.x+1,GROUND_LEVEL+3,self.z+1)
68-
-- signs
69-
digBlock(UpdateQueue,self.x+3,GROUND_LEVEL+2,self.z-1)
70-
digBlock(UpdateQueue,self.x,GROUND_LEVEL+2,self.z-1)
71-
digBlock(UpdateQueue,self.x+1,GROUND_LEVEL+2,self.z-1)
72-
-- torch
73-
digBlock(UpdateQueue,self.x+1,GROUND_LEVEL+3,self.z+1)
74-
--button
75-
digBlock(UpdateQueue,self.x+2,GROUND_LEVEL+3,self.z+2)
76-
77-
-- rest of the blocks
78-
for py = GROUND_LEVEL+1, GROUND_LEVEL+4
79-
do
80-
for px=self.x-1, self.x+4
81-
do
82-
for pz=self.z-1, self.z+5
83-
do
84-
digBlock(UpdateQueue,px,py,pz)
85-
end
86-
end
87-
end
55+
local X = self.x+2
56+
local Y = GROUND_LEVEL+2
57+
local Z = self.z+2
58+
LOG("Exploding at X:" .. X .. " Y:" .. Y .. " Z:" .. Z)
59+
local World = cRoot:Get():GetDefaultWorld()
60+
World:BroadcastSoundEffect("random.explode", X, Y, Z, 1, 1)
61+
World:BroadcastParticleEffect("hugeexplosion",X, Y, Z, 0, 0, 0, 1, 1)
62+
63+
-- if a block is removed before it's button/lever/sign, that object will drop
64+
-- and the player can collect it. Remove these first
65+
66+
-- lever
67+
digBlock(UpdateQueue,self.x+1,GROUND_LEVEL+3,self.z+1)
68+
-- signs
69+
digBlock(UpdateQueue,self.x+3,GROUND_LEVEL+2,self.z-1)
70+
digBlock(UpdateQueue,self.x,GROUND_LEVEL+2,self.z-1)
71+
digBlock(UpdateQueue,self.x+1,GROUND_LEVEL+2,self.z-1)
72+
-- torch
73+
digBlock(UpdateQueue,self.x+1,GROUND_LEVEL+3,self.z+1)
74+
--button
75+
digBlock(UpdateQueue,self.x+2,GROUND_LEVEL+3,self.z+2)
76+
77+
-- rest of the blocks
78+
for py = GROUND_LEVEL+1, GROUND_LEVEL+4
79+
do
80+
for px=self.x-1, self.x+4
81+
do
82+
for pz=self.z-1, self.z+5
83+
do
84+
digBlock(UpdateQueue,px,py,pz)
85+
end
86+
end
87+
end
8888
end
8989

9090
-- Container:display displays all Container's blocks
91-
-- Blocks will be blue if the container is running,
91+
-- Blocks will be blue if the container is running,
9292
-- orange otherwise.
9393
function Container:display(running)
9494

95-
local metaPrimaryColor = E_META_WOOL_LIGHTBLUE
96-
local metaSecondaryColor = E_META_WOOL_BLUE
95+
local metaPrimaryColor = E_META_WOOL_LIGHTBLUE
96+
local metaSecondaryColor = E_META_WOOL_BLUE
9797

98-
if running == false
99-
then
100-
metaPrimaryColor = E_META_WOOL_ORANGE
101-
metaSecondaryColor = E_META_WOOL_RED
102-
end
98+
if running == false
99+
then
100+
metaPrimaryColor = E_META_WOOL_ORANGE
101+
metaSecondaryColor = E_META_WOOL_RED
102+
end
103+
104+
self.displayed = true
105+
106+
for px=self.x, self.x+3
107+
do
108+
for pz=self.z, self.z+4
109+
do
110+
setBlock(UpdateQueue,px,GROUND_LEVEL + 1,pz,E_BLOCK_WOOL,metaPrimaryColor)
111+
end
112+
end
103113

104-
self.displayed = true
105-
106-
for px=self.x, self.x+3
107-
do
108-
for pz=self.z, self.z+4
109-
do
110-
setBlock(UpdateQueue,px,GROUND_LEVEL + 1,pz,E_BLOCK_WOOL,metaPrimaryColor)
111-
end
112-
end
114+
for py = GROUND_LEVEL+2, GROUND_LEVEL+3
115+
do
116+
setBlock(UpdateQueue,self.x+1,py,self.z,E_BLOCK_WOOL,metaPrimaryColor)
113117

114-
for py = GROUND_LEVEL+2, GROUND_LEVEL+3
115-
do
116-
setBlock(UpdateQueue,self.x+1,py,self.z,E_BLOCK_WOOL,metaPrimaryColor)
118+
-- leave empty space for the door
119+
-- setBlock(UpdateQueue,self.x+2,py,self.z,E_BLOCK_WOOL,metaPrimaryColor)
117120

118-
-- leave empty space for the door
119-
-- setBlock(UpdateQueue,self.x+2,py,self.z,E_BLOCK_WOOL,metaPrimaryColor)
120-
121-
setBlock(UpdateQueue,self.x,py,self.z,E_BLOCK_WOOL,metaPrimaryColor)
122-
setBlock(UpdateQueue,self.x+3,py,self.z,E_BLOCK_WOOL,metaPrimaryColor)
121+
setBlock(UpdateQueue,self.x,py,self.z,E_BLOCK_WOOL,metaPrimaryColor)
122+
setBlock(UpdateQueue,self.x+3,py,self.z,E_BLOCK_WOOL,metaPrimaryColor)
123123

124-
setBlock(UpdateQueue,self.x,py,self.z+1,E_BLOCK_WOOL,metaSecondaryColor)
125-
setBlock(UpdateQueue,self.x+3,py,self.z+1,E_BLOCK_WOOL,metaSecondaryColor)
124+
setBlock(UpdateQueue,self.x,py,self.z+1,E_BLOCK_WOOL,metaSecondaryColor)
125+
setBlock(UpdateQueue,self.x+3,py,self.z+1,E_BLOCK_WOOL,metaSecondaryColor)
126126

127-
setBlock(UpdateQueue,self.x,py,self.z+2,E_BLOCK_WOOL,metaPrimaryColor)
128-
setBlock(UpdateQueue,self.x+3,py,self.z+2,E_BLOCK_WOOL,metaPrimaryColor)
127+
setBlock(UpdateQueue,self.x,py,self.z+2,E_BLOCK_WOOL,metaPrimaryColor)
128+
setBlock(UpdateQueue,self.x+3,py,self.z+2,E_BLOCK_WOOL,metaPrimaryColor)
129129

130-
setBlock(UpdateQueue,self.x,py,self.z+3,E_BLOCK_WOOL,metaSecondaryColor)
131-
setBlock(UpdateQueue,self.x+3,py,self.z+3,E_BLOCK_WOOL,metaSecondaryColor)
130+
setBlock(UpdateQueue,self.x,py,self.z+3,E_BLOCK_WOOL,metaSecondaryColor)
131+
setBlock(UpdateQueue,self.x+3,py,self.z+3,E_BLOCK_WOOL,metaSecondaryColor)
132132

133-
setBlock(UpdateQueue,self.x,py,self.z+4,E_BLOCK_WOOL,metaPrimaryColor)
134-
setBlock(UpdateQueue,self.x+3,py,self.z+4,E_BLOCK_WOOL,metaPrimaryColor)
133+
setBlock(UpdateQueue,self.x,py,self.z+4,E_BLOCK_WOOL,metaPrimaryColor)
134+
setBlock(UpdateQueue,self.x+3,py,self.z+4,E_BLOCK_WOOL,metaPrimaryColor)
135135

136-
setBlock(UpdateQueue,self.x+1,py,self.z+4,E_BLOCK_WOOL,metaPrimaryColor)
137-
setBlock(UpdateQueue,self.x+2,py,self.z+4,E_BLOCK_WOOL,metaPrimaryColor)
138-
end
136+
setBlock(UpdateQueue,self.x+1,py,self.z+4,E_BLOCK_WOOL,metaPrimaryColor)
137+
setBlock(UpdateQueue,self.x+2,py,self.z+4,E_BLOCK_WOOL,metaPrimaryColor)
138+
end
139139

140-
-- torch
141-
setBlock(UpdateQueue,self.x+1,GROUND_LEVEL+3,self.z+3,E_BLOCK_TORCH,E_META_TORCH_ZP)
140+
-- torch
141+
setBlock(UpdateQueue,self.x+1,GROUND_LEVEL+3,self.z+3,E_BLOCK_TORCH,E_META_TORCH_ZP)
142142

143-
-- start / stop lever
144-
setBlock(UpdateQueue,self.x+1,GROUND_LEVEL + 3,self.z + 2,E_BLOCK_WALLSIGN,E_META_CHEST_FACING_XP)
145-
updateSign(UpdateQueue,self.x+1,GROUND_LEVEL + 3,self.z + 2,"","START/STOP","---->","",2)
143+
-- start / stop lever
144+
setBlock(UpdateQueue,self.x+1,GROUND_LEVEL + 3,self.z + 2,E_BLOCK_WALLSIGN,E_META_CHEST_FACING_XP)
145+
updateSign(UpdateQueue,self.x+1,GROUND_LEVEL + 3,self.z + 2,"","START/STOP","---->","",2)
146146

147147

148-
if running
149-
then
150-
setBlock(UpdateQueue,self.x+1,GROUND_LEVEL+3,self.z+1,E_BLOCK_LEVER,1)
151-
else
152-
setBlock(UpdateQueue,self.x+1,GROUND_LEVEL+3,self.z+1,E_BLOCK_LEVER,9)
153-
end
148+
if running
149+
then
150+
setBlock(UpdateQueue,self.x+1,GROUND_LEVEL+3,self.z+1,E_BLOCK_LEVER,1)
151+
else
152+
setBlock(UpdateQueue,self.x+1,GROUND_LEVEL+3,self.z+1,E_BLOCK_LEVER,9)
153+
end
154154

155155

156-
-- remove button
156+
-- remove button
157157

158-
setBlock(UpdateQueue,self.x+2,GROUND_LEVEL + 3,self.z + 2,E_BLOCK_WALLSIGN,E_META_CHEST_FACING_XM)
159-
updateSign(UpdateQueue,self.x+2,GROUND_LEVEL + 3,self.z + 2,"","REMOVE","---->","",2)
158+
setBlock(UpdateQueue,self.x+2,GROUND_LEVEL + 3,self.z + 2,E_BLOCK_WALLSIGN,E_META_CHEST_FACING_XM)
159+
updateSign(UpdateQueue,self.x+2,GROUND_LEVEL + 3,self.z + 2,"","REMOVE","---->","",2)
160160

161-
setBlock(UpdateQueue,self.x+2,GROUND_LEVEL+3,self.z+3,E_BLOCK_STONE_BUTTON,E_BLOCK_BUTTON_XM)
161+
setBlock(UpdateQueue,self.x+2,GROUND_LEVEL+3,self.z+3,E_BLOCK_STONE_BUTTON,E_BLOCK_BUTTON_XM)
162162

163163

164-
-- door
165-
-- Cuberite bug with Minecraft 1.8 apparently, doors are not displayed correctly
166-
-- setBlock(UpdateQueue,self.x+2,GROUND_LEVEL+2,self.z,E_BLOCK_WOODEN_DOOR,E_META_CHEST_FACING_ZM)
164+
-- door
165+
-- Cuberite bug with Minecraft 1.8 apparently, doors are not displayed correctly
166+
-- setBlock(UpdateQueue,self.x+2,GROUND_LEVEL+2,self.z,E_BLOCK_WOODEN_DOOR,E_META_CHEST_FACING_ZM)
167167

168168

169-
for px=self.x, self.x+3
170-
do
171-
for pz=self.z, self.z+4
172-
do
173-
setBlock(UpdateQueue,px,GROUND_LEVEL + 4,pz,E_BLOCK_WOOL,metaPrimaryColor)
174-
end
175-
end
169+
for px=self.x, self.x+3
170+
do
171+
for pz=self.z, self.z+4
172+
do
173+
setBlock(UpdateQueue,px,GROUND_LEVEL + 4,pz,E_BLOCK_WOOL,metaPrimaryColor)
174+
end
175+
end
176176

177-
setBlock(UpdateQueue,self.x+3,GROUND_LEVEL + 2,self.z - 1,E_BLOCK_WALLSIGN,E_META_CHEST_FACING_ZM)
178-
updateSign(UpdateQueue,self.x+3,GROUND_LEVEL + 2,self.z - 1,string.sub(self.id,1,8),self.name,self.imageRepo,self.imageTag,2)
177+
setBlock(UpdateQueue,self.x+3,GROUND_LEVEL + 2,self.z - 1,E_BLOCK_WALLSIGN,E_META_CHEST_FACING_ZM)
178+
updateSign(UpdateQueue,self.x+3,GROUND_LEVEL + 2,self.z - 1,string.sub(self.id,1,8),self.name,self.imageRepo,self.imageTag,2)
179179

180-
-- Mem sign
181-
setBlock(UpdateQueue,self.x,GROUND_LEVEL + 2,self.z - 1,E_BLOCK_WALLSIGN,E_META_CHEST_FACING_ZM)
180+
-- Mem sign
181+
setBlock(UpdateQueue,self.x,GROUND_LEVEL + 2,self.z - 1,E_BLOCK_WALLSIGN,E_META_CHEST_FACING_ZM)
182182

183-
-- CPU sign
184-
setBlock(UpdateQueue,self.x+1,GROUND_LEVEL + 2,self.z - 1,E_BLOCK_WALLSIGN,E_META_CHEST_FACING_ZM)
183+
-- CPU sign
184+
setBlock(UpdateQueue,self.x+1,GROUND_LEVEL + 2,self.z - 1,E_BLOCK_WALLSIGN,E_META_CHEST_FACING_ZM)
185185
end
186186

187187

188188
-- Container:updateMemSign updates the mem usage
189189
-- value displayed on Container's sign
190190
function Container:updateMemSign(s)
191-
updateSign(UpdateQueue,self.x,GROUND_LEVEL + 2,self.z - 1,"Mem usage","",s,"")
191+
updateSign(UpdateQueue,self.x,GROUND_LEVEL + 2,self.z - 1,"Mem usage","",s,"")
192192
end
193193

194194
-- Container:updateCPUSign updates the mem usage
195195
-- value displayed on Container's sign
196196
function Container:updateCPUSign(s)
197-
updateSign(UpdateQueue,self.x+1,GROUND_LEVEL + 2,self.z - 1,"CPU usage","",s,"")
197+
updateSign(UpdateQueue,self.x+1,GROUND_LEVEL + 2,self.z - 1,"CPU usage","",s,"")
198198
end
199199

200200
-- Container:addGround creates ground blocks

0 commit comments

Comments
 (0)