Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Show Bands by Crashguard303
- Script request by jeff101.
- 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.
- Input box will only appear if there is more than 1 band.
- ]]--
- function BandDialog(BIndex,BDisable)
- -- create dialog input box and fetch band index to select by a slider
- -- by variable BIndex, initial position of slider is set
- -- by variable BDisable, intial state of checkbox is set
- local ask = dialog.CreateDialog("Show Band Details") -- window title
- ask.Qwhich = dialog.AddLabel("Show which band details?") -- question
- ask.BIndex = dialog.AddSlider("Band index:", BIndex, 1, NumBands, 0)
- -- slider for band index selection
- -- initial position: by variable BIndex
- -- minimum value: 1
- -- maximum value: by variable NumBands (global)
- -- decimal fraction adjustment: no, just integer values
- ask.Qdisable = dialog.AddLabel("Enable selected, disable others?") -- question
- ask.BDisable = dialog.AddCheckbox("Yes", BDisable)
- -- checkbox for band disabling
- -- initial state: by variable BDisable
- ask.OK = dialog.AddButton("OK", 1) -- OK button, results 1 for dialog.Show(ask)
- ask.End = dialog.AddButton("End", 0) -- End button, results 0 for dialog.Show(ask)
- if dialog.Show(ask)>0 then -- If OK was pressed
- return ask.BIndex.value,ask.BDisable.value -- return slider position (selected band index)
- else -- If OK was not pressed
- return 0,false
- end -- if dialog.Show(ask)
- end -- function
- function BandShow(BandIndex)
- -- by variable BandIndex, show details of band with this index
- local OS="Band: "..BandIndex.." strength: "..band.GetStrength(BandIndex) -- show index number and band strength
- print(OS)
- local OS=" current length: "..band.GetLength(BandIndex) -- show currenct length
- print(OS)
- local OS=" goal length: "..band.GetGoalLength(BandIndex) -- show goal length
- print(OS)
- end -- function
- NumBands=band.GetCount() -- by variable NumBands (global), fetch number of applied bands
- if NumBands>1 then -- if there is more than 1 band, make dialog box appear
- local BIndex=1 -- by variable BIndex, set slider position to 1 by default
- local BDisable=true -- by variable BDisable, set band disabling to true by default
- repeat
- BIndex,BDisable=BandDialog(BIndex,BDisable) -- by variable BIndex, feed in old slider position an fetch new one by dialog
- if BIndex>0 then -- if OK was pressed in dialog box (and not End)
- BandShow(BIndex) -- show this band with index as in variable BIndex
- if BDisable then -- if disabling was checked in dialog box
- band.DisableAll() -- disable all bands
- band.Enable(BIndex) -- enable only selected band index to distinguish it
- end -- if BDisable
- end -- if BIndex>0
- until BIndex==0 -- if End was hit, don't repeat anymore
- print ("Script ended by user.")
- elseif NumBands==1 then -- if there is only one band
- BandShow(1) -- show it's details
- print ("Script end.") -- and end automatically
- else -- if there is no band
- print ("There are no bands to show!") -- show this
- print ("Script abandoned.") -- and end automatically
- end -- if NumBands
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement