mirror of https://github.com/teverse/teverse
Compare commits
3 Commits
cdb0134b41
...
270e510b57
Author | SHA1 | Date |
---|---|---|
Jay | 270e510b57 | |
Jay | 152d91dc6e | |
Jay | 46707b698f |
|
@ -11,13 +11,31 @@ 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)
|
||||
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
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
@ -140,6 +138,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)
|
||||
|
||||
print("server loaded")
|
Loading…
Reference in New Issue