Advertisement
Guest User

volumeControl-widget

a guest
Aug 14th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. require "base/internal/ui/reflexcore";
  2.  
  3. volumeControl = {canHide = false; canPosition = false;};
  4.  
  5. registerWidget("volumeControl");
  6.  
  7. function volumeControl:initialize()
  8.     widgetCreateConsoleVariable("increment", "float", 0);
  9. end
  10.  
  11. function volumeControl:draw()
  12.     local volumeIncrement = clampTo4Decimal(widgetGetConsoleVariable("increment"));
  13.     if volumeIncrement ~= 0 then
  14.         local newVolume = clamp(clampTo4Decimal(consoleGetVariable("s_volume")) + volumeIncrement, 0, 1);
  15.         consolePerformCommand("s_volume " .. newVolume);
  16.         consolePrint("s_volume " .. newVolume);
  17.         widgetSetConsoleVariable("increment", 0);
  18.     end
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement