Tabletop Simulator

Tabletop Simulator

Gloomhaven - Fantasy Setup (Scripted UI)
aname Apr 22, 2020 @ 7:05pm
Scripted Shortcuts
Hello. Was wondering if I could have some guidance on setting up a few scripted shortcuts? I saw that under Scripts there is a function onScriptingButtonDown for the scripted keys in which the author has assigned scripts to 1-3 and 7-9. I tried to set up my own but was running into some trouble. particularly I was trying to set up four shortcuts.
  1. A shortcut to draw an attack modifier for the player.
  2. A shortcut to open and close the game setup UI
  3. A shortcut to start the round
  4. and A shortcut to sort hand

For the first one I tried this
elseif index == 4 then drawClicked()
I also tried Global.drawClicked(), which I am certain is wrong and I tried to send variables to the function but I was unsure what the second variable should be.
drawClicked("activePlayer", ,"activeColor")

I have tried this with the other functions involved and haven't made any progress. Without global I get an error about accesing nil values. with Global it says it cannot access field FunctionName of userdata<LuaGameObjectScript>

Obviously I have very little experience with code and none with Lua I am just trying to piece together what I can by looking through it. Any help would be appreciated.

Thank you
Last edited by aname; Apr 22, 2020 @ 7:20pm
< >
Showing 1-2 of 2 comments
Kijan  [developer] Apr 22, 2020 @ 10:31pm 
Maybe you should have a look here:
https://api.tabletopsimulator.com/

drawClicked and the others are in Global not in Scripts so you have to call them but there you will have a problem because in a call you can only give a table as a parameter not 3 variables what drawClicked need.
so you have to put the function onScriptingButtonDown in Global.
this should not be a problem if you create in Global the same function with only the keys you use in Global.
you have to use the function like this:
function onScriptingButtonDown(index, color) end
and you have to give the functions then the values something like this:
drawClicked(player, nil, nil)
unless you want to asign a button for all for colors then you have to do like this
drawClicked(player, nil, "Red")
aname Apr 23, 2020 @ 6:46pm 
Thank you very much that helped a lot.

If anyone sees this and is interested I basically mapped all the buttons from the battle interface to the numpad as well as the "Scenario won" button. I kept 1-3 but deleted the mappings for 7-9. (7-9 are present under Scripts under the function onScriptingButtonDown, the section starts with a line that says something like if index > 6 and <10) I input the following script near the end of Global.

function onScriptingButtonDown(index, color) playerList = Player.getPlayers() for k, v in pairs(playerList) do if color == v.color then player = v break end end if index == 4 then drawClicked(player, nil, color) elseif index == 5 then reveal() elseif index == 6 then endRound() elseif index == 7 then sortHand(player, nil, color) elseif index == 8 then longRest(player, nil, color) elseif index == 9 then spawnerClicked(player, nil, "win") elseif index == 10 then spawnerClicked(player, nil, "showSpawner") end end

The keys are mapped as follows

4 = draw attack modifier drawClicked(player, nil, color)
5 = start round reveal()
6 = end round endRound()
7 = sort hand sortHand(player, value, id)
8 = long rest longRest(player, value, id)
9 = Scenario Won spawnerClicked(player, value, id) id is for button so pass "win"
0 = game setup spawnerClicked(player, value, "showSpawner")

Some of these won't work as the black player for obvious reason.
Last edited by aname; Apr 23, 2020 @ 8:49pm
< >
Showing 1-2 of 2 comments
Per page: 1530 50