Skip to content

Instantly share code, notes, and snippets.

@ghost355
Last active April 2, 2023 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghost355/b166d9cf940255c617044fa5a5a03982 to your computer and use it in GitHub Desktop.
Save ghost355/b166d9cf940255c617044fa5a5a03982 to your computer and use it in GitHub Desktop.
Статус чего-либо в игре. В виде висящих постоянно кнопок
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
<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