ah_sce_unpacked/unpacked/Custom_Tile Token Remover 0a5a29.ttslua
2023-01-29 19:31:52 -05:00

139 lines
3.3 KiB
Plaintext

-- Bundled by luabundle {"version":"1.6.0"}
local __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)
local loadingPlaceholder = {[{}] = true}
local register
local modules = {}
local require
local loaded = {}
register = function(name, body)
if not modules[name] then
modules[name] = body
end
end
require = function(name)
local loadedModule = loaded[name]
if loadedModule then
if loadedModule == loadingPlaceholder then
return nil
end
else
if not modules[name] then
if not superRequire then
local identifier = type(name) == 'string' and '\"' .. name .. '\"' or tostring(name)
error('Tried to require ' .. identifier .. ', but no such module has been registered')
else
return superRequire(name)
end
end
loaded[name] = loadingPlaceholder
loadedModule = modules[name](require, loaded, register, modules)
loaded[name] = loadedModule
end
return loadedModule
end
return require, loaded, register, modules
end)(nil)
__bundle_register("__root", function(require, _LOADED, __bundle_register, __bundle_modules)
require("util/TokenRemover")
end)
__bundle_register("util/TokenRemover", function(require, _LOADED, __bundle_register, __bundle_modules)
local zone = nil
local tokenChecker = require("core/token/TokenChecker")
-- general code
function onSave()
return JSON.encode(zone and zone.getGUID() or nil)
end
function onLoad(savedData)
if savedData ~= "" and savedData ~= nil then
zone = getObjectFromGUID(JSON.decode(savedData))
end
setMenu(zone == nil)
end
-- context menu functions
function enable()
local scale = self.getScale()
zone = spawnObject({
type = "ScriptingTrigger",
position = self.getPosition() + Vector(0, 2.5 + 0.11, 0),
rotation = self.getRotation(),
scale = { scale.x * 2, 5, scale.z * 2 }
})
setMenu(false)
end
function disable()
if zone ~= nil then zone.destruct() end
setMenu(true)
end
-- core functions
function setMenu(isEnabled)
self.clearContextMenu()
if isEnabled then
self.addContextMenuItem("Enable", enable)
else
self.addContextMenuItem("Disable", disable)
end
end
function onObjectEnterScriptingZone(entering, object)
if zone ~= entering then return end
if object == self or object.type == "Deck" or object.type == "Card" then return end
if tokenChecker.isChaosToken(object) then return end
object.destruct()
end
function onPickUp()
disable()
end
end)
__bundle_register("core/token/TokenChecker", function(require, _LOADED, __bundle_register, __bundle_modules)
do
local CHAOS_TOKEN_NAMES = {
["Elder Sign"] = true,
["+1"] = true,
["0"] = true,
["-1"] = true,
["-2"] = true,
["-3"] = true,
["-4"] = true,
["-5"] = true,
["-6"] = true,
["-7"] = true,
["-8"] = true,
["Skull"] = true,
["Cultist"] = true,
["Tablet"] = true,
["Elder Thing"] = true,
["Auto-fail"] = true,
["Bless"] = true,
["Curse"] = true,
["Frost"] = true
}
local TokenChecker = {}
-- returns true if the passed object is a chaos token (by name)
TokenChecker.isChaosToken = function(obj)
if CHAOS_TOKEN_NAMES[obj.getName()] then
return true
else
return false
end
end
return TokenChecker
end
end)
return __bundle_require("__root")