Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onload()
- live = 0
- track = 1
- --self.createButton({
- --label="PlayButton", click_function="queueAnimation", function_owner=self,
- -- position={0.8,0.3,1.15}, height=100, width=90, font_size=240, rotation={0,0,0}
- -- })
- -- previous btn
- self.createButton({
- label="", click_function="previousTrack", function_owner=self,
- position={0.84,0.3,-0.98}, height=100, width=40, font_size=240, rotation={0,0,0}
- })
- -- next btn
- self.createButton({
- label="", click_function="nextTrack", function_owner=self,
- position={0.84,0.3,-1.175}, height=100, width=40, font_size=240, rotation={0,0,0}
- })
- end
- function queueAnimation()
- self.AssetBundle.playTriggerEffect(2)
- Timer.destroy("waitforanimation")
- Timer.create({identifier="waitforanimation", function_name='armIn', delay=0.6})
- end
- function armIn()
- if live == 0 then
- self.AssetBundle.playTriggerEffect(0)
- live = 1
- track = 1
- queueMusic()
- print("Playing track: " .. track)
- elseif live == 1 then
- self.AssetBundle.playTriggerEffect(1)
- live = 0
- stopMusic()
- end
- end
- function queueMusic()
- Timer.destroy("waitforanimation")
- Timer.create({identifier="waitforanimation", function_name='musicOn', delay=2})
- end
- function musicOn()
- findMusic()
- findObject()
- end
- function nextTrack()
- self.AssetBundle.playTriggerEffect(4)
- if live == 0 then
- -- don't play!
- print("Invalid input - No music is currently playing.")
- elseif live == 1 then
- track = track + 1
- print("Playing track: " .. track)
- findMusic()
- end
- end
- function findMusic()
- local allObjects = getAllObjects()
- local toolPos = self.getPosition()
- local toolPosX = toolPos.x
- local toolPosZ = toolPos.z
- for i, v in pairs(allObjects) do
- if v.tag == "Generic" then
- local vPos = v.getPosition()
- local vPosX = vPos.x
- local vPosZ = vPos.z
- local dX = toolPosX - vPosX
- local dZ = toolPosZ - vPosZ
- if dX<3 and dX>-3 and dZ<2 and dZ>-2 then
- v.AssetBundle.playTriggerEffect(track)
- end
- end
- end
- end
- function previousTrack()
- self.AssetBundle.playTriggerEffect(3)
- if live == 0 then
- -- don't play!
- print("Invalid input - No music is currently playing.")
- elseif live == 1 then
- if track <= 1 then
- track = 1
- else
- track = track - 1
- print("Playing track: " .. track)
- findMusic()
- end
- end
- end
- function stopMusic()
- track = 0
- findMusic()
- end
- function findObject()
- local allObjects = getAllObjects()
- local toolPos = self.getPosition()
- local toolPosX = toolPos.x
- local toolPosZ = toolPos.z
- for i, v in pairs(allObjects) do
- if v.tag == "Generic" then
- local vPos = v.getPosition()
- local vPosX = vPos.x
- local vPosZ = vPos.z
- local dX = toolPosX - vPosX
- local dZ = toolPosZ - vPosZ
- if dX<3 and dX>-3 and dZ<2 and dZ>-2 then
- rotateMe(v)
- end
- end
- end
- end
- function rotateMe(v)
- rot = v.getRotation()
- v.setRotation({0,rot['y']+5,0})
- end
- function update()
- if live == 1 then
- findObject()
- elseif live == 0 then
- -- don't!
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement