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?
Call time connected into a trigger
Posted by Xandler on Sun 30 Dec 2018 04:55 AM — 4 posts, 18,391 views.
It sounds like you want https://www.mushclient.com/scripts/doc.php?function=GetConnectDuration
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).
say I have gained suchandsuch over this amount of time (in days, hours, minutes, seconds).
There is a function that turns seconds into printable time from a seconds input. Your trigger could look like this:
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:
<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