Tabletop Simulator

Tabletop Simulator

Gloomhaven - Fantasy Setup (Scripted UI)
Vax'ion Jun 26, 2020 @ 1:52pm
Anyone here know how I could make a script to take a battle goal from my hand, and return it to the deck?
Not a big time-loss or saver, but it would be convenient to be able to return cards quickly
< >
Showing 1-2 of 2 comments
Sebästschjin Jun 27, 2020 @ 4:34am 
This should do:

function moveBattleGoals(obj, playerColor, altClick) local battleGoalDeck = "dc92d0" for _, card in pairs(Player[playerColor].getHandObjects()) do if isBattleGoal(card) then getObjectFromGUID(battleGoalDeck).putObject(card) end end end function isBattleGoal(object) if object.tag ~= "Card" or not object.getData().CustomDeck then return false end for key, _ in pairs(object.getData().CustomDeck) do return key == 1932 end end

The question would be, how you want to integrate it? So what should trigger this script? Options I see:
  • a button on the table
  • a button in the global UI
  • hitting a key

For the first you'd have code like this on a game component that should have the button
function onLoad(save_state) self.createButton({ click_function = "moveBattleGoals", function_owner = self, label = "Load", position = {0, 0.1, -0.9}, scale = {1.5, 1.5, 1.5}, width = 1200, height = 400, font_size = 200, color = {0.5, 0.5, 0.5, 1}, font_color = {1, 1, 1, 1}, }) end

I don't know yet how you'd best add that to the global UI, as I haven't good experience with it.

For the button press you could use:
function onScriptingButtonDown(index, playerColor) if index == 5 then moveBattleGoals(nil, playerColor) end end
Put that code on the same object you put the code at the top. The example above triggers, when you press the fifth scripting button (with is Numpad 5 per default).
Last edited by Sebästschjin; Jun 27, 2020 @ 4:35am
Vax'ion Jun 27, 2020 @ 7:59am 
Wow, thats very specific and exactly what I am looking for, thank you.
< >
Showing 1-2 of 2 comments
Per page: 1530 50