diff --git a/config.json b/config.json index 0cd2293c..1335be54 100644 --- a/config.json +++ b/config.json @@ -154,7 +154,7 @@ "ChaosBagStatTracker.766620", "Blesstokens.afa06b", "Cursetokens.bd0253", - "WhimsicalsTokenRemover.0a5a29", + "TokenRemover.0a5a29", "TokenSpawner.36b4ee", "Fan-MadeScenariosCampaignsMiscellany.66e97c", "OfficialStandaloneChallengeScenarios.0ef5c8", diff --git a/modsettings/TabStates.json b/modsettings/TabStates.json index 7b9e9a7c..14d7babc 100644 --- a/modsettings/TabStates.json +++ b/modsettings/TabStates.json @@ -1,6 +1,6 @@ { "10": { - "body": "Created by Whimsical\n\nAnything that passes over the remover that isn't a card or a deck will be deleted.\r\nTo use the remover, right click on it, choose the \"Enable\" option, and take your card with resources/horror/damage and swipe it over the remover. You may wish to unlock and/or copy the remover to your play area first.", + "body": "Created by Whimsical\n\nAnything that passes over the remover that isn't a card, deck or chaos token will be deleted.\r\nTo use the remover, right click on it, choose the \"Enable\" option, and take your card with resources/horror/damage and swipe it over the remover. You may wish to unlock and/or copy the remover to your play area first.", "color": "Grey", "id": 10, "title": "Token Remover", diff --git a/objects/WhimsicalsTokenRemover.0a5a29.json b/objects/TokenRemover.0a5a29.json similarity index 86% rename from objects/WhimsicalsTokenRemover.0a5a29.json rename to objects/TokenRemover.0a5a29.json index 3778f096..cc3be20c 100644 --- a/objects/WhimsicalsTokenRemover.0a5a29.json +++ b/objects/TokenRemover.0a5a29.json @@ -14,7 +14,7 @@ "CustomTile": { "Stackable": false, "Stretch": true, - "Thickness": 0.2, + "Thickness": 0.1, "Type": 0 }, "ImageScalar": 1, @@ -34,10 +34,10 @@ "LayoutGroupSortIndex": 0, "Locked": false, "LuaScript": "require(\"util/TokenRemover\")", - "LuaScriptState": "[]", + "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Tile", - "Nickname": "Whimsical's Token Remover", + "Nickname": "Token Remover", "Snap": true, "Sticky": true, "Tags": [ @@ -45,16 +45,16 @@ ], "Tooltip": true, "Transform": { - "posX": -6.868, + "posX": -7, "posY": 1.583, - "posZ": -16.394, + "posZ": -16.4, "rotX": 0, "rotY": 90, "rotZ": 0, - "scaleX": 0.75, + "scaleX": 0.8, "scaleY": 1, - "scaleZ": 0.75 + "scaleZ": 0.8 }, "Value": 0, "XmlUI": "" -} +} \ No newline at end of file diff --git a/src/util/TokenRemover.ttslua b/src/util/TokenRemover.ttslua index 9ed755f9..859808a4 100644 --- a/src/util/TokenRemover.ttslua +++ b/src/util/TokenRemover.ttslua @@ -1,72 +1,80 @@ ---- ---- Generated by EmmyLua(https://github.com/EmmyLua) ---- Created by Whimsical. ---- DateTime: 2021-02-02 9:41 a.m. ---- - local zone = nil +local CHAOS_TOKEN_NAMES = { + "Elder Sign", + "+1", + "0", + "-1", + "-2", + "-3", + "-4", + "-5", + "-6", + "-7", + "-8", + "Skull", + "Cultist", + "Tablet", + "Elder Thing", + "Auto-fail", + "Bless", + "Curse", + "Frost" +} --- Forward Declaration ----@param is_enabled boolean -local setMenu = function(is_enabled) end - -local function enable() - if self.held_by_color~=nil then return end - local position = self:getPosition() - local rotation = self:getRotation() - local scale = self:getScale() - - zone = spawnObject { - type = "ScriptingTrigger", - position = Vector(position.x, position.y+25+(bit32.rshift(scale.y, 1))+0.41, position.z), - rotation = rotation, - scale = Vector(scale.x*2, 50, scale.z*2), - sound = true, - snap_to_grid = true - } - - setMenu(false) -end - -local function disable() - if zone~=nil then zone:destruct() end - setMenu(true) -end - ----@param is_enabled boolean -setMenu = function(is_enabled) - self:clearContextMenu() - if is_enabled then - self:addContextMenuItem("Enable", enable, false) - else - self:addContextMenuItem("Disable", disable, false) - end -end - -function onLoad(save_state) - if save_state=="" then return end - local data = JSON.decode(save_state) - zone = getObjectFromGUID(data.zone) - setMenu(zone==nil) -end - +-- general code function onSave() - return JSON.encode { - zone = zone and zone:getGUID() or nil - } + return JSON.encode(zone and zone.getGUID() or nil) end ----@param entering TTSObject ----@param object TTSObject -function onObjectEnterScriptingZone(entering , object) - if zone~=entering then return end - if object==self then return end - if object.type=="Deck" or object.type=="Card" then return end - - object:destruct() +function onLoad(savedData) + if savedData ~= "" and savedData ~= nil then + zone = getObjectFromGUID(JSON.decode(savedData)) + end + setMenu(zone == nil) end ----@param color string -function onPickUp(color) - disable() +-- 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 or object == self or object.type == "Deck" or object.type == "Card" then + return + end + + local name = object.getName() + for _, entry in ipairs(CHAOS_TOKEN_NAMES) do + if entry == name then return end + end + + object.destruct() +end + +function onPickUp() + disable() end