mirror of https://github.com/teverse/teverse
Compare commits
6 Commits
57fdb64a08
...
016135116c
Author | SHA1 | Date |
---|---|---|
Sanjay | 016135116c | |
Sanjay Bhadra | 4a2bbd66b4 | |
Sanjay | 687898493f | |
Sanjay Bhadra | d3841a3db7 | |
Sanjay Bhadra | 5218fa7804 | |
Sanjay | bfc2f95a5c |
|
@ -1,6 +1,8 @@
|
|||
-- Copyright 2020- Teverse
|
||||
-- This script is required when workshop is loaded & acts as the 3D Camera for the 3D Environment
|
||||
|
||||
local globals = require("tevgit:workshop/library/globals.lua") -- globals; variables or instances that can be shared between files
|
||||
|
||||
local keyMap = {
|
||||
[tonumber(enums.keys.KEY_W)] = vector3(0, 0, 1),
|
||||
[tonumber(enums.keys.KEY_S)] = vector3(0, 0, -1),
|
||||
|
@ -19,14 +21,14 @@ local db = false
|
|||
teverse.input:on("keyDown", function(key)
|
||||
local mapped = keyMap[tonumber(key)]
|
||||
if mapped then
|
||||
while sleep() and teverse.input:isKeyDown(key) do
|
||||
while sleep() and teverse.input:isKeyDown(key) and not globals.ignoreCameraInput do
|
||||
cam.position = cam.position + (cam.rotation * mapped * moveStep)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
teverse.input:on("mouseMoved", function( movement )
|
||||
if teverse.input:isMouseButtonDown(3) then
|
||||
if teverse.input:isMouseButtonDown(3) and not globals.ignoreCameraInput then
|
||||
local pitch = quaternion.euler(movement.y * rotateStep, 0, 0)
|
||||
local yaw = quaternion.euler(0, movement.x * rotateStep, 0)
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ return {
|
|||
dev = nil, -- Holds workshop instance and is set in main.lua
|
||||
user = nil, -- Holds user instance and is set in main.lua
|
||||
developerMode = false, -- Holds the developer_mode boolean and is set in main.lua
|
||||
ignoreCameraInput = false, -- Determines if the camera should be able to move or not (useful when we're trying to type and we don't want the camera to move)
|
||||
commandGroups = {}, -- Holds the command groups that have been registered (~\library\toolchain\commands.lua)
|
||||
defaultColours = { -- Default colors used for theming UI components (~\library\ui\components)
|
||||
primary = colour.rgb(52, 58, 64),
|
||||
|
|
|
@ -111,7 +111,6 @@ return {
|
|||
strokeRadius = 3
|
||||
})
|
||||
|
||||
-- Test command Bar
|
||||
local commandBarIcon = teverse.construct("guiIcon", {
|
||||
parent = container,
|
||||
size = guiCoord(0, 32, 0, 32),
|
||||
|
@ -130,7 +129,6 @@ return {
|
|||
parent = container,
|
||||
size = guiCoord(0, 200, 0, 32),
|
||||
position = guiCoord(0, 191, 0, 4),
|
||||
--text = " >",
|
||||
textAlign = "middleLeft",
|
||||
textFont = "tevurl:fonts/firaCodeBold.otf",
|
||||
textSize = 15,
|
||||
|
@ -158,19 +156,17 @@ return {
|
|||
end)
|
||||
|
||||
commandBarField:on("keyDown", function(key)
|
||||
globals.ignoreCameraInput = true -- Restrict the camera from moving if typing in command bar
|
||||
if key == "KEY_RETURN" then
|
||||
print("Command: "..(commandBarField.text))
|
||||
|
||||
-- Invoke Command Trigger
|
||||
commands.parse(commandBarField.text)
|
||||
|
||||
commandBarField.text = " >"
|
||||
globals.ignoreCameraInput = false -- Re-enable the camera when the commandbar is done being used
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
-- End Test Command Bar
|
||||
|
||||
self.registerIcon = function(icon, callback)
|
||||
local icon = teverse.construct("guiIcon", {
|
||||
parent = container,
|
||||
|
|
Loading…
Reference in New Issue