Created
April 2, 2023 18:22
-
-
Save ghost355/2c1bef28e5f5c47b4204cf0b960d95a8 to your computer and use it in GitHub Desktop.
TTS Lua script staus image float
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Pavel Pavlov @ 2023 | |
-- Project "Floating image as Status with forward/backward loop icon switch" | |
--=========== UI config ================ | |
-- XML : write ID you want, write name in image from asset as your default image, | |
-- width and heithg are size of your image | |
-- offsetXY or position - x,y coordinate where your icon appear after loading | |
-- [[ in the begining and ]] in the end are muliline Lua syntax | |
all_objects_xml = [[ | |
<Button id="Contact" | |
allowDragging='true' | |
returnToOriginalPositionWhenReleased="false" | |
image="No Contact" | |
width='75' | |
height="75" | |
onClick='clickIcon' | |
offsetXY ="-100 0"> | |
</Button> | |
<Button id="Spacemarine" | |
allowDragging='true' | |
returnToOriginalPositionWhenReleased="false" | |
image="1" | |
width='150' | |
height="150" | |
onClick='clickIcon' | |
position = "200 300"> | |
</Button> | |
]] | |
-- write your images below | |
all_images_asset = UI.setCustomAssets({ | |
{ | |
name = "No Contact", | |
url = 'http://cloud-3.steamusercontent.com/ugc/2065504167937408778/BFA61829A8DFD16E81A2E922FF01C62CBFF3B735/' | |
}, | |
{ | |
name = "Contact", | |
url = 'http://cloud-3.steamusercontent.com/ugc/2065504167937405350/4975A63C6D2505935886ED26666C50AE04205BB3/' | |
}, | |
{ | |
name = "Engaged", | |
url = 'http://cloud-3.steamusercontent.com/ugc/2065504167937415545/EC4C40A7FD6F9D0CEAD10B102B550EBBE75795B6/' | |
}, | |
{ | |
name = "Heavy", | |
url = 'http://cloud-3.steamusercontent.com/ugc/2065504167937411442/935261BAD9D5E74EA359D8F2A701260D13B8C806/' | |
}, | |
{ | |
name = "1", | |
url = 'http://cloud-3.steamusercontent.com/ugc/5097543432699983198/9FB030B514FB2F95D97818EDEE8503F19993F21D/' | |
}, | |
{ | |
name = "2", | |
url = 'http://cloud-3.steamusercontent.com/ugc/5097543432699982901/F1DFBE509A64878D20B3486EC71CBEAE781340DA/' | |
}, | |
{ | |
name = "3", | |
url = 'http://cloud-3.steamusercontent.com/ugc/5097543432699982737/4CA96863C2C2E20A4C488551CEC3712055E1FA0B/' | |
}, | |
{ | |
name = "4", | |
url = 'http://cloud-3.steamusercontent.com/ugc/5097543432699982641/B628E70E8D07D9AE54C0F77FDCAAA49CE28B705E/' | |
}, | |
{ | |
name = "5", | |
url = 'http://cloud-3.steamusercontent.com/ugc/5097543432699982549/6E879DB0825EAE36DC24191E582426347192906D/' | |
}, | |
{ | |
name = "6", | |
url = 'http://cloud-3.steamusercontent.com/ugc/5097543432699982336/03D36558438C60EBFBC9F1E664FB5CD0A7202321/' | |
} | |
}) | |
-- draw images button | |
UI.setXml(all_objects_xml, all_images_asset) | |
--================= Click Function =============== | |
-- Left Mouse click - next icon image | |
-- Right Mouse click - previous icon image | |
-- The first image appears aftre the last and vice verse | |
local iconSet = {} | |
local index = {} | |
--=============== Change these =============== | |
-- You'll need to upload your images to Modding-Scripting-Tab Global-Custom UI Assets | |
-- where Tools icon top right , click red cross and select image file you want | |
-- Names of images must be matched with Names in iconSet below | |
-- Write ID from each <Button> in [] | |
index["Contact"] = 0 | |
index["Spacemarine"] = 0 | |
-- Write ID from each <Button> in [] | |
iconSet["Contact"] = { "No Contact", "Contact", "Engaged", "Heavy" } | |
iconSet["Spacemarine"] = { "1", "2", "3", "4", "5", "6" } | |
--========= Don't change anything below this line =========== | |
function clickIcon(player, mouseButton, id) | |
icons = iconSet[id] | |
if mouseButton == "-1" then index[id] = index[id] + 1 end | |
if mouseButton == "-2" then index[id] = index[id] - 1 end | |
UI.setAttribute(id, "image", icons[index[id] % #icons + 1]) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment