Compare commits

..

No commits in common. "e00a44c54f7a374adfabb9cb32c69817805d6ea4" and "4e8e35c71bef13ba8563c9c5d427fa97237a3138" have entirely different histories.

4 changed files with 9 additions and 101 deletions
core
client
server
demos/multiplayer

View File

@ -7,6 +7,10 @@
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)

View File

@ -4,6 +4,7 @@
@Author(s) Jay
--]]
print("creating handler")
engine.networking:bind( "message", function( client, message )
if type(message) == "string" then
print(client.name, "said", message)

View File

@ -5,17 +5,4 @@ print("Hello Client!")
require("tevgit:core/client/debug.lua")
require("tevgit:core/client/chat.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)
require("tevgit:core/client/playerList.lua")

View File

@ -4,88 +4,4 @@ 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")
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)
require("tevgit:core/server/chat.lua")