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

View File

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

View File

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

View File

@ -6,10 +6,10 @@ 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/characterController.lua")
workspace.camera.position = vector3(0, 25, -15)
workspace.camera.position = vector3(0, 15, -10)
workspace.camera:lookAt(vector3(0, 0, 0))
require("tevgit:workshop/controllers/environment/camera.lua")
local function registerBlock(c)
if c.className == "block" then

View File

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

View File

@ -35,6 +35,18 @@ return {
mesh = "primitive:wedge",
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,
setupEnvironment = function ()