ability to find out spell duration at any given time

Posted by Guest1 on Sat 11 Oct 2003 12:59 AM — 10 posts, 42,737 views.

USA #0
Had a look at a couple of old threads but didn't really cover what I want.

I want to set up a trigger so when a spell starts, it will fire a timer of some sort which records how long the spell has been running (usually wouldn't be more than 10 mins max), so that at any time I can type in an alias to get a report of how long the spell has been running so far at that point..

What would be ideal is if there was something in GetTimerInfo that would give me that time (in minutes + seconds) since it fired, but don't see that it can.

The other options seem pretty involved, like maybe having the timer add 1 to a numerical variable every second and then the alias would check the variable, but dunno if I want a timer firing and resetting a variable every second slowing other processes down..

Any other suggestions that aren't too involved? I saw something about getting the current real time off the PC at startup and seting it as a variable somehow, and then using an alias to call current real time and somehow it working out the difference, but farked if I know how to pull the real time off the pc..

How about a command that pulls the time connected to world that shows in the status bar? There must be a way to get that info and use it.. maybe..

p.s. I'm using vb for my scripts
Amended on Sat 11 Oct 2003 08:11 AM by Guest1
USA #1
Its real easy, theres a function called "now"

for example, to note the current time, you type this:
/note now
well, assuming your script prefix is /
That should be all you need... theres also a function for time, called... time

(Now returns date as well)

There are also Hour, Minute, second, year, etc. and for those, you would do: Minute(now), this is all tons better documented in the Windows Script documentation (a link can be found on the same page with the link to the scripting engines)
Greece #2
Just get a trigger that fires on each spell to store VBScript's "Timer" on a variable, and do a OldTimer - Timer to get seconds since the trigger fired.
USA #3
Thanks Flannel.. unfortunately I couldn't find anything about the 'now' function on the page that you referred to
http://www.gammon.com.au/scripts/function.php
I entered '/note time' etc and yeah it gave me the time as a world note which is all very nice but didn't do much else for me.

Poromenos, yup that is exactly what I want, but as I originally posted, I can't seem to find what exactly calls that vbtimer to store it as a variable and, well I'm repeating myself now.

I've got a bad flu atm, guess I'm not thinking straight. I'll go back to the script help files once again or just give up.

addon:
this thread should help me
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=719
altho it's 2 years old..
Amended on Sat 11 Oct 2003 07:33 PM by Guest1
USA #4
You might want to look for the 'help' files for windows scripting. You can get them from:

http://download.microsoft.com/download/winscript56/Install/5.6/W982KMeXP/EN-US/scrdoc56en.exe

Assuming they haven't changed the link at Microsoft again. They have a nasty habit of doing so. These help files cover VBScript, JScript and WSH. The 'now' function people have mentioned in built in to the script engine, which is why it is not listed in the Mushclient commands. Basically, when your spell starts you set a variable to now:

setvariable "Myspell", now

then when it falls you would do something like:

note datediff("s",getavariable("Myspell"),now)

Datediff is also a VBScript command, and not listed among Mushclient's commands. JScript, Perl and Python would all have some equivalent form of both 'now' and 'datediff' in them.
Amended on Sat 11 Oct 2003 07:59 PM by Shadowfyr
USA #5
ahhh ok thanks Shadowfyr.. 'fraid I'm not firing on all cylinders atm *bangs head against wall a few times*
..so once I set the trigger up, I can just use
note datediff("s",getavariable("Myspell"),now)
via an alias at any time to get an update on the time taken so far at that moment since the spell started, and then send it as a group tell. The reason behind this is that the mud I play on has basically removed 'ticks' altogether and also made spell durations variable within certain parameters, in the process making life as a tank hell.
cheers
Amended on Sat 11 Oct 2003 09:14 PM by Guest1
USA #6
Great it all works and grouptells duration in seconds.. now to just convert it to minutes and seconds instead for the grouptell..
USA #7
Ok if anyone is interested, this is how I did it (even if it is a mickey mouse way around it, it works)

triggers on 'You are surrounded by a radiant light.'
which calls a script called aegis_up which sets a variable called 'durationstart'


sub aegis_up
  World.SetVariable "durationstart", time
end sub


at anytime I can type the alias 'ld' (lite duration) to see how long it's been running for. The alias calls a script called 'getduration'..


sub getduration
	dim durationA
	dim durationB
	dim durationC
	    durationA = datediff("s",getvariable("durationstart"),time)
	    World.SetVariable "durationA", durationA
		durationB = (Fix(durationA / 60))
		durationC = (durationA - (durationB * 60))
	world.EchoInput = 0
  world.send "grouptell :: spell has been up for " & durationB & "mins " & durationC & "secs "
	world.EchoInput = 1
end sub


seems to work so far... :)
Amended on Sat 11 Oct 2003 11:05 PM by Guest1
Canada #8
Yeah, I do something similar, although mine looks way longer:

Function TimeFormat (Seconds)
	Dim Hours, Minutes
	Seconds = CLng(Seconds)
	Minutes = Seconds / 60
	Minutes = Fix(Minutes)
	Seconds = Seconds - (Minutes * 60)
	Hours = Minutes / 60
	Hours = Fix(Hours)
	Minutes = Minutes - (Hours * 60)
	Seconds = CStr(Seconds)
	Minutes = CStr(Minutes)
	Hours = CStr(Hours)
	If Len(Seconds) = 1 Then Seconds = "0" + Seconds
	If Len(Minutes) = 1 Then Minutes = "0" + Minutes
	If Len(Hours) = 1 Then Hours = "0" + Hours
	TimeFormat = Hours & ":" & Minutes & ":" & Seconds
End Function

Function TimeDiff (StartTime, EndTime)
	Dim Hours, Minutes, Seconds
	Seconds = DateDiff("s", StartTime, EndTime)
	If Seconds > 2147483647 Then Seconds = 2147483647
	If Seconds < 0 Then Seconds = 0
	TimeDiff = TimeFormat(Seconds)
End Function
Australia Forum Administrator #9
See:

http://www.gammon.com.au/scripts/doc.php?function=GetTimerInfo

You can get the date/time it fired, when it will fire next and how many seconds until it fires next. The last one (how many seconds till it fires next) is a pretty good indicator of how long the spell has to go.