Tabletop Simulator

Tabletop Simulator

Unconditional Surrender! HQ (GMT Games)
RocketMan Dec 31, 2020 @ 7:17pm
Script for Sorties
The VASSAL version of USE has a neat feature where the sorties for air and naval units are tracked on the counters themselves without having to use the sortie counter markers. I figured this feature would be nice to have in the TTS version, so I modified a simple script to add a number in the upper right of the air counters that increases +1 (starting from 0) when you left click on it and decreases when you right click on it. You can see how this looks in the following image: https://imgur.com/h9Q2zPA

Unfortunately there is no area on the fleet counters with the base game images to position the button conveniently so it doesn't overwrite portions of the text on the counter. The fleet images would need to be modified, or the number would need to be over the flag or crammed above the country name to use this script.

Below is the script. You can change the color, size, and position of the number with the position, font_size, and font_color command. For instance, on the USSR and USA units, the font_color should be changed from black to white (from 0,0,0,100 to 1,1,1,100) to match the text on those counters.

If you want help implementing this, let me know. I think it would be a big help in playing the game.

MIN_VALUE = 0
MAX_VALUE = 6

function onload(saved_data)
val = 0
if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data)
val = loaded_data[1]
end
createAll()
end

function updateSave()
local data_to_save = {val}
saved_data = JSON.encode(data_to_save)
self.script_state = saved_data
end

function createAll()
self.createButton({
label=tostring(val),
click_function="add_subtract",
function_owner=self,
position={0.7,0.1,-0.6,0},
height=600,
width=600,
font_size=250,
font_color={0,0,0,100},
color={0,0,0,0}
})
end

function removeAll()
self.removeInput(0)
self.removeButton(0)
end

function reloadAll()
removeAll()
createAll()
updateSave()
end

function add_subtract(_obj, _color, alt_click)
mod = alt_click and -1 or 1
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE)
if val ~= new_value then
val = new_value
updateVal()
updateSave()
end
end

function updateVal()
self.editButton({
index = 0,
label = tostring(val),
})
end
Last edited by RocketMan; Dec 31, 2020 @ 7:35pm
< >
Showing 1-3 of 3 comments
RocketMan Dec 31, 2020 @ 10:13pm 
I actually figured out how to make the Naval units work. The counter covers a little of the flag, but it's not too bad.

https://imgur.com/YGNGqw2

Modified Script for the Naval units is below:

MIN_VALUE = 0
MAX_VALUE = 6

function onload(saved_data)
val = 0
if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data)
val = loaded_data[1]
end
createAll()
end

function updateSave()
local data_to_save = {val}
saved_data = JSON.encode(data_to_save)
self.script_state = saved_data
end

function createAll()
self.createButton({
label=tostring(val),
click_function="add_subtract",
function_owner=self,
position={0.7,0.1,0.6,0},
height=300,
width=250,
font_size=250,
font_color={0,0,0,100},
color={1,1,1,100}
})
end

function removeAll()
self.removeInput(0)
self.removeButton(0)
end

function reloadAll()
removeAll()
createAll()
updateSave()
end

function add_subtract(_obj, _color, alt_click)
mod = alt_click and -1 or 1
new_value = math.min(math.max(val + mod, MIN_VALUE), MAX_VALUE)
if val ~= new_value then
val = new_value
updateVal()
updateSave()
end
end

function updateVal()
self.editButton({
index = 0,
label = tostring(val),
})
end
Last edited by RocketMan; Jan 1, 2021 @ 8:02am
RocketMan Jan 1, 2021 @ 7:03am 
Upon further reflection, you can use the script in the second post for all air and naval units to make them all consistent.
KarateSnoopy  [developer] Mar 25, 2021 @ 12:21am 
Thanks! Updated the tokens with this script. Let me know if you spot any missing
< >
Showing 1-3 of 3 comments
Per page: 1530 50