Merge pull request #25 from argonui/globalscript

updated global script
This commit is contained in:
Chr1Z 2022-11-15 12:15:53 +01:00 committed by GitHub
commit c88c185950
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 400 additions and 745 deletions

View File

@ -1,103 +1,10 @@
function onload(saved_data) -- button calls respective function in "Global"
light_mode = false function onLoad()
if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data)
light_mode = loaded_data[1]
end
createAll()
end
-- functions delegated to Global
function printStats(object, player, isRightClick)
-- local toPosition = self.positionToWorld(DRAWN_CHAOS_TOKEN_OFFSET)
if isRightClick then
Global.call("resetStats")
else
Global.call("printStats")
end
end
function updateSave()
local data_to_save = {light_mode }
saved_data = JSON.encode(data_to_save)
self.script_state = saved_data
end
function createAll()
s_color = {0.5, 0.5, 0.5, 95}
if light_mode then
f_color = {1,1,1,95}
else
f_color = {0,0,0,100}
end
self.createButton({ self.createButton({
click_function="printStats", click_function = "handleStatTrackerClick",
function_owner=self, tooltip = "Left-Click: Print stats\nRight-Click: Reset stats",
position={0,0.05,0}, height = 1250,
height=600, width = 1250,
width=1000, color = { 0, 0, 0, 0 }
alignment = 3,
tooltip = "Left Click to print stats. Right Click to reset them.",
scale={x=1.5, y=1.5, z=1.5},
font_size=600,
font_color=f_color,
color={0,0,0,0}
})
if light_mode then
lightButtonText = "[ Set dark ]"
else
lightButtonText = "[ Set light ]"
end
end
function removeAll()
self.removeInput(0)
self.removeInput(1)
self.removeButton(0)
self.removeButton(1)
self.removeButton(2)
end
function reloadAll()
removeAll()
createAll()
updateSave()
end
function swap_fcolor(_obj, _color, alt_click)
light_mode = not light_mode
reloadAll()
end
function swap_align(_obj, _color, alt_click)
center_mode = not center_mode
reloadAll()
end
function editName(_obj, _string, value)
self.setName(value)
setTooltips()
end
function setTooltips()
self.editInput({
index = 0,
value = self.getName(),
tooltip = "Left click to show stats. Right click to reset them."
}) })
end end
function keepSample(_obj, _string, value)
reloadAll()
end
function onDestroy()
if timerID and type(timerID) == 'object' then
Timer.destroy(timerID)
end
end

File diff suppressed because it is too large Load Diff