mirror of https://github.com/teverse/teverse
Compare commits
7 Commits
4e8e35c71b
...
e00a44c54f
Author | SHA1 | Date |
---|---|---|
teverse | e00a44c54f | |
teverse | 2bb8d87306 | |
teverse | c2fd57b82d | |
teverse | f67b6abfc6 | |
teverse | 7802e1d111 | |
teverse | c05d6e5f9c | |
teverse | 15a57a1875 |
|
@ -7,10 +7,6 @@
|
|||
|
||||
print("Loaded Client")
|
||||
require("tevgit:core/client/debug.lua")
|
||||
require("tevgit:core/client/chat.lua")
|
||||
require("tevgit:core/client/playerList.lua")
|
||||
|
||||
engine.networking:connected(function (serverId)
|
||||
print("Connected")
|
||||
require("tevgit:core/client/chat.lua")
|
||||
require("tevgit:core/client/playerList.lua")
|
||||
--local characterController = require("tevgit:core/client/characterController.lua")
|
||||
end)
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
@Author(s) Jay
|
||||
--]]
|
||||
|
||||
print("creating handler")
|
||||
engine.networking:bind( "message", function( client, message )
|
||||
if type(message) == "string" then
|
||||
print(client.name, "said", message)
|
||||
|
|
|
@ -5,4 +5,17 @@ print("Hello Client!")
|
|||
|
||||
require("tevgit:core/client/debug.lua")
|
||||
require("tevgit:core/client/chat.lua")
|
||||
require("tevgit:core/client/playerList.lua")
|
||||
require("tevgit:core/client/playerList.lua")
|
||||
|
||||
workspace.camera.position = vector3(0, 15, -10)
|
||||
workspace.camera:lookAt(vector3(0, 0, 0))
|
||||
|
||||
workspace:childAdded(function(c)
|
||||
if c.className == "block" then
|
||||
c:once("mouseLeftPressed", function ()
|
||||
if c.size == vector3(4, 4, 4) then
|
||||
engine.networking:toServer("mineBlock", c.position.x/4, c.position.y/4, c.position.z/4)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
|
@ -4,4 +4,88 @@ print("Hello Server!")
|
|||
-- however: we want to load some core server code anyway
|
||||
|
||||
require("tevgit:core/server/debug.lua")
|
||||
require("tevgit:core/server/chat.lua")
|
||||
require("tevgit:core/server/chat.lua")
|
||||
|
||||
for _,v in pairs(workspace.children) do
|
||||
if v.className == "block" then
|
||||
v:destroy()
|
||||
end
|
||||
end
|
||||
|
||||
local minable = {}
|
||||
|
||||
local function setSpaceUsed(x, y, z, value)
|
||||
if not minable[x] then
|
||||
minable[x] = {}
|
||||
end
|
||||
|
||||
if not minable[x][y] then
|
||||
minable[x][y] = {}
|
||||
end
|
||||
|
||||
minable[x][y][z] = value
|
||||
end
|
||||
|
||||
local function fillSpace(x, y, z)
|
||||
local block = engine.construct("block", workspace, {
|
||||
name = "minable",
|
||||
position = vector3(x * 4, y * 4, z * 4),
|
||||
size = vector3(4, 4, 4),
|
||||
colour = colour:random(),
|
||||
static = true
|
||||
})
|
||||
|
||||
setSpaceUsed(x, y, z, block)
|
||||
|
||||
return block
|
||||
end
|
||||
|
||||
local function isSpaceUsed(x, y, z)
|
||||
if y > 0 then
|
||||
return true
|
||||
elseif not minable[x] or not minable[x][y] or not minable[x][y][z] then
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
for x = -5, 5 do
|
||||
for z = -5, 5 do
|
||||
fillSpace(x, 0, z)
|
||||
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 block = minable[x][y][z]
|
||||
block:destroy()
|
||||
|
||||
setSpaceUsed(x, y, z, true)
|
||||
|
||||
if not isSpaceUsed(x, y - 1, z) then
|
||||
fillSpace(x, y - 1, z)
|
||||
end
|
||||
|
||||
if not isSpaceUsed(x, y + 1, z) then
|
||||
fillSpace(x, y + 1, z)
|
||||
end
|
||||
|
||||
if not isSpaceUsed(x - 1, y, z) then
|
||||
fillSpace(x - 1, y, z)
|
||||
end
|
||||
|
||||
if not isSpaceUsed(x + 1, y, z) then
|
||||
fillSpace(x + 1, y, z)
|
||||
end
|
||||
|
||||
if not isSpaceUsed(x, y, z - 1) then
|
||||
fillSpace(x, y, z - 1)
|
||||
end
|
||||
|
||||
if not isSpaceUsed(x, y, z + 1) then
|
||||
fillSpace(x, y, z + 1)
|
||||
end
|
||||
end
|
||||
end)
|
Loading…
Reference in New Issue