Clean indentation
This commit is contained in:
parent
fd7a38f407
commit
2426302dd8
126
main.lua
126
main.lua
|
@ -10,21 +10,21 @@ end
|
|||
-- App
|
||||
hands = {"hand/right","hand/left"}
|
||||
limbs = {
|
||||
"head",
|
||||
"hand/left",
|
||||
"hand/right",
|
||||
"hand/left/grip",
|
||||
"hand/right/grip",
|
||||
"elbow/left",
|
||||
"elbow/right",
|
||||
"shoulder/left",
|
||||
"shoulder/right",
|
||||
"chest",
|
||||
"waist",
|
||||
"knee/left",
|
||||
"knee/right",
|
||||
"foot/left",
|
||||
"foot/right"
|
||||
"head",
|
||||
"hand/left",
|
||||
"hand/right",
|
||||
"hand/left/grip",
|
||||
"hand/right/grip",
|
||||
"elbow/left",
|
||||
"elbow/right",
|
||||
"shoulder/left",
|
||||
"shoulder/right",
|
||||
"chest",
|
||||
"waist",
|
||||
"knee/left",
|
||||
"knee/right",
|
||||
"foot/left",
|
||||
"foot/right"
|
||||
}
|
||||
|
||||
configDirs = {}
|
||||
|
@ -98,9 +98,9 @@ function getClosestDistanceToPerimeter(x, y, z, points)
|
|||
end
|
||||
|
||||
function getButton(method,button,devices)
|
||||
for _,device in ipairs(devices) do
|
||||
if method(device,button) == true then return device end
|
||||
end
|
||||
for _,device in ipairs(devices) do
|
||||
if method(device,button) == true then return device end
|
||||
end
|
||||
end
|
||||
|
||||
function drawSinglePointGrid(pass, point1, point2, cornerColor, miscColor)
|
||||
|
@ -181,34 +181,34 @@ function lovr.load()
|
|||
}
|
||||
|
||||
-- Helper function to read file with fallback to default
|
||||
local function loadSetting(filename, default, parser)
|
||||
print("Checking file:", filename)
|
||||
local function loadSetting(filename, default, parser)
|
||||
print("Checking file:", filename)
|
||||
|
||||
if not lovr.filesystem.isFile(filename) then
|
||||
print("File doesn't exist, creating:", filename)
|
||||
local valueToSave
|
||||
if type(default) == "table" then
|
||||
valueToSave = json.encode(default)
|
||||
else
|
||||
valueToSave = tostring(default)
|
||||
end
|
||||
if not lovr.filesystem.isFile(filename) then
|
||||
print("File doesn't exist, creating:", filename)
|
||||
local valueToSave
|
||||
if type(default) == "table" then
|
||||
valueToSave = json.encode(default)
|
||||
else
|
||||
valueToSave = tostring(default)
|
||||
end
|
||||
|
||||
local success = lovr.filesystem.write(filename, valueToSave)
|
||||
print("Write success:", success, "for", filename, "with value:", valueToSave)
|
||||
return default
|
||||
end
|
||||
local success = lovr.filesystem.write(filename, valueToSave)
|
||||
print("Write success:", success, "for", filename, "with value:", valueToSave)
|
||||
return default
|
||||
end
|
||||
|
||||
-- File exists, try to read it
|
||||
local content = lovr.filesystem.read(filename)
|
||||
if content and parser then
|
||||
local success, value = pcall(parser, content)
|
||||
if success then return value end
|
||||
elseif content then
|
||||
return content
|
||||
end
|
||||
-- File exists, try to read it
|
||||
local content = lovr.filesystem.read(filename)
|
||||
if content and parser then
|
||||
local success, value = pcall(parser, content)
|
||||
if success then return value end
|
||||
elseif content then
|
||||
return content
|
||||
end
|
||||
|
||||
return default
|
||||
end
|
||||
return default
|
||||
end
|
||||
|
||||
-- Initialize settings with fallbacks
|
||||
settings = {
|
||||
|
@ -304,37 +304,37 @@ function modeConfigure(pass)
|
|||
end
|
||||
end
|
||||
|
||||
local inputDev = getButton(lovr.headset.wasReleased,settings.action_button,hands)
|
||||
if inputDev ~= nil and lovr.headset.isTracked(inputDev) then
|
||||
local inputDev = getButton(lovr.headset.wasReleased,settings.action_button,hands)
|
||||
if inputDev ~= nil and lovr.headset.isTracked(inputDev) then
|
||||
local cx, _, cz = lovr.headset.getPosition(inputDev)
|
||||
table.insert(settings.points,{cx,cz})
|
||||
end
|
||||
table.insert(settings.points,{cx,cz})
|
||||
end
|
||||
|
||||
inputDev = getButton(lovr.headset.isDown,settings.action_button,hands)
|
||||
if inputDev ~= nil then
|
||||
saveProg = saveProg - (deltaTime / 3)
|
||||
if saveProg <= 0 then
|
||||
inputDev = getButton(lovr.headset.isDown,settings.action_button,hands)
|
||||
if inputDev ~= nil then
|
||||
saveProg = saveProg - (deltaTime / 3)
|
||||
if saveProg <= 0 then
|
||||
local floorSpacePoints = {}
|
||||
for _,point in ipairs(settings.points) do
|
||||
local floorSpacePoint = lovr.math.vec3(point[1], 0, point[2]):transform(floorMatrixInv)
|
||||
local x, _, z = floorSpacePoint:unpack()
|
||||
table.insert(floorSpacePoints,{x,z})
|
||||
end
|
||||
lovr.filesystem.write("points.json", json.encode(floorSpacePoints))
|
||||
deinitConfigure()
|
||||
modeDraw(pass)
|
||||
return
|
||||
end
|
||||
else
|
||||
saveProg = 1.0
|
||||
end
|
||||
lovr.filesystem.write("points.json", json.encode(floorSpacePoints))
|
||||
deinitConfigure()
|
||||
modeDraw(pass)
|
||||
return
|
||||
end
|
||||
else
|
||||
saveProg = 1.0
|
||||
end
|
||||
|
||||
pass:setColor(1,0,0,0.5)
|
||||
for _,point in ipairs(settings.points) do
|
||||
pass:sphere(point[1],1.5,point[2],0.1)
|
||||
end
|
||||
pass:setColor(1,0,0,0.5)
|
||||
for _,point in ipairs(settings.points) do
|
||||
pass:sphere(point[1],1.5,point[2],0.1)
|
||||
end
|
||||
|
||||
modeDraw(pass)
|
||||
modeDraw(pass)
|
||||
end
|
||||
|
||||
function modeDraw(pass)
|
||||
|
|
Loading…
Reference in a new issue