[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Jscript
. . -> [Subject]  Help needed in Conversion

Help needed in Conversion

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Valhart   (14 posts)  [Biography] bio
Date Sun 08 Jun 2003 09:50 AM (UTC)
Message
Calling to helpful Jscript and VB script knowledge user. I need help in converting the following VB script into Jscript. I had been learning some minor Jscripting and hopes to expand this VB script with the knowledge of Jscript I learnt. However, I do not know VB script very well. Hence, hoping for a kind soul to help converting them.

Thanks in advance.

The script is as follows:

sub OnSpell (strTriggerName, strTriggerLine, aryWildcards)
dim chant
dim spellname
dim minutes

' spell chant was from previous trigger
chant = world.GetVariable ("LastSpellName")

' work out spell duration based on chant
Select Case chant
Case "Voluntas ferrum!"
minutes = 25
spellname = "IW"
Case "Voluntas movimas!"
minutes = 26
spellname = "PFH"
Case "Rubber"
minutes = 4.4
spellname = "Mi.Phys"
Case "Major kretsz rex xero"
minutes = 4.4
spellname = "Ma.Phys"

End select

call NewSpell (spellname, aryWildcards (1), minutes)

end sub

sub NewSpell (spellname, target, minutes)

dim number

' get a unique number

number = world.GetUniqueNumber

' Flags:
' 1 = enabled
' 4 = one shot (once only)
' 1024 = replace any of same name

' add a timer to go off after the appropriate time

world.AddTimer "SpellTimer_" & number, 0, minutes - 1, 50, "", _
1 + 4 + 1024, "OnSpellTimer"

' remember when the spell expires, the target and the spell name

world.setvariable "SpellTimer_Time_" & number, _
DateAdd ("n", minutes, Now)
world.setvariable "SpellTimer_Name_" & number, target
world.setvariable "SpellTimer_Spellname_" & number, spellname
world.deletevariable ("LastSpellName")
end sub


sub OnSpellTimer (strTimerName)
dim splitname
dim spellname
dim mylist
dim number
dim i
dim character

splitname = split (strTimerName, "_")

number = CInt (splitname (1)) ' find our unique number

mylist = world.GetVariableList

' scan variables list to find timer number

if not IsEmpty (mylist) then
for i = lbound (mylist) to ubound (mylist)
splitname = split (mylist (i), "_")
if ubound (splitname) = 2 then
if splitname (0) = "spelltimer" and splitname (1) = "name" then
if CInt (splitname (2)) = number then
' work out character name
character = world.GetVariable (mylist (i))
spellname = world.GetVariable _
(splitname (0) & "_SpellName_" & splitname (2))
' tell them time is up
world.send "say {" & spellname & "} on " _
& character & ", left 10 secs .(DANGER)"
' delete associated variables
world.deletevariable splitname (0) & "_Name_" & splitname (2)
world.deletevariable splitname (0) & "_Time_" & splitname (2)
world.deletevariable splitname (0) & "_SpellName_" & splitname (2)
end if
end if ' found a spelltimer variable
end if ' split into 3 pieces
next ' end of loop
End If ' have any variables

end sub

sub OnSpellQuery (thename, theoutput, thewildcards)
dim mylist
dim i
dim splitname
dim spellname
dim endtime
dim timeleft
dim character

mylist = world.GetVariableList


if not IsEmpty (mylist) then
for i = lbound (mylist) to ubound (mylist)
splitname = split (mylist (i), "_")
if ubound (splitname) = 2 then
if splitname (0) = "spelltimer" and splitname (1) = "name" then
endtime = CDate (world.GetVariable _
(splitname (0) & "_Time_" & splitname (2)))
spellname = world.GetVariable _
(splitname (0) & "_SpellName_" & splitname (2))
if spellname = thewildcards (1) or thewildcards (1) = "all" then
character = world.GetVariable (mylist (i))
timeleft = DateDiff("s", Now, endtime)
if timeleft > 0 then
world.send "say {" & spellname & "} on " _
& character & ", left " _
& timeleft & " secs .(TIMER)"
end if
end if
end if ' found a spelltimer variable
end if ' split into 3 pieces
next ' end of loop
End If ' have any variables

end sub
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


6,962 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]