Skip to content

Commit

Permalink
Merge pull request #139 from pyrrhicPachyderm/delete-buttons
Browse files Browse the repository at this point in the history
Make buttons on power/event/fear cards remove only themselves.
  • Loading branch information
iakona authored Oct 21, 2023
2 parents f39c803 + 67c07cb commit d9dbe28
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ function onLoad()
end
function noHeal(card)
Global.setVar("noHealInvader", true)
card.clearButtons()
Global.call("removeButtons", {obj = card, click_function = "noHeal", function_owner = self})
end
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ function onLoad()
end
function returnFear(card)
Global.getVar("aidBoard").call("fearCard", { earned = false })
self.clearButtons()
Global.call("removeButtons", {obj = card, click_function = "returnFear", function_owner = self})
end
2 changes: 1 addition & 1 deletion objects/BnCBag/contained/cfd4d1/object.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"Type": 0
}
},
"LuaScript": "function onLoad()\n self.createButton({\n click_function = \"returnFear\",\n function_owner = self,\n label = \"Add Fear Card\",\n position = Vector(0,0.3,1.43),\n width = 1200,\n scale = Vector(0.65,1,0.65),\n height = 160,\n font_size = 150,\n tooltip = \"Add Fear Card\"\n })\nend\nfunction returnFear(card)\n Global.call(\"addFearCard\", {})\n self.clearButtons()\nend",
"LuaScript": "function onLoad()\n self.createButton({\n click_function = \"returnFear\",\n function_owner = self,\n label = \"Add Fear Card\",\n position = Vector(0,0.3,1.43),\n width = 1200,\n scale = Vector(0.65,1,0.65),\n height = 160,\n font_size = 150,\n tooltip = \"Add Fear Card\"\n })\nend\nfunction returnFear(card)\n Global.call(\"addFearCard\", {})\n Global.call(\"removeButtons\", {obj = card, click_function = \"returnFear\", function_owner = self})\nend",
"LuaScriptState": "",
"XmlUI": ""
}
Expand Down
2 changes: 1 addition & 1 deletion objects/BnCBag/contained/cfd4d1/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ function onLoad()
end
function returnFear(card)
Global.call("addFearCard", {})
self.clearButtons()
Global.call("removeButtons", {obj = card, click_function = "returnFear", function_owner = self})
end
2 changes: 1 addition & 1 deletion objects/JEBag/contained/299e38/contained/6d14c5/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ function grabReminder(card)
position = card.getPosition() + Vector(0, 1, 0),
rotation = Vector(0, 180, 0)
})
card.clearButtons()
Global.call("removeButtons", {obj = card, click_function = "grabReminder", function_owner = self})
end
2 changes: 1 addition & 1 deletion objects/JEBag/contained/299e38/contained/86c840/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ function removeCards(card)
end
end
end
card.clearButtons()
Global.call("removeButtons", {obj = card, click_function = "removeCards", function_owner = self})
end
2 changes: 1 addition & 1 deletion objects/JEBag/contained/299e38/contained/b7ac93/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ function onLoad()
end
function noFear(card)
Global.setVar("noFear", true)
card.clearButtons()
Global.call("removeButtons", {obj = card, click_function = "noFear", function_owner = self})
end
2 changes: 1 addition & 1 deletion objects/JEBag/contained/299e38/contained/c5a72e/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ function grabReminder(card)
position = card.getPosition() + Vector(0, 1, 0),
rotation = Vector(0, 180, 0)
})
card.clearButtons()
Global.call("removeButtons", {obj = card, click_function = "grabReminder", function_owner = self})
end
2 changes: 1 addition & 1 deletion objects/JEBag/contained/98a916/contained/bab312/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ function grabReminder(card)
position = card.getPosition() + Vector(0, 1, 0),
rotation = Vector(0, 180, 0)
})
card.clearButtons()
Global.call("removeButtons", {obj = card, click_function = "grabReminder", function_owner = self})
end
2 changes: 1 addition & 1 deletion objects/JEBag/contained/98a916/contained/d45b0d/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ function grabReminder(card)
position = card.getPosition() + Vector(0, 1, 0),
rotation = Vector(0, 180, 0)
})
card.clearButtons()
Global.call("removeButtons", {obj = card, click_function = "grabReminder", function_owner = self})
end
23 changes: 23 additions & 0 deletions script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2285,6 +2285,29 @@ function isObjectInHand(obj)
return false
end

function removeButtons(params)
-- "params" is a table containing "obj", plus any number of other parameters
-- Removes buttons on obj with parameters matching all the other parameters given in params
-- "label" and "click_function" are the most likely parameters to match by
local obj = params.obj
params.obj = nil

-- Iterate over buttons in reverse order, so that removals do not change indices
local buttons = obj.getButtons()
for i = #buttons,1,-1 do
local match = true
for key,val in pairs(params) do
if buttons[i][key] ~= val then
match = false
break
end
end
if match then
obj.removeButton(buttons[i].index)
end
end
end

function getPowerZoneObjects(handP)
local hits = upCastPosSizRot(
handOffset + handP, -- pos
Expand Down

0 comments on commit d9dbe28

Please sign in to comment.