Advertisement
Crashguard303

CG303 Show Bands V1.0

Jun 4th, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.29 KB | None | 0 0
  1. --[[
  2. Show Bands by Crashguard303
  3. Script request by jeff101.
  4. This script shows details of a band which index is selected via input box and (if selected) highlights it by activating it (turning it pink) and deactivating all other bands, turning them grey.
  5. Input box will only appear if there is more than 1 band.
  6. ]]--
  7.  
  8.  
  9. function BandDialog(BIndex,BDisable)
  10.  -- create dialog input box and fetch band index to select by a slider
  11.  -- by variable BIndex, initial position of slider is set
  12.  -- by variable BDisable, intial state of checkbox is set
  13.  
  14.  local ask = dialog.CreateDialog("Show Band Details") -- window title
  15.        ask.Qwhich = dialog.AddLabel("Show which band details?") -- question
  16.        ask.BIndex = dialog.AddSlider("Band index:", BIndex, 1, NumBands, 0)
  17.        -- slider for band index selection
  18.         -- initial position: by variable BIndex
  19.         -- minimum value: 1
  20.         -- maximum value: by variable NumBands (global)
  21.         -- decimal fraction adjustment: no, just integer values
  22.        ask.Qdisable = dialog.AddLabel("Enable selected, disable others?") -- question
  23.        ask.BDisable = dialog.AddCheckbox("Yes", BDisable)
  24.        -- checkbox for band disabling
  25.         -- initial state: by variable BDisable
  26.        ask.OK = dialog.AddButton("OK", 1) -- OK button, results 1 for dialog.Show(ask)
  27.        ask.End = dialog.AddButton("End", 0) -- End button, results 0 for dialog.Show(ask)
  28.  
  29.  if dialog.Show(ask)>0 then -- If OK was pressed
  30.  
  31.   return ask.BIndex.value,ask.BDisable.value -- return slider position (selected band index)
  32.  
  33.   else  -- If OK was not pressed
  34.  
  35.    return 0,false
  36.  
  37.  end -- if dialog.Show(ask)
  38. end -- function
  39.  
  40. function BandShow(BandIndex)
  41.  -- by variable BandIndex, show details of band with this index
  42.  
  43.  local OS="Band: "..BandIndex.." strength: "..band.GetStrength(BandIndex) -- show index number and band strength
  44.  print(OS)
  45.  local OS=" current length: "..band.GetLength(BandIndex) -- show currenct length
  46.  print(OS)
  47.  local OS=" goal length: "..band.GetGoalLength(BandIndex) -- show goal length
  48.  print(OS)
  49. end -- function
  50.  
  51. NumBands=band.GetCount() -- by variable NumBands (global), fetch number of applied bands
  52.  
  53. if NumBands>1 then -- if there is more than 1 band, make dialog box appear
  54.   local BIndex=1 -- by variable BIndex, set slider position to 1 by default
  55.   local BDisable=true -- by variable BDisable, set band disabling to true by default
  56.  
  57.   repeat
  58.    BIndex,BDisable=BandDialog(BIndex,BDisable) -- by variable BIndex, feed in old slider position an fetch new one by dialog
  59.  
  60.    if BIndex>0 then -- if OK was pressed in dialog box (and not End)
  61.     BandShow(BIndex) -- show this band with index as in variable BIndex
  62.     if BDisable then -- if disabling was checked in dialog box
  63.      band.DisableAll() -- disable all bands
  64.      band.Enable(BIndex) -- enable only selected band index to distinguish it
  65.     end -- if BDisable
  66.    end -- if BIndex>0
  67.  
  68.   until BIndex==0 -- if End was hit, don't repeat anymore
  69.   print ("Script ended by user.")
  70.  
  71.  elseif NumBands==1 then -- if there is only one band
  72.   BandShow(1) -- show it's details
  73.   print ("Script end.") -- and end automatically
  74.  
  75.  else -- if there is no band
  76.   print ("There are no bands to show!") -- show this
  77.   print ("Script abandoned.") -- and end automatically
  78. end -- if NumBands
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement