./msn_tank_hud.lua

  1. local Screen_grp_h 	= -1 
  2. local Meter_h			= -1 
  3. local Meter_width, Meter_height 
  4.  
  5. function msn_tank_hud_init() 
  6. 	Screen_grp_h = vint_object_find( "screen_grp" ) 
  7. 	Meter_h = vint_object_find( "tank_mask" ) 
  8. 	Meter_width, Meter_height = element_get_actual_size(Meter_h) 
  9. 	vint_set_mouse_cursor("ui_cursor_target") 
  10. 	vint_dataitem_add_subscription("msn_tank_hud_data", "update", "msn_tank_hud_set_meter") 
  11. end 
  12.  
  13. function msn_tank_hud_set_meter(di_h) 
  14. 	local meter_value = vint_dataitem_get(di_h) 
  15. 	if meter_value == nil or meter_value < 0 then 
  16. 		meter_value = 0 
  17. 	end 
  18. 	 
  19. 	local new_meter_width = Meter_width * meter_value  
  20. 	 
  21. 	if meter_value ~= 1 then --if 1 then set it to full 
  22. 		local incriment = Meter_width/16 
  23. 		 
  24. 		for i = 0, Meter_width, incriment do 
  25. 			if new_meter_width >= i and new_meter_width < (i + incriment) then 
  26. 				new_meter_width = i 
  27. 			end 
  28. 		end 
  29. 	end 
  30. 	element_set_actual_size(Meter_h, new_meter_width, Meter_height) 
  31. end 
  32.  
  33. function msn_tank_hud_cleanup() 
  34. 	vint_set_mouse_cursor("") 
  35. end 
  36.  
  37.