Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- * notes * --
- -- this is only the main part of the script - the rest is done inside the editor itself!
- -- this is my modified english version of einzelkaempfer's vol slider script!
- -- I've added various new functions like:
- -- º active handle animation image on mouse button hold
- -- º plays a sound or speech file depending on current active volume type
- -- º added various glitch fixes
- -- º included some print statements to log file
- -- º etc
- -- * --
- -- Regards, Lee :)
- -- VolConMinPos / VolConMaxPos(volume control slider minimum/maximum position; x axis - "ReglerMinPos/ReglerMaxPos")
- -- VolConWidth (the width of the image you're using as the slider handle - "ReglerWidth")
- -- VolConYPos (sets the y position (vertical axis) of the slider handles - use bottom edge of image for y position - "ReglerYPos"
- VolConMinPos = 1063
- VolConMaxPos = 1872
- VolConWidth = 18
- VolConYPos = {558; 477; 395} --music(0),sfx(1),voice(2)
- ------------------------------------------------------------------
- -- VolConTotal (gets the distance between the min & max pos - "ReglerTotal")
- -- Slider1 (converts volcontotal into % - "Regler1")
- -- defaultHoldTime (time it take for mouse hold to register "GehaltenStandard")
- -- play_sound (variable containing the location to an action that plays a sound file)
- -- play_speech (variable containing the location to an action that plays a speech file)
- VolConTotal = VolConMaxPos - VolConMinPos
- Slider1 = VolConTotal / 100
- defaultHoldTime = game:getInt(VGameHoldTime)
- play_sound = getObject('Scenes[Options_Menu].SceneActions[play_sound]')
- play_speech = getObject('Scenes[Options_Menu].SceneActions[play_speech]')
- -- Load Volume Options Script
- -- i = 0, 2 (i defines which slider is active: music[0], sfx[1], voice[2])
- -- VolVal (volume value is the volume level - "VolWert")
- function beginVolCon()
- for i = 0, 2 do
- startAnimation("Animations[AniVolCon_" .. i .. "]")
- startAnimation("Animations[AniVolCon_" .. i .. "x]")
- local VolVal = getVolume(i)
- if VolVal < 0 then
- setVolume(i, 0)
- VolVal = 0
- elseif VolVal > 100 then
- setVolume(i, 100)
- VolVal = 100
- end
- local VolConPos = math.floor((VolVal * Slider1 + VolConMinPos) + 0.5)
- setVolConPos(i, VolConPos)
- end
- print("volume script has been started!")
- end
- -- Set the positions of the slider handles (slider only)
- function setVolConPos(typ, xpos)
- local VolAnim = getObject("ActiveAnimations[AniVolCon_" .. typ .. "]")
- local VolAnim2 = getObject("ActiveAnimations[AniVolCon_" .. typ .. "x]")
- VolAnim:setValue(VAnimationCurrentPosition, {x=xpos,y=VolConYPos[typ + 1]})
- VolAnim2:setValue(VAnimationCurrentPosition, {x=xpos,y=VolConYPos[typ + 1]})
- end
- -- Set the positions of the slider handles (buttons only)
- function setVolConPos2(typ, xpos)
- local VolAnim = getObject("ActiveAnimations[AniVolCon_" .. typ .. "]")
- VolAnim:setValue(VAnimationCurrentPosition, {x=xpos,y=VolConYPos[typ + 1]})
- end
- -- Checks if mouse button is being held down
- function mousebtnHold(standard)
- if standard == false then
- game:setValue(VGameHoldTime, 1)
- else
- game:setValue(VGameHoldTime, defaultHoldTime)
- end
- end
- -- The function which allows you to drag the slider handle
- function dragVolCon(typ)
- local CursorPos = getCursorPos()
- local VolConPos = math.floor(CursorPos.x - VolConWidth / 2 + 0.5)
- if VolConPos < VolConMinPos then
- VolConPos = VolConMinPos
- elseif VolConPos > VolConMaxPos then
- VolConPos = VolConMaxPos
- end
- setVolConPos(typ, VolConPos)
- local VolVal = math.floor(((VolConPos - VolConMinPos) / Slider1) + 0.5)
- setVolume(typ, VolVal)
- end
- -- Plus_Minus Buttons raise or lower vol by 10%
- function pluminClick(typ, cond)
- VolVal = getVolume(typ)
- if cond == true then
- VolVal = VolVal + 10
- if VolVal > 100 then VolVal = 100 end
- else
- VolVal = VolVal - 10
- if VolVal < 0 then VolVal = 0 end
- end
- setVolume(typ, VolVal)
- local VolConPos = math.floor((VolVal * Slider1 + VolConMinPos) + 0.5)
- setVolConPos2(typ, VolConPos)
- if typ == 1 then
- startAction(play_sound)
- print("sound volume is now set at " .. VolVal .. " - button")
- else
- if typ == 2 then
- startAction(play_speech)
- print("speech volume is now set at " .. VolVal .." - button")
- else
- print("music Volume is now set at " .. VolVal .. " - button")
- end
- end
- end -- pluminClick()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement