Suggestions for improvement

Posted by Greven on Sat 13 Aug 2005 05:25 AM — 1 posts, 9,948 views.

Canada #0
I was bored and decided to mess around with some of mushclients scripting for the first time. I decided to make a winamp script to mess around with, and this is eventually what I came up with:
set winamp = createObject("WinampCOM.Application")
call winampstatus

sub winampstatus
'  Set the status bar in MUSHclient to display winamp info12/08/2005

'Checks the global variable each time
if StrComp(world.GetVariable("songname"),winamp.CurrentSongTitle) <> 0 then
    call update_song
End if

'The time returns for current is in milliseconds, so convert and round to seconds
	world.SetVariable "songseconds", Round(winamp.CurrentPos/1000)
'We don't want to actually round the minute, just to get rid of any decimal places, so fix instead of round
    world.Setvariable "songminutes", fix(world.GetVariable("songseconds") / 60)
    world.SetVariable "songseconds", world.GetVariable("songseconds") mod 60
'This is just to produce a "0:07" type look instead of "0:7"
	if world.GetVariable("songseconds") < 10 then
        world.SetVariable "songseconds", "0" + world.GetVariable("songseconds")
    End if
'Just format the current string
    world.SetVariable "songtime", world.GetVariable("songminutes") + ":"
    world.SetVariable "songtime", world.GetVariable("songtime") + world.GetVariable("songseconds")



    world.SetVariable "statstring", world.GetVariable("songname") + " ("
    world.SetVariable "statstring", world.GetVariable("statstring") + world.GetVariable("songtime")
    world.SetVariable "statstring", world.GetVariable("statstring") + "/"
    world.SetVariable "statstring", world.GetVariable("statstring") + world.GetVariable("songtimetotal")
    world.SetVariable "statstring", world.GetVariable("statstring") + ")"


    world.setstatus world.GetVariable("statstring")
end sub

sub update_song
'  Update the song info

    world.SetVariable "songname", winamp.CurrentSongTitle
    DoAfterSpecial 1,"call update_song_name", 12 

end sub 

sub update_song_name
'  Update the song info

    world.SetVariable "songlength",  winamp.CurrentSongLength
    world.SetVariable "songsecondstotal", world.GetVariable("songlength") mod 60
    world.Setvariable "songminutestotal", fix(world.GetVariable("songlength") / 60)

    if world.GetVariable("songsecondstotal") < 10 then
        world.SetVariable "songsecondstotal", "0" + world.GetVariable("songsecondstotal")
    End if
    world.SetVariable "songtimetotal", world.GetVariable("songminutestotal") + ":"
    world.SetVariable "songtimetotal", world.GetVariable("songtimetotal") + world.GetVariable("songsecondstotal")

end sub
It is probably really redundant and in poor scripting style, but I am very unfamiliar with vbscript and mushclient scripting in general. Any comments would be great, thanks.