Compare commits

..

No commits in common. "e51f49eb6ad6fe61082f0c8809439ed0460501f2" and "698cc12615a9ed85de1e6bf44210b37e8b3cea30" have entirely different histories.

6 changed files with 33 additions and 25 deletions

View File

@ -9,7 +9,7 @@ print("loading chars")
local controller = {} local controller = {}
-- set to false for debugging purposes. -- set to false for debugging purposes.
local CLIENT_PREDICTION = false local CLIENT_PREDICTION = true
controller.character = nil -- server creates this controller.character = nil -- server creates this
controller.camera = require("tevgit:core/client/cameraController.lua") controller.camera = require("tevgit:core/client/cameraController.lua")
@ -40,17 +40,14 @@ local function setupCharacterLocally(client, char)
end end
local function characterSpawnedHandler(newClientId) local function characterSpawnedHandler(newClientId)
print('waiting for mne') print("spawning", newClientId, engine.networking.me.id)
repeat wait() until engine.networking.me
if engine.networking.me.id == newClientId then if engine.networking.me.id == newClientId then
print("Waiting for my character") print("waiting")
repeat wait() until workspace[engine.networking.me.id] repeat wait() until workspace[engine.networking.me.id]
print('GOT my CHAR') print("got char")
controller.character = workspace[engine.networking.me.id] controller.character = workspace[engine.networking.me.id]
setupCharacterLocally(engine.networking.me, controller.character) setupCharacterLocally(engine.networking.me, controller.character)
print('set up')
-- controller.character.physics=false -- controller.character.physics=false
if controller.camera then if controller.camera then
-- controller.character.opacity = 0 -- controller.character.opacity = 0
@ -59,9 +56,7 @@ local function characterSpawnedHandler(newClientId)
controller.camera.setTarget(controller.character) controller.camera.setTarget(controller.character)
end end
else else
print("Waiting for other character")
repeat wait() until workspace[newClientId] repeat wait() until workspace[newClientId]
print("got other character")
local client = engine.networking.clients:getClientFromId(newClientId) local client = engine.networking.clients:getClientFromId(newClientId)
setupCharacterLocally(client, workspace[newClientId]) setupCharacterLocally(client, workspace[newClientId])
end end
@ -71,9 +66,6 @@ engine.networking.clients:clientConnected(function (client)
characterSpawnedHandler(client.id) characterSpawnedHandler(client.id)
end) end)
for _,v in pairs(engine.networking.clients.children)do
characterSpawnedHandler(v.id)
end
controller.keyBinds = { controller.keyBinds = {
[enums.key.w] = 1, [enums.key.w] = 1,
@ -177,4 +169,7 @@ engine.input:keyReleased(function (inputObj)
end end
end) end)
repeat print(engine.networking.me) wait() until engine.networking.me
characterSpawnedHandler(engine.networking.me.id)
return controller return controller

View File

@ -70,8 +70,8 @@ end)
function addMessage(txt) function addMessage(txt)
local newValue = messagesOutput.text .. "\n" .. txt local newValue = messagesOutput.text .. "\n" .. txt
if (newValue:len() > 310) then if (newValue:len() > 610) then
newValue = newValue:sub(newValue:len() - 300) newValue = newValue:sub(newValue:len() - 600)
end end
messagesOutput.text = newValue messagesOutput.text = newValue
end end

View File

@ -44,6 +44,8 @@ function onConnection(client)
colour = colour:random(), colour = colour:random(),
position = vector3(0, 20, 0), position = vector3(0, 20, 0),
static = false, static = false,
rollingFriction = 1.5,
spinningFriction = 1.5,
friction = 1.5, friction = 1.5,
linearDamping = 0.5, linearDamping = 0.5,
-- mesh = "primitive:sphere", -- mesh = "primitive:sphere",

View File

@ -6,10 +6,10 @@ print("Hello Client!")
require("tevgit:core/client/debug.lua") require("tevgit:core/client/debug.lua")
require("tevgit:core/client/chat.lua") require("tevgit:core/client/chat.lua")
require("tevgit:core/client/playerList.lua") require("tevgit:core/client/playerList.lua")
require("tevgit:core/client/characterController.lua")
workspace.camera.position = vector3(0, 25, -15) workspace.camera.position = vector3(0, 15, -10)
workspace.camera:lookAt(vector3(0, 0, 0)) workspace.camera:lookAt(vector3(0, 0, 0))
require("tevgit:workshop/controllers/environment/camera.lua")
local function registerBlock(c) local function registerBlock(c)
if c.className == "block" then if c.className == "block" then

View File

@ -5,6 +5,7 @@ print("Hello Server!")
require("tevgit:core/server/debug.lua") require("tevgit:core/server/debug.lua")
require("tevgit:core/server/chat.lua") require("tevgit:core/server/chat.lua")
local char = require("tevgit:core/server/characterController.lua")
workspace:destroyAllChildren() workspace:destroyAllChildren()
@ -20,28 +21,28 @@ local mainLight = engine.construct("light", workspace, {
engine.construct("block", workspace, { engine.construct("block", workspace, {
name = "base", name = "base",
position = vector3(-72, 2, 0), position = vector3(-72, 2, 0),
size = vector3(100, 0.5, 100), size = vector3(100, 1, 100),
colour = colour:fromRGB(75, 163, 57) colour = colour:fromRGB(75, 163, 57)
}) })
engine.construct("block", workspace, { engine.construct("block", workspace, {
name = "base", name = "base",
position = vector3(72, 2, 0), position = vector3(72, 2, 0),
size = vector3(100, 0.5, 100), size = vector3(100, 1, 100),
colour = colour:fromRGB(75, 163, 57) colour = colour:fromRGB(75, 163, 57)
}) })
engine.construct("block", workspace, { engine.construct("block", workspace, {
name = "base", name = "base",
position = vector3(0, 2, 72), position = vector3(0, 2, 72),
size = vector3(100, 0.5, 100), size = vector3(100, 1, 100),
colour = colour:fromRGB(75, 163, 57) colour = colour:fromRGB(75, 163, 57)
}) })
engine.construct("block", workspace, { engine.construct("block", workspace, {
name = "base", name = "base",
position = vector3(0, 2, -72), position = vector3(0, 2, -72),
size = vector3(100, 0.5, 100), size = vector3(100, 1, 100),
colour = colour:fromRGB(75, 163, 57) colour = colour:fromRGB(75, 163, 57)
}) })
@ -64,9 +65,8 @@ local function fillSpace(x, y, z)
name = "minable", name = "minable",
position = vector3(x * 4, y * 4, z * 4), position = vector3(x * 4, y * 4, z * 4),
size = vector3(4, 4, 4), size = vector3(4, 4, 4),
colour = colour:fromRGB(math.random(85, 150), math.random(70, 140), 25), colour = colour:fromRGB(math.random(55, 85), math.random(40, 60), 5),
static = true, static = true
roughness = math.random()
}) })
-- If we dont set the space as used, it will not be mineable... -- If we dont set the space as used, it will not be mineable...
@ -101,6 +101,7 @@ end
engine.networking:bind( "mineBlock", function( client, x, y, z ) 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 if type(x) == "number" and type(y) == "number" and type(z) == "number" and isSpaceUsed(x, y, z) then
local block = minable[x][y][z] local block = minable[x][y][z]
block:destroy()
setSpaceUsed(x, y, z, true) setSpaceUsed(x, y, z, true)
@ -127,8 +128,6 @@ engine.networking:bind( "mineBlock", function( client, x, y, z )
if not isSpaceUsed(x, y, z + 1) then if not isSpaceUsed(x, y, z + 1) then
fillSpace(x, y, z + 1) fillSpace(x, y, z + 1)
end end
block:destroy()
end end
end) end)

View File

@ -35,6 +35,18 @@ return {
mesh = "primitive:wedge", mesh = "primitive:wedge",
rotation = quaternion:setEuler(0, math.rad(90), 0) rotation = quaternion:setEuler(0, math.rad(90), 0)
}) })
local block = engine.construct("block", workspace, {
name = "blueSphere",
colour = colour(0, 0, 1),
size = vector3(1, 1, 1),
position = vector3(0.5, 5, 0),
mesh = "primitive:sphere",
roughness = 0.5,
metalness = 0.8,
static = false
})
engine.physics:resume()
end, end,
setupEnvironment = function () setupEnvironment = function ()