Compare commits

...

7 Commits

Author SHA1 Message Date
teverse e00a44c54f fix fatal flaw 2019-11-20 20:50:38 +00:00
teverse 2bb8d87306 fixed 2019-11-20 20:48:31 +00:00
teverse c2fd57b82d twesr 2019-11-20 20:45:36 +00:00
teverse f67b6abfc6 no typos allowed 2019-11-20 20:31:49 +00:00
teverse 7802e1d111 this isn't c# 2019-11-20 20:30:10 +00:00
teverse c05d6e5f9c demo game 2019-11-20 20:29:19 +00:00
teverse 15a57a1875 remove event listener from client loader (0.10.1 only loads this script on connection) 2019-11-20 20:01:22 +00:00
4 changed files with 101 additions and 9 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)