Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ VBscript
➜ Timer for following how long spells last
Timer for following how long spells last
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Tassu
(3 posts) Bio
|
Date
| Wed 20 Oct 2004 05:41 PM (UTC) Amended on Wed 20 Oct 2004 06:08 PM (UTC) by Tassu
|
Message
| For some time I have been looking into making a timer
with VB-script that would help me following how long does
my spells last with my character.
Coz I totally lack the skills I was hoping I could find some
genius here!
The timer should start from trigger..
example:
You feel like your the strongest person in the world!
And when the spell expires I would want to see how long
did this spell last. I get message again for example:
You feel weak again.
I would want to send it to world containing the information
how long the spell lasted, example:
world.send "say Spell expired (xx minutes,xx secconds)"
In addition I would want to check the time already passed
with alias too...
like alias called: check spells
This way I could estimate how long the spell will still last
I hope I get answers about,
1) is this possible to do
2) and maybe little help in doing so :D
My thanks already!
| Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #1 on Wed 20 Oct 2004 06:42 PM (UTC) |
Message
| Anything and (almost) everything is possible.
You wont actually be using timers.
Instead, youll use one of the time functions in VBScript and subtraction.
Depending on how you want to make it, you have a few options. You could use "now" except if you store that variable, you run into problems converting it back to a date variant.
Well, youre going to have to convert it back to a date format if youre planning on storing it as a MC variable (the alternative would be a VBscript variable, which would only be around as long as your script was active).
So, youll have to break it down sooner or later.
You could use "time", and then store it to a variable and then use timevalue to return it as a time, and then subtract from the current time.
The only problem with that is you have to deal with negatives if you get a spell at say, 11:55(pm) and then it goes away at 12:05 the next day. But instead of adding a date to your variable, I think itd be easier to check if it was negative, and then if it was, add (since its negative) to 24 hours.
That would be how you figured out the duration of a spell. you could use the same routine (make it a subroutine, so you can reuse it in different contexts) for total time, or the elapsed time. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #2 on Wed 20 Oct 2004 06:56 PM (UTC) |
Message
| Nevermind. That gets messy quickly.
Use these:
Setvariable "spellname", now
to set the spell start time.
then use this to return the number of seconds:
Datediff("s", getvariable("spellname"), now)
and you can change that "s" to "m" if you want minutes (or you can divide s by 60).
And again, you use that code to return the time since it started to now (whether thats to figure out how much longer, or how long something lasts. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #3 on Wed 20 Oct 2004 07:07 PM (UTC) |
Message
| This will work for your strength spell. It matches on "You feel like you're the strongest person in the world!", and "You feel weak again".
For the alias, you type "checkspell XX" where XX is the variable name ("checkspell strength" will work for this example), this way you don't need to make a bunch of aliases.
Copy from <triggers> to </triggers> then paste in the trigger dialog, and between <aliases> and </aliases> and paste in the alias dialog.
<triggers>
<trigger
enabled="y"
ignore_case="y"
match="You feel like you're the strongest person in the world!"
send_to="12"
sequence="100"
>
<send>Setvariable "strength", now</send>
</trigger>
<trigger
enabled="y"
match="You feel weak again."
send_to="12"
sequence="100"
>
<send>note "The Strength spell lasted: " & Datediff("s", getvariable("strength"), now) & " seconds."</send>
</trigger>
</triggers>
<aliases>
<alias
match="checkspell *"
enabled="y"
send_to="12"
ignore_case="y"
sequence="100"
>
<send>note "The %1 spell has lasted " & Datediff("s", getvariable("%1"), now) & " seconds so far."</send>
</alias>
</aliases>
|
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Tassu
(3 posts) Bio
|
Date
| Reply #4 on Thu 21 Oct 2004 01:34 AM (UTC) Amended on Mon 25 Oct 2004 11:56 PM (UTC) by Tassu
|
Message
| Ok its all good got it working :D | Top |
|
Posted by
| Aheram
(23 posts) Bio
|
Date
| Reply #5 on Mon 27 Dec 2004 04:58 PM (UTC) |
Message
| Hey! A spell timer! *reads*
I have a thread up asking about it. | Top |
|
Posted by
| Aheram
(23 posts) Bio
|
Date
| Reply #6 on Mon 27 Dec 2004 05:12 PM (UTC) |
Message
| Now, is there a way to get say the duration and then instead of telling me how long it is lasting, it will tell me how long it WILL last. Ie, "You have 60 seconds left from this spell." | Top |
|
Posted by
| Aheram
(23 posts) Bio
|
Date
| Reply #7 on Mon 27 Dec 2004 07:36 PM (UTC) |
Message
| Well, I have figured out what to do with the XP calculator and I am "almost" there with the spell duration.
Is there a way to replace negative integers from a display?
<aliases>
<alias
match="aff"
enabled="y"
echo_alias="y"
expand_variables="y"
send_to="12"
sequence="100"
>
<send>AnsiNote ANSI (37) & "These are the spells currently casted on you."
AnsiNote ANSI (37) & "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
AnsiNote ANSI (37) & "Magic Shield: @SpellMagicShield\."
AnsiNote ANSI (37) & "Haste: @SpellHaste\."
AnsiNote ANSI (37) & "Fireshield: " & ANSI (33) & "@SpellFireshield\." & ANSI (37) & " It has " & CLng(GetVariable("SpellFireshieldDuration"))-CLng(Datediff("s", getvariable("SpellFireshieldTimer"), now)) & " out of @SpellFireshieldDuration seconds left."
AnsiNote ANSI (37) & " "
AnsiNote ANSI (37) & "NullAura: @SpellNullAura\."
AnsiNote ANSI (37) & "AbsorbAura: @SpellAbsorbAura\."
AnsiNote ANSI (37) & "ReflectAura: @SpellReflectAura\."
AnsiNote ANSI (37) & " "
AnsiNote ANSI (37) & "You are currently using the offensive spell: @SetSpell\."
AnsiNote ANSI (37) & "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"</send>
</alias>
</aliases>
This is what it looks like right now. When Fireshield ends, the screen will display "-54 out of 138 seconds left." And it gets bigger and bigger. Is there a way to either stop the timer (if all the counting takes too much computer resource, especially if it is gets to -19034859038903 or something) or replace the negative integers with a 0? | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #8 on Mon 27 Dec 2004 08:18 PM (UTC) Amended on Mon 27 Dec 2004 08:26 PM (UTC) by Flannel
|
Message
| There actually is no timer. It just subtracts "now" from the time stored in memory (in that variable).
So you cant 'stop' the timer. But you could add an if statement about it (and then not calculate it) since I imagine you'll get an overflow if you have too much difference.
Which means you could toggle that aspect of the spell reporting (make each spell report independantly (with if statements)). Since obviously you dont have that spell on you if its 0 out of 113 seconds.
Then you could check if the spell is active, before outputting the whole thing and then having to force a 0 into the duration.
Or you could simply use an if statement to write a 0 and skip the calculation. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Aheram
(23 posts) Bio
|
Date
| Reply #9 on Mon 27 Dec 2004 08:38 PM (UTC) |
Message
| Will...
if world.GetVariable("SpellFireshieldTimer") = CLng(GetVariable("SpellFireshieldDuration"))+1 Then
world.SetVariable "SpellFireshieldTimer", GetVariable("SpellFireshieldDuration")
end if
...work?
Basically, if SpellFireshieldTimer goes 1 higher than SpellFireshieldDuration (which would give a negative result if you subtract it from SpellFireshieldDuration), then the client forces SpellFireshieldTimer to be the same value as SpellFireshieldDuration.... which would result in a 0. But it seems that it creates an overflow. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #10 on Mon 27 Dec 2004 08:46 PM (UTC) Amended on Mon 27 Dec 2004 08:47 PM (UTC) by Flannel
|
Message
| Problem is the date format (in the Timer variable). You need to use the date functions to convert things into 'real' numbers (and not the number of seconds since... whenever in 1971).
You can read about them in the VBScript (Windows Script) help file. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Aheram
(23 posts) Bio
|
Date
| Reply #11 on Mon 27 Dec 2004 11:15 PM (UTC) |
Message
| Well, I did this instead and it worked. ^_^
alias aff01
if world.getvariable("SpellMagicShield") = "Yes" Then
World.SetVariable "SpellMagicShieldTimer2", CLng(GetVariable("SpellMagicShieldDuration"))-CLng(Datediff("s", getvariable("SpellMagicShieldTimer"), now))
else
end if
if world.getVariable("SpellMagicShield") = "No" Then
world.SetVariable "SpellMagicShieldTimer2", "0"
else
end if
alias aff02
AnsiNote ANSI (37) & "With the intelligence of a mage you examine the magic flowing about you:"
AnsiNote ANSI (37) & "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
AnsiNote ANSI (37) & "Magic Shield: " & ANSI (33) & "@SpellMagicShield\." & ANSI (37) & " It has @SpellMagicShieldTimer2 out of @SpellMagicShieldDuration seconds left."
If I put alias aff01 and aff02 together, it does not show me the current duration, but rather the old one. So, I separated them, but created a new alias called "aff" that sends to "execute" both aff01 and aff02. Thank you! | 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.
27,608 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top