Сповіщення
Очистити все

SoC. Виводимо годинник на HUD


Ранг:
Майстер
Роль:
Гість
Записи:
752
Приєднався:
2 роки тому
 

Для цього нам знадобляться стандартні файли: 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" ) 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 ( )
 

у будь-яку функцію.


   
Цитата