mirror of https://github.com/teverse/teverse
Compare commits
6 Commits
698cc12615
...
e51f49eb6a
Author | SHA1 | Date |
---|---|---|
Jay | e51f49eb6a | |
Jay | 5df98696a4 | |
Jay | 5c540516b4 | |
teverse | e2a161bae0 | |
teverse | cf1b24979b | |
Jay | 9f10e167d6 |
|
@ -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 = true
|
local CLIENT_PREDICTION = false
|
||||||
|
|
||||||
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,14 +40,17 @@ local function setupCharacterLocally(client, char)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function characterSpawnedHandler(newClientId)
|
local function characterSpawnedHandler(newClientId)
|
||||||
print("spawning", newClientId, engine.networking.me.id)
|
print('waiting for mne')
|
||||||
|
repeat wait() until engine.networking.me
|
||||||
if engine.networking.me.id == newClientId then
|
if engine.networking.me.id == newClientId then
|
||||||
print("waiting")
|
print("Waiting for my character")
|
||||||
repeat wait() until workspace[engine.networking.me.id]
|
repeat wait() until workspace[engine.networking.me.id]
|
||||||
print("got char")
|
print('GOT my 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
|
||||||
|
@ -56,7 +59,9 @@ 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
|
||||||
|
@ -66,6 +71,9 @@ 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,
|
||||||
|
@ -169,7 +177,4 @@ 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
|
|
@ -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() > 610) then
|
if (newValue:len() > 310) then
|
||||||
newValue = newValue:sub(newValue:len() - 600)
|
newValue = newValue:sub(newValue:len() - 300)
|
||||||
end
|
end
|
||||||
messagesOutput.text = newValue
|
messagesOutput.text = newValue
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,8 +44,6 @@ 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",
|
||||||
|
|
|
@ -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, 15, -10)
|
workspace.camera.position = vector3(0, 25, -15)
|
||||||
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
|
||||||
|
|
|
@ -5,7 +5,6 @@ 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()
|
||||||
|
|
||||||
|
@ -21,28 +20,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, 1, 100),
|
size = vector3(100, 0.5, 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, 1, 100),
|
size = vector3(100, 0.5, 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, 1, 100),
|
size = vector3(100, 0.5, 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, 1, 100),
|
size = vector3(100, 0.5, 100),
|
||||||
colour = colour:fromRGB(75, 163, 57)
|
colour = colour:fromRGB(75, 163, 57)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -65,8 +64,9 @@ 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(55, 85), math.random(40, 60), 5),
|
colour = colour:fromRGB(math.random(85, 150), math.random(70, 140), 25),
|
||||||
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,7 +101,6 @@ 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)
|
||||||
|
|
||||||
|
@ -128,6 +127,8 @@ 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)
|
||||||
|
|
||||||
|
|
|
@ -35,18 +35,6 @@ 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 ()
|
||||||
|
|
Loading…
Reference in New Issue