forked from hkc/cc-stuff
1
0
Fork 0

Compare commits

..

No commits in common. "vftdan" and "master" have entirely different histories.

4 changed files with 6 additions and 124 deletions

View File

@ -1,5 +1,5 @@
{ {
"repository": "https://git.salushnes.solutions/vftdan/cc-stuff/raw/branch/vftdan/augment", "repository": "https://git.salushnes.solutions/hkc/cc-stuff/raw/branch/master/augment",
"files": [ "files": [
{ {
"path": "startup", "path": "startup",
@ -13,10 +13,6 @@
"path": "modules/event.lua", "path": "modules/event.lua",
"src": "modules/event.lua" "src": "modules/event.lua"
}, },
{
"path": "modules/hangglider_boost.lua",
"src": "modules/hangglider_boost.lua"
},
{ {
"path": "modules/wh.lua", "path": "modules/wh.lua",
"src": "modules/wh.lua" "src": "modules/wh.lua"

View File

@ -1,32 +0,0 @@
return function()
local sneakTicks = 0
local windowEvents = {nil, nil, nil}
local windowDuration = 20
local clockCounter = 0
while _G.player == nil do
os.sleep(0.05)
end
parallel.waitForAny(
function() while _G._running do
if player and windowEvents[3] ~= nil and windowEvents[3] + windowDuration >= clockCounter then
local mainHand = player.heldItem and player.heldItem.getMetadata().name
local offHand = player.offhandItem and player.offhandItem.getMetadata().name
if mainHand == "openblocks:hang_glider" or offHand == "openblocks:hang_glider" then
NI.launch(player.yaw, player.pitch, 4)
end
end
os.sleep(0.05)
end end,
function() while _G._running do
clockCounter = clockCounter + 1
if player.isSneaking then
sneakTicks = sneakTicks + 1
elseif sneakTicks ~= 0 then
windowEvents = {clockCounter, windowEvents[1], windowEvents[2]}
sneakTicks = 0
end
os.sleep(0.05)
end end)
end

View File

@ -1,69 +1,10 @@
return function() return function()
local playerLookVector = nil
local function getEntityLookVector(entity)
-- yaw:
-- 0 => positive Z
-- 90 => negative X
-- pitch:
-- 0 => forward
-- 90 => down
if entity == nil or entity.yaw == nil or entity.pitch == nil then
return {0, 0, 0, x = 0, y = 0, z = 0}
end
local yawr = math.rad(entity.yaw)
local pitchr = math.rad(entity.pitch)
local cosPitch = math.cos(pitchr)
local x = cosPitch * -math.sin(yawr)
local z = cosPitch * math.cos(yawr)
local y = -math.sin(pitchr)
return {x, y, z, x = x, y = y, z = z}
end
local function updateLookVector()
playerLookVector = getEntityLookVector(player)
return playerLookVector
end
local function dotProduct3(u, v)
return u.x * v.x + u.y * v.y + u.z * v.z
end
local function vec3Scale(k, v)
return {x = k * v.x, y = k * v.y, z = k * v.z}
end
local function vec3Add(u, v)
return {x = u.x + v.x, y = u.y + v.y, z = u.z + v.z}
end
local function vec3Abs(v)
return math.sqrt(dotProduct3(v, v))
end
local function toFrontCoords(entity)
local dotResult = dotProduct3(entity, playerLookVector)
if dotResult >= 0.0 then
return {x = entity.x, y = entity.y, z = entity.z, flipped = false}
end
local result = vec3Add(entity, vec3Scale(-2 * dotResult, playerLookVector))
result.flipped = true
return result
end
while _G.player == nil do
os.sleep(0.05)
end
local cache = {} local cache = {}
while _G._running do while _G._running do
updateLookVector()
for id, entry in pairs(cache) do for id, entry in pairs(cache) do
if nearbyEntitiesByUUID[id] == nil then if nearbyEntitiesByUUID[id] == nil then
entry.cube.remove() entry.cube.remove()
entry.frame.remove() entry.frame.remove()
entry.lookLine.remove()
cache[id] = nil cache[id] = nil
end end
end end
@ -76,40 +17,17 @@ return function()
cache[id].cube.setSize(0.5, 0.5, 0.5) cache[id].cube.setSize(0.5, 0.5, 0.5)
cache[id].frame = canvas3d.addFrame({ 0, 0, 0 }) cache[id].frame = canvas3d.addFrame({ 0, 0, 0 })
cache[id].text = cache[id].frame.addText({ 0, 0 }, "") cache[id].text = cache[id].frame.addText({ 0, 0 }, "")
cache[id].lookLine = canvas3d.addLine({ 0, 0, 0 }, { 0, 0, 0 }, 2, 0)
end
local entityFront = toFrontCoords(entity)
local entityLook = getEntityLookVector(entity)
local entityLookEnd = vec3Add(entityFront, entityLook)
if entityFront.flipped then
cache[id].cube.setColor(0x004040FF)
cache[id].lookLine.setColor(0x206060FF)
else
cache[id].cube.setColor(0xFFC0C0FF)
cache[id].lookLine.setColor(0xE0A0A0FF)
end end
cache[id].cube.setAlpha(0x20) cache[id].cube.setAlpha(0x20)
cache[id].lookLine.setAlpha(0x30)
cache[id].cube.setDepthTested(false) cache[id].cube.setDepthTested(false)
cache[id].frame.setDepthTested(false) cache[id].frame.setDepthTested(false)
cache[id].lookLine.setDepthTested(false) cache[id].cube.setPosition(entity.x - 0.25, entity.y - 0.25, entity.z - 0.25)
cache[id].cube.setPosition(entityFront.x - 0.25, entityFront.y - 0.25, entityFront.z - 0.25) cache[id].frame.setPosition(entity.x, entity.y, entity.z)
cache[id].frame.setPosition(entityFront.x, entityFront.y, entityFront.z)
cache[id].lookLine.setPoint(1, entityFront.x, entityFront.y, entityFront.z)
cache[id].lookLine.setPoint(2, entityLookEnd.x, entityLookEnd.y, entityLookEnd.z)
cache[id].text.setAlpha(0xFF) cache[id].text.setAlpha(0xFF)
if player.isSneaking then
cache[id].text.setText(entity.name .. "\n" .. textutils.serialize(entity)) cache[id].text.setText(entity.name .. "\n" .. textutils.serialize(entity))
else
cache[id].text.setText(("%s\n|{%.2f, %.2f, %.2f}| = %.2f"):format(entity.name, entity.x, entity.y, entity.z, vec3Abs(entity)))
end
if entityFront.flipped then
cache[id].text.setColor(0x00FFFFFF)
else
cache[id].text.setColor(0xFF0000FF) cache[id].text.setColor(0xFF0000FF)
end end
end end
end
os.sleep(0.05) os.sleep(0.05)
end end
end end

View File

@ -1,4 +1,4 @@
local repository = "https://git.salushnes.solutions/vftdan/cc-stuff/raw/branch/vftdan/augment/files.json" local repository = "https://git.salushnes.solutions/hkc/cc-stuff/raw/branch/master/augment/files.json"
local files = textutils.unserializeJSON(http.get(repository).readAll()) local files = textutils.unserializeJSON(http.get(repository).readAll())
local function getFile(url, path) local function getFile(url, path)