Convert to unix line endings again

This commit is contained in:
Adam Goldsmith 2020-12-06 09:42:32 -05:00
parent 272bf37088
commit 815e590fa4
524 changed files with 147669 additions and 147669 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,113 +1,113 @@
--Counting Bowl by MrStump --Counting Bowl by MrStump
--Table of items which can be counted in this Bowl --Table of items which can be counted in this Bowl
--Each entry has 2 things to enter --Each entry has 2 things to enter
--a name (what is in the name field of that object) --a name (what is in the name field of that object)
--a value (how much it is worth) --a value (how much it is worth)
--A number in the items description will override the number entry in this table --A number in the items description will override the number entry in this table
validCountItemList = { validCountItemList = {
["Clue"] = 1, ["Clue"] = 1,
[""] = 1, [""] = 1,
--["Name3"] = 2, --["Name3"] = 2,
--["Name4"] = 31, --["Name4"] = 31,
--Add more entries as needed --Add more entries as needed
--Remove the -- from before a line for the script to use it --Remove the -- from before a line for the script to use it
} }
--END OF CODE TO EDIT --END OF CODE TO EDIT
function onLoad() function onLoad()
timerID = self.getGUID()..math.random(9999999999999) timerID = self.getGUID()..math.random(9999999999999)
--Sets position/color for the button, spawns it --Sets position/color for the button, spawns it
self.createButton({ self.createButton({
label="", click_function="removeAllClues", function_owner=self, label="", click_function="removeAllClues", function_owner=self,
position={0,0,0}, rotation={0,8,0}, height=0, width=0, position={0,0,0}, rotation={0,8,0}, height=0, width=0,
font_color={0,0,0}, font_size=2000 font_color={0,0,0}, font_size=2000
}) })
--Start timer which repeats forever, running countItems() every second --Start timer which repeats forever, running countItems() every second
Timer.create({ Timer.create({
identifier=timerID, identifier=timerID,
function_name="countItems", function_owner=self, function_name="countItems", function_owner=self,
repetitions=0, delay=1 repetitions=0, delay=1
}) })
exposedValue = 0 exposedValue = 0
trashCan = getObjectFromGUID("147e80") trashCan = getObjectFromGUID("147e80")
end end
function findValidItemsInSphere() function findValidItemsInSphere()
return filterByValidity(findItemsInSphere()) return filterByValidity(findItemsInSphere())
end end
--Activated once per second, counts items in bowls --Activated once per second, counts items in bowls
function countItems() function countItems()
local totalValue = -1 local totalValue = -1
local countableItems = findValidItemsInSphere() local countableItems = findValidItemsInSphere()
for ind, entry in ipairs(countableItems) do for ind, entry in ipairs(countableItems) do
local descValue = tonumber(entry.hit_object.getDescription()) local descValue = tonumber(entry.hit_object.getDescription())
local stackMult = math.abs(entry.hit_object.getQuantity()) local stackMult = math.abs(entry.hit_object.getQuantity())
--Use value in description if available --Use value in description if available
if descValue ~= nil then if descValue ~= nil then
totalValue = totalValue + descValue * stackMult totalValue = totalValue + descValue * stackMult
else else
--Otherwise use the value in validCountItemList --Otherwise use the value in validCountItemList
totalValue = totalValue + validCountItemList[entry.hit_object.getName()] * stackMult totalValue = totalValue + validCountItemList[entry.hit_object.getName()] * stackMult
end end
end end
exposedValue = totalValue exposedValue = totalValue
--Updates the number display --Updates the number display
self.editButton({index=0, label=totalValue}) self.editButton({index=0, label=totalValue})
end end
function filterByValidity(items) function filterByValidity(items)
retval = {} retval = {}
for _, entry in ipairs(items) do for _, entry in ipairs(items) do
--Ignore the bowl --Ignore the bowl
if entry.hit_object ~= self then if entry.hit_object ~= self then
--Ignore if not in validCountItemList --Ignore if not in validCountItemList
local tableEntry = validCountItemList[entry.hit_object.getName()] local tableEntry = validCountItemList[entry.hit_object.getName()]
if tableEntry ~= nil then if tableEntry ~= nil then
table.insert(retval, entry) table.insert(retval, entry)
end end
end end
end end
return retval return retval
end end
--Gets the items in the bowl for countItems to count --Gets the items in the bowl for countItems to count
function findItemsInSphere() function findItemsInSphere()
--Find scaling factor --Find scaling factor
local scale = self.getScale() local scale = self.getScale()
--Set position for the sphere --Set position for the sphere
local pos = self.getPosition() local pos = self.getPosition()
pos.y=pos.y+(1.25*scale.y) pos.y=pos.y+(1.25*scale.y)
--Ray trace to get all objects --Ray trace to get all objects
return Physics.cast({ return Physics.cast({
origin=pos, direction={0,1,0}, type=2, max_distance=0, origin=pos, direction={0,1,0}, type=2, max_distance=0,
size={6*scale.x,6*scale.y,6*scale.z}, --debug=true size={6*scale.x,6*scale.y,6*scale.z}, --debug=true
}) })
end end
function removeAllClues() function removeAllClues()
startLuaCoroutine(self, "clueRemovalCoroutine") startLuaCoroutine(self, "clueRemovalCoroutine")
end end
function clueRemovalCoroutine() function clueRemovalCoroutine()
for _, entry in ipairs(findValidItemsInSphere()) do for _, entry in ipairs(findValidItemsInSphere()) do
-- Do not put the table in the garbage -- Do not put the table in the garbage
if entry.hit_object.getGUID() ~= "4ee1f2" then if entry.hit_object.getGUID() ~= "4ee1f2" then
--delay for animation purposes --delay for animation purposes
for k=1,10 do for k=1,10 do
coroutine.yield(0) coroutine.yield(0)
end end
trashCan.putObject(entry.hit_object) trashCan.putObject(entry.hit_object)
end end
end end
--coroutines must return a value --coroutines must return a value
return 1 return 1
end end
function onDestroy() function onDestroy()
Timer.destroy(timerID) Timer.destroy(timerID)
end end

View File

@ -1,113 +1,113 @@
--Counting Bowl by MrStump --Counting Bowl by MrStump
--Table of items which can be counted in this Bowl --Table of items which can be counted in this Bowl
--Each entry has 2 things to enter --Each entry has 2 things to enter
--a name (what is in the name field of that object) --a name (what is in the name field of that object)
--a value (how much it is worth) --a value (how much it is worth)
--A number in the items description will override the number entry in this table --A number in the items description will override the number entry in this table
validCountItemList = { validCountItemList = {
["Clue"] = 1, ["Clue"] = 1,
[""] = 1, [""] = 1,
--["Name3"] = 2, --["Name3"] = 2,
--["Name4"] = 31, --["Name4"] = 31,
--Add more entries as needed --Add more entries as needed
--Remove the -- from before a line for the script to use it --Remove the -- from before a line for the script to use it
} }
--END OF CODE TO EDIT --END OF CODE TO EDIT
function onLoad() function onLoad()
timerID = self.getGUID()..math.random(9999999999999) timerID = self.getGUID()..math.random(9999999999999)
--Sets position/color for the button, spawns it --Sets position/color for the button, spawns it
self.createButton({ self.createButton({
label="", click_function="removeAllClues", function_owner=self, label="", click_function="removeAllClues", function_owner=self,
position={0,0,0}, rotation={0,8,0}, height=0, width=0, position={0,0,0}, rotation={0,8,0}, height=0, width=0,
font_color={0,0,0}, font_size=2000 font_color={0,0,0}, font_size=2000
}) })
--Start timer which repeats forever, running countItems() every second --Start timer which repeats forever, running countItems() every second
Timer.create({ Timer.create({
identifier=timerID, identifier=timerID,
function_name="countItems", function_owner=self, function_name="countItems", function_owner=self,
repetitions=0, delay=1 repetitions=0, delay=1
}) })
exposedValue = 0 exposedValue = 0
trashCan = getObjectFromGUID("147e80") trashCan = getObjectFromGUID("147e80")
end end
function findValidItemsInSphere() function findValidItemsInSphere()
return filterByValidity(findItemsInSphere()) return filterByValidity(findItemsInSphere())
end end
--Activated once per second, counts items in bowls --Activated once per second, counts items in bowls
function countItems() function countItems()
local totalValue = -1 local totalValue = -1
local countableItems = findValidItemsInSphere() local countableItems = findValidItemsInSphere()
for ind, entry in ipairs(countableItems) do for ind, entry in ipairs(countableItems) do
local descValue = tonumber(entry.hit_object.getDescription()) local descValue = tonumber(entry.hit_object.getDescription())
local stackMult = math.abs(entry.hit_object.getQuantity()) local stackMult = math.abs(entry.hit_object.getQuantity())
--Use value in description if available --Use value in description if available
if descValue ~= nil then if descValue ~= nil then
totalValue = totalValue + descValue * stackMult totalValue = totalValue + descValue * stackMult
else else
--Otherwise use the value in validCountItemList --Otherwise use the value in validCountItemList
totalValue = totalValue + validCountItemList[entry.hit_object.getName()] * stackMult totalValue = totalValue + validCountItemList[entry.hit_object.getName()] * stackMult
end end
end end
exposedValue = totalValue exposedValue = totalValue
--Updates the number display --Updates the number display
self.editButton({index=0, label=totalValue}) self.editButton({index=0, label=totalValue})
end end
function filterByValidity(items) function filterByValidity(items)
retval = {} retval = {}
for _, entry in ipairs(items) do for _, entry in ipairs(items) do
--Ignore the bowl --Ignore the bowl
if entry.hit_object ~= self then if entry.hit_object ~= self then
--Ignore if not in validCountItemList --Ignore if not in validCountItemList
local tableEntry = validCountItemList[entry.hit_object.getName()] local tableEntry = validCountItemList[entry.hit_object.getName()]
if tableEntry ~= nil then if tableEntry ~= nil then
table.insert(retval, entry) table.insert(retval, entry)
end end
end end
end end
return retval return retval
end end
--Gets the items in the bowl for countItems to count --Gets the items in the bowl for countItems to count
function findItemsInSphere() function findItemsInSphere()
--Find scaling factor --Find scaling factor
local scale = self.getScale() local scale = self.getScale()
--Set position for the sphere --Set position for the sphere
local pos = self.getPosition() local pos = self.getPosition()
pos.y=pos.y+(1.25*scale.y) pos.y=pos.y+(1.25*scale.y)
--Ray trace to get all objects --Ray trace to get all objects
return Physics.cast({ return Physics.cast({
origin=pos, direction={0,1,0}, type=2, max_distance=0, origin=pos, direction={0,1,0}, type=2, max_distance=0,
size={6*scale.x,6*scale.y,6*scale.z}, --debug=true size={6*scale.x,6*scale.y,6*scale.z}, --debug=true
}) })
end end
function removeAllClues() function removeAllClues()
startLuaCoroutine(self, "clueRemovalCoroutine") startLuaCoroutine(self, "clueRemovalCoroutine")
end end
function clueRemovalCoroutine() function clueRemovalCoroutine()
for _, entry in ipairs(findValidItemsInSphere()) do for _, entry in ipairs(findValidItemsInSphere()) do
-- Do not put the table in the garbage -- Do not put the table in the garbage
if entry.hit_object.getGUID() ~= "4ee1f2" then if entry.hit_object.getGUID() ~= "4ee1f2" then
--delay for animation purposes --delay for animation purposes
for k=1,10 do for k=1,10 do
coroutine.yield(0) coroutine.yield(0)
end end
trashCan.putObject(entry.hit_object) trashCan.putObject(entry.hit_object)
end end
end end
--coroutines must return a value --coroutines must return a value
return 1 return 1
end end
function onDestroy() function onDestroy()
Timer.destroy(timerID) Timer.destroy(timerID)
end end

View File

@ -1,113 +1,113 @@
--Counting Bowl by MrStump --Counting Bowl by MrStump
--Table of items which can be counted in this Bowl --Table of items which can be counted in this Bowl
--Each entry has 2 things to enter --Each entry has 2 things to enter
--a name (what is in the name field of that object) --a name (what is in the name field of that object)
--a value (how much it is worth) --a value (how much it is worth)
--A number in the items description will override the number entry in this table --A number in the items description will override the number entry in this table
validCountItemList = { validCountItemList = {
["Clue"] = 1, ["Clue"] = 1,
[""] = 1, [""] = 1,
--["Name3"] = 2, --["Name3"] = 2,
--["Name4"] = 31, --["Name4"] = 31,
--Add more entries as needed --Add more entries as needed
--Remove the -- from before a line for the script to use it --Remove the -- from before a line for the script to use it
} }
--END OF CODE TO EDIT --END OF CODE TO EDIT
function onLoad() function onLoad()
timerID = self.getGUID()..math.random(9999999999999) timerID = self.getGUID()..math.random(9999999999999)
--Sets position/color for the button, spawns it --Sets position/color for the button, spawns it
self.createButton({ self.createButton({
label="", click_function="removeAllClues", function_owner=self, label="", click_function="removeAllClues", function_owner=self,
position={0,0,0}, rotation={0,8,0}, height=0, width=0, position={0,0,0}, rotation={0,8,0}, height=0, width=0,
font_color={0,0,0}, font_size=2000 font_color={0,0,0}, font_size=2000
}) })
--Start timer which repeats forever, running countItems() every second --Start timer which repeats forever, running countItems() every second
Timer.create({ Timer.create({
identifier=timerID, identifier=timerID,
function_name="countItems", function_owner=self, function_name="countItems", function_owner=self,
repetitions=0, delay=1 repetitions=0, delay=1
}) })
exposedValue = 0 exposedValue = 0
trashCan = getObjectFromGUID("147e80") trashCan = getObjectFromGUID("147e80")
end end
function findValidItemsInSphere() function findValidItemsInSphere()
return filterByValidity(findItemsInSphere()) return filterByValidity(findItemsInSphere())
end end
--Activated once per second, counts items in bowls --Activated once per second, counts items in bowls
function countItems() function countItems()
local totalValue = -1 local totalValue = -1
local countableItems = findValidItemsInSphere() local countableItems = findValidItemsInSphere()
for ind, entry in ipairs(countableItems) do for ind, entry in ipairs(countableItems) do
local descValue = tonumber(entry.hit_object.getDescription()) local descValue = tonumber(entry.hit_object.getDescription())
local stackMult = math.abs(entry.hit_object.getQuantity()) local stackMult = math.abs(entry.hit_object.getQuantity())
--Use value in description if available --Use value in description if available
if descValue ~= nil then if descValue ~= nil then
totalValue = totalValue + descValue * stackMult totalValue = totalValue + descValue * stackMult
else else
--Otherwise use the value in validCountItemList --Otherwise use the value in validCountItemList
totalValue = totalValue + validCountItemList[entry.hit_object.getName()] * stackMult totalValue = totalValue + validCountItemList[entry.hit_object.getName()] * stackMult
end end
end end
exposedValue = totalValue exposedValue = totalValue
--Updates the number display --Updates the number display
self.editButton({index=0, label=totalValue}) self.editButton({index=0, label=totalValue})
end end
function filterByValidity(items) function filterByValidity(items)
retval = {} retval = {}
for _, entry in ipairs(items) do for _, entry in ipairs(items) do
--Ignore the bowl --Ignore the bowl
if entry.hit_object ~= self then if entry.hit_object ~= self then
--Ignore if not in validCountItemList --Ignore if not in validCountItemList
local tableEntry = validCountItemList[entry.hit_object.getName()] local tableEntry = validCountItemList[entry.hit_object.getName()]
if tableEntry ~= nil then if tableEntry ~= nil then
table.insert(retval, entry) table.insert(retval, entry)
end end
end end
end end
return retval return retval
end end
--Gets the items in the bowl for countItems to count --Gets the items in the bowl for countItems to count
function findItemsInSphere() function findItemsInSphere()
--Find scaling factor --Find scaling factor
local scale = self.getScale() local scale = self.getScale()
--Set position for the sphere --Set position for the sphere
local pos = self.getPosition() local pos = self.getPosition()
pos.y=pos.y+(1.25*scale.y) pos.y=pos.y+(1.25*scale.y)
--Ray trace to get all objects --Ray trace to get all objects
return Physics.cast({ return Physics.cast({
origin=pos, direction={0,1,0}, type=2, max_distance=0, origin=pos, direction={0,1,0}, type=2, max_distance=0,
size={6*scale.x,6*scale.y,6*scale.z}, --debug=true size={6*scale.x,6*scale.y,6*scale.z}, --debug=true
}) })
end end
function removeAllClues() function removeAllClues()
startLuaCoroutine(self, "clueRemovalCoroutine") startLuaCoroutine(self, "clueRemovalCoroutine")
end end
function clueRemovalCoroutine() function clueRemovalCoroutine()
for _, entry in ipairs(findValidItemsInSphere()) do for _, entry in ipairs(findValidItemsInSphere()) do
-- Do not put the table in the garbage -- Do not put the table in the garbage
if entry.hit_object.getGUID() ~= "4ee1f2" then if entry.hit_object.getGUID() ~= "4ee1f2" then
--delay for animation purposes --delay for animation purposes
for k=1,10 do for k=1,10 do
coroutine.yield(0) coroutine.yield(0)
end end
trashCan.putObject(entry.hit_object) trashCan.putObject(entry.hit_object)
end end
end end
--coroutines must return a value --coroutines must return a value
return 1 return 1
end end
function onDestroy() function onDestroy()
Timer.destroy(timerID) Timer.destroy(timerID)
end end

View File

@ -1,113 +1,113 @@
--Counting Bowl by MrStump --Counting Bowl by MrStump
--Table of items which can be counted in this Bowl --Table of items which can be counted in this Bowl
--Each entry has 2 things to enter --Each entry has 2 things to enter
--a name (what is in the name field of that object) --a name (what is in the name field of that object)
--a value (how much it is worth) --a value (how much it is worth)
--A number in the items description will override the number entry in this table --A number in the items description will override the number entry in this table
validCountItemList = { validCountItemList = {
["Clue"] = 1, ["Clue"] = 1,
[""] = 1, [""] = 1,
--["Name3"] = 2, --["Name3"] = 2,
--["Name4"] = 31, --["Name4"] = 31,
--Add more entries as needed --Add more entries as needed
--Remove the -- from before a line for the script to use it --Remove the -- from before a line for the script to use it
} }
--END OF CODE TO EDIT --END OF CODE TO EDIT
function onLoad() function onLoad()
timerID = self.getGUID()..math.random(9999999999999) timerID = self.getGUID()..math.random(9999999999999)
--Sets position/color for the button, spawns it --Sets position/color for the button, spawns it
self.createButton({ self.createButton({
label="", click_function="removeAllClues", function_owner=self, label="", click_function="removeAllClues", function_owner=self,
position={0,0,0}, rotation={0,8,0}, height=0, width=0, position={0,0,0}, rotation={0,8,0}, height=0, width=0,
font_color={0,0,0}, font_size=2000 font_color={0,0,0}, font_size=2000
}) })
--Start timer which repeats forever, running countItems() every second --Start timer which repeats forever, running countItems() every second
Timer.create({ Timer.create({
identifier=timerID, identifier=timerID,
function_name="countItems", function_owner=self, function_name="countItems", function_owner=self,
repetitions=0, delay=1 repetitions=0, delay=1
}) })
exposedValue = 0 exposedValue = 0
trashCan = getObjectFromGUID("147e80") trashCan = getObjectFromGUID("147e80")
end end
function findValidItemsInSphere() function findValidItemsInSphere()
return filterByValidity(findItemsInSphere()) return filterByValidity(findItemsInSphere())
end end
--Activated once per second, counts items in bowls --Activated once per second, counts items in bowls
function countItems() function countItems()
local totalValue = -1 local totalValue = -1
local countableItems = findValidItemsInSphere() local countableItems = findValidItemsInSphere()
for ind, entry in ipairs(countableItems) do for ind, entry in ipairs(countableItems) do
local descValue = tonumber(entry.hit_object.getDescription()) local descValue = tonumber(entry.hit_object.getDescription())
local stackMult = math.abs(entry.hit_object.getQuantity()) local stackMult = math.abs(entry.hit_object.getQuantity())
--Use value in description if available --Use value in description if available
if descValue ~= nil then if descValue ~= nil then
totalValue = totalValue + descValue * stackMult totalValue = totalValue + descValue * stackMult
else else
--Otherwise use the value in validCountItemList --Otherwise use the value in validCountItemList
totalValue = totalValue + validCountItemList[entry.hit_object.getName()] * stackMult totalValue = totalValue + validCountItemList[entry.hit_object.getName()] * stackMult
end end
end end
exposedValue = totalValue exposedValue = totalValue
--Updates the number display --Updates the number display
self.editButton({index=0, label=totalValue}) self.editButton({index=0, label=totalValue})
end end
function filterByValidity(items) function filterByValidity(items)
retval = {} retval = {}
for _, entry in ipairs(items) do for _, entry in ipairs(items) do
--Ignore the bowl --Ignore the bowl
if entry.hit_object ~= self then if entry.hit_object ~= self then
--Ignore if not in validCountItemList --Ignore if not in validCountItemList
local tableEntry = validCountItemList[entry.hit_object.getName()] local tableEntry = validCountItemList[entry.hit_object.getName()]
if tableEntry ~= nil then if tableEntry ~= nil then
table.insert(retval, entry) table.insert(retval, entry)
end end
end end
end end
return retval return retval
end end
--Gets the items in the bowl for countItems to count --Gets the items in the bowl for countItems to count
function findItemsInSphere() function findItemsInSphere()
--Find scaling factor --Find scaling factor
local scale = self.getScale() local scale = self.getScale()
--Set position for the sphere --Set position for the sphere
local pos = self.getPosition() local pos = self.getPosition()
pos.y=pos.y+(1.25*scale.y) pos.y=pos.y+(1.25*scale.y)
--Ray trace to get all objects --Ray trace to get all objects
return Physics.cast({ return Physics.cast({
origin=pos, direction={0,1,0}, type=2, max_distance=0, origin=pos, direction={0,1,0}, type=2, max_distance=0,
size={6*scale.x,6*scale.y,6*scale.z}, --debug=true size={6*scale.x,6*scale.y,6*scale.z}, --debug=true
}) })
end end
function removeAllClues() function removeAllClues()
startLuaCoroutine(self, "clueRemovalCoroutine") startLuaCoroutine(self, "clueRemovalCoroutine")
end end
function clueRemovalCoroutine() function clueRemovalCoroutine()
for _, entry in ipairs(findValidItemsInSphere()) do for _, entry in ipairs(findValidItemsInSphere()) do
-- Do not put the table in the garbage -- Do not put the table in the garbage
if entry.hit_object.getGUID() ~= "4ee1f2" then if entry.hit_object.getGUID() ~= "4ee1f2" then
--delay for animation purposes --delay for animation purposes
for k=1,10 do for k=1,10 do
coroutine.yield(0) coroutine.yield(0)
end end
trashCan.putObject(entry.hit_object) trashCan.putObject(entry.hit_object)
end end
end end
--coroutines must return a value --coroutines must return a value
return 1 return 1
end end
function onDestroy() function onDestroy()
Timer.destroy(timerID) Timer.destroy(timerID)
end end

View File

@ -1,37 +1,37 @@
-- set true to enable debug logging -- set true to enable debug logging
DEBUG = false DEBUG = false
function log(message) function log(message)
if DEBUG then if DEBUG then
print(message) print(message)
end end
end end
--[[ --[[
Known locations and clues. We check this to determine if we should Known locations and clues. We check this to determine if we should
atttempt to spawn clues, first we look for <LOCATION_NAME>_<GUID> and if atttempt to spawn clues, first we look for <LOCATION_NAME>_<GUID> and if
we find nothing we look for <LOCATION_NAME> we find nothing we look for <LOCATION_NAME>
format is [location_guid -> clueCount] format is [location_guid -> clueCount]
]] ]]
LOCATIONS_DATA_JSON = [[ LOCATIONS_DATA_JSON = [[
{ {
"San Francisco": {"type": "fixed", "value": 1, "clueSide": "back"}, "San Francisco": {"type": "fixed", "value": 1, "clueSide": "back"},
" Arkham": {"type": "perPlayer", "value": 1, "clueSide": "back"}, " Arkham": {"type": "perPlayer", "value": 1, "clueSide": "back"},
"Buenos Aires": {"type": "fixed", "value": 2, "clueSide": "back"}, "Buenos Aires": {"type": "fixed", "value": 2, "clueSide": "back"},
" London": {"type": "perPlayer", "value": 2, "clueSide": "front"}, " London": {"type": "perPlayer", "value": 2, "clueSide": "front"},
"Rome": {"type": "perPlayer", "value": 3, "clueSide": "front"}, "Rome": {"type": "perPlayer", "value": 3, "clueSide": "front"},
"Istanbul": {"type": "perPlayer", "value": 4, "clueSide": "front"}, "Istanbul": {"type": "perPlayer", "value": 4, "clueSide": "front"},
"Tokyo_123abc": {"type": "perPlayer", "value": 0, "clueSide": "back"}, "Tokyo_123abc": {"type": "perPlayer", "value": 0, "clueSide": "back"},
"Tokyo_456efg": {"type": "perPlayer", "value": 4, "clueSide": "back"}, "Tokyo_456efg": {"type": "perPlayer", "value": 4, "clueSide": "back"},
"Tokyo": {"type": "fixed", "value": 2, "clueSide": "back"}, "Tokyo": {"type": "fixed", "value": 2, "clueSide": "back"},
"Shanghai_123": {"type": "fixed", "value": 12, "clueSide": "front"}, "Shanghai_123": {"type": "fixed", "value": 12, "clueSide": "front"},
"Sydney": {"type": "fixed", "value": 0, "clueSide": "front"} "Sydney": {"type": "fixed", "value": 0, "clueSide": "front"}
} }
]] ]]
LOCATIONS_DATA = JSON.decode(LOCATIONS_DATA_JSON) LOCATIONS_DATA = JSON.decode(LOCATIONS_DATA_JSON)
function onload(save_state) function onload(save_state)
local playArea = getObjectFromGUID('721ba2') local playArea = getObjectFromGUID('721ba2')
playArea.call("updateLocations", {self.getGUID()}) playArea.call("updateLocations", {self.getGUID()})
end end

File diff suppressed because it is too large Load Diff

View File

@ -1,273 +1,273 @@
function updateSave() function updateSave()
local data_to_save = {["ml"]=memoryList} local data_to_save = {["ml"]=memoryList}
saved_data = JSON.encode(data_to_save) saved_data = JSON.encode(data_to_save)
self.script_state = saved_data self.script_state = saved_data
end end
function onload(saved_data) function onload(saved_data)
if saved_data ~= "" then if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
--Set up information off of loaded_data --Set up information off of loaded_data
memoryList = loaded_data.ml memoryList = loaded_data.ml
else else
--Set up information for if there is no saved saved data --Set up information for if there is no saved saved data
memoryList = {} memoryList = {}
end end
if next(memoryList) == nil then if next(memoryList) == nil then
createSetupButton() createSetupButton()
else else
createMemoryActionButtons() createMemoryActionButtons()
end end
end end
--Beginning Setup --Beginning Setup
--Make setup button --Make setup button
function createSetupButton() function createSetupButton()
self.createButton({ self.createButton({
label="Setup", click_function="buttonClick_setup", function_owner=self, label="Setup", click_function="buttonClick_setup", function_owner=self,
position={0,0.3,-2}, rotation={0,180,0}, height=350, width=800, position={0,0.3,-2}, rotation={0,180,0}, height=350, width=800,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
end end
--Triggered by setup button, --Triggered by setup button,
function buttonClick_setup() function buttonClick_setup()
memoryListBackup = duplicateTable(memoryList) memoryListBackup = duplicateTable(memoryList)
memoryList = {} memoryList = {}
self.clearButtons() self.clearButtons()
createButtonsOnAllObjects() createButtonsOnAllObjects()
createSetupActionButtons() createSetupActionButtons()
end end
--Creates selection buttons on objects --Creates selection buttons on objects
function createButtonsOnAllObjects() function createButtonsOnAllObjects()
local howManyButtons = 0 local howManyButtons = 0
for _, obj in ipairs(getAllObjects()) do for _, obj in ipairs(getAllObjects()) do
if obj ~= self then if obj ~= self then
local dummyIndex = howManyButtons local dummyIndex = howManyButtons
--On a normal bag, the button positions aren't the same size as the bag. --On a normal bag, the button positions aren't the same size as the bag.
globalScaleFactor = 1.25 * 1/self.getScale().x globalScaleFactor = 1.25 * 1/self.getScale().x
--Super sweet math to set button positions --Super sweet math to set button positions
local selfPos = self.getPosition() local selfPos = self.getPosition()
local objPos = obj.getPosition() local objPos = obj.getPosition()
local deltaPos = findOffsetDistance(selfPos, objPos, obj) local deltaPos = findOffsetDistance(selfPos, objPos, obj)
local objPos = rotateLocalCoordinates(deltaPos, self) local objPos = rotateLocalCoordinates(deltaPos, self)
objPos.x = -objPos.x * globalScaleFactor objPos.x = -objPos.x * globalScaleFactor
objPos.y = objPos.y * globalScaleFactor objPos.y = objPos.y * globalScaleFactor
objPos.z = objPos.z * globalScaleFactor objPos.z = objPos.z * globalScaleFactor
--Offset rotation of bag --Offset rotation of bag
local rot = self.getRotation() local rot = self.getRotation()
rot.y = -rot.y + 180 rot.y = -rot.y + 180
--Create function --Create function
local funcName = "selectButton_" .. howManyButtons local funcName = "selectButton_" .. howManyButtons
local func = function() buttonClick_selection(dummyIndex, obj) end local func = function() buttonClick_selection(dummyIndex, obj) end
self.setVar(funcName, func) self.setVar(funcName, func)
self.createButton({ self.createButton({
click_function=funcName, function_owner=self, click_function=funcName, function_owner=self,
position=objPos, rotation=rot, height=1000, width=1000, position=objPos, rotation=rot, height=1000, width=1000,
color={0.75,0.25,0.25,0.6}, color={0.75,0.25,0.25,0.6},
}) })
howManyButtons = howManyButtons + 1 howManyButtons = howManyButtons + 1
end end
end end
end end
--Creates submit and cancel buttons --Creates submit and cancel buttons
function createSetupActionButtons() function createSetupActionButtons()
self.createButton({ self.createButton({
label="Cancel", click_function="buttonClick_cancel", function_owner=self, label="Cancel", click_function="buttonClick_cancel", function_owner=self,
position={0,0.3,-2}, rotation={0,180,0}, height=350, width=1100, position={0,0.3,-2}, rotation={0,180,0}, height=350, width=1100,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
self.createButton({ self.createButton({
label="Submit", click_function="buttonClick_submit", function_owner=self, label="Submit", click_function="buttonClick_submit", function_owner=self,
position={0,0.3,-2.8}, rotation={0,180,0}, height=350, width=1100, position={0,0.3,-2.8}, rotation={0,180,0}, height=350, width=1100,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
self.createButton({ self.createButton({
label="Reset", click_function="buttonClick_reset", function_owner=self, label="Reset", click_function="buttonClick_reset", function_owner=self,
position={-2,0.3,0}, rotation={0,270,0}, height=350, width=800, position={-2,0.3,0}, rotation={0,270,0}, height=350, width=800,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
end end
--During Setup --During Setup
--Checks or unchecks buttons --Checks or unchecks buttons
function buttonClick_selection(index, obj) function buttonClick_selection(index, obj)
local color = {0,1,0,0.6} local color = {0,1,0,0.6}
if memoryList[obj.getGUID()] == nil then if memoryList[obj.getGUID()] == nil then
self.editButton({index=index, color=color}) self.editButton({index=index, color=color})
--Adding pos/rot to memory table --Adding pos/rot to memory table
local pos, rot = obj.getPosition(), obj.getRotation() local pos, rot = obj.getPosition(), obj.getRotation()
--I need to add it like this or it won't save due to indexing issue --I need to add it like this or it won't save due to indexing issue
memoryList[obj.getGUID()] = { memoryList[obj.getGUID()] = {
pos={x=round(pos.x,4), y=round(pos.y,4), z=round(pos.z,4)}, pos={x=round(pos.x,4), y=round(pos.y,4), z=round(pos.z,4)},
rot={x=round(rot.x,4), y=round(rot.y,4), z=round(rot.z,4)}, rot={x=round(rot.x,4), y=round(rot.y,4), z=round(rot.z,4)},
lock=obj.getLock() lock=obj.getLock()
} }
obj.highlightOn({0,1,0}) obj.highlightOn({0,1,0})
else else
color = {0.75,0.25,0.25,0.6} color = {0.75,0.25,0.25,0.6}
self.editButton({index=index, color=color}) self.editButton({index=index, color=color})
memoryList[obj.getGUID()] = nil memoryList[obj.getGUID()] = nil
obj.highlightOff() obj.highlightOff()
end end
end end
--Cancels selection process --Cancels selection process
function buttonClick_cancel() function buttonClick_cancel()
memoryList = memoryListBackup memoryList = memoryListBackup
self.clearButtons() self.clearButtons()
if next(memoryList) == nil then if next(memoryList) == nil then
createSetupButton() createSetupButton()
else else
createMemoryActionButtons() createMemoryActionButtons()
end end
removeAllHighlights() removeAllHighlights()
broadcastToAll("Selection Canceled", {1,1,1}) broadcastToAll("Selection Canceled", {1,1,1})
end end
--Saves selections --Saves selections
function buttonClick_submit() function buttonClick_submit()
if next(memoryList) == nil then if next(memoryList) == nil then
broadcastToAll("You cannot submit without any selections.", {0.75, 0.25, 0.25}) broadcastToAll("You cannot submit without any selections.", {0.75, 0.25, 0.25})
else else
self.clearButtons() self.clearButtons()
createMemoryActionButtons() createMemoryActionButtons()
local count = 0 local count = 0
for guid in pairs(memoryList) do for guid in pairs(memoryList) do
count = count + 1 count = count + 1
local obj = getObjectFromGUID(guid) local obj = getObjectFromGUID(guid)
if obj ~= nil then obj.highlightOff() end if obj ~= nil then obj.highlightOff() end
end end
broadcastToAll(count.." Objects Saved", {1,1,1}) broadcastToAll(count.." Objects Saved", {1,1,1})
updateSave() updateSave()
end end
end end
--Resets bag to starting status --Resets bag to starting status
function buttonClick_reset() function buttonClick_reset()
memoryList = {} memoryList = {}
self.clearButtons() self.clearButtons()
createSetupButton() createSetupButton()
removeAllHighlights() removeAllHighlights()
broadcastToAll("Tool Reset", {1,1,1}) broadcastToAll("Tool Reset", {1,1,1})
updateSave() updateSave()
end end
--After Setup --After Setup
--Creates recall and place buttons --Creates recall and place buttons
function createMemoryActionButtons() function createMemoryActionButtons()
self.createButton({ self.createButton({
label="Place", click_function="buttonClick_place", function_owner=self, label="Place", click_function="buttonClick_place", function_owner=self,
position={0,0.3,-2}, rotation={0,180,0}, height=350, width=800, position={0,0.3,-2}, rotation={0,180,0}, height=350, width=800,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
self.createButton({ self.createButton({
label="Recall", click_function="buttonClick_recall", function_owner=self, label="Recall", click_function="buttonClick_recall", function_owner=self,
position={0,0.3,-2.8}, rotation={0,180,0}, height=350, width=800, position={0,0.3,-2.8}, rotation={0,180,0}, height=350, width=800,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
self.createButton({ self.createButton({
label="Setup", click_function="buttonClick_setup", function_owner=self, label="Setup", click_function="buttonClick_setup", function_owner=self,
position={-2,0.3,0}, rotation={0,270,0}, height=350, width=800, position={-2,0.3,0}, rotation={0,270,0}, height=350, width=800,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
end end
--Sends objects from bag/table to their saved position/rotation --Sends objects from bag/table to their saved position/rotation
function buttonClick_place() function buttonClick_place()
local bagObjList = self.getObjects() local bagObjList = self.getObjects()
for guid, entry in pairs(memoryList) do for guid, entry in pairs(memoryList) do
local obj = getObjectFromGUID(guid) local obj = getObjectFromGUID(guid)
--If obj is out on the table, move it to the saved pos/rot --If obj is out on the table, move it to the saved pos/rot
if obj ~= nil then if obj ~= nil then
obj.setPositionSmooth(entry.pos) obj.setPositionSmooth(entry.pos)
obj.setRotationSmooth(entry.rot) obj.setRotationSmooth(entry.rot)
obj.setLock(entry.lock) obj.setLock(entry.lock)
else else
--If obj is inside of the bag --If obj is inside of the bag
for _, bagObj in ipairs(bagObjList) do for _, bagObj in ipairs(bagObjList) do
if bagObj.guid == guid then if bagObj.guid == guid then
local item = self.takeObject({ local item = self.takeObject({
guid=guid, position=entry.pos, rotation=entry.rot, guid=guid, position=entry.pos, rotation=entry.rot,
}) })
item.setLock(entry.lock) item.setLock(entry.lock)
break break
end end
end end
end end
end end
broadcastToAll("Objects Placed", {1,1,1}) broadcastToAll("Objects Placed", {1,1,1})
end end
--Recalls objects to bag from table --Recalls objects to bag from table
function buttonClick_recall() function buttonClick_recall()
for guid, entry in pairs(memoryList) do for guid, entry in pairs(memoryList) do
local obj = getObjectFromGUID(guid) local obj = getObjectFromGUID(guid)
if obj ~= nil then self.putObject(obj) end if obj ~= nil then self.putObject(obj) end
end end
broadcastToAll("Objects Recalled", {1,1,1}) broadcastToAll("Objects Recalled", {1,1,1})
end end
--Utility functions --Utility functions
--Find delta (difference) between 2 x/y/z coordinates --Find delta (difference) between 2 x/y/z coordinates
function findOffsetDistance(p1, p2, obj) function findOffsetDistance(p1, p2, obj)
local deltaPos = {} local deltaPos = {}
local bounds = obj.getBounds() local bounds = obj.getBounds()
deltaPos.x = (p2.x-p1.x) deltaPos.x = (p2.x-p1.x)
deltaPos.y = (p2.y-p1.y) + (bounds.size.y - bounds.offset.y) deltaPos.y = (p2.y-p1.y) + (bounds.size.y - bounds.offset.y)
deltaPos.z = (p2.z-p1.z) deltaPos.z = (p2.z-p1.z)
return deltaPos return deltaPos
end end
--Used to rotate a set of coordinates by an angle --Used to rotate a set of coordinates by an angle
function rotateLocalCoordinates(desiredPos, obj) function rotateLocalCoordinates(desiredPos, obj)
local objPos, objRot = obj.getPosition(), obj.getRotation() local objPos, objRot = obj.getPosition(), obj.getRotation()
local angle = math.rad(objRot.y) local angle = math.rad(objRot.y)
local x = desiredPos.x * math.cos(angle) - desiredPos.z * math.sin(angle) local x = desiredPos.x * math.cos(angle) - desiredPos.z * math.sin(angle)
local z = desiredPos.x * math.sin(angle) + desiredPos.z * math.cos(angle) local z = desiredPos.x * math.sin(angle) + desiredPos.z * math.cos(angle)
--return {x=objPos.x+x, y=objPos.y+desiredPos.y, z=objPos.z+z} --return {x=objPos.x+x, y=objPos.y+desiredPos.y, z=objPos.z+z}
return {x=x, y=desiredPos.y, z=z} return {x=x, y=desiredPos.y, z=z}
end end
--Coroutine delay, in seconds --Coroutine delay, in seconds
function wait(time) function wait(time)
local start = os.time() local start = os.time()
repeat coroutine.yield(0) until os.time() > start + time repeat coroutine.yield(0) until os.time() > start + time
end end
--Duplicates a table (needed to prevent it making reference to the same objects) --Duplicates a table (needed to prevent it making reference to the same objects)
function duplicateTable(oldTable) function duplicateTable(oldTable)
local newTable = {} local newTable = {}
for k, v in pairs(oldTable) do for k, v in pairs(oldTable) do
newTable[k] = v newTable[k] = v
end end
return newTable return newTable
end end
--Moves scripted highlight from all objects --Moves scripted highlight from all objects
function removeAllHighlights() function removeAllHighlights()
for _, obj in ipairs(getAllObjects()) do for _, obj in ipairs(getAllObjects()) do
obj.highlightOff() obj.highlightOff()
end end
end end
--Round number (num) to the Nth decimal (dec) --Round number (num) to the Nth decimal (dec)
function round(num, dec) function round(num, dec)
local mult = 10^(dec or 0) local mult = 10^(dec or 0)
return math.floor(num * mult + 0.5) / mult return math.floor(num * mult + 0.5) / mult
end end

View File

@ -1,29 +1,29 @@
function onload() function onload()
b_display = { index = 0, b_display = { index = 0,
click_function = 'updateDisplay', click_function = 'updateDisplay',
label = self.getName(), label = self.getName(),
function_owner = self, function_owner = self,
position = {0, 1.4, 0}, position = {0, 1.4, 0},
rotation = {0, 270, 0}, rotation = {0, 270, 0},
width = 500, width = 500,
height = 200, height = 200,
font_size = 200} font_size = 200}
local description = string.match(self.getDescription(), '%d+') local description = string.match(self.getDescription(), '%d+')
if description != '' and type(tonumber(description)) == 'number' then if description != '' and type(tonumber(description)) == 'number' then
b_display.font_size = tonumber(description) b_display.font_size = tonumber(description)
end end
self.createButton(b_display) self.createButton(b_display)
end end
function updateDisplay() function updateDisplay()
b_display.label = self.getName() b_display.label = self.getName()
local description = string.match(self.getDescription(), '%d+') local description = string.match(self.getDescription(), '%d+')
if description != '' and type(tonumber(description)) == 'number' then if description != '' and type(tonumber(description)) == 'number' then
b_display.font_size = tonumber(description) b_display.font_size = tonumber(description)
end end
self.editButton(b_display) self.editButton(b_display)
end end

View File

@ -1,29 +1,29 @@
function onload() function onload()
b_display = { index = 0, b_display = { index = 0,
click_function = 'updateDisplay', click_function = 'updateDisplay',
label = self.getName(), label = self.getName(),
function_owner = self, function_owner = self,
position = {0, 1.4, 0}, position = {0, 1.4, 0},
rotation = {0, 270, 0}, rotation = {0, 270, 0},
width = 500, width = 500,
height = 200, height = 200,
font_size = 200} font_size = 200}
local description = string.match(self.getDescription(), '%d+') local description = string.match(self.getDescription(), '%d+')
if description != '' and type(tonumber(description)) == 'number' then if description != '' and type(tonumber(description)) == 'number' then
b_display.font_size = tonumber(description) b_display.font_size = tonumber(description)
end end
self.createButton(b_display) self.createButton(b_display)
end end
function updateDisplay() function updateDisplay()
b_display.label = self.getName() b_display.label = self.getName()
local description = string.match(self.getDescription(), '%d+') local description = string.match(self.getDescription(), '%d+')
if description != '' and type(tonumber(description)) == 'number' then if description != '' and type(tonumber(description)) == 'number' then
b_display.font_size = tonumber(description) b_display.font_size = tonumber(description)
end end
self.editButton(b_display) self.editButton(b_display)
end end

View File

@ -1,29 +1,29 @@
function onload() function onload()
b_display = { index = 0, b_display = { index = 0,
click_function = 'updateDisplay', click_function = 'updateDisplay',
label = self.getName(), label = self.getName(),
function_owner = self, function_owner = self,
position = {0, 1.4, 0}, position = {0, 1.4, 0},
rotation = {0, 270, 0}, rotation = {0, 270, 0},
width = 500, width = 500,
height = 200, height = 200,
font_size = 200} font_size = 200}
local description = string.match(self.getDescription(), '%d+') local description = string.match(self.getDescription(), '%d+')
if description != '' and type(tonumber(description)) == 'number' then if description != '' and type(tonumber(description)) == 'number' then
b_display.font_size = tonumber(description) b_display.font_size = tonumber(description)
end end
self.createButton(b_display) self.createButton(b_display)
end end
function updateDisplay() function updateDisplay()
b_display.label = self.getName() b_display.label = self.getName()
local description = string.match(self.getDescription(), '%d+') local description = string.match(self.getDescription(), '%d+')
if description != '' and type(tonumber(description)) == 'number' then if description != '' and type(tonumber(description)) == 'number' then
b_display.font_size = tonumber(description) b_display.font_size = tonumber(description)
end end
self.editButton(b_display) self.editButton(b_display)
end end

View File

@ -1,29 +1,29 @@
function onload() function onload()
b_display = { index = 0, b_display = { index = 0,
click_function = 'updateDisplay', click_function = 'updateDisplay',
label = self.getName(), label = self.getName(),
function_owner = self, function_owner = self,
position = {0, 1.4, 0}, position = {0, 1.4, 0},
rotation = {0, 270, 0}, rotation = {0, 270, 0},
width = 500, width = 500,
height = 200, height = 200,
font_size = 200} font_size = 200}
local description = string.match(self.getDescription(), '%d+') local description = string.match(self.getDescription(), '%d+')
if description != '' and type(tonumber(description)) == 'number' then if description != '' and type(tonumber(description)) == 'number' then
b_display.font_size = tonumber(description) b_display.font_size = tonumber(description)
end end
self.createButton(b_display) self.createButton(b_display)
end end
function updateDisplay() function updateDisplay()
b_display.label = self.getName() b_display.label = self.getName()
local description = string.match(self.getDescription(), '%d+') local description = string.match(self.getDescription(), '%d+')
if description != '' and type(tonumber(description)) == 'number' then if description != '' and type(tonumber(description)) == 'number' then
b_display.font_size = tonumber(description) b_display.font_size = tonumber(description)
end end
self.editButton(b_display) self.editButton(b_display)
end end

View File

@ -1,29 +1,29 @@
function onload() function onload()
b_display = { index = 0, b_display = { index = 0,
click_function = 'updateDisplay', click_function = 'updateDisplay',
label = self.getName(), label = self.getName(),
function_owner = self, function_owner = self,
position = {0, 1.4, 0}, position = {0, 1.4, 0},
rotation = {0, 270, 0}, rotation = {0, 270, 0},
width = 500, width = 500,
height = 200, height = 200,
font_size = 200} font_size = 200}
local description = string.match(self.getDescription(), '%d+') local description = string.match(self.getDescription(), '%d+')
if description != '' and type(tonumber(description)) == 'number' then if description != '' and type(tonumber(description)) == 'number' then
b_display.font_size = tonumber(description) b_display.font_size = tonumber(description)
end end
self.createButton(b_display) self.createButton(b_display)
end end
function updateDisplay() function updateDisplay()
b_display.label = self.getName() b_display.label = self.getName()
local description = string.match(self.getDescription(), '%d+') local description = string.match(self.getDescription(), '%d+')
if description != '' and type(tonumber(description)) == 'number' then if description != '' and type(tonumber(description)) == 'number' then
b_display.font_size = tonumber(description) b_display.font_size = tonumber(description)
end end
self.editButton(b_display) self.editButton(b_display)
end end

View File

@ -1,5 +1,5 @@
function onCollisionEnter(collision_info) function onCollisionEnter(collision_info)
self.shuffle() self.shuffle()
self.shuffle() self.shuffle()
self.shuffle() self.shuffle()
end end

View File

@ -1,273 +1,273 @@
function updateSave() function updateSave()
local data_to_save = {["ml"]=memoryList} local data_to_save = {["ml"]=memoryList}
saved_data = JSON.encode(data_to_save) saved_data = JSON.encode(data_to_save)
self.script_state = saved_data self.script_state = saved_data
end end
function onload(saved_data) function onload(saved_data)
if saved_data ~= "" then if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
--Set up information off of loaded_data --Set up information off of loaded_data
memoryList = loaded_data.ml memoryList = loaded_data.ml
else else
--Set up information for if there is no saved saved data --Set up information for if there is no saved saved data
memoryList = {} memoryList = {}
end end
if next(memoryList) == nil then if next(memoryList) == nil then
createSetupButton() createSetupButton()
else else
createMemoryActionButtons() createMemoryActionButtons()
end end
end end
--Beginning Setup --Beginning Setup
--Make setup button --Make setup button
function createSetupButton() function createSetupButton()
self.createButton({ self.createButton({
label="Setup", click_function="buttonClick_setup", function_owner=self, label="Setup", click_function="buttonClick_setup", function_owner=self,
position={0,5,-2}, rotation={0,0,0}, height=250, width=600, position={0,5,-2}, rotation={0,0,0}, height=250, width=600,
font_size=150, color={0,0,0}, font_color={1,1,1} font_size=150, color={0,0,0}, font_color={1,1,1}
}) })
end end
--Triggered by setup button, --Triggered by setup button,
function buttonClick_setup() function buttonClick_setup()
memoryListBackup = duplicateTable(memoryList) memoryListBackup = duplicateTable(memoryList)
memoryList = {} memoryList = {}
self.clearButtons() self.clearButtons()
createButtonsOnAllObjects() createButtonsOnAllObjects()
createSetupActionButtons() createSetupActionButtons()
end end
--Creates selection buttons on objects --Creates selection buttons on objects
function createButtonsOnAllObjects() function createButtonsOnAllObjects()
local howManyButtons = 0 local howManyButtons = 0
for _, obj in ipairs(getAllObjects()) do for _, obj in ipairs(getAllObjects()) do
if obj ~= self then if obj ~= self then
local dummyIndex = howManyButtons local dummyIndex = howManyButtons
--On a normal bag, the button positions aren't the same size as the bag. --On a normal bag, the button positions aren't the same size as the bag.
globalScaleFactor = 1.25 * 1/self.getScale().x globalScaleFactor = 1.25 * 1/self.getScale().x
--Super sweet math to set button positions --Super sweet math to set button positions
local selfPos = self.getPosition() local selfPos = self.getPosition()
local objPos = obj.getPosition() local objPos = obj.getPosition()
local deltaPos = findOffsetDistance(selfPos, objPos, obj) local deltaPos = findOffsetDistance(selfPos, objPos, obj)
local objPos = rotateLocalCoordinates(deltaPos, self) local objPos = rotateLocalCoordinates(deltaPos, self)
objPos.x = -objPos.x * globalScaleFactor objPos.x = -objPos.x * globalScaleFactor
objPos.y = objPos.y * globalScaleFactor objPos.y = objPos.y * globalScaleFactor
objPos.z = objPos.z * 4 objPos.z = objPos.z * 4
--Offset rotation of bag --Offset rotation of bag
local rot = self.getRotation() local rot = self.getRotation()
rot.y = -rot.y + 180 rot.y = -rot.y + 180
--Create function --Create function
local funcName = "selectButton_" .. howManyButtons local funcName = "selectButton_" .. howManyButtons
local func = function() buttonClick_selection(dummyIndex, obj) end local func = function() buttonClick_selection(dummyIndex, obj) end
self.setVar(funcName, func) self.setVar(funcName, func)
self.createButton({ self.createButton({
click_function=funcName, function_owner=self, click_function=funcName, function_owner=self,
position=objPos, rotation=rot, height=1000, width=1000, position=objPos, rotation=rot, height=1000, width=1000,
color={0.75,0.25,0.25,0.6}, color={0.75,0.25,0.25,0.6},
}) })
howManyButtons = howManyButtons + 1 howManyButtons = howManyButtons + 1
end end
end end
end end
--Creates submit and cancel buttons --Creates submit and cancel buttons
function createSetupActionButtons() function createSetupActionButtons()
self.createButton({ self.createButton({
label="Cancel", click_function="buttonClick_cancel", function_owner=self, label="Cancel", click_function="buttonClick_cancel", function_owner=self,
position={1.5,5,2}, rotation={0,0,0}, height=350, width=1100, position={1.5,5,2}, rotation={0,0,0}, height=350, width=1100,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
self.createButton({ self.createButton({
label="Submit", click_function="buttonClick_submit", function_owner=self, label="Submit", click_function="buttonClick_submit", function_owner=self,
position={-1.2,5,2}, rotation={0,0,0}, height=350, width=1100, position={-1.2,5,2}, rotation={0,0,0}, height=350, width=1100,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
self.createButton({ self.createButton({
label="Reset", click_function="buttonClick_reset", function_owner=self, label="Reset", click_function="buttonClick_reset", function_owner=self,
position={-3.5,5,2}, rotation={0,0,0}, height=350, width=800, position={-3.5,5,2}, rotation={0,0,0}, height=350, width=800,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
end end
--During Setup --During Setup
--Checks or unchecks buttons --Checks or unchecks buttons
function buttonClick_selection(index, obj) function buttonClick_selection(index, obj)
local color = {0,1,0,0.6} local color = {0,1,0,0.6}
if memoryList[obj.getGUID()] == nil then if memoryList[obj.getGUID()] == nil then
self.editButton({index=index, color=color}) self.editButton({index=index, color=color})
--Adding pos/rot to memory table --Adding pos/rot to memory table
local pos, rot = obj.getPosition(), obj.getRotation() local pos, rot = obj.getPosition(), obj.getRotation()
--I need to add it like this or it won't save due to indexing issue --I need to add it like this or it won't save due to indexing issue
memoryList[obj.getGUID()] = { memoryList[obj.getGUID()] = {
pos={x=round(pos.x,4), y=round(pos.y,4), z=round(pos.z,4)}, pos={x=round(pos.x,4), y=round(pos.y,4), z=round(pos.z,4)},
rot={x=round(rot.x,4), y=round(rot.y,4), z=round(rot.z,4)}, rot={x=round(rot.x,4), y=round(rot.y,4), z=round(rot.z,4)},
lock=obj.getLock() lock=obj.getLock()
} }
obj.highlightOn({0,1,0}) obj.highlightOn({0,1,0})
else else
color = {0.75,0.25,0.25,0.6} color = {0.75,0.25,0.25,0.6}
self.editButton({index=index, color=color}) self.editButton({index=index, color=color})
memoryList[obj.getGUID()] = nil memoryList[obj.getGUID()] = nil
obj.highlightOff() obj.highlightOff()
end end
end end
--Cancels selection process --Cancels selection process
function buttonClick_cancel() function buttonClick_cancel()
memoryList = memoryListBackup memoryList = memoryListBackup
self.clearButtons() self.clearButtons()
if next(memoryList) == nil then if next(memoryList) == nil then
createSetupButton() createSetupButton()
else else
createMemoryActionButtons() createMemoryActionButtons()
end end
removeAllHighlights() removeAllHighlights()
broadcastToAll("Selection Canceled", {1,1,1}) broadcastToAll("Selection Canceled", {1,1,1})
end end
--Saves selections --Saves selections
function buttonClick_submit() function buttonClick_submit()
if next(memoryList) == nil then if next(memoryList) == nil then
broadcastToAll("You cannot submit without any selections.", {0.75, 0.25, 0.25}) broadcastToAll("You cannot submit without any selections.", {0.75, 0.25, 0.25})
else else
self.clearButtons() self.clearButtons()
createMemoryActionButtons() createMemoryActionButtons()
local count = 0 local count = 0
for guid in pairs(memoryList) do for guid in pairs(memoryList) do
count = count + 1 count = count + 1
local obj = getObjectFromGUID(guid) local obj = getObjectFromGUID(guid)
if obj ~= nil then obj.highlightOff() end if obj ~= nil then obj.highlightOff() end
end end
broadcastToAll(count.." Objects Saved", {1,1,1}) broadcastToAll(count.." Objects Saved", {1,1,1})
updateSave() updateSave()
end end
end end
--Resets bag to starting status --Resets bag to starting status
function buttonClick_reset() function buttonClick_reset()
memoryList = {} memoryList = {}
self.clearButtons() self.clearButtons()
createSetupButton() createSetupButton()
removeAllHighlights() removeAllHighlights()
broadcastToAll("Tool Reset", {1,1,1}) broadcastToAll("Tool Reset", {1,1,1})
updateSave() updateSave()
end end
--After Setup --After Setup
--Creates recall and place buttons --Creates recall and place buttons
function createMemoryActionButtons() function createMemoryActionButtons()
self.createButton({ self.createButton({
label="Clicker", click_function="buttonClick_place", function_owner=self, label="Clicker", click_function="buttonClick_place", function_owner=self,
position={4.2,1,0}, rotation={0,0,0}, height=500, width=1100, position={4.2,1,0}, rotation={0,0,0}, height=500, width=1100,
font_size=350, color={0,0,0}, font_color={1,1,1} font_size=350, color={0,0,0}, font_color={1,1,1}
}) })
self.createButton({ self.createButton({
label="Counter", click_function="buttonClick_recall", function_owner=self, label="Counter", click_function="buttonClick_recall", function_owner=self,
position={-4.2,1,-0.1}, rotation={0,0,0}, height=500, width=1300, position={-4.2,1,-0.1}, rotation={0,0,0}, height=500, width=1300,
font_size=350, color={0,0,0}, font_color={1,1,1} font_size=350, color={0,0,0}, font_color={1,1,1}
}) })
-- self.createButton({ -- self.createButton({
-- label="Setup", click_function="buttonClick_setup", function_owner=self, -- label="Setup", click_function="buttonClick_setup", function_owner=self,
-- position={-6,1,0}, rotation={0,90,0}, height=500, width=1200, -- position={-6,1,0}, rotation={0,90,0}, height=500, width=1200,
-- font_size=350, color={0,0,0}, font_color={1,1,1} -- font_size=350, color={0,0,0}, font_color={1,1,1}
-- }) -- })
end end
--Sends objects from bag/table to their saved position/rotation --Sends objects from bag/table to their saved position/rotation
function buttonClick_place() function buttonClick_place()
local bagObjList = self.getObjects() local bagObjList = self.getObjects()
for guid, entry in pairs(memoryList) do for guid, entry in pairs(memoryList) do
local obj = getObjectFromGUID(guid) local obj = getObjectFromGUID(guid)
--If obj is out on the table, move it to the saved pos/rot --If obj is out on the table, move it to the saved pos/rot
if obj ~= nil then if obj ~= nil then
obj.setPositionSmooth(entry.pos) obj.setPositionSmooth(entry.pos)
obj.setRotationSmooth(entry.rot) obj.setRotationSmooth(entry.rot)
obj.setLock(entry.lock) obj.setLock(entry.lock)
else else
--If obj is inside of the bag --If obj is inside of the bag
for _, bagObj in ipairs(bagObjList) do for _, bagObj in ipairs(bagObjList) do
if bagObj.guid == guid then if bagObj.guid == guid then
local item = self.takeObject({ local item = self.takeObject({
guid=guid, position=entry.pos, rotation=entry.rot, guid=guid, position=entry.pos, rotation=entry.rot,
}) })
item.setLock(entry.lock) item.setLock(entry.lock)
break break
end end
end end
end end
end end
broadcastToAll("Objects Placed", {1,1,1}) broadcastToAll("Objects Placed", {1,1,1})
end end
--Recalls objects to bag from table --Recalls objects to bag from table
function buttonClick_recall() function buttonClick_recall()
for guid, entry in pairs(memoryList) do for guid, entry in pairs(memoryList) do
local obj = getObjectFromGUID(guid) local obj = getObjectFromGUID(guid)
if obj ~= nil then self.putObject(obj) end if obj ~= nil then self.putObject(obj) end
end end
broadcastToAll("Objects Recalled", {1,1,1}) broadcastToAll("Objects Recalled", {1,1,1})
end end
--Utility functions --Utility functions
--Find delta (difference) between 2 x/y/z coordinates --Find delta (difference) between 2 x/y/z coordinates
function findOffsetDistance(p1, p2, obj) function findOffsetDistance(p1, p2, obj)
local deltaPos = {} local deltaPos = {}
local bounds = obj.getBounds() local bounds = obj.getBounds()
deltaPos.x = (p2.x-p1.x) deltaPos.x = (p2.x-p1.x)
deltaPos.y = (p2.y-p1.y) + (bounds.size.y - bounds.offset.y) deltaPos.y = (p2.y-p1.y) + (bounds.size.y - bounds.offset.y)
deltaPos.z = (p2.z-p1.z) deltaPos.z = (p2.z-p1.z)
return deltaPos return deltaPos
end end
--Used to rotate a set of coordinates by an angle --Used to rotate a set of coordinates by an angle
function rotateLocalCoordinates(desiredPos, obj) function rotateLocalCoordinates(desiredPos, obj)
local objPos, objRot = obj.getPosition(), obj.getRotation() local objPos, objRot = obj.getPosition(), obj.getRotation()
local angle = math.rad(objRot.y) local angle = math.rad(objRot.y)
local x = desiredPos.x * math.cos(angle) - desiredPos.z * math.sin(angle) local x = desiredPos.x * math.cos(angle) - desiredPos.z * math.sin(angle)
local z = desiredPos.x * math.sin(angle) + desiredPos.z * math.cos(angle) local z = desiredPos.x * math.sin(angle) + desiredPos.z * math.cos(angle)
--return {x=objPos.x+x, y=objPos.y+desiredPos.y, z=objPos.z+z} --return {x=objPos.x+x, y=objPos.y+desiredPos.y, z=objPos.z+z}
return {x=x, y=desiredPos.y, z=z} return {x=x, y=desiredPos.y, z=z}
end end
--Coroutine delay, in seconds --Coroutine delay, in seconds
function wait(time) function wait(time)
local start = os.time() local start = os.time()
repeat coroutine.yield(0) until os.time() > start + time repeat coroutine.yield(0) until os.time() > start + time
end end
--Duplicates a table (needed to prevent it making reference to the same objects) --Duplicates a table (needed to prevent it making reference to the same objects)
function duplicateTable(oldTable) function duplicateTable(oldTable)
local newTable = {} local newTable = {}
for k, v in pairs(oldTable) do for k, v in pairs(oldTable) do
newTable[k] = v newTable[k] = v
end end
return newTable return newTable
end end
--Moves scripted highlight from all objects --Moves scripted highlight from all objects
function removeAllHighlights() function removeAllHighlights()
for _, obj in ipairs(getAllObjects()) do for _, obj in ipairs(getAllObjects()) do
obj.highlightOff() obj.highlightOff()
end end
end end
--Round number (num) to the Nth decimal (dec) --Round number (num) to the Nth decimal (dec)
function round(num, dec) function round(num, dec)
local mult = 10^(dec or 0) local mult = 10^(dec or 0)
return math.floor(num * mult + 0.5) / mult return math.floor(num * mult + 0.5) / mult
end end

View File

@ -1,132 +1,132 @@
MIN_VALUE = -99 MIN_VALUE = -99
MAX_VALUE = 999 MAX_VALUE = 999
function onload(saved_data) function onload(saved_data)
light_mode = false light_mode = false
val = 0 val = 0
if saved_data ~= "" then if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1] light_mode = loaded_data[1]
val = loaded_data[2] val = loaded_data[2]
end end
createAll() createAll()
end end
function updateSave() function updateSave()
local data_to_save = {light_mode, val} local data_to_save = {light_mode, val}
saved_data = JSON.encode(data_to_save) saved_data = JSON.encode(data_to_save)
self.script_state = saved_data self.script_state = saved_data
end end
function createAll() function createAll()
s_color = {0.5, 0.5, 0.5, 95} s_color = {0.5, 0.5, 0.5, 95}
if light_mode then if light_mode then
f_color = {1,1,1,95} f_color = {1,1,1,95}
else else
f_color = {0,0,0,100} f_color = {0,0,0,100}
end end
self.createButton({ self.createButton({
label=tostring(val), label=tostring(val),
click_function="add_subtract", click_function="add_subtract",
function_owner=self, function_owner=self,
position={0,0.05,0}, position={0,0.05,0},
height=600, height=600,
width=1000, width=1000,
alignment = 3, alignment = 3,
scale={x=1.5, y=1.5, z=1.5}, scale={x=1.5, y=1.5, z=1.5},
font_size=600, font_size=600,
font_color=f_color, font_color=f_color,
color={0,0,0,0} color={0,0,0,0}
}) })
if light_mode then if light_mode then
lightButtonText = "[ Set dark ]" lightButtonText = "[ Set dark ]"
else else
lightButtonText = "[ Set light ]" lightButtonText = "[ Set light ]"
end end
end end
function removeAll() function removeAll()
self.removeInput(0) self.removeInput(0)
self.removeInput(1) self.removeInput(1)
self.removeButton(0) self.removeButton(0)
self.removeButton(1) self.removeButton(1)
self.removeButton(2) self.removeButton(2)
end end
function reloadAll() function reloadAll()
removeAll() removeAll()
createAll() createAll()
updateSave() updateSave()
end end
function swap_fcolor(_obj, _color, alt_click) function swap_fcolor(_obj, _color, alt_click)
light_mode = not light_mode light_mode = not light_mode
reloadAll() reloadAll()
end end
function swap_align(_obj, _color, alt_click) function swap_align(_obj, _color, alt_click)
center_mode = not center_mode center_mode = not center_mode
reloadAll() reloadAll()
end end
function editName(_obj, _string, value) function editName(_obj, _string, value)
self.setName(value) self.setName(value)
setTooltips() setTooltips()
end end
function add_subtract(_obj, _color, alt_click) function add_subtract(_obj, _color, alt_click)
mod = alt_click and -1 or 1 mod = alt_click and -1 or 1
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE) new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE)
if val ~= new_value then if val ~= new_value then
val = new_value val = new_value
updateVal() updateVal()
updateSave() updateSave()
end end
end end
function updateVal() function updateVal()
self.editButton({ self.editButton({
index = 0, index = 0,
label = tostring(val), label = tostring(val),
}) })
end end
function reset_val() function reset_val()
val = 0 val = 0
updateVal() updateVal()
updateSave() updateSave()
end end
function setTooltips() function setTooltips()
self.editInput({ self.editInput({
index = 0, index = 0,
value = self.getName(), value = self.getName(),
tooltip = ttText tooltip = ttText
}) })
self.editButton({ self.editButton({
index = 0, index = 0,
value = tostring(val), value = tostring(val),
tooltip = ttText tooltip = ttText
}) })
end end
function null() function null()
end end
function keepSample(_obj, _string, value) function keepSample(_obj, _string, value)
reloadAll() reloadAll()
end end

View File

@ -1,132 +1,132 @@
MIN_VALUE = -99 MIN_VALUE = -99
MAX_VALUE = 999 MAX_VALUE = 999
function onload(saved_data)
light_mode = true
val = 0
if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1]
val = loaded_data[2]
end
createAll()
end
function updateSave()
local data_to_save = {light_mode, val}
saved_data = JSON.encode(data_to_save)
self.script_state = saved_data
end
function createAll()
s_color = {0,0,0,100}
if light_mode then function onload(saved_data)
f_color = {1,1,1,100} light_mode = true
else val = 0
f_color = {0,0,0,100}
end if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1]
val = loaded_data[2]
self.createButton({ end
label=tostring(val),
click_function="add_subtract", createAll()
function_owner=self, end
position={0,0.05,0.1},
height=600, function updateSave()
width=1000, local data_to_save = {light_mode, val}
alignment = 3, saved_data = JSON.encode(data_to_save)
scale={x=1.5, y=1.5, z=1.5}, self.script_state = saved_data
font_size=600, end
font_color=f_color,
color={1,1,1,0} function createAll()
}) s_color = {0,0,0,100}
if light_mode then
f_color = {1,1,1,100}
else
if light_mode then f_color = {0,0,0,100}
lightButtonText = "[ Set dark ]" end
else
lightButtonText = "[ Set light ]"
end
self.createButton({
end label=tostring(val),
click_function="add_subtract",
function removeAll() function_owner=self,
self.removeInput(0) position={0,0.05,0.1},
self.removeInput(1) height=600,
self.removeButton(0) width=1000,
self.removeButton(1) alignment = 3,
self.removeButton(2) scale={x=1.5, y=1.5, z=1.5},
end font_size=600,
font_color=f_color,
function reloadAll() color={1,1,1,0}
removeAll() })
createAll()
updateSave()
end
if light_mode then
function swap_fcolor(_obj, _color, alt_click) lightButtonText = "[ Set dark ]"
light_mode = not light_mode else
reloadAll() lightButtonText = "[ Set light ]"
end end
function swap_align(_obj, _color, alt_click) end
center_mode = not center_mode
reloadAll() function removeAll()
end self.removeInput(0)
self.removeInput(1)
function editName(_obj, _string, value) self.removeButton(0)
self.setName(value) self.removeButton(1)
setTooltips() self.removeButton(2)
end end
function add_subtract(_obj, _color, alt_click) function reloadAll()
mod = alt_click and -1 or 1 removeAll()
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE) createAll()
if val ~= new_value then
val = new_value updateSave()
updateVal() end
updateSave()
end function swap_fcolor(_obj, _color, alt_click)
end light_mode = not light_mode
reloadAll()
function updateVal() end
self.editButton({ function swap_align(_obj, _color, alt_click)
index = 0, center_mode = not center_mode
label = tostring(val), reloadAll()
end
})
end function editName(_obj, _string, value)
self.setName(value)
function reset_val() setTooltips()
val = 0 end
updateVal()
updateSave() function add_subtract(_obj, _color, alt_click)
end mod = alt_click and -1 or 1
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE)
function setTooltips() if val ~= new_value then
self.editInput({ val = new_value
index = 0, updateVal()
value = self.getName(), updateSave()
tooltip = ttText end
}) end
self.editButton({
index = 0, function updateVal()
value = tostring(val),
tooltip = ttText self.editButton({
}) index = 0,
end label = tostring(val),
function null() })
end end
function keepSample(_obj, _string, value) function reset_val()
reloadAll() val = 0
updateVal()
updateSave()
end
function setTooltips()
self.editInput({
index = 0,
value = self.getName(),
tooltip = ttText
})
self.editButton({
index = 0,
value = tostring(val),
tooltip = ttText
})
end
function null()
end
function keepSample(_obj, _string, value)
reloadAll()
end end

View File

@ -1,132 +1,132 @@
MIN_VALUE = -99 MIN_VALUE = -99
MAX_VALUE = 999 MAX_VALUE = 999
function onload(saved_data)
light_mode = true
val = 0
if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1]
val = loaded_data[2]
end
createAll()
end
function updateSave()
local data_to_save = {light_mode, val}
saved_data = JSON.encode(data_to_save)
self.script_state = saved_data
end
function createAll()
s_color = {0,0,0,100}
if light_mode then function onload(saved_data)
f_color = {1,1,1,100} light_mode = true
else val = 0
f_color = {0,0,0,100}
end if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1]
val = loaded_data[2]
self.createButton({ end
label=tostring(val),
click_function="add_subtract", createAll()
function_owner=self, end
position={0,0.05,0.1},
height=600, function updateSave()
width=1000, local data_to_save = {light_mode, val}
alignment = 3, saved_data = JSON.encode(data_to_save)
scale={x=1.5, y=1.5, z=1.5}, self.script_state = saved_data
font_size=600, end
font_color=f_color,
color={1,1,1,0} function createAll()
}) s_color = {0,0,0,100}
if light_mode then
f_color = {1,1,1,100}
else
if light_mode then f_color = {0,0,0,100}
lightButtonText = "[ Set dark ]" end
else
lightButtonText = "[ Set light ]"
end
self.createButton({
end label=tostring(val),
click_function="add_subtract",
function removeAll() function_owner=self,
self.removeInput(0) position={0,0.05,0.1},
self.removeInput(1) height=600,
self.removeButton(0) width=1000,
self.removeButton(1) alignment = 3,
self.removeButton(2) scale={x=1.5, y=1.5, z=1.5},
end font_size=600,
font_color=f_color,
function reloadAll() color={1,1,1,0}
removeAll() })
createAll()
updateSave()
end
if light_mode then
function swap_fcolor(_obj, _color, alt_click) lightButtonText = "[ Set dark ]"
light_mode = not light_mode else
reloadAll() lightButtonText = "[ Set light ]"
end end
function swap_align(_obj, _color, alt_click) end
center_mode = not center_mode
reloadAll() function removeAll()
end self.removeInput(0)
self.removeInput(1)
function editName(_obj, _string, value) self.removeButton(0)
self.setName(value) self.removeButton(1)
setTooltips() self.removeButton(2)
end end
function add_subtract(_obj, _color, alt_click) function reloadAll()
mod = alt_click and -1 or 1 removeAll()
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE) createAll()
if val ~= new_value then
val = new_value updateSave()
updateVal() end
updateSave()
end function swap_fcolor(_obj, _color, alt_click)
end light_mode = not light_mode
reloadAll()
function updateVal() end
self.editButton({ function swap_align(_obj, _color, alt_click)
index = 0, center_mode = not center_mode
label = tostring(val), reloadAll()
end
})
end function editName(_obj, _string, value)
self.setName(value)
function reset_val() setTooltips()
val = 0 end
updateVal()
updateSave() function add_subtract(_obj, _color, alt_click)
end mod = alt_click and -1 or 1
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE)
function setTooltips() if val ~= new_value then
self.editInput({ val = new_value
index = 0, updateVal()
value = self.getName(), updateSave()
tooltip = ttText end
}) end
self.editButton({
index = 0, function updateVal()
value = tostring(val),
tooltip = ttText self.editButton({
}) index = 0,
end label = tostring(val),
function null() })
end end
function keepSample(_obj, _string, value) function reset_val()
reloadAll() val = 0
updateVal()
updateSave()
end
function setTooltips()
self.editInput({
index = 0,
value = self.getName(),
tooltip = ttText
})
self.editButton({
index = 0,
value = tostring(val),
tooltip = ttText
})
end
function null()
end
function keepSample(_obj, _string, value)
reloadAll()
end end

View File

@ -1,132 +1,132 @@
MIN_VALUE = -99 MIN_VALUE = -99
MAX_VALUE = 999 MAX_VALUE = 999
function onload(saved_data)
light_mode = true
val = 0
if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1]
val = loaded_data[2]
end
createAll()
end
function updateSave()
local data_to_save = {light_mode, val}
saved_data = JSON.encode(data_to_save)
self.script_state = saved_data
end
function createAll()
s_color = {0,0,0,100}
if light_mode then function onload(saved_data)
f_color = {1,1,1,100} light_mode = true
else val = 0
f_color = {0,0,0,100}
end if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1]
val = loaded_data[2]
self.createButton({ end
label=tostring(val),
click_function="add_subtract", createAll()
function_owner=self, end
position={0,0.05,0.1},
height=600, function updateSave()
width=1000, local data_to_save = {light_mode, val}
alignment = 3, saved_data = JSON.encode(data_to_save)
scale={x=1.5, y=1.5, z=1.5}, self.script_state = saved_data
font_size=600, end
font_color=f_color,
color={1,1,1,0} function createAll()
}) s_color = {0,0,0,100}
if light_mode then
f_color = {1,1,1,100}
else
if light_mode then f_color = {0,0,0,100}
lightButtonText = "[ Set dark ]" end
else
lightButtonText = "[ Set light ]"
end
self.createButton({
end label=tostring(val),
click_function="add_subtract",
function removeAll() function_owner=self,
self.removeInput(0) position={0,0.05,0.1},
self.removeInput(1) height=600,
self.removeButton(0) width=1000,
self.removeButton(1) alignment = 3,
self.removeButton(2) scale={x=1.5, y=1.5, z=1.5},
end font_size=600,
font_color=f_color,
function reloadAll() color={1,1,1,0}
removeAll() })
createAll()
updateSave()
end
if light_mode then
function swap_fcolor(_obj, _color, alt_click) lightButtonText = "[ Set dark ]"
light_mode = not light_mode else
reloadAll() lightButtonText = "[ Set light ]"
end end
function swap_align(_obj, _color, alt_click) end
center_mode = not center_mode
reloadAll() function removeAll()
end self.removeInput(0)
self.removeInput(1)
function editName(_obj, _string, value) self.removeButton(0)
self.setName(value) self.removeButton(1)
setTooltips() self.removeButton(2)
end end
function add_subtract(_obj, _color, alt_click) function reloadAll()
mod = alt_click and -1 or 1 removeAll()
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE) createAll()
if val ~= new_value then
val = new_value updateSave()
updateVal() end
updateSave()
end function swap_fcolor(_obj, _color, alt_click)
end light_mode = not light_mode
reloadAll()
function updateVal() end
self.editButton({ function swap_align(_obj, _color, alt_click)
index = 0, center_mode = not center_mode
label = tostring(val), reloadAll()
end
})
end function editName(_obj, _string, value)
self.setName(value)
function reset_val() setTooltips()
val = 0 end
updateVal()
updateSave() function add_subtract(_obj, _color, alt_click)
end mod = alt_click and -1 or 1
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE)
function setTooltips() if val ~= new_value then
self.editInput({ val = new_value
index = 0, updateVal()
value = self.getName(), updateSave()
tooltip = ttText end
}) end
self.editButton({
index = 0, function updateVal()
value = tostring(val),
tooltip = ttText self.editButton({
}) index = 0,
end label = tostring(val),
function null() })
end end
function keepSample(_obj, _string, value) function reset_val()
reloadAll() val = 0
updateVal()
updateSave()
end
function setTooltips()
self.editInput({
index = 0,
value = self.getName(),
tooltip = ttText
})
self.editButton({
index = 0,
value = tostring(val),
tooltip = ttText
})
end
function null()
end
function keepSample(_obj, _string, value)
reloadAll()
end end

View File

@ -1,132 +1,132 @@
MIN_VALUE = -99 MIN_VALUE = -99
MAX_VALUE = 999 MAX_VALUE = 999
function onload(saved_data)
light_mode = true
val = 0
if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1]
val = loaded_data[2]
end
createAll()
end
function updateSave()
local data_to_save = {light_mode, val}
saved_data = JSON.encode(data_to_save)
self.script_state = saved_data
end
function createAll()
s_color = {0,0,0,100}
if light_mode then function onload(saved_data)
f_color = {1,1,1,100} light_mode = true
else val = 0
f_color = {0,0,0,100}
end if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1]
val = loaded_data[2]
self.createButton({ end
label=tostring(val),
click_function="add_subtract", createAll()
function_owner=self, end
position={0,0.05,0.1},
height=600, function updateSave()
width=1000, local data_to_save = {light_mode, val}
alignment = 3, saved_data = JSON.encode(data_to_save)
scale={x=1.5, y=1.5, z=1.5}, self.script_state = saved_data
font_size=600, end
font_color=f_color,
color={1,1,1,0} function createAll()
}) s_color = {0,0,0,100}
if light_mode then
f_color = {1,1,1,100}
else
if light_mode then f_color = {0,0,0,100}
lightButtonText = "[ Set dark ]" end
else
lightButtonText = "[ Set light ]"
end
self.createButton({
end label=tostring(val),
click_function="add_subtract",
function removeAll() function_owner=self,
self.removeInput(0) position={0,0.05,0.1},
self.removeInput(1) height=600,
self.removeButton(0) width=1000,
self.removeButton(1) alignment = 3,
self.removeButton(2) scale={x=1.5, y=1.5, z=1.5},
end font_size=600,
font_color=f_color,
function reloadAll() color={1,1,1,0}
removeAll() })
createAll()
updateSave()
end
if light_mode then
function swap_fcolor(_obj, _color, alt_click) lightButtonText = "[ Set dark ]"
light_mode = not light_mode else
reloadAll() lightButtonText = "[ Set light ]"
end end
function swap_align(_obj, _color, alt_click) end
center_mode = not center_mode
reloadAll() function removeAll()
end self.removeInput(0)
self.removeInput(1)
function editName(_obj, _string, value) self.removeButton(0)
self.setName(value) self.removeButton(1)
setTooltips() self.removeButton(2)
end end
function add_subtract(_obj, _color, alt_click) function reloadAll()
mod = alt_click and -1 or 1 removeAll()
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE) createAll()
if val ~= new_value then
val = new_value updateSave()
updateVal() end
updateSave()
end function swap_fcolor(_obj, _color, alt_click)
end light_mode = not light_mode
reloadAll()
function updateVal() end
self.editButton({ function swap_align(_obj, _color, alt_click)
index = 0, center_mode = not center_mode
label = tostring(val), reloadAll()
end
})
end function editName(_obj, _string, value)
self.setName(value)
function reset_val() setTooltips()
val = 0 end
updateVal()
updateSave() function add_subtract(_obj, _color, alt_click)
end mod = alt_click and -1 or 1
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE)
function setTooltips() if val ~= new_value then
self.editInput({ val = new_value
index = 0, updateVal()
value = self.getName(), updateSave()
tooltip = ttText end
}) end
self.editButton({
index = 0, function updateVal()
value = tostring(val),
tooltip = ttText self.editButton({
}) index = 0,
end label = tostring(val),
function null() })
end end
function keepSample(_obj, _string, value) function reset_val()
reloadAll() val = 0
updateVal()
updateSave()
end
function setTooltips()
self.editInput({
index = 0,
value = self.getName(),
tooltip = ttText
})
self.editButton({
index = 0,
value = tostring(val),
tooltip = ttText
})
end
function null()
end
function keepSample(_obj, _string, value)
reloadAll()
end end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,273 +1,273 @@
function updateSave() function updateSave()
local data_to_save = {["ml"]=memoryList} local data_to_save = {["ml"]=memoryList}
saved_data = JSON.encode(data_to_save) saved_data = JSON.encode(data_to_save)
self.script_state = saved_data self.script_state = saved_data
end end
function onload(saved_data) function onload(saved_data)
if saved_data ~= "" then if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
--Set up information off of loaded_data --Set up information off of loaded_data
memoryList = loaded_data.ml memoryList = loaded_data.ml
else else
--Set up information for if there is no saved saved data --Set up information for if there is no saved saved data
memoryList = {} memoryList = {}
end end
if next(memoryList) == nil then if next(memoryList) == nil then
createSetupButton() createSetupButton()
else else
createMemoryActionButtons() createMemoryActionButtons()
end end
end end
--Beginning Setup --Beginning Setup
--Make setup button --Make setup button
function createSetupButton() function createSetupButton()
self.createButton({ self.createButton({
label="Setup", click_function="buttonClick_setup", function_owner=self, label="Setup", click_function="buttonClick_setup", function_owner=self,
position={0,0.3,-2}, rotation={0,180,0}, height=350, width=800, position={0,0.3,-2}, rotation={0,180,0}, height=350, width=800,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
end end
--Triggered by setup button, --Triggered by setup button,
function buttonClick_setup() function buttonClick_setup()
memoryListBackup = duplicateTable(memoryList) memoryListBackup = duplicateTable(memoryList)
memoryList = {} memoryList = {}
self.clearButtons() self.clearButtons()
createButtonsOnAllObjects() createButtonsOnAllObjects()
createSetupActionButtons() createSetupActionButtons()
end end
--Creates selection buttons on objects --Creates selection buttons on objects
function createButtonsOnAllObjects() function createButtonsOnAllObjects()
local howManyButtons = 0 local howManyButtons = 0
for _, obj in ipairs(getAllObjects()) do for _, obj in ipairs(getAllObjects()) do
if obj ~= self then if obj ~= self then
local dummyIndex = howManyButtons local dummyIndex = howManyButtons
--On a normal bag, the button positions aren't the same size as the bag. --On a normal bag, the button positions aren't the same size as the bag.
globalScaleFactor = 1.25 * 1/self.getScale().x globalScaleFactor = 1.25 * 1/self.getScale().x
--Super sweet math to set button positions --Super sweet math to set button positions
local selfPos = self.getPosition() local selfPos = self.getPosition()
local objPos = obj.getPosition() local objPos = obj.getPosition()
local deltaPos = findOffsetDistance(selfPos, objPos, obj) local deltaPos = findOffsetDistance(selfPos, objPos, obj)
local objPos = rotateLocalCoordinates(deltaPos, self) local objPos = rotateLocalCoordinates(deltaPos, self)
objPos.x = -objPos.x * globalScaleFactor objPos.x = -objPos.x * globalScaleFactor
objPos.y = objPos.y * globalScaleFactor objPos.y = objPos.y * globalScaleFactor
objPos.z = objPos.z * globalScaleFactor objPos.z = objPos.z * globalScaleFactor
--Offset rotation of bag --Offset rotation of bag
local rot = self.getRotation() local rot = self.getRotation()
rot.y = -rot.y + 180 rot.y = -rot.y + 180
--Create function --Create function
local funcName = "selectButton_" .. howManyButtons local funcName = "selectButton_" .. howManyButtons
local func = function() buttonClick_selection(dummyIndex, obj) end local func = function() buttonClick_selection(dummyIndex, obj) end
self.setVar(funcName, func) self.setVar(funcName, func)
self.createButton({ self.createButton({
click_function=funcName, function_owner=self, click_function=funcName, function_owner=self,
position=objPos, rotation=rot, height=1000, width=1000, position=objPos, rotation=rot, height=1000, width=1000,
color={0.75,0.25,0.25,0.6}, color={0.75,0.25,0.25,0.6},
}) })
howManyButtons = howManyButtons + 1 howManyButtons = howManyButtons + 1
end end
end end
end end
--Creates submit and cancel buttons --Creates submit and cancel buttons
function createSetupActionButtons() function createSetupActionButtons()
self.createButton({ self.createButton({
label="Cancel", click_function="buttonClick_cancel", function_owner=self, label="Cancel", click_function="buttonClick_cancel", function_owner=self,
position={0,0.3,-2}, rotation={0,180,0}, height=350, width=1100, position={0,0.3,-2}, rotation={0,180,0}, height=350, width=1100,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
self.createButton({ self.createButton({
label="Submit", click_function="buttonClick_submit", function_owner=self, label="Submit", click_function="buttonClick_submit", function_owner=self,
position={0,0.3,-2.8}, rotation={0,180,0}, height=350, width=1100, position={0,0.3,-2.8}, rotation={0,180,0}, height=350, width=1100,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
self.createButton({ self.createButton({
label="Reset", click_function="buttonClick_reset", function_owner=self, label="Reset", click_function="buttonClick_reset", function_owner=self,
position={-2,0.3,0}, rotation={0,270,0}, height=350, width=800, position={-2,0.3,0}, rotation={0,270,0}, height=350, width=800,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
end end
--During Setup --During Setup
--Checks or unchecks buttons --Checks or unchecks buttons
function buttonClick_selection(index, obj) function buttonClick_selection(index, obj)
local color = {0,1,0,0.6} local color = {0,1,0,0.6}
if memoryList[obj.getGUID()] == nil then if memoryList[obj.getGUID()] == nil then
self.editButton({index=index, color=color}) self.editButton({index=index, color=color})
--Adding pos/rot to memory table --Adding pos/rot to memory table
local pos, rot = obj.getPosition(), obj.getRotation() local pos, rot = obj.getPosition(), obj.getRotation()
--I need to add it like this or it won't save due to indexing issue --I need to add it like this or it won't save due to indexing issue
memoryList[obj.getGUID()] = { memoryList[obj.getGUID()] = {
pos={x=round(pos.x,4), y=round(pos.y,4), z=round(pos.z,4)}, pos={x=round(pos.x,4), y=round(pos.y,4), z=round(pos.z,4)},
rot={x=round(rot.x,4), y=round(rot.y,4), z=round(rot.z,4)}, rot={x=round(rot.x,4), y=round(rot.y,4), z=round(rot.z,4)},
lock=obj.getLock() lock=obj.getLock()
} }
obj.highlightOn({0,1,0}) obj.highlightOn({0,1,0})
else else
color = {0.75,0.25,0.25,0.6} color = {0.75,0.25,0.25,0.6}
self.editButton({index=index, color=color}) self.editButton({index=index, color=color})
memoryList[obj.getGUID()] = nil memoryList[obj.getGUID()] = nil
obj.highlightOff() obj.highlightOff()
end end
end end
--Cancels selection process --Cancels selection process
function buttonClick_cancel() function buttonClick_cancel()
memoryList = memoryListBackup memoryList = memoryListBackup
self.clearButtons() self.clearButtons()
if next(memoryList) == nil then if next(memoryList) == nil then
createSetupButton() createSetupButton()
else else
createMemoryActionButtons() createMemoryActionButtons()
end end
removeAllHighlights() removeAllHighlights()
broadcastToAll("Selection Canceled", {1,1,1}) broadcastToAll("Selection Canceled", {1,1,1})
end end
--Saves selections --Saves selections
function buttonClick_submit() function buttonClick_submit()
if next(memoryList) == nil then if next(memoryList) == nil then
broadcastToAll("You cannot submit without any selections.", {0.75, 0.25, 0.25}) broadcastToAll("You cannot submit without any selections.", {0.75, 0.25, 0.25})
else else
self.clearButtons() self.clearButtons()
createMemoryActionButtons() createMemoryActionButtons()
local count = 0 local count = 0
for guid in pairs(memoryList) do for guid in pairs(memoryList) do
count = count + 1 count = count + 1
local obj = getObjectFromGUID(guid) local obj = getObjectFromGUID(guid)
if obj ~= nil then obj.highlightOff() end if obj ~= nil then obj.highlightOff() end
end end
broadcastToAll(count.." Objects Saved", {1,1,1}) broadcastToAll(count.." Objects Saved", {1,1,1})
updateSave() updateSave()
end end
end end
--Resets bag to starting status --Resets bag to starting status
function buttonClick_reset() function buttonClick_reset()
memoryList = {} memoryList = {}
self.clearButtons() self.clearButtons()
createSetupButton() createSetupButton()
removeAllHighlights() removeAllHighlights()
broadcastToAll("Tool Reset", {1,1,1}) broadcastToAll("Tool Reset", {1,1,1})
updateSave() updateSave()
end end
--After Setup --After Setup
--Creates recall and place buttons --Creates recall and place buttons
function createMemoryActionButtons() function createMemoryActionButtons()
self.createButton({ self.createButton({
label="Place", click_function="buttonClick_place", function_owner=self, label="Place", click_function="buttonClick_place", function_owner=self,
position={0.6,0.1,2.1}, rotation={0,0,0}, height=220, width=500, position={0.6,0.1,2.1}, rotation={0,0,0}, height=220, width=500,
font_size=130, color={0,0,0}, font_color={1,1,1} font_size=130, color={0,0,0}, font_color={1,1,1}
}) })
self.createButton({ self.createButton({
label="Recall", click_function="buttonClick_recall", function_owner=self, label="Recall", click_function="buttonClick_recall", function_owner=self,
position={-0.6,0.1,2.1}, rotation={0,0,0}, height=220, width=500, position={-0.6,0.1,2.1}, rotation={0,0,0}, height=220, width=500,
font_size=130, color={0,0,0}, font_color={1,1,1} font_size=130, color={0,0,0}, font_color={1,1,1}
}) })
-- self.createButton({ -- self.createButton({
-- label="Setup", click_function="buttonClick_setup", function_owner=self, -- label="Setup", click_function="buttonClick_setup", function_owner=self,
-- position={2,0.3,0}, rotation={0,90,0}, height=350, width=800, -- position={2,0.3,0}, rotation={0,90,0}, height=350, width=800,
-- font_size=250, color={0,0,0}, font_color={1,1,1} -- font_size=250, color={0,0,0}, font_color={1,1,1}
-- }) -- })
end end
--Sends objects from bag/table to their saved position/rotation --Sends objects from bag/table to their saved position/rotation
function buttonClick_place() function buttonClick_place()
local bagObjList = self.getObjects() local bagObjList = self.getObjects()
for guid, entry in pairs(memoryList) do for guid, entry in pairs(memoryList) do
local obj = getObjectFromGUID(guid) local obj = getObjectFromGUID(guid)
--If obj is out on the table, move it to the saved pos/rot --If obj is out on the table, move it to the saved pos/rot
if obj ~= nil then if obj ~= nil then
obj.setPositionSmooth(entry.pos) obj.setPositionSmooth(entry.pos)
obj.setRotationSmooth(entry.rot) obj.setRotationSmooth(entry.rot)
obj.setLock(entry.lock) obj.setLock(entry.lock)
else else
--If obj is inside of the bag --If obj is inside of the bag
for _, bagObj in ipairs(bagObjList) do for _, bagObj in ipairs(bagObjList) do
if bagObj.guid == guid then if bagObj.guid == guid then
local item = self.takeObject({ local item = self.takeObject({
guid=guid, position=entry.pos, rotation=entry.rot, guid=guid, position=entry.pos, rotation=entry.rot,
}) })
item.setLock(entry.lock) item.setLock(entry.lock)
break break
end end
end end
end end
end end
broadcastToAll("Objects Placed", {1,1,1}) broadcastToAll("Objects Placed", {1,1,1})
end end
--Recalls objects to bag from table --Recalls objects to bag from table
function buttonClick_recall() function buttonClick_recall()
for guid, entry in pairs(memoryList) do for guid, entry in pairs(memoryList) do
local obj = getObjectFromGUID(guid) local obj = getObjectFromGUID(guid)
if obj ~= nil then self.putObject(obj) end if obj ~= nil then self.putObject(obj) end
end end
broadcastToAll("Objects Recalled", {1,1,1}) broadcastToAll("Objects Recalled", {1,1,1})
end end
--Utility functions --Utility functions
--Find delta (difference) between 2 x/y/z coordinates --Find delta (difference) between 2 x/y/z coordinates
function findOffsetDistance(p1, p2, obj) function findOffsetDistance(p1, p2, obj)
local deltaPos = {} local deltaPos = {}
local bounds = obj.getBounds() local bounds = obj.getBounds()
deltaPos.x = (p2.x-p1.x) deltaPos.x = (p2.x-p1.x)
deltaPos.y = (p2.y-p1.y) + (bounds.size.y - bounds.offset.y) deltaPos.y = (p2.y-p1.y) + (bounds.size.y - bounds.offset.y)
deltaPos.z = (p2.z-p1.z) deltaPos.z = (p2.z-p1.z)
return deltaPos return deltaPos
end end
--Used to rotate a set of coordinates by an angle --Used to rotate a set of coordinates by an angle
function rotateLocalCoordinates(desiredPos, obj) function rotateLocalCoordinates(desiredPos, obj)
local objPos, objRot = obj.getPosition(), obj.getRotation() local objPos, objRot = obj.getPosition(), obj.getRotation()
local angle = math.rad(objRot.y) local angle = math.rad(objRot.y)
local x = desiredPos.x * math.cos(angle) - desiredPos.z * math.sin(angle) local x = desiredPos.x * math.cos(angle) - desiredPos.z * math.sin(angle)
local z = desiredPos.x * math.sin(angle) + desiredPos.z * math.cos(angle) local z = desiredPos.x * math.sin(angle) + desiredPos.z * math.cos(angle)
--return {x=objPos.x+x, y=objPos.y+desiredPos.y, z=objPos.z+z} --return {x=objPos.x+x, y=objPos.y+desiredPos.y, z=objPos.z+z}
return {x=x, y=desiredPos.y, z=z} return {x=x, y=desiredPos.y, z=z}
end end
--Coroutine delay, in seconds --Coroutine delay, in seconds
function wait(time) function wait(time)
local start = os.time() local start = os.time()
repeat coroutine.yield(0) until os.time() > start + time repeat coroutine.yield(0) until os.time() > start + time
end end
--Duplicates a table (needed to prevent it making reference to the same objects) --Duplicates a table (needed to prevent it making reference to the same objects)
function duplicateTable(oldTable) function duplicateTable(oldTable)
local newTable = {} local newTable = {}
for k, v in pairs(oldTable) do for k, v in pairs(oldTable) do
newTable[k] = v newTable[k] = v
end end
return newTable return newTable
end end
--Moves scripted highlight from all objects --Moves scripted highlight from all objects
function removeAllHighlights() function removeAllHighlights()
for _, obj in ipairs(getAllObjects()) do for _, obj in ipairs(getAllObjects()) do
obj.highlightOff() obj.highlightOff()
end end
end end
--Round number (num) to the Nth decimal (dec) --Round number (num) to the Nth decimal (dec)
function round(num, dec) function round(num, dec)
local mult = 10^(dec or 0) local mult = 10^(dec or 0)
return math.floor(num * mult + 0.5) / mult return math.floor(num * mult + 0.5) / mult
end end

View File

@ -1,21 +1,21 @@
name = 'Core Set' name = 'Core Set'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end

View File

@ -1,273 +1,273 @@
function updateSave() function updateSave()
local data_to_save = {["ml"]=memoryList} local data_to_save = {["ml"]=memoryList}
saved_data = JSON.encode(data_to_save) saved_data = JSON.encode(data_to_save)
self.script_state = saved_data self.script_state = saved_data
end end
function onload(saved_data) function onload(saved_data)
if saved_data ~= "" then if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
--Set up information off of loaded_data --Set up information off of loaded_data
memoryList = loaded_data.ml memoryList = loaded_data.ml
else else
--Set up information for if there is no saved saved data --Set up information for if there is no saved saved data
memoryList = {} memoryList = {}
end end
if next(memoryList) == nil then if next(memoryList) == nil then
createSetupButton() createSetupButton()
else else
createMemoryActionButtons() createMemoryActionButtons()
end end
end end
--Beginning Setup --Beginning Setup
--Make setup button --Make setup button
function createSetupButton() function createSetupButton()
self.createButton({ self.createButton({
label="Setup", click_function="buttonClick_setup", function_owner=self, label="Setup", click_function="buttonClick_setup", function_owner=self,
position={0,0.3,-2}, rotation={0,180,0}, height=350, width=800, position={0,0.3,-2}, rotation={0,180,0}, height=350, width=800,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
end end
--Triggered by setup button, --Triggered by setup button,
function buttonClick_setup() function buttonClick_setup()
memoryListBackup = duplicateTable(memoryList) memoryListBackup = duplicateTable(memoryList)
memoryList = {} memoryList = {}
self.clearButtons() self.clearButtons()
createButtonsOnAllObjects() createButtonsOnAllObjects()
createSetupActionButtons() createSetupActionButtons()
end end
--Creates selection buttons on objects --Creates selection buttons on objects
function createButtonsOnAllObjects() function createButtonsOnAllObjects()
local howManyButtons = 0 local howManyButtons = 0
for _, obj in ipairs(getAllObjects()) do for _, obj in ipairs(getAllObjects()) do
if obj ~= self then if obj ~= self then
local dummyIndex = howManyButtons local dummyIndex = howManyButtons
--On a normal bag, the button positions aren't the same size as the bag. --On a normal bag, the button positions aren't the same size as the bag.
globalScaleFactor = 1.25 * 1/self.getScale().x globalScaleFactor = 1.25 * 1/self.getScale().x
--Super sweet math to set button positions --Super sweet math to set button positions
local selfPos = self.getPosition() local selfPos = self.getPosition()
local objPos = obj.getPosition() local objPos = obj.getPosition()
local deltaPos = findOffsetDistance(selfPos, objPos, obj) local deltaPos = findOffsetDistance(selfPos, objPos, obj)
local objPos = rotateLocalCoordinates(deltaPos, self) local objPos = rotateLocalCoordinates(deltaPos, self)
objPos.x = -objPos.x * globalScaleFactor objPos.x = -objPos.x * globalScaleFactor
objPos.y = objPos.y * globalScaleFactor objPos.y = objPos.y * globalScaleFactor
objPos.z = objPos.z * globalScaleFactor objPos.z = objPos.z * globalScaleFactor
--Offset rotation of bag --Offset rotation of bag
local rot = self.getRotation() local rot = self.getRotation()
rot.y = -rot.y + 180 rot.y = -rot.y + 180
--Create function --Create function
local funcName = "selectButton_" .. howManyButtons local funcName = "selectButton_" .. howManyButtons
local func = function() buttonClick_selection(dummyIndex, obj) end local func = function() buttonClick_selection(dummyIndex, obj) end
self.setVar(funcName, func) self.setVar(funcName, func)
self.createButton({ self.createButton({
click_function=funcName, function_owner=self, click_function=funcName, function_owner=self,
position=objPos, rotation=rot, height=1000, width=1000, position=objPos, rotation=rot, height=1000, width=1000,
color={0.75,0.25,0.25,0.6}, color={0.75,0.25,0.25,0.6},
}) })
howManyButtons = howManyButtons + 1 howManyButtons = howManyButtons + 1
end end
end end
end end
--Creates submit and cancel buttons --Creates submit and cancel buttons
function createSetupActionButtons() function createSetupActionButtons()
self.createButton({ self.createButton({
label="Cancel", click_function="buttonClick_cancel", function_owner=self, label="Cancel", click_function="buttonClick_cancel", function_owner=self,
position={0,0.3,-2}, rotation={0,180,0}, height=350, width=1100, position={0,0.3,-2}, rotation={0,180,0}, height=350, width=1100,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
self.createButton({ self.createButton({
label="Submit", click_function="buttonClick_submit", function_owner=self, label="Submit", click_function="buttonClick_submit", function_owner=self,
position={0,0.3,-2.8}, rotation={0,180,0}, height=350, width=1100, position={0,0.3,-2.8}, rotation={0,180,0}, height=350, width=1100,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
self.createButton({ self.createButton({
label="Reset", click_function="buttonClick_reset", function_owner=self, label="Reset", click_function="buttonClick_reset", function_owner=self,
position={-2,0.3,0}, rotation={0,270,0}, height=350, width=800, position={-2,0.3,0}, rotation={0,270,0}, height=350, width=800,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
end end
--During Setup --During Setup
--Checks or unchecks buttons --Checks or unchecks buttons
function buttonClick_selection(index, obj) function buttonClick_selection(index, obj)
local color = {0,1,0,0.6} local color = {0,1,0,0.6}
if memoryList[obj.getGUID()] == nil then if memoryList[obj.getGUID()] == nil then
self.editButton({index=index, color=color}) self.editButton({index=index, color=color})
--Adding pos/rot to memory table --Adding pos/rot to memory table
local pos, rot = obj.getPosition(), obj.getRotation() local pos, rot = obj.getPosition(), obj.getRotation()
--I need to add it like this or it won't save due to indexing issue --I need to add it like this or it won't save due to indexing issue
memoryList[obj.getGUID()] = { memoryList[obj.getGUID()] = {
pos={x=round(pos.x,4), y=round(pos.y,4), z=round(pos.z,4)}, pos={x=round(pos.x,4), y=round(pos.y,4), z=round(pos.z,4)},
rot={x=round(rot.x,4), y=round(rot.y,4), z=round(rot.z,4)}, rot={x=round(rot.x,4), y=round(rot.y,4), z=round(rot.z,4)},
lock=obj.getLock() lock=obj.getLock()
} }
obj.highlightOn({0,1,0}) obj.highlightOn({0,1,0})
else else
color = {0.75,0.25,0.25,0.6} color = {0.75,0.25,0.25,0.6}
self.editButton({index=index, color=color}) self.editButton({index=index, color=color})
memoryList[obj.getGUID()] = nil memoryList[obj.getGUID()] = nil
obj.highlightOff() obj.highlightOff()
end end
end end
--Cancels selection process --Cancels selection process
function buttonClick_cancel() function buttonClick_cancel()
memoryList = memoryListBackup memoryList = memoryListBackup
self.clearButtons() self.clearButtons()
if next(memoryList) == nil then if next(memoryList) == nil then
createSetupButton() createSetupButton()
else else
createMemoryActionButtons() createMemoryActionButtons()
end end
removeAllHighlights() removeAllHighlights()
broadcastToAll("Selection Canceled", {1,1,1}) broadcastToAll("Selection Canceled", {1,1,1})
end end
--Saves selections --Saves selections
function buttonClick_submit() function buttonClick_submit()
if next(memoryList) == nil then if next(memoryList) == nil then
broadcastToAll("You cannot submit without any selections.", {0.75, 0.25, 0.25}) broadcastToAll("You cannot submit without any selections.", {0.75, 0.25, 0.25})
else else
self.clearButtons() self.clearButtons()
createMemoryActionButtons() createMemoryActionButtons()
local count = 0 local count = 0
for guid in pairs(memoryList) do for guid in pairs(memoryList) do
count = count + 1 count = count + 1
local obj = getObjectFromGUID(guid) local obj = getObjectFromGUID(guid)
if obj ~= nil then obj.highlightOff() end if obj ~= nil then obj.highlightOff() end
end end
broadcastToAll(count.." Objects Saved", {1,1,1}) broadcastToAll(count.." Objects Saved", {1,1,1})
updateSave() updateSave()
end end
end end
--Resets bag to starting status --Resets bag to starting status
function buttonClick_reset() function buttonClick_reset()
memoryList = {} memoryList = {}
self.clearButtons() self.clearButtons()
createSetupButton() createSetupButton()
removeAllHighlights() removeAllHighlights()
broadcastToAll("Tool Reset", {1,1,1}) broadcastToAll("Tool Reset", {1,1,1})
updateSave() updateSave()
end end
--After Setup --After Setup
--Creates recall and place buttons --Creates recall and place buttons
function createMemoryActionButtons() function createMemoryActionButtons()
self.createButton({ self.createButton({
label="Place", click_function="buttonClick_place", function_owner=self, label="Place", click_function="buttonClick_place", function_owner=self,
position={0.6,0.1,2.1}, rotation={0,0,0}, height=220, width=500, position={0.6,0.1,2.1}, rotation={0,0,0}, height=220, width=500,
font_size=130, color={0,0,0}, font_color={1,1,1} font_size=130, color={0,0,0}, font_color={1,1,1}
}) })
self.createButton({ self.createButton({
label="Recall", click_function="buttonClick_recall", function_owner=self, label="Recall", click_function="buttonClick_recall", function_owner=self,
position={-0.6,0.1,2.1}, rotation={0,0,0}, height=220, width=500, position={-0.6,0.1,2.1}, rotation={0,0,0}, height=220, width=500,
font_size=130, color={0,0,0}, font_color={1,1,1} font_size=130, color={0,0,0}, font_color={1,1,1}
}) })
-- self.createButton({ -- self.createButton({
-- label="Setup", click_function="buttonClick_setup", function_owner=self, -- label="Setup", click_function="buttonClick_setup", function_owner=self,
-- position={2,0.3,0}, rotation={0,90,0}, height=350, width=800, -- position={2,0.3,0}, rotation={0,90,0}, height=350, width=800,
-- font_size=250, color={0,0,0}, font_color={1,1,1} -- font_size=250, color={0,0,0}, font_color={1,1,1}
-- }) -- })
end end
--Sends objects from bag/table to their saved position/rotation --Sends objects from bag/table to their saved position/rotation
function buttonClick_place() function buttonClick_place()
local bagObjList = self.getObjects() local bagObjList = self.getObjects()
for guid, entry in pairs(memoryList) do for guid, entry in pairs(memoryList) do
local obj = getObjectFromGUID(guid) local obj = getObjectFromGUID(guid)
--If obj is out on the table, move it to the saved pos/rot --If obj is out on the table, move it to the saved pos/rot
if obj ~= nil then if obj ~= nil then
obj.setPositionSmooth(entry.pos) obj.setPositionSmooth(entry.pos)
obj.setRotationSmooth(entry.rot) obj.setRotationSmooth(entry.rot)
obj.setLock(entry.lock) obj.setLock(entry.lock)
else else
--If obj is inside of the bag --If obj is inside of the bag
for _, bagObj in ipairs(bagObjList) do for _, bagObj in ipairs(bagObjList) do
if bagObj.guid == guid then if bagObj.guid == guid then
local item = self.takeObject({ local item = self.takeObject({
guid=guid, position=entry.pos, rotation=entry.rot, guid=guid, position=entry.pos, rotation=entry.rot,
}) })
item.setLock(entry.lock) item.setLock(entry.lock)
break break
end end
end end
end end
end end
broadcastToAll("Objects Placed", {1,1,1}) broadcastToAll("Objects Placed", {1,1,1})
end end
--Recalls objects to bag from table --Recalls objects to bag from table
function buttonClick_recall() function buttonClick_recall()
for guid, entry in pairs(memoryList) do for guid, entry in pairs(memoryList) do
local obj = getObjectFromGUID(guid) local obj = getObjectFromGUID(guid)
if obj ~= nil then self.putObject(obj) end if obj ~= nil then self.putObject(obj) end
end end
broadcastToAll("Objects Recalled", {1,1,1}) broadcastToAll("Objects Recalled", {1,1,1})
end end
--Utility functions --Utility functions
--Find delta (difference) between 2 x/y/z coordinates --Find delta (difference) between 2 x/y/z coordinates
function findOffsetDistance(p1, p2, obj) function findOffsetDistance(p1, p2, obj)
local deltaPos = {} local deltaPos = {}
local bounds = obj.getBounds() local bounds = obj.getBounds()
deltaPos.x = (p2.x-p1.x) deltaPos.x = (p2.x-p1.x)
deltaPos.y = (p2.y-p1.y) + (bounds.size.y - bounds.offset.y) deltaPos.y = (p2.y-p1.y) + (bounds.size.y - bounds.offset.y)
deltaPos.z = (p2.z-p1.z) deltaPos.z = (p2.z-p1.z)
return deltaPos return deltaPos
end end
--Used to rotate a set of coordinates by an angle --Used to rotate a set of coordinates by an angle
function rotateLocalCoordinates(desiredPos, obj) function rotateLocalCoordinates(desiredPos, obj)
local objPos, objRot = obj.getPosition(), obj.getRotation() local objPos, objRot = obj.getPosition(), obj.getRotation()
local angle = math.rad(objRot.y) local angle = math.rad(objRot.y)
local x = desiredPos.x * math.cos(angle) - desiredPos.z * math.sin(angle) local x = desiredPos.x * math.cos(angle) - desiredPos.z * math.sin(angle)
local z = desiredPos.x * math.sin(angle) + desiredPos.z * math.cos(angle) local z = desiredPos.x * math.sin(angle) + desiredPos.z * math.cos(angle)
--return {x=objPos.x+x, y=objPos.y+desiredPos.y, z=objPos.z+z} --return {x=objPos.x+x, y=objPos.y+desiredPos.y, z=objPos.z+z}
return {x=x, y=desiredPos.y, z=z} return {x=x, y=desiredPos.y, z=z}
end end
--Coroutine delay, in seconds --Coroutine delay, in seconds
function wait(time) function wait(time)
local start = os.time() local start = os.time()
repeat coroutine.yield(0) until os.time() > start + time repeat coroutine.yield(0) until os.time() > start + time
end end
--Duplicates a table (needed to prevent it making reference to the same objects) --Duplicates a table (needed to prevent it making reference to the same objects)
function duplicateTable(oldTable) function duplicateTable(oldTable)
local newTable = {} local newTable = {}
for k, v in pairs(oldTable) do for k, v in pairs(oldTable) do
newTable[k] = v newTable[k] = v
end end
return newTable return newTable
end end
--Moves scripted highlight from all objects --Moves scripted highlight from all objects
function removeAllHighlights() function removeAllHighlights()
for _, obj in ipairs(getAllObjects()) do for _, obj in ipairs(getAllObjects()) do
obj.highlightOff() obj.highlightOff()
end end
end end
--Round number (num) to the Nth decimal (dec) --Round number (num) to the Nth decimal (dec)
function round(num, dec) function round(num, dec)
local mult = 10^(dec or 0) local mult = 10^(dec or 0)
return math.floor(num * mult + 0.5) / mult return math.floor(num * mult + 0.5) / mult
end end

View File

@ -1,21 +1,21 @@
name = 'Core Set' name = 'Core Set'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end

View File

@ -1,273 +1,273 @@
function updateSave() function updateSave()
local data_to_save = {["ml"]=memoryList} local data_to_save = {["ml"]=memoryList}
saved_data = JSON.encode(data_to_save) saved_data = JSON.encode(data_to_save)
self.script_state = saved_data self.script_state = saved_data
end end
function onload(saved_data) function onload(saved_data)
if saved_data ~= "" then if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
--Set up information off of loaded_data --Set up information off of loaded_data
memoryList = loaded_data.ml memoryList = loaded_data.ml
else else
--Set up information for if there is no saved saved data --Set up information for if there is no saved saved data
memoryList = {} memoryList = {}
end end
if next(memoryList) == nil then if next(memoryList) == nil then
createSetupButton() createSetupButton()
else else
createMemoryActionButtons() createMemoryActionButtons()
end end
end end
--Beginning Setup --Beginning Setup
--Make setup button --Make setup button
function createSetupButton() function createSetupButton()
self.createButton({ self.createButton({
label="Setup", click_function="buttonClick_setup", function_owner=self, label="Setup", click_function="buttonClick_setup", function_owner=self,
position={0,0.3,-2}, rotation={0,180,0}, height=350, width=800, position={0,0.3,-2}, rotation={0,180,0}, height=350, width=800,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
end end
--Triggered by setup button, --Triggered by setup button,
function buttonClick_setup() function buttonClick_setup()
memoryListBackup = duplicateTable(memoryList) memoryListBackup = duplicateTable(memoryList)
memoryList = {} memoryList = {}
self.clearButtons() self.clearButtons()
createButtonsOnAllObjects() createButtonsOnAllObjects()
createSetupActionButtons() createSetupActionButtons()
end end
--Creates selection buttons on objects --Creates selection buttons on objects
function createButtonsOnAllObjects() function createButtonsOnAllObjects()
local howManyButtons = 0 local howManyButtons = 0
for _, obj in ipairs(getAllObjects()) do for _, obj in ipairs(getAllObjects()) do
if obj ~= self then if obj ~= self then
local dummyIndex = howManyButtons local dummyIndex = howManyButtons
--On a normal bag, the button positions aren't the same size as the bag. --On a normal bag, the button positions aren't the same size as the bag.
globalScaleFactor = 1.25 * 1/self.getScale().x globalScaleFactor = 1.25 * 1/self.getScale().x
--Super sweet math to set button positions --Super sweet math to set button positions
local selfPos = self.getPosition() local selfPos = self.getPosition()
local objPos = obj.getPosition() local objPos = obj.getPosition()
local deltaPos = findOffsetDistance(selfPos, objPos, obj) local deltaPos = findOffsetDistance(selfPos, objPos, obj)
local objPos = rotateLocalCoordinates(deltaPos, self) local objPos = rotateLocalCoordinates(deltaPos, self)
objPos.x = -objPos.x * globalScaleFactor objPos.x = -objPos.x * globalScaleFactor
objPos.y = objPos.y * globalScaleFactor objPos.y = objPos.y * globalScaleFactor
objPos.z = objPos.z * globalScaleFactor objPos.z = objPos.z * globalScaleFactor
--Offset rotation of bag --Offset rotation of bag
local rot = self.getRotation() local rot = self.getRotation()
rot.y = -rot.y + 180 rot.y = -rot.y + 180
--Create function --Create function
local funcName = "selectButton_" .. howManyButtons local funcName = "selectButton_" .. howManyButtons
local func = function() buttonClick_selection(dummyIndex, obj) end local func = function() buttonClick_selection(dummyIndex, obj) end
self.setVar(funcName, func) self.setVar(funcName, func)
self.createButton({ self.createButton({
click_function=funcName, function_owner=self, click_function=funcName, function_owner=self,
position=objPos, rotation=rot, height=1000, width=1000, position=objPos, rotation=rot, height=1000, width=1000,
color={0.75,0.25,0.25,0.6}, color={0.75,0.25,0.25,0.6},
}) })
howManyButtons = howManyButtons + 1 howManyButtons = howManyButtons + 1
end end
end end
end end
--Creates submit and cancel buttons --Creates submit and cancel buttons
function createSetupActionButtons() function createSetupActionButtons()
self.createButton({ self.createButton({
label="Cancel", click_function="buttonClick_cancel", function_owner=self, label="Cancel", click_function="buttonClick_cancel", function_owner=self,
position={0,0.3,-2}, rotation={0,180,0}, height=350, width=1100, position={0,0.3,-2}, rotation={0,180,0}, height=350, width=1100,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
self.createButton({ self.createButton({
label="Submit", click_function="buttonClick_submit", function_owner=self, label="Submit", click_function="buttonClick_submit", function_owner=self,
position={0,0.3,-2.8}, rotation={0,180,0}, height=350, width=1100, position={0,0.3,-2.8}, rotation={0,180,0}, height=350, width=1100,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
self.createButton({ self.createButton({
label="Reset", click_function="buttonClick_reset", function_owner=self, label="Reset", click_function="buttonClick_reset", function_owner=self,
position={-2,0.3,0}, rotation={0,270,0}, height=350, width=800, position={-2,0.3,0}, rotation={0,270,0}, height=350, width=800,
font_size=250, color={0,0,0}, font_color={1,1,1} font_size=250, color={0,0,0}, font_color={1,1,1}
}) })
end end
--During Setup --During Setup
--Checks or unchecks buttons --Checks or unchecks buttons
function buttonClick_selection(index, obj) function buttonClick_selection(index, obj)
local color = {0,1,0,0.6} local color = {0,1,0,0.6}
if memoryList[obj.getGUID()] == nil then if memoryList[obj.getGUID()] == nil then
self.editButton({index=index, color=color}) self.editButton({index=index, color=color})
--Adding pos/rot to memory table --Adding pos/rot to memory table
local pos, rot = obj.getPosition(), obj.getRotation() local pos, rot = obj.getPosition(), obj.getRotation()
--I need to add it like this or it won't save due to indexing issue --I need to add it like this or it won't save due to indexing issue
memoryList[obj.getGUID()] = { memoryList[obj.getGUID()] = {
pos={x=round(pos.x,4), y=round(pos.y,4), z=round(pos.z,4)}, pos={x=round(pos.x,4), y=round(pos.y,4), z=round(pos.z,4)},
rot={x=round(rot.x,4), y=round(rot.y,4), z=round(rot.z,4)}, rot={x=round(rot.x,4), y=round(rot.y,4), z=round(rot.z,4)},
lock=obj.getLock() lock=obj.getLock()
} }
obj.highlightOn({0,1,0}) obj.highlightOn({0,1,0})
else else
color = {0.75,0.25,0.25,0.6} color = {0.75,0.25,0.25,0.6}
self.editButton({index=index, color=color}) self.editButton({index=index, color=color})
memoryList[obj.getGUID()] = nil memoryList[obj.getGUID()] = nil
obj.highlightOff() obj.highlightOff()
end end
end end
--Cancels selection process --Cancels selection process
function buttonClick_cancel() function buttonClick_cancel()
memoryList = memoryListBackup memoryList = memoryListBackup
self.clearButtons() self.clearButtons()
if next(memoryList) == nil then if next(memoryList) == nil then
createSetupButton() createSetupButton()
else else
createMemoryActionButtons() createMemoryActionButtons()
end end
removeAllHighlights() removeAllHighlights()
broadcastToAll("Selection Canceled", {1,1,1}) broadcastToAll("Selection Canceled", {1,1,1})
end end
--Saves selections --Saves selections
function buttonClick_submit() function buttonClick_submit()
if next(memoryList) == nil then if next(memoryList) == nil then
broadcastToAll("You cannot submit without any selections.", {0.75, 0.25, 0.25}) broadcastToAll("You cannot submit without any selections.", {0.75, 0.25, 0.25})
else else
self.clearButtons() self.clearButtons()
createMemoryActionButtons() createMemoryActionButtons()
local count = 0 local count = 0
for guid in pairs(memoryList) do for guid in pairs(memoryList) do
count = count + 1 count = count + 1
local obj = getObjectFromGUID(guid) local obj = getObjectFromGUID(guid)
if obj ~= nil then obj.highlightOff() end if obj ~= nil then obj.highlightOff() end
end end
broadcastToAll(count.." Objects Saved", {1,1,1}) broadcastToAll(count.." Objects Saved", {1,1,1})
updateSave() updateSave()
end end
end end
--Resets bag to starting status --Resets bag to starting status
function buttonClick_reset() function buttonClick_reset()
memoryList = {} memoryList = {}
self.clearButtons() self.clearButtons()
createSetupButton() createSetupButton()
removeAllHighlights() removeAllHighlights()
broadcastToAll("Tool Reset", {1,1,1}) broadcastToAll("Tool Reset", {1,1,1})
updateSave() updateSave()
end end
--After Setup --After Setup
--Creates recall and place buttons --Creates recall and place buttons
function createMemoryActionButtons() function createMemoryActionButtons()
self.createButton({ self.createButton({
label="Place", click_function="buttonClick_place", function_owner=self, label="Place", click_function="buttonClick_place", function_owner=self,
position={0.6,0.1,2.1}, rotation={0,0,0}, height=220, width=500, position={0.6,0.1,2.1}, rotation={0,0,0}, height=220, width=500,
font_size=130, color={0,0,0}, font_color={1,1,1} font_size=130, color={0,0,0}, font_color={1,1,1}
}) })
self.createButton({ self.createButton({
label="Recall", click_function="buttonClick_recall", function_owner=self, label="Recall", click_function="buttonClick_recall", function_owner=self,
position={-0.6,0.1,2.1}, rotation={0,0,0}, height=220, width=500, position={-0.6,0.1,2.1}, rotation={0,0,0}, height=220, width=500,
font_size=130, color={0,0,0}, font_color={1,1,1} font_size=130, color={0,0,0}, font_color={1,1,1}
}) })
-- self.createButton({ -- self.createButton({
-- label="Setup", click_function="buttonClick_setup", function_owner=self, -- label="Setup", click_function="buttonClick_setup", function_owner=self,
-- position={2,0.3,0}, rotation={0,90,0}, height=350, width=800, -- position={2,0.3,0}, rotation={0,90,0}, height=350, width=800,
-- font_size=250, color={0,0,0}, font_color={1,1,1} -- font_size=250, color={0,0,0}, font_color={1,1,1}
-- }) -- })
end end
--Sends objects from bag/table to their saved position/rotation --Sends objects from bag/table to their saved position/rotation
function buttonClick_place() function buttonClick_place()
local bagObjList = self.getObjects() local bagObjList = self.getObjects()
for guid, entry in pairs(memoryList) do for guid, entry in pairs(memoryList) do
local obj = getObjectFromGUID(guid) local obj = getObjectFromGUID(guid)
--If obj is out on the table, move it to the saved pos/rot --If obj is out on the table, move it to the saved pos/rot
if obj ~= nil then if obj ~= nil then
obj.setPositionSmooth(entry.pos) obj.setPositionSmooth(entry.pos)
obj.setRotationSmooth(entry.rot) obj.setRotationSmooth(entry.rot)
obj.setLock(entry.lock) obj.setLock(entry.lock)
else else
--If obj is inside of the bag --If obj is inside of the bag
for _, bagObj in ipairs(bagObjList) do for _, bagObj in ipairs(bagObjList) do
if bagObj.guid == guid then if bagObj.guid == guid then
local item = self.takeObject({ local item = self.takeObject({
guid=guid, position=entry.pos, rotation=entry.rot, guid=guid, position=entry.pos, rotation=entry.rot,
}) })
item.setLock(entry.lock) item.setLock(entry.lock)
break break
end end
end end
end end
end end
broadcastToAll("Objects Placed", {1,1,1}) broadcastToAll("Objects Placed", {1,1,1})
end end
--Recalls objects to bag from table --Recalls objects to bag from table
function buttonClick_recall() function buttonClick_recall()
for guid, entry in pairs(memoryList) do for guid, entry in pairs(memoryList) do
local obj = getObjectFromGUID(guid) local obj = getObjectFromGUID(guid)
if obj ~= nil then self.putObject(obj) end if obj ~= nil then self.putObject(obj) end
end end
broadcastToAll("Objects Recalled", {1,1,1}) broadcastToAll("Objects Recalled", {1,1,1})
end end
--Utility functions --Utility functions
--Find delta (difference) between 2 x/y/z coordinates --Find delta (difference) between 2 x/y/z coordinates
function findOffsetDistance(p1, p2, obj) function findOffsetDistance(p1, p2, obj)
local deltaPos = {} local deltaPos = {}
local bounds = obj.getBounds() local bounds = obj.getBounds()
deltaPos.x = (p2.x-p1.x) deltaPos.x = (p2.x-p1.x)
deltaPos.y = (p2.y-p1.y) + (bounds.size.y - bounds.offset.y) deltaPos.y = (p2.y-p1.y) + (bounds.size.y - bounds.offset.y)
deltaPos.z = (p2.z-p1.z) deltaPos.z = (p2.z-p1.z)
return deltaPos return deltaPos
end end
--Used to rotate a set of coordinates by an angle --Used to rotate a set of coordinates by an angle
function rotateLocalCoordinates(desiredPos, obj) function rotateLocalCoordinates(desiredPos, obj)
local objPos, objRot = obj.getPosition(), obj.getRotation() local objPos, objRot = obj.getPosition(), obj.getRotation()
local angle = math.rad(objRot.y) local angle = math.rad(objRot.y)
local x = desiredPos.x * math.cos(angle) - desiredPos.z * math.sin(angle) local x = desiredPos.x * math.cos(angle) - desiredPos.z * math.sin(angle)
local z = desiredPos.x * math.sin(angle) + desiredPos.z * math.cos(angle) local z = desiredPos.x * math.sin(angle) + desiredPos.z * math.cos(angle)
--return {x=objPos.x+x, y=objPos.y+desiredPos.y, z=objPos.z+z} --return {x=objPos.x+x, y=objPos.y+desiredPos.y, z=objPos.z+z}
return {x=x, y=desiredPos.y, z=z} return {x=x, y=desiredPos.y, z=z}
end end
--Coroutine delay, in seconds --Coroutine delay, in seconds
function wait(time) function wait(time)
local start = os.time() local start = os.time()
repeat coroutine.yield(0) until os.time() > start + time repeat coroutine.yield(0) until os.time() > start + time
end end
--Duplicates a table (needed to prevent it making reference to the same objects) --Duplicates a table (needed to prevent it making reference to the same objects)
function duplicateTable(oldTable) function duplicateTable(oldTable)
local newTable = {} local newTable = {}
for k, v in pairs(oldTable) do for k, v in pairs(oldTable) do
newTable[k] = v newTable[k] = v
end end
return newTable return newTable
end end
--Moves scripted highlight from all objects --Moves scripted highlight from all objects
function removeAllHighlights() function removeAllHighlights()
for _, obj in ipairs(getAllObjects()) do for _, obj in ipairs(getAllObjects()) do
obj.highlightOff() obj.highlightOff()
end end
end end
--Round number (num) to the Nth decimal (dec) --Round number (num) to the Nth decimal (dec)
function round(num, dec) function round(num, dec)
local mult = 10^(dec or 0) local mult = 10^(dec or 0)
return math.floor(num * mult + 0.5) / mult return math.floor(num * mult + 0.5) / mult
end end

View File

@ -1,21 +1,21 @@
name = 'The Devourer Below' name = 'The Devourer Below'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end

View File

@ -1,132 +1,132 @@
MIN_VALUE = -99 MIN_VALUE = -99
MAX_VALUE = 999 MAX_VALUE = 999
function onload(saved_data) function onload(saved_data)
light_mode = false light_mode = false
val = 0 val = 0
if saved_data ~= "" then if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1] light_mode = loaded_data[1]
val = loaded_data[2] val = loaded_data[2]
end end
createAll() createAll()
end end
function updateSave() function updateSave()
local data_to_save = {light_mode, val} local data_to_save = {light_mode, val}
saved_data = JSON.encode(data_to_save) saved_data = JSON.encode(data_to_save)
self.script_state = saved_data self.script_state = saved_data
end end
function createAll() function createAll()
s_color = {0.5, 0.5, 0.5, 95} s_color = {0.5, 0.5, 0.5, 95}
if light_mode then if light_mode then
f_color = {0,0,0,98} f_color = {0,0,0,98}
else else
f_color = {0,0,0,100} f_color = {0,0,0,100}
end end
self.createButton({ self.createButton({
label=tostring(val), label=tostring(val),
click_function="add_subtract", click_function="add_subtract",
function_owner=self, function_owner=self,
position={0,0.05,1.45}, position={0,0.05,1.45},
height=600, height=600,
width=1000, width=1000,
alignment = 3, alignment = 3,
scale={x=1, y=1, z=1}, scale={x=1, y=1, z=1},
font_size=350, font_size=350,
font_color=f_color, font_color=f_color,
color={0,0,0,0} color={0,0,0,0}
}) })
if light_mode then if light_mode then
lightButtonText = "[ Set dark ]" lightButtonText = "[ Set dark ]"
else else
lightButtonText = "[ Set light ]" lightButtonText = "[ Set light ]"
end end
end end
function removeAll() function removeAll()
self.removeInput(0) self.removeInput(0)
self.removeInput(1) self.removeInput(1)
self.removeButton(0) self.removeButton(0)
self.removeButton(1) self.removeButton(1)
self.removeButton(2) self.removeButton(2)
end end
function reloadAll() function reloadAll()
removeAll() removeAll()
createAll() createAll()
updateSave() updateSave()
end end
function swap_fcolor(_obj, _color, alt_click) function swap_fcolor(_obj, _color, alt_click)
light_mode = not light_mode light_mode = not light_mode
reloadAll() reloadAll()
end end
function swap_align(_obj, _color, alt_click) function swap_align(_obj, _color, alt_click)
center_mode = not center_mode center_mode = not center_mode
reloadAll() reloadAll()
end end
function editName(_obj, _string, value) function editName(_obj, _string, value)
self.setName(value) self.setName(value)
setTooltips() setTooltips()
end end
function add_subtract(_obj, _color, alt_click) function add_subtract(_obj, _color, alt_click)
mod = alt_click and -1 or 1 mod = alt_click and -1 or 1
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE) new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE)
if val ~= new_value then if val ~= new_value then
val = new_value val = new_value
updateVal() updateVal()
updateSave() updateSave()
end end
end end
function updateVal() function updateVal()
self.editButton({ self.editButton({
index = 0, index = 0,
label = tostring(val), label = tostring(val),
}) })
end end
function reset_val() function reset_val()
val = 0 val = 0
updateVal() updateVal()
updateSave() updateSave()
end end
function setTooltips() function setTooltips()
self.editInput({ self.editInput({
index = 0, index = 0,
value = self.getName(), value = self.getName(),
tooltip = ttText tooltip = ttText
}) })
self.editButton({ self.editButton({
index = 0, index = 0,
value = tostring(val), value = tostring(val),
tooltip = ttText tooltip = ttText
}) })
end end
function null() function null()
end end
function keepSample(_obj, _string, value) function keepSample(_obj, _string, value)
reloadAll() reloadAll()
end end

View File

@ -1,132 +1,132 @@
MIN_VALUE = -99 MIN_VALUE = -99
MAX_VALUE = 999 MAX_VALUE = 999
function onload(saved_data) function onload(saved_data)
light_mode = false light_mode = false
val = 0 val = 0
if saved_data ~= "" then if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1] light_mode = loaded_data[1]
val = loaded_data[2] val = loaded_data[2]
end end
createAll() createAll()
end end
function updateSave() function updateSave()
local data_to_save = {light_mode, val} local data_to_save = {light_mode, val}
saved_data = JSON.encode(data_to_save) saved_data = JSON.encode(data_to_save)
self.script_state = saved_data self.script_state = saved_data
end end
function createAll() function createAll()
s_color = {0.5, 0.5, 0.5, 95} s_color = {0.5, 0.5, 0.5, 95}
if light_mode then if light_mode then
f_color = {0,0,0,98} f_color = {0,0,0,98}
else else
f_color = {0,0,0,100} f_color = {0,0,0,100}
end end
self.createButton({ self.createButton({
label=tostring(val), label=tostring(val),
click_function="add_subtract", click_function="add_subtract",
function_owner=self, function_owner=self,
position={0,0.05,1.45}, position={0,0.05,1.45},
height=600, height=600,
width=1000, width=1000,
alignment = 3, alignment = 3,
scale={x=1, y=1, z=1}, scale={x=1, y=1, z=1},
font_size=350, font_size=350,
font_color=f_color, font_color=f_color,
color={0,0,0,0} color={0,0,0,0}
}) })
if light_mode then if light_mode then
lightButtonText = "[ Set dark ]" lightButtonText = "[ Set dark ]"
else else
lightButtonText = "[ Set light ]" lightButtonText = "[ Set light ]"
end end
end end
function removeAll() function removeAll()
self.removeInput(0) self.removeInput(0)
self.removeInput(1) self.removeInput(1)
self.removeButton(0) self.removeButton(0)
self.removeButton(1) self.removeButton(1)
self.removeButton(2) self.removeButton(2)
end end
function reloadAll() function reloadAll()
removeAll() removeAll()
createAll() createAll()
updateSave() updateSave()
end end
function swap_fcolor(_obj, _color, alt_click) function swap_fcolor(_obj, _color, alt_click)
light_mode = not light_mode light_mode = not light_mode
reloadAll() reloadAll()
end end
function swap_align(_obj, _color, alt_click) function swap_align(_obj, _color, alt_click)
center_mode = not center_mode center_mode = not center_mode
reloadAll() reloadAll()
end end
function editName(_obj, _string, value) function editName(_obj, _string, value)
self.setName(value) self.setName(value)
setTooltips() setTooltips()
end end
function add_subtract(_obj, _color, alt_click) function add_subtract(_obj, _color, alt_click)
mod = alt_click and -1 or 1 mod = alt_click and -1 or 1
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE) new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE)
if val ~= new_value then if val ~= new_value then
val = new_value val = new_value
updateVal() updateVal()
updateSave() updateSave()
end end
end end
function updateVal() function updateVal()
self.editButton({ self.editButton({
index = 0, index = 0,
label = tostring(val), label = tostring(val),
}) })
end end
function reset_val() function reset_val()
val = 0 val = 0
updateVal() updateVal()
updateSave() updateSave()
end end
function setTooltips() function setTooltips()
self.editInput({ self.editInput({
index = 0, index = 0,
value = self.getName(), value = self.getName(),
tooltip = ttText tooltip = ttText
}) })
self.editButton({ self.editButton({
index = 0, index = 0,
value = tostring(val), value = tostring(val),
tooltip = ttText tooltip = ttText
}) })
end end
function null() function null()
end end
function keepSample(_obj, _string, value) function keepSample(_obj, _string, value)
reloadAll() reloadAll()
end end

View File

@ -1,132 +1,132 @@
MIN_VALUE = -99 MIN_VALUE = -99
MAX_VALUE = 999 MAX_VALUE = 999
function onload(saved_data) function onload(saved_data)
light_mode = false light_mode = false
val = 0 val = 0
if saved_data ~= "" then if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1] light_mode = loaded_data[1]
val = loaded_data[2] val = loaded_data[2]
end end
createAll() createAll()
end end
function updateSave() function updateSave()
local data_to_save = {light_mode, val} local data_to_save = {light_mode, val}
saved_data = JSON.encode(data_to_save) saved_data = JSON.encode(data_to_save)
self.script_state = saved_data self.script_state = saved_data
end end
function createAll() function createAll()
s_color = {0.5, 0.5, 0.5, 95} s_color = {0.5, 0.5, 0.5, 95}
if light_mode then if light_mode then
f_color = {0,0,0,98} f_color = {0,0,0,98}
else else
f_color = {0,0,0,100} f_color = {0,0,0,100}
end end
self.createButton({ self.createButton({
label=tostring(val), label=tostring(val),
click_function="add_subtract", click_function="add_subtract",
function_owner=self, function_owner=self,
position={0,0.05,1.45}, position={0,0.05,1.45},
height=600, height=600,
width=1000, width=1000,
alignment = 3, alignment = 3,
scale={x=1, y=1, z=1}, scale={x=1, y=1, z=1},
font_size=350, font_size=350,
font_color=f_color, font_color=f_color,
color={0,0,0,0} color={0,0,0,0}
}) })
if light_mode then if light_mode then
lightButtonText = "[ Set dark ]" lightButtonText = "[ Set dark ]"
else else
lightButtonText = "[ Set light ]" lightButtonText = "[ Set light ]"
end end
end end
function removeAll() function removeAll()
self.removeInput(0) self.removeInput(0)
self.removeInput(1) self.removeInput(1)
self.removeButton(0) self.removeButton(0)
self.removeButton(1) self.removeButton(1)
self.removeButton(2) self.removeButton(2)
end end
function reloadAll() function reloadAll()
removeAll() removeAll()
createAll() createAll()
updateSave() updateSave()
end end
function swap_fcolor(_obj, _color, alt_click) function swap_fcolor(_obj, _color, alt_click)
light_mode = not light_mode light_mode = not light_mode
reloadAll() reloadAll()
end end
function swap_align(_obj, _color, alt_click) function swap_align(_obj, _color, alt_click)
center_mode = not center_mode center_mode = not center_mode
reloadAll() reloadAll()
end end
function editName(_obj, _string, value) function editName(_obj, _string, value)
self.setName(value) self.setName(value)
setTooltips() setTooltips()
end end
function add_subtract(_obj, _color, alt_click) function add_subtract(_obj, _color, alt_click)
mod = alt_click and -1 or 1 mod = alt_click and -1 or 1
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE) new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE)
if val ~= new_value then if val ~= new_value then
val = new_value val = new_value
updateVal() updateVal()
updateSave() updateSave()
end end
end end
function updateVal() function updateVal()
self.editButton({ self.editButton({
index = 0, index = 0,
label = tostring(val), label = tostring(val),
}) })
end end
function reset_val() function reset_val()
val = 0 val = 0
updateVal() updateVal()
updateSave() updateSave()
end end
function setTooltips() function setTooltips()
self.editInput({ self.editInput({
index = 0, index = 0,
value = self.getName(), value = self.getName(),
tooltip = ttText tooltip = ttText
}) })
self.editButton({ self.editButton({
index = 0, index = 0,
value = tostring(val), value = tostring(val),
tooltip = ttText tooltip = ttText
}) })
end end
function null() function null()
end end
function keepSample(_obj, _string, value) function keepSample(_obj, _string, value)
reloadAll() reloadAll()
end end

View File

@ -1,132 +1,132 @@
MIN_VALUE = -99 MIN_VALUE = -99
MAX_VALUE = 999 MAX_VALUE = 999
function onload(saved_data) function onload(saved_data)
light_mode = false light_mode = false
val = 0 val = 0
if saved_data ~= "" then if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1] light_mode = loaded_data[1]
val = loaded_data[2] val = loaded_data[2]
end end
createAll() createAll()
end end
function updateSave() function updateSave()
local data_to_save = {light_mode, val} local data_to_save = {light_mode, val}
saved_data = JSON.encode(data_to_save) saved_data = JSON.encode(data_to_save)
self.script_state = saved_data self.script_state = saved_data
end end
function createAll() function createAll()
s_color = {0.5, 0.5, 0.5, 95} s_color = {0.5, 0.5, 0.5, 95}
if light_mode then if light_mode then
f_color = {0,0,0,98} f_color = {0,0,0,98}
else else
f_color = {0,0,0,100} f_color = {0,0,0,100}
end end
self.createButton({ self.createButton({
label=tostring(val), label=tostring(val),
click_function="add_subtract", click_function="add_subtract",
function_owner=self, function_owner=self,
position={0,0.05,1.45}, position={0,0.05,1.45},
height=600, height=600,
width=1000, width=1000,
alignment = 3, alignment = 3,
scale={x=1, y=1, z=1}, scale={x=1, y=1, z=1},
font_size=350, font_size=350,
font_color=f_color, font_color=f_color,
color={0,0,0,0} color={0,0,0,0}
}) })
if light_mode then if light_mode then
lightButtonText = "[ Set dark ]" lightButtonText = "[ Set dark ]"
else else
lightButtonText = "[ Set light ]" lightButtonText = "[ Set light ]"
end end
end end
function removeAll() function removeAll()
self.removeInput(0) self.removeInput(0)
self.removeInput(1) self.removeInput(1)
self.removeButton(0) self.removeButton(0)
self.removeButton(1) self.removeButton(1)
self.removeButton(2) self.removeButton(2)
end end
function reloadAll() function reloadAll()
removeAll() removeAll()
createAll() createAll()
updateSave() updateSave()
end end
function swap_fcolor(_obj, _color, alt_click) function swap_fcolor(_obj, _color, alt_click)
light_mode = not light_mode light_mode = not light_mode
reloadAll() reloadAll()
end end
function swap_align(_obj, _color, alt_click) function swap_align(_obj, _color, alt_click)
center_mode = not center_mode center_mode = not center_mode
reloadAll() reloadAll()
end end
function editName(_obj, _string, value) function editName(_obj, _string, value)
self.setName(value) self.setName(value)
setTooltips() setTooltips()
end end
function add_subtract(_obj, _color, alt_click) function add_subtract(_obj, _color, alt_click)
mod = alt_click and -1 or 1 mod = alt_click and -1 or 1
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE) new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE)
if val ~= new_value then if val ~= new_value then
val = new_value val = new_value
updateVal() updateVal()
updateSave() updateSave()
end end
end end
function updateVal() function updateVal()
self.editButton({ self.editButton({
index = 0, index = 0,
label = tostring(val), label = tostring(val),
}) })
end end
function reset_val() function reset_val()
val = 0 val = 0
updateVal() updateVal()
updateSave() updateSave()
end end
function setTooltips() function setTooltips()
self.editInput({ self.editInput({
index = 0, index = 0,
value = self.getName(), value = self.getName(),
tooltip = ttText tooltip = ttText
}) })
self.editButton({ self.editButton({
index = 0, index = 0,
value = tostring(val), value = tostring(val),
tooltip = ttText tooltip = ttText
}) })
end end
function null() function null()
end end
function keepSample(_obj, _string, value) function keepSample(_obj, _string, value)
reloadAll() reloadAll()
end end

View File

@ -1,132 +1,132 @@
MIN_VALUE = -99 MIN_VALUE = -99
MAX_VALUE = 999 MAX_VALUE = 999
function onload(saved_data) function onload(saved_data)
light_mode = false light_mode = false
val = 0 val = 0
if saved_data ~= "" then if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1] light_mode = loaded_data[1]
val = loaded_data[2] val = loaded_data[2]
end end
createAll() createAll()
end end
function updateSave() function updateSave()
local data_to_save = {light_mode, val} local data_to_save = {light_mode, val}
saved_data = JSON.encode(data_to_save) saved_data = JSON.encode(data_to_save)
self.script_state = saved_data self.script_state = saved_data
end end
function createAll() function createAll()
s_color = {0.5, 0.5, 0.5, 95} s_color = {0.5, 0.5, 0.5, 95}
if light_mode then if light_mode then
f_color = {0,0,0,98} f_color = {0,0,0,98}
else else
f_color = {0,0,0,100} f_color = {0,0,0,100}
end end
self.createButton({ self.createButton({
label=tostring(val), label=tostring(val),
click_function="add_subtract", click_function="add_subtract",
function_owner=self, function_owner=self,
position={0,0.05,1.45}, position={0,0.05,1.45},
height=600, height=600,
width=1000, width=1000,
alignment = 3, alignment = 3,
scale={x=1, y=1, z=1}, scale={x=1, y=1, z=1},
font_size=350, font_size=350,
font_color=f_color, font_color=f_color,
color={0,0,0,0} color={0,0,0,0}
}) })
if light_mode then if light_mode then
lightButtonText = "[ Set dark ]" lightButtonText = "[ Set dark ]"
else else
lightButtonText = "[ Set light ]" lightButtonText = "[ Set light ]"
end end
end end
function removeAll() function removeAll()
self.removeInput(0) self.removeInput(0)
self.removeInput(1) self.removeInput(1)
self.removeButton(0) self.removeButton(0)
self.removeButton(1) self.removeButton(1)
self.removeButton(2) self.removeButton(2)
end end
function reloadAll() function reloadAll()
removeAll() removeAll()
createAll() createAll()
updateSave() updateSave()
end end
function swap_fcolor(_obj, _color, alt_click) function swap_fcolor(_obj, _color, alt_click)
light_mode = not light_mode light_mode = not light_mode
reloadAll() reloadAll()
end end
function swap_align(_obj, _color, alt_click) function swap_align(_obj, _color, alt_click)
center_mode = not center_mode center_mode = not center_mode
reloadAll() reloadAll()
end end
function editName(_obj, _string, value) function editName(_obj, _string, value)
self.setName(value) self.setName(value)
setTooltips() setTooltips()
end end
function add_subtract(_obj, _color, alt_click) function add_subtract(_obj, _color, alt_click)
mod = alt_click and -1 or 1 mod = alt_click and -1 or 1
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE) new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE)
if val ~= new_value then if val ~= new_value then
val = new_value val = new_value
updateVal() updateVal()
updateSave() updateSave()
end end
end end
function updateVal() function updateVal()
self.editButton({ self.editButton({
index = 0, index = 0,
label = tostring(val), label = tostring(val),
}) })
end end
function reset_val() function reset_val()
val = 0 val = 0
updateVal() updateVal()
updateSave() updateSave()
end end
function setTooltips() function setTooltips()
self.editInput({ self.editInput({
index = 0, index = 0,
value = self.getName(), value = self.getName(),
tooltip = ttText tooltip = ttText
}) })
self.editButton({ self.editButton({
index = 0, index = 0,
value = tostring(val), value = tostring(val),
tooltip = ttText tooltip = ttText
}) })
end end
function null() function null()
end end
function keepSample(_obj, _string, value) function keepSample(_obj, _string, value)
reloadAll() reloadAll()
end end

View File

@ -1,132 +1,132 @@
MIN_VALUE = -99 MIN_VALUE = -99
MAX_VALUE = 999 MAX_VALUE = 999
function onload(saved_data) function onload(saved_data)
light_mode = false light_mode = false
val = 0 val = 0
if saved_data ~= "" then if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1] light_mode = loaded_data[1]
val = loaded_data[2] val = loaded_data[2]
end end
createAll() createAll()
end end
function updateSave() function updateSave()
local data_to_save = {light_mode, val} local data_to_save = {light_mode, val}
saved_data = JSON.encode(data_to_save) saved_data = JSON.encode(data_to_save)
self.script_state = saved_data self.script_state = saved_data
end end
function createAll() function createAll()
s_color = {0.5, 0.5, 0.5, 95} s_color = {0.5, 0.5, 0.5, 95}
if light_mode then if light_mode then
f_color = {0,0,0,98} f_color = {0,0,0,98}
else else
f_color = {0,0,0,100} f_color = {0,0,0,100}
end end
self.createButton({ self.createButton({
label=tostring(val), label=tostring(val),
click_function="add_subtract", click_function="add_subtract",
function_owner=self, function_owner=self,
position={0,0.05,1.45}, position={0,0.05,1.45},
height=600, height=600,
width=1000, width=1000,
alignment = 3, alignment = 3,
scale={x=1, y=1, z=1}, scale={x=1, y=1, z=1},
font_size=350, font_size=350,
font_color=f_color, font_color=f_color,
color={0,0,0,0} color={0,0,0,0}
}) })
if light_mode then if light_mode then
lightButtonText = "[ Set dark ]" lightButtonText = "[ Set dark ]"
else else
lightButtonText = "[ Set light ]" lightButtonText = "[ Set light ]"
end end
end end
function removeAll() function removeAll()
self.removeInput(0) self.removeInput(0)
self.removeInput(1) self.removeInput(1)
self.removeButton(0) self.removeButton(0)
self.removeButton(1) self.removeButton(1)
self.removeButton(2) self.removeButton(2)
end end
function reloadAll() function reloadAll()
removeAll() removeAll()
createAll() createAll()
updateSave() updateSave()
end end
function swap_fcolor(_obj, _color, alt_click) function swap_fcolor(_obj, _color, alt_click)
light_mode = not light_mode light_mode = not light_mode
reloadAll() reloadAll()
end end
function swap_align(_obj, _color, alt_click) function swap_align(_obj, _color, alt_click)
center_mode = not center_mode center_mode = not center_mode
reloadAll() reloadAll()
end end
function editName(_obj, _string, value) function editName(_obj, _string, value)
self.setName(value) self.setName(value)
setTooltips() setTooltips()
end end
function add_subtract(_obj, _color, alt_click) function add_subtract(_obj, _color, alt_click)
mod = alt_click and -1 or 1 mod = alt_click and -1 or 1
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE) new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE)
if val ~= new_value then if val ~= new_value then
val = new_value val = new_value
updateVal() updateVal()
updateSave() updateSave()
end end
end end
function updateVal() function updateVal()
self.editButton({ self.editButton({
index = 0, index = 0,
label = tostring(val), label = tostring(val),
}) })
end end
function reset_val() function reset_val()
val = 0 val = 0
updateVal() updateVal()
updateSave() updateSave()
end end
function setTooltips() function setTooltips()
self.editInput({ self.editInput({
index = 0, index = 0,
value = self.getName(), value = self.getName(),
tooltip = ttText tooltip = ttText
}) })
self.editButton({ self.editButton({
index = 0, index = 0,
value = tostring(val), value = tostring(val),
tooltip = ttText tooltip = ttText
}) })
end end
function null() function null()
end end
function keepSample(_obj, _string, value) function keepSample(_obj, _string, value)
reloadAll() reloadAll()
end end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +1,21 @@
name = 'The Dunwich Legacy' name = 'The Dunwich Legacy'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end

View File

@ -1,21 +1,21 @@
name = 'The Dunwich Legacy' name = 'The Dunwich Legacy'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end

View File

@ -1,25 +1,25 @@
name = 'The Miskatonic Museum' name = 'The Miskatonic Museum'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end
function standaloneClick() function standaloneClick()
Global.call('fillContainer', {object=self, key=name, mode='standalone'}) Global.call('fillContainer', {object=self, key=name, mode='standalone'})
end end

View File

@ -1,25 +1,25 @@
name = 'The Essex County Express' name = 'The Essex County Express'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end
function standaloneClick() function standaloneClick()
Global.call('fillContainer', {object=self, key=name, mode='standalone'}) Global.call('fillContainer', {object=self, key=name, mode='standalone'})
end end

View File

@ -1,25 +1,25 @@
name = 'Blood on the Altar' name = 'Blood on the Altar'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end
function standaloneClick() function standaloneClick()
Global.call('fillContainer', {object=self, key=name, mode='standalone'}) Global.call('fillContainer', {object=self, key=name, mode='standalone'})
end end

View File

@ -1,25 +1,25 @@
name = 'Undimensioned and Unseen' name = 'Undimensioned and Unseen'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end
function standaloneClick() function standaloneClick()
Global.call('fillContainer', {object=self, key=name, mode='standalone'}) Global.call('fillContainer', {object=self, key=name, mode='standalone'})
end end

View File

@ -1,25 +1,25 @@
name = 'Where Doom Awaits' name = 'Where Doom Awaits'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end
function standaloneClick() function standaloneClick()
Global.call('fillContainer', {object=self, key=name, mode='standalone'}) Global.call('fillContainer', {object=self, key=name, mode='standalone'})
end end

View File

@ -1,25 +1,25 @@
name = 'Lost in Time and Space' name = 'Lost in Time and Space'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end
function standaloneClick() function standaloneClick()
Global.call('fillContainer', {object=self, key=name, mode='standalone'}) Global.call('fillContainer', {object=self, key=name, mode='standalone'})
end end

View File

@ -1,21 +1,21 @@
name = 'The Forgotten Age' name = 'The Forgotten Age'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end

View File

@ -1,25 +1,25 @@
name = 'The Doom of Eztli' name = 'The Doom of Eztli'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end
function standaloneClick() function standaloneClick()
Global.call('fillContainer', {object=self, key=name, mode='standalone'}) Global.call('fillContainer', {object=self, key=name, mode='standalone'})
end end

View File

@ -1,25 +1,25 @@
name = 'Threads of Fate' name = 'Threads of Fate'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end
function standaloneClick() function standaloneClick()
Global.call('fillContainer', {object=self, key=name, mode='standalone'}) Global.call('fillContainer', {object=self, key=name, mode='standalone'})
end end

View File

@ -1,25 +1,25 @@
name = 'The Boundary Beyond' name = 'The Boundary Beyond'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end
function standaloneClick() function standaloneClick()
Global.call('fillContainer', {object=self, key=name, mode='standalone'}) Global.call('fillContainer', {object=self, key=name, mode='standalone'})
end end

View File

@ -1,25 +1,25 @@
name = 'Heart of the Elders' name = 'Heart of the Elders'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end
function standaloneClick() function standaloneClick()
Global.call('fillContainer', {object=self, key=name, mode='standalone'}) Global.call('fillContainer', {object=self, key=name, mode='standalone'})
end end

View File

@ -1,25 +1,25 @@
name = 'The City of Archives' name = 'The City of Archives'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end
function standaloneClick() function standaloneClick()
Global.call('fillContainer', {object=self, key=name, mode='standalone'}) Global.call('fillContainer', {object=self, key=name, mode='standalone'})
end end

View File

@ -1,25 +1,25 @@
name = 'The Depths of Yoth' name = 'The Depths of Yoth'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end
function standaloneClick() function standaloneClick()
Global.call('fillContainer', {object=self, key=name, mode='standalone'}) Global.call('fillContainer', {object=self, key=name, mode='standalone'})
end end

View File

@ -1,132 +1,132 @@
MIN_VALUE = -99 MIN_VALUE = -99
MAX_VALUE = 999 MAX_VALUE = 999
function onload(saved_data) function onload(saved_data)
light_mode = false light_mode = false
val = 0 val = 0
if saved_data ~= "" then if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1] light_mode = loaded_data[1]
val = loaded_data[2] val = loaded_data[2]
end end
createAll() createAll()
end end
function updateSave() function updateSave()
local data_to_save = {light_mode, val} local data_to_save = {light_mode, val}
saved_data = JSON.encode(data_to_save) saved_data = JSON.encode(data_to_save)
self.script_state = saved_data self.script_state = saved_data
end end
function createAll() function createAll()
s_color = {0.5, 0.5, 0.5, 95} s_color = {0.5, 0.5, 0.5, 95}
if light_mode then if light_mode then
f_color = {0,0,0,98} f_color = {0,0,0,98}
else else
f_color = {0,0,0,100} f_color = {0,0,0,100}
end end
self.createButton({ self.createButton({
label=tostring(val), label=tostring(val),
click_function="add_subtract", click_function="add_subtract",
function_owner=self, function_owner=self,
position={0,0.05,1.45}, position={0,0.05,1.45},
height=600, height=600,
width=1000, width=1000,
alignment = 3, alignment = 3,
scale={x=1, y=1, z=1}, scale={x=1, y=1, z=1},
font_size=350, font_size=350,
font_color=f_color, font_color=f_color,
color={0,0,0,0} color={0,0,0,0}
}) })
if light_mode then if light_mode then
lightButtonText = "[ Set dark ]" lightButtonText = "[ Set dark ]"
else else
lightButtonText = "[ Set light ]" lightButtonText = "[ Set light ]"
end end
end end
function removeAll() function removeAll()
self.removeInput(0) self.removeInput(0)
self.removeInput(1) self.removeInput(1)
self.removeButton(0) self.removeButton(0)
self.removeButton(1) self.removeButton(1)
self.removeButton(2) self.removeButton(2)
end end
function reloadAll() function reloadAll()
removeAll() removeAll()
createAll() createAll()
updateSave() updateSave()
end end
function swap_fcolor(_obj, _color, alt_click) function swap_fcolor(_obj, _color, alt_click)
light_mode = not light_mode light_mode = not light_mode
reloadAll() reloadAll()
end end
function swap_align(_obj, _color, alt_click) function swap_align(_obj, _color, alt_click)
center_mode = not center_mode center_mode = not center_mode
reloadAll() reloadAll()
end end
function editName(_obj, _string, value) function editName(_obj, _string, value)
self.setName(value) self.setName(value)
setTooltips() setTooltips()
end end
function add_subtract(_obj, _color, alt_click) function add_subtract(_obj, _color, alt_click)
mod = alt_click and -1 or 1 mod = alt_click and -1 or 1
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE) new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE)
if val ~= new_value then if val ~= new_value then
val = new_value val = new_value
updateVal() updateVal()
updateSave() updateSave()
end end
end end
function updateVal() function updateVal()
self.editButton({ self.editButton({
index = 0, index = 0,
label = tostring(val), label = tostring(val),
}) })
end end
function reset_val() function reset_val()
val = 0 val = 0
updateVal() updateVal()
updateSave() updateSave()
end end
function setTooltips() function setTooltips()
self.editInput({ self.editInput({
index = 0, index = 0,
value = self.getName(), value = self.getName(),
tooltip = ttText tooltip = ttText
}) })
self.editButton({ self.editButton({
index = 0, index = 0,
value = tostring(val), value = tostring(val),
tooltip = ttText tooltip = ttText
}) })
end end
function null() function null()
end end
function keepSample(_obj, _string, value) function keepSample(_obj, _string, value)
reloadAll() reloadAll()
end end

View File

@ -1,132 +1,132 @@
MIN_VALUE = -99 MIN_VALUE = -99
MAX_VALUE = 999 MAX_VALUE = 999
function onload(saved_data) function onload(saved_data)
light_mode = false light_mode = false
val = 0 val = 0
if saved_data ~= "" then if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1] light_mode = loaded_data[1]
val = loaded_data[2] val = loaded_data[2]
end end
createAll() createAll()
end end
function updateSave() function updateSave()
local data_to_save = {light_mode, val} local data_to_save = {light_mode, val}
saved_data = JSON.encode(data_to_save) saved_data = JSON.encode(data_to_save)
self.script_state = saved_data self.script_state = saved_data
end end
function createAll() function createAll()
s_color = {0.5, 0.5, 0.5, 95} s_color = {0.5, 0.5, 0.5, 95}
if light_mode then if light_mode then
f_color = {0,0,0,98} f_color = {0,0,0,98}
else else
f_color = {0,0,0,100} f_color = {0,0,0,100}
end end
self.createButton({ self.createButton({
label=tostring(val), label=tostring(val),
click_function="add_subtract", click_function="add_subtract",
function_owner=self, function_owner=self,
position={0,0.05,1.45}, position={0,0.05,1.45},
height=600, height=600,
width=1000, width=1000,
alignment = 3, alignment = 3,
scale={x=1, y=1, z=1}, scale={x=1, y=1, z=1},
font_size=350, font_size=350,
font_color=f_color, font_color=f_color,
color={0,0,0,0} color={0,0,0,0}
}) })
if light_mode then if light_mode then
lightButtonText = "[ Set dark ]" lightButtonText = "[ Set dark ]"
else else
lightButtonText = "[ Set light ]" lightButtonText = "[ Set light ]"
end end
end end
function removeAll() function removeAll()
self.removeInput(0) self.removeInput(0)
self.removeInput(1) self.removeInput(1)
self.removeButton(0) self.removeButton(0)
self.removeButton(1) self.removeButton(1)
self.removeButton(2) self.removeButton(2)
end end
function reloadAll() function reloadAll()
removeAll() removeAll()
createAll() createAll()
updateSave() updateSave()
end end
function swap_fcolor(_obj, _color, alt_click) function swap_fcolor(_obj, _color, alt_click)
light_mode = not light_mode light_mode = not light_mode
reloadAll() reloadAll()
end end
function swap_align(_obj, _color, alt_click) function swap_align(_obj, _color, alt_click)
center_mode = not center_mode center_mode = not center_mode
reloadAll() reloadAll()
end end
function editName(_obj, _string, value) function editName(_obj, _string, value)
self.setName(value) self.setName(value)
setTooltips() setTooltips()
end end
function add_subtract(_obj, _color, alt_click) function add_subtract(_obj, _color, alt_click)
mod = alt_click and -1 or 1 mod = alt_click and -1 or 1
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE) new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE)
if val ~= new_value then if val ~= new_value then
val = new_value val = new_value
updateVal() updateVal()
updateSave() updateSave()
end end
end end
function updateVal() function updateVal()
self.editButton({ self.editButton({
index = 0, index = 0,
label = tostring(val), label = tostring(val),
}) })
end end
function reset_val() function reset_val()
val = 0 val = 0
updateVal() updateVal()
updateSave() updateSave()
end end
function setTooltips() function setTooltips()
self.editInput({ self.editInput({
index = 0, index = 0,
value = self.getName(), value = self.getName(),
tooltip = ttText tooltip = ttText
}) })
self.editButton({ self.editButton({
index = 0, index = 0,
value = tostring(val), value = tostring(val),
tooltip = ttText tooltip = ttText
}) })
end end
function null() function null()
end end
function keepSample(_obj, _string, value) function keepSample(_obj, _string, value)
reloadAll() reloadAll()
end end

View File

@ -1,21 +1,21 @@
name = 'Shattered Aeons' name = 'Shattered Aeons'
function onLoad() function onLoad()
Global.call('createSetupButtons', {object=self, key=name}) Global.call('createSetupButtons', {object=self, key=name})
end end
function easyClick() function easyClick()
Global.call('fillContainer', {object=self, key=name, mode='easy'}) Global.call('fillContainer', {object=self, key=name, mode='easy'})
end end
function normalClick() function normalClick()
Global.call('fillContainer', {object=self, key=name, mode='normal'}) Global.call('fillContainer', {object=self, key=name, mode='normal'})
end end
function hardClick() function hardClick()
Global.call('fillContainer', {object=self, key=name, mode='hard'}) Global.call('fillContainer', {object=self, key=name, mode='hard'})
end end
function expertClick() function expertClick()
Global.call('fillContainer', {object=self, key=name, mode='expert'}) Global.call('fillContainer', {object=self, key=name, mode='expert'})
end end

Some files were not shown because too many files have changed in this diff Show More