Advertisement
Daemonion

new daemonion_sound.script

Dec 12th, 2012
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.81 KB | None | 0 0
  1. -- Zoom in and out for Daemonion
  2. -- by Alundaio
  3.  
  4.  
  5.  
  6. -- [section]  = { sound, fov }
  7. local sections_zoom_in = {
  8.     ["wpn_pm"] = {[[weapons\in]],54},
  9. }
  10.  
  11. local sections_zoom_out = {
  12.     ["wpn_pm"] = [[weapons\out]],
  13. }
  14.  
  15. -------------------
  16. -- goes in stalker_binder:update()
  17. -------------------
  18. function actor_on_update()
  19.     local wpn = db.actor:active_item()
  20.     if (wpn) then
  21.         if (sections_zoom_in[wpn:section()]) then
  22.             if (sections_zoom_in[wpn:section()][2] and device().fov < sections_zoom_in[wpn:section()][2]) then
  23.                 if not (actor_scope) then
  24.                     actor_scope = true
  25.                     actor_on_weapon_zoom_in(wpn)
  26.                 end
  27.             else
  28.                 if (actor_scope) then
  29.                     actor_scope = nil
  30.                     actor_on_weapon_zoom_out(wpn)
  31.                 end
  32.             end
  33.         else
  34.             if (actor_scope) then
  35.                 actor_scope = nil
  36.                 actor_on_weapon_zoom_out(wpn)
  37.             end
  38.         end
  39.     end
  40. end
  41.  
  42. -------------------
  43. -- actor_on_weapon_zoom_in(wpn)
  44. -------------------
  45. function actor_on_weapon_zoom_in(wpn)
  46.     printf("Zoom In")
  47.     local snd = sections_zoom_in[wpn:section()] and sections_zoom_in[wpn:section()][1] and get_sound(sections_zoom_in[wpn:section()][1])
  48.     if (snd) then
  49.         snd:play_at_pos(db.actor,db.actor:position(),0)
  50.     end
  51. end
  52.  
  53. -------------------
  54. -- actor_on_weapon_zoom_out(wpn)
  55. -------------------
  56. function actor_on_weapon_zoom_out(wpn)
  57.     printf("Zoom In")
  58.     local snd = sections_zoom_out[wpn:section()] and get_sound(sections_zoom_out[wpn:section()])
  59.     if (snd) then
  60.         snd:play_at_pos(db.actor,db.actor:position(),0)
  61.     end
  62. end
  63.  
  64.  
  65. function get_sound(snd)
  66.     if snd then
  67.         return sound_object(snd)
  68.     end
  69. end
  70.  
  71. function printf(text,...)
  72.     if not (text) then return end
  73.     local i = 0
  74.     local p = {...}
  75.     local function sr(a)
  76.         i = i + 1
  77.         return tostring(p[i])
  78.     end
  79.     local output = string.gsub(text,"%%s",sr)
  80.     get_console():execute("load ~#I#:"..output)
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement