Compare commits

...

3 Commits

Author SHA1 Message Date
Jay 270e510b57 NIL CHECK 2020-02-06 11:17:05 +00:00
Jay 152d91dc6e check 2020-02-06 11:13:36 +00:00
Jay 46707b698f explode mode 2020-02-06 11:09:43 +00:00
2 changed files with 42 additions and 7 deletions

View File

@ -11,12 +11,30 @@ workspace.camera.position = vector3(0, 25, -15)
workspace.camera:lookAt(vector3(0, 0, 0))
require("tevgit:workshop/controllers/environment/camera.lua")
local boomMode = false
local boomBtn = engine.construct("guiTextBox", engine.interface, {
text = "Boom Mode Off",
position = guiCoord(0.5, -70, 0, 10),
size = guiCoord(0, 140, 0, 24),
fontSize = 18,
backgroundColour = colour(0.2, 0.2, 0.25),
borderRadius = 4,
align = enums.align.middle
})
boomBtn:on("mouseLeftReleased", function()
boomMode = not boomMode
boomBtn.text = boomMode and "Boom Mode On" or "Boom Mode Off"
end)
local function registerBlock(c)
if c.className == "block" then
c:once("mouseLeftPressed", function ()
if c.size == vector3(4, 4, 4) then
--print("mining", c.position.x/4, c.position.y/4, c.position.z/4)
engine.networking:toServer("mineBlock", c.position.x/4, c.position.y/4, c.position.z/4)
if boomMode then
engine.networking:toServer("explodeBlock", c.position.x/4, c.position.y/4, c.position.z/4)
else
engine.networking:toServer("mineBlock", c.position.x/4, c.position.y/4, c.position.z/4)
end
end
end)
end

View File

@ -105,12 +105,10 @@ for x = -5, 5 do
end
end
-- There's not much validation here...
engine.networking:bind( "mineBlock", function( client, x, y, z )
if type(x) == "number" and type(y) == "number" and type(z) == "number" and isSpaceUsed(x, y, z) then
local function mine(x, y, z)
if isSpaceUsed(x, y, z) and minable[x] and minable[x][y] and minable[x][y][z] then
local block = minable[x][y][z]
if block then
if type(block) == "block" then
setSpaceUsed(x, y, z, true)
if not isSpaceUsed(x, y - 1, z) then
@ -139,6 +137,25 @@ engine.networking:bind( "mineBlock", function( client, x, y, z )
block:destroy()
end
end
end
-- There's not much validation here...
engine.networking:bind( "mineBlock", function( client, x, y, z )
if type(x) == "number" and type(y) == "number" and type(z) == "number" then
mine(x, y, z)
end
end)
engine.networking:bind( "explodeBlock", function( client, x, y, z )
if type(x) == "number" and type(y) == "number" and type(z) == "number" then
for xo = -2, 2 do
for yo = -2, 2 do
for zo = -2, 2 do
mine(x + xo, y + yo, z + zo)
end
end
end
end
end)