Compare commits

..

No commits in common. "270e510b575fe1b75da39834af9d3bb96ce524d3" and "cdb0134b4115fcdfd40e8f389f70c564f1f6fc0a" have entirely different histories.

2 changed files with 7 additions and 42 deletions

View File

@ -11,31 +11,13 @@ 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
if boomMode then
engine.networking:toServer("explodeBlock", c.position.x/4, c.position.y/4, c.position.z/4)
else
--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)
end
end
end)
end
end

View File

@ -105,10 +105,12 @@ for x = -5, 5 do
end
end
local function mine(x, y, z)
if isSpaceUsed(x, y, z) and minable[x] and minable[x][y] and minable[x][y][z] then
-- 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 block = minable[x][y][z]
if type(block) == "block" then
if block then
setSpaceUsed(x, y, z, true)
if not isSpaceUsed(x, y - 1, z) then
@ -138,25 +140,6 @@ local function mine(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)
print("server loaded")