Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- MusPlayer (ver 2.01), you can find more scripts at aionmusic.blogspot.com
- -- play_list={"Tree of Savior - Rondo of Tedium","FF XI - Republic Bastok"}
- random=true
- wsec=2
- share=true
- function s(n)return ("r16"):rep(n) end
- function st(n)return "t"..n.." " end
- sl=_G.LBoxList
- r={}w={}z=0
- x=coroutine
- y=x.resume
- ot=os.time
- sct=ot()
- PS=H.PlaySound
- RM=H.RegisterMenu
- SI=H.SetInstrument
- SP=H.SetPercussion
- SA=H.SayAll
- msl=nil
- msz=0
- psz=0
- sync=0
- mc=0
- nm=0
- ft=1.0
- mn={}
- ch_t={}
- cur_m=0
- cs=nil
- function prt(s) PS(1,"r8[11]") SA(11,s)end
- function v()
- repeat
- new_m=(cur_m+nm)%msz
- if(random)then
- repeat
- new_m=math.random(0,msz-1)
- until(cur_m~=new_m)
- end
- cur_m=new_m
- set_music(cur_m)
- nm=1
- _i=cs.s_info
- PS(0, st(_i.temp).."r1[10]")
- H.AlertAll(10, _i.name..". Be patient while channels synchronizing.")
- x.yield()
- dsync=5
- ntry=64
- sync=dsync
- _ab=0.01
- sync_s={}
- ctry=0
- slnce=st(_i.temp)..s(64)
- for c=0,mc do sync_s[c]=st(240).."r64[9]r64r64" end
- for c=0,mc do PS(c, slnce) end
- repeat
- ctry=ctry+1
- for c=0,mc do PS(c, sync_s[c])end
- if(ctry>ntry)then
- _ab=_ab*1.5 ntry=math.max(16,ntry*0.5) ctry=0
- SA(9, "Synchronizing...[".._ab.."]")
- end
- x.yield()
- _a=999999999
- _b=0
- for c=0,mc do _a=math.min(_a,ch_t[c]) _b=math.max(_b,ch_t[c])end
- if((_b-_a)<=_ab) then sync=sync-1 else sync=dsync end
- until(sync<1)
- for c=0,7 do PS(c,r[c])end
- x.yield()
- until(false)
- end
- u=x.create(v)
- function search_script(n)
- cpl=play_list[(n%psz)+1]
- if(type(msl[cpl])=="table")then cs=msl[cpl]else cs=msl[mn[n%msz]]end
- end
- function set_music(n)
- if(psz>0)then search_script(n) else cs=msl[mn[n%msz]]end
- for c=0,7 do SI(c,0)end
- r={}
- z=0
- if(type(cs.r)=="table")then
- local sz=table.getn(cs.r)
- for c=1,sz do _tr={cs.r[c]()}
- for k,v in pairs(_tr) do if(r[k])then r[k]=r[k].."[1]v10"..v else r[k]=v end end
- end
- end
- if(type(cs.r)=="function")then
- r={cs.r()}
- end
- ft=(240.0/cs.s_info.temp)-0.1
- mc=table.getn(r)-1
- for c=1,mc+1 do r[c-1]=r[c].."[9]" end
- for c=mc+1,7 do r[c]=st(cs.s_info.temp)..s(1024*8)end
- end
- function add_script(s)
- if(s and s.s_info and s.s_info.name and (s.r or s.s_info.run))then
- _i=s.s_info
- _r=s.r
- _p=_i.part
- _s=msl[_i.name]
- if(_s and (not _s.ct or _s.ct<sct))then _s=nil end
- if(_i.run)then _r=_i.run end
- if(_p)then
- if(not _s)then _s={r={},ct=ot()}end
- _s.r[_p]=_r
- else
- _s={r=_r,ct=ot()}
- _p=0
- end
- if(not _i.temp)then _i.temp=120 end
- _s.s_info=_i
- msl[_i.name]=_s
- end
- end
- function f1(k,v)
- if(v and v.s_info)then
- if(v.s_info.type=="music")then add_script(v)end
- if(v.s_info.type=="multi_music" and v.s_info.array)then
- sz=table.getn(v.s_info.array)
- for j=1,sz do add_script({["s_info"]=v.s_info.array[j],["r"]=v.r})end
- end
- end
- end
- function f2(k,v)
- if(type(v)=="table" and v.s_info and v.s_info.name)then
- _h="[-] "
- if(v.ct>=sct)then _h="[+] "end
- prt(_h..k)
- mn[msz]=k
- msz=msz+1
- end
- end
- function scan()
- table.foreach(sl,f1)
- table.foreach(msl,f2)
- if((psz>0 and psz<3) or msz<3)then random=false end
- RM("> Next",2)
- if(not random)then RM("> Prev",3)RM("> Repeat",4)end
- if(msz>0)then y(u)end
- end
- function OnSoundPlay(a,b,c,d)
- if(cs and cs.s_info.onsound)then cs.s_info.onsound(a,b,c,d)end
- if(d)then
- if(d>0 and d<6)then SI(a,d-1)
- elseif(d>20)then SP(a,d-20)end
- end
- if(d==9)then ch_t[a]=os.clock() z=z+1 if(z>mc)then z=0 y(u)end end
- if(d==10)then y(u)
- elseif(d==12)then scan()
- elseif(d==0 and b and w[b])then
- H.GlowNow(w[b],ft/c,255,255,255)
- --H.JumpNow(w[b],16.0/(c+7))
- end
- end
- function setup()
- if((not _G.MPlayer) or (not share))then _G.MPlayer={}end
- msl=_G.MPlayer
- i=1("cdefgab"):gsub(".",function(c)w[c]=i i=i+1 end)
- h_str="MusPlayer (ver 2.01)"
- if(random)then h_str=h_str.." [random mode]"end
- prt(h_str..":")
- if(play_list)then psz=table.getn(play_list)end
- if(wsec<=0)then scan()else PS(2,"t120"..s(wsec*8).."[12]")end
- end
- function OnInit()
- H.SetOutletCount(7)
- H.EnableSoundCallback(1)
- setup()
- end
- function mf(_a)
- if(sync<1)then nm=_a y(u)end
- end
- mfa={0,1,-1,0}
- function OnMenu(a)
- mf(mfa[a])
- end
- function OnUserSay(str)
- str=str:lower()
- if(str=="list")then end
- if(str=="next")then mf(1) end
- if(not random)then
- if(str=="prev")then mf(-1)end
- if(str=="try again")then mf(0)end
- end
- if(str:len()>4)then for m=0,msz-1 do
- if(mn[m]:lower():find(str) ~= nil)then cur_m=m tr=random random=false mf(0)random=tr break end end end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement