Last active
April 2, 2023 16:33
-
-
Save ghost355/b166d9cf940255c617044fa5a5a03982 to your computer and use it in GitHub Desktop.
Статус чего-либо в игре. В виде висящих постоянно кнопок
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
local iconSet = {} | |
local index = {} | |
--=============== Тут нужно поменять значения =============== | |
-- index["ВАШЕ_НАЗВАНИЕ_ID_В_BUTTON"] - их будет столько сколько у вас кнопок-статусов | |
-- iconSet["ВАШЕ_НАЗВАНИЕ_ID_В_BUTTON"] = {В кавычках, через запятую имена - | |
-- нзвания файлов тайлов-иконок, сколько их чередуется в одной кнопке-статусе | |
-- в меню Modding-Scripting-Закладка Global-Custom UI Assets | |
-- (Это молоток и гаечный ключ справа вверху панельки) | |
-- Нажмите красный плюс там чтобы добавить} | |
-- !!! Важно - в XML файле id в <Button> должны точно свопадать с названиями в index и iconSet | |
index["Contact"] = 0 | |
index["Weather"] = 0 | |
iconSet["Contact"] = { "No Contact", "Contact", "Engaged", "Heavy" } | |
iconSet["Weather"] = { "Daylight", "Fog", "Rain/Snow", "Twilight", "Moon2", "Moon3", "Moon4", "Moon5" } | |
--========= Ниже ничего менять не надо =========== | |
function clickIcon(player, mouseButton, id) | |
print(#iconSet[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 |
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
<Button id="Contact" | |
allowDragging='true' | |
returnToOriginalPositionWhenReleased="false" | |
image="No Contact" | |
width='100' | |
height="100" | |
onClick='statusIcon_Contact' | |
offsetXY ="-100 0"> | |
</Button> | |
<Button id="Weather" | |
allowDragging='true' | |
returnToOriginalPositionWhenReleased="false" | |
image="Daylight" | |
width='100' | |
height="100" | |
onClick='statusIcon_Weather' | |
offsetXY ="100 0" > | |
</Button> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment