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

Commit c88c259

Browse files
author
Adrien Duermael
committed
Merge pull request #46 from dave-tucker/boom
Implement Explosions!
2 parents 94010e4 + 1f4421e commit c88c259

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

world/Plugins/Docker/container.lua

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,29 @@ end
5252
-- Container:destroy removes all blocks of the
5353
-- container, it won't be visible on the map anymore
5454
function Container:destroy(running)
55+
X = self.x+2
56+
Y = GROUND_LEVEL+2
57+
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
5578
for py = GROUND_LEVEL+1, GROUND_LEVEL+4
5679
do
5780
for px=self.x-1, self.x+4

world/Plugins/Docker/docker.lua

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ end
9191
-- destroyContainer looks for the first container having the given id,
9292
-- removes it from the Minecraft world and from the 'Containers' array
9393
function destroyContainer(id)
94+
LOG("destroyContainer: " .. id)
9495
-- loop over the containers and remove the first having the given id
9596
for i=1, table.getn(Containers)
9697
do
@@ -174,7 +175,7 @@ function updateContainer(id,name,imageRepo,imageTag,state)
174175
end
175176

176177
--
177-
function WorldStarted()
178+
function WorldStarted(World)
178179
y = GROUND_LEVEL
179180
-- just enough to fit one container
180181
-- then it should be dynamic
@@ -390,11 +391,12 @@ function OnPlayerFoodLevelChange(Player, NewFoodLevel)
390391
end
391392

392393
function OnTakeDamage(Receiver, TDI)
393-
-- Don't allow the player to take falling damage
394-
dt_fall = 3
395-
if Receiver:GetClass() == 'cPlayer' and TDI.DamageType == dt_fall
394+
-- Don't allow the player to take falling or explosion damage
395+
if Receiver:GetClass() == 'cPlayer'
396396
then
397-
return true, Receiver, TDI
397+
if TDI.DamageType == dtFall or TDI.DamageType == dtExplosion then
398+
return true, Receiver, TDI
399+
end
398400
end
399401
return false, Receiver, TDI
400402
end

0 commit comments

Comments
 (0)