SoC. Выводим часы на HUD — различия между версиями
Материал из S.T.A.L.K.E.R. Inside Wiki
Oxygenium (обсуждение | вклад) |
RedPython (обсуждение | вклад) |
||
Строка 1: | Строка 1: | ||
− | Для этого нам понадобятся стандартные файлы: | + | Для этого нам понадобятся стандартные файлы: '''config/ui/ui_custom_msgs.xml''' и '''scripts/bind_stalker.script'''. |
− | config/ui/ui_custom_msgs.xml | + | |
− | scripts/bind_stalker.script | + | |
− | 1. Создаём файл ваше_название_скрипта.script в папке gamedata/scripts и пишем в него: | + | '''1.''' Создаём файл '''ваше_название_скрипта.script''' в папке ''gamedata/scripts'' и пишем в него: |
− | < | + | <lua> |
+ | function show_time() | ||
local hud = get_hud() | local hud = get_hud() | ||
local cs = hud:GetCustomStatic("hud_show_time") | local cs = hud:GetCustomStatic("hud_show_time") | ||
Строка 25: | Строка 24: | ||
if cs ~= nil then cs:wnd():SetText(msg) end | if cs ~= nil then cs:wnd():SetText(msg) end | ||
− | end</ | + | end |
+ | </lua> | ||
− | 2. Далее открываем файл ui_custom_msgs.xml в config/ui/ и пишем туда: | + | '''2.''' Далее открываем файл '''ui_custom_msgs.xml''' в ''config/ui/'' и пишем туда: |
− | < | + | <xml> |
+ | <hud_time_static x="852" y="17" width="156" height="52"> | ||
<text complex_mode="0" x="65" y="0" font="letterica16" r="255" g="255" b="255" a="130">Time</text> | <text complex_mode="0" x="65" y="0" font="letterica16" r="255" g="255" b="255" a="130">Time</text> | ||
<texture>ui_hud_frame_clock</texture> | <texture>ui_hud_frame_clock</texture> | ||
Строка 34: | Строка 35: | ||
<hud_show_time x="862" y="38" width="156" height="52"> | <hud_show_time x="862" y="38" width="156" height="52"> | ||
<text x="0" y="0" font="graffiti19" r="255" g="255" b="255" a="140" align="c"/> | <text x="0" y="0" font="graffiti19" r="255" g="255" b="255" a="140" align="c"/> | ||
− | </hud_show_time></ | + | </hud_show_time> |
+ | </xml> | ||
− | 3. Открываем файл bind_stalker.script и пишем после: | + | '''3.''' Открываем файл '''bind_stalker.script''' и пишем после: |
− | < | + | <lua> |
+ | function actor_binder:update(delta) | ||
object_binder.update(self, delta) | object_binder.update(self, delta) | ||
local time = time_global() | local time = time_global() | ||
− | game_stats.update (delta, self.object)</ | + | game_stats.update (delta, self.object) |
+ | </lua> | ||
+ | <lua> | ||
ваше_название_скрипта.show_time() | ваше_название_скрипта.show_time() | ||
− | + | </lua> | |
+ | в любую функцию. | ||
− | Автор: '''steelrat''' | + | ==Автор== |
+ | Статья: '''steelrat''' | ||
[[Категория:Скрипты]] | [[Категория:Скрипты]] |
Версия 13:48, 30 июня 2010
Для этого нам понадобятся стандартные файлы: config/ui/ui_custom_msgs.xml и scripts/bind_stalker.script.
1. Создаём файл ваше_название_скрипта.script в папке gamedata/scripts и пишем в него:
function show_time() local hud = get_hud() local cs = hud:GetCustomStatic("hud_show_time") if cs == nil then hud:AddCustomStatic("hud_time_static", true) hud:AddCustomStatic("hud_show_time", true) cs = hud:GetCustomStatic("hud_show_time") end local time_h = level.get_time_hours() local time_m = level.get_time_minutes() local msg if time_m >= 10 then msg = string.format(" %02d:%02d\n", time_h, time_m) else msg = string.format(" %02d:%02d\n", time_h, time_m) end if cs ~= nil then cs:wnd():SetText(msg) end end
2. Далее открываем файл ui_custom_msgs.xml в config/ui/ и пишем туда:
<hud_time_static x="852" y="17" width="156" height="52"> <text complex_mode="0" x="65" y="0" font="letterica16" r="255" g="255" b="255" a="130">Time</text> <texture>ui_hud_frame_clock</texture> </hud_time_static> <hud_show_time x="862" y="38" width="156" height="52"> <text x="0" y="0" font="graffiti19" r="255" g="255" b="255" a="140" align="c"/> </hud_show_time>
3. Открываем файл bind_stalker.script и пишем после:
function actor_binder:update(delta) object_binder.update(self, delta) local time = time_global() game_stats.update (delta, self.object)
ваше_название_скрипта.show_time()
в любую функцию.
Автор
Статья: steelrat