Compare commits

..

6 Commits

Author SHA1 Message Date
Jay e51f49eb6a chat 2020-02-02 21:28:28 +00:00
Jay 5df98696a4 update demo game 2020-02-02 21:16:46 +00:00
Jay 5c540516b4 demo game 1 2020-02-02 21:11:43 +00:00
teverse e2a161bae0 Removwe deubg 2020-02-02 19:34:04 +00:00
teverse cf1b24979b 0.17 2020-02-02 19:10:19 +00:00
Jay 9f10e167d6 char 2020-02-02 17:57:46 +00:00
6 changed files with 25 additions and 33 deletions

View File

@ -9,7 +9,7 @@ print("loading chars")
local controller = {}
-- set to false for debugging purposes.
local CLIENT_PREDICTION = true
local CLIENT_PREDICTION = false
controller.character = nil -- server creates this
controller.camera = require("tevgit:core/client/cameraController.lua")
@ -40,14 +40,17 @@ local function setupCharacterLocally(client, char)
end
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
print("waiting")
print("Waiting for my character")
repeat wait() until workspace[engine.networking.me.id]
print("got char")
print('GOT my 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
@ -56,7 +59,9 @@ 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
@ -66,6 +71,9 @@ 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,
@ -169,7 +177,4 @@ 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() > 610) then
newValue = newValue:sub(newValue:len() - 600)
if (newValue:len() > 310) then
newValue = newValue:sub(newValue:len() - 300)
end
messagesOutput.text = newValue
end

View File

@ -44,8 +44,6 @@ 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, 15, -10)
workspace.camera.position = vector3(0, 25, -15)
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,7 +5,6 @@ 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()
@ -21,28 +20,28 @@ local mainLight = engine.construct("light", workspace, {
engine.construct("block", workspace, {
name = "base",
position = vector3(-72, 2, 0),
size = vector3(100, 1, 100),
size = vector3(100, 0.5, 100),
colour = colour:fromRGB(75, 163, 57)
})
engine.construct("block", workspace, {
name = "base",
position = vector3(72, 2, 0),
size = vector3(100, 1, 100),
size = vector3(100, 0.5, 100),
colour = colour:fromRGB(75, 163, 57)
})
engine.construct("block", workspace, {
name = "base",
position = vector3(0, 2, 72),
size = vector3(100, 1, 100),
size = vector3(100, 0.5, 100),
colour = colour:fromRGB(75, 163, 57)
})
engine.construct("block", workspace, {
name = "base",
position = vector3(0, 2, -72),
size = vector3(100, 1, 100),
size = vector3(100, 0.5, 100),
colour = colour:fromRGB(75, 163, 57)
})
@ -65,8 +64,9 @@ 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(55, 85), math.random(40, 60), 5),
static = true
colour = colour:fromRGB(math.random(85, 150), math.random(70, 140), 25),
static = true,
roughness = math.random()
})
-- 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 )
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)
@ -128,6 +127,8 @@ 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,18 +35,6 @@ 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 ()