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
➜ General
➜ Call time connected into a trigger
Call time connected into a trigger
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Xandler
(52 posts) Bio
|
Date
| Sun 30 Dec 2018 04:55 AM (UTC) |
Message
| This is what I want to do. I want to call the time connected from the status bar into a totals type trigger, but I am unaware how to do so or even if it's possible. I haven't played with the status bar much so I don't even know if the time connected can be called. If it can, how does one do so? | Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #1 on Sun 30 Dec 2018 06:19 PM (UTC) |
Message
| |
Posted by
| Xandler
(52 posts) Bio
|
Date
| Reply #2 on Mon 31 Dec 2018 05:12 AM (UTC) |
Message
| That might be it, but seems that only returns the time in seconds? I was more referring to the portion of the status bar that has the time connected information in days, hours, minutes, seconds. I see that it's called with a note, I want it to be seen by all and not just myself, I'm a novice at this, can this be done? For example, the output would be something along the lines of:
say I have gained suchandsuch over this amount of time (in days, hours, minutes, seconds). | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #3 on Mon 31 Dec 2018 08:23 PM (UTC) Amended on Mon 31 Dec 2018 08:43 PM (UTC) by Nick Gammon
|
Message
| There is a function that turns seconds into printable time from a seconds input. Your trigger could look like this:
<triggers>
<trigger
enabled="y"
match="You kill *"
send_to="12"
sequence="100"
>
<send>
require "commas" -- for convert_time function
xp_gain = 42 -- whatever
Send (string.format ("say I have gained %i XP over %s", xp_gain, convert_time (GetConnectDuration())))
</send>
</trigger>
</triggers>
I'll leave it to you to do the xp calculation.
This however is not in the status bar, it is sent to the MUD. You could set the status bar to the same thing as a separate line of code.
The function convert_time gives you a "short form" time - that is, it rounds to the nearest larger interval (eg. 5m rather than 4m 30s). You could rewrite to do a longer form. For example:
function convert_full_time (secs)
-- handle negative numbers
local sign = ""
if secs < 0 then
secs = math.abs (secs)
sign = "-"
end -- if negative seconds
local result = {}
local secs_in_min = 60
local secs_in_hour = secs_in_min * 60
local secs_in_day = secs_in_hour * 24
local secs_in_week = secs_in_day * 7
-- weeks
if secs >= secs_in_week then
table.insert (result, math.floor (secs / secs_in_week) .. "w" )
secs = secs % secs_in_week -- remainder
end -- a week or more
-- days
if secs >= secs_in_day then
table.insert (result, math.floor (secs / secs_in_day) .. "d" )
secs = secs % secs_in_day -- remainder
end -- a day or more
-- hours
if secs >= secs_in_hour then
table.insert (result, math.floor (secs / secs_in_hour) .. "h" )
secs = secs % secs_in_hour -- remainder
end -- an hour or more
-- mins
if secs >= secs_in_min then
table.insert (result, math.floor (secs / secs_in_min) .. "m" )
secs = secs % secs_in_min -- remainder
end -- a min or more
-- seconds
if secs > 0 then
table.insert (result, secs .. "s" )
end -- if any seconds over
return sign .. table.concat (result, " ")
end -- function convert_full_time
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
13,301 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top