 |
chris123zugg Adept
Joined: 23 Aug 2013 Posts: 221
|
Posted: Sun Mar 16, 2025 11:45 pm
time formatting not working? |
//GXP:93031026 G2N:18110(99.0977) WPN:Immaculate COF:20/20 MOB: emergency
G2N is where this is pulling the capture from
gxprd=21
//gxp
$wardergxp = %int(%2)
$warderrds = (($wardergxp / @gxprd))
$gxptime = 0
$gxpdays = 0+($warderrds/86400)
$gxphours = 0+%eval(%mod($warderrds/3600,86400)-(24*$gxpdays))
$gxpmins = 0+%eval(%mod($warderrds/60,60))
$gxpsecs = 0+%eval(%mod($warderrds,60))
$gxpprefix = "-- "
$gxpsuffix = " --"
#switch ($gxpdays > 0) {$gxptime = %string($gxpdays)+"d "+%string($gxphours)+"h "+%string($gxpmins)+"m "+%string($gxpsecs)+"s"} ($gxphours > 0) {$gxptime = %string($gxphours)+"h "+%string($gxpmins)+"m "+%string($gxpsecs)+"s"} ($gxpmins > 0) {$gxptime = %string($gxpmins)+"m "+%string($gxpsecs)+"s"}
$gxptime = %string($gxphours)+"h "+%string($gxpmins)+"m "+%string($gxpsecs)+"s"
gxptimenow = $gxptime
gxprds=$warderrds
#print @gxptimenow @gxprds
gxptimenow = $gxptime
gxprds=$warderrds
im confused as heck about this, its accurate to the second but its not mathing right... anyone can point to the part thats broken?
this is the #help file for %mod
mod
Syntax: %mod(a,b)
returns a modulus b. This is the remainder after dividing a by b.
Example:
#SHOW %mod(8,3)
Displays: 2
#SHOW %mod(8,4)
Displays: 0
seconds=3917
#SHOW hours:%eval(@seconds/3600) mins:%mod(@seconds/60,60) secs:%mod(@seconds,60)
Displays: hours:1 mins:5 secs:17
thanks in advance.[/code] |
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4765 Location: Pensacola, FL, USA
|
Posted: Mon Mar 17, 2025 12:35 am |
pattern might help
|
|
_________________ Discord: Shalimarwildcat |
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4765 Location: Pensacola, FL, USA
|
Posted: Mon Mar 17, 2025 12:40 am |
Instead of cycling things through %string perhaps just use %concat?
$gxptime=%concat($gxpdays, "d ", $gxphours, "h ", "etc", "etc")
and what's with all the 0+ before the function call?
Unnecessary and it won't evaluate without being enclosed in parentheses like any other expression |
|
_________________ Discord: Shalimarwildcat |
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4765 Location: Pensacola, FL, USA
|
Posted: Mon Mar 17, 2025 1:46 am |
Instead of defining gpxtime as 0 at the start, use the #LOCAL command to declare it with a null value
#LOCAL $gpxTime
this is the preferred method when you just need the variable to exist before something in a subroutine (anything in curly brackets) actually defines it |
|
_________________ Discord: Shalimarwildcat |
|
|
 |
chris123zugg Adept
Joined: 23 Aug 2013 Posts: 221
|
Posted: Mon Mar 17, 2025 2:05 am |
hrrrm ok, ill re-draw it all. and the top line is the capture...
|
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4765 Location: Pensacola, FL, USA
|
Posted: Mon Mar 17, 2025 2:07 am |
Code: |
#LOCAL $time
$tot=(%2/@gxprd)
$days=($tot/86400)
#IF ($days) {
$tot=%mod($tot, 86400)
$time=%concat($days, "d")
}
$hours=($tot/60)
#IF ($hours) {
$tot=%mod($tot, 60)
$time=%trim(%concat($time, " ", $hours, "h"))
}
$mins=($tot/60)
#IF ($mins) {
$tot=%mod($tot, 60)
$time=%trim(%concat($time, " ", $mins, "m"))
}
$secs=($tot/60)
#IF ($secs) {$time=%trim(%concat($time, " ", $secs, "s"))}
#PRINT $time %eval(%2/@gxprd) |
|
|
_________________ Discord: Shalimarwildcat |
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4765 Location: Pensacola, FL, USA
|
Posted: Mon Mar 17, 2025 2:40 am |
This is a better version that prevents erroneous displays, the original is not properly error checking:
Code: |
#LOCAL $time
$tot=$cur=(%2/@gxprd)
#while $cur {#SWITCH ($cur)
(>86400) {
$days=($cur/86400)
$cur=%mod( $cur, 86400)
$time=%concat( $days, "d")
}
(>3600) {
$hours=($cur/3600)
$cur=%mod( $cur, 3600)
$time=%trim( %concat( $time, " ", $hours, "h")
}
(>60) {
$mins=($cur/60)
$cur=%mod( $cur, 60)
$time=%trim(%concat( $time, " ", $mins, "m")
}
{$time=%trim(%concat($time, " ", %pop( $cur), "s")}}
#PRINT $time $tot |
|
|
_________________ Discord: Shalimarwildcat |
|
|
 |
chris123zugg Adept
Joined: 23 Aug 2013 Posts: 221
|
Posted: Mon Mar 17, 2025 3:36 am |
sorry shalimar, wehn i added this in the trigger, it shows error and doesnt work
|
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4765 Location: Pensacola, FL, USA
|
Posted: Mon Mar 17, 2025 10:57 am |
Yea, I was half asleep, i made a few errors
Code: |
#LOCAL $time
$tot=(%2/@gxprd)
$cur=$tot
#while $cur {#SWITCH ($cur>86400) {
$days=($cur/86400)
$cur=%mod( $cur, 86400)
$time=%concat( $days, "d")
}
($cur>3600) {
$hours=($cur/3600)
$cur=%mod( $cur, 60)
$time=%trim( %concat( $time, " ", $hours, "h"))
}
($cur>60) {
$mins=($cur/60)
$cur=%mod( $cur, 60)
$time=%trim( %concat( $time, " ", $mins, "m"))
}
{$time=%trim( %concat( $time, " ", %pop( $cur), "s"))}}
#PRINT $time $tot |
|
|
_________________ Discord: Shalimarwildcat
Last edited by shalimar on Mon Mar 17, 2025 5:15 pm; edited 1 time in total |
|
|
 |
chris123zugg Adept
Joined: 23 Aug 2013 Posts: 221
|
Posted: Mon Mar 17, 2025 12:21 pm |
3108h 12s 74592 <-- is the output from that script, i think the issue is this mud uses 2 seconds per round, so it's not propgating correctly, do i just change seconds to 30 instead of 60?
and the "H" "M" "S" portion of print in $tot where should i add the mins to separate the output?
and is it also the because the gxprd is "what i get PER rd", then the G2N is the TOTAL required for next glevel.
the math im seeing is g2n/gxprd then its passed through the function you made for establishing and adding math -> mins -> seconds, which is showing 3108h, which im going to just make ag2n up to put this in perspective
1526900/21 = 74423.8
then i would divide the (total rounds needed) 74423/30 (every round is 2 seconds...) 2480
then divide that by hours (60) 41.34
sorry if i've gone about this the wrong way, i just dont now how to correct that function to parse that correctly.
thanks again shalimar:) |
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4765 Location: Pensacola, FL, USA
|
Posted: Mon Mar 17, 2025 5:20 pm |
No, i had left another typo in
|
|
_________________ Discord: Shalimarwildcat |
|
|
 |
chris123zugg Adept
Joined: 23 Aug 2013 Posts: 221
|
Posted: Tue Mar 18, 2025 7:48 pm |
**EDIT**
and the hours aren't showing, but i think i broke something when i added a space somewhere ?
#LOCAL $time
$tot=(%2/@gxprd)
$cur=$tot
#while $cur {#SWITCH ($cur > 86400) {
$days=($cur / 86400)
$cur=%mod( $cur, 86400)
$time=%concat( $days, "d")
}
($cur > 3600) {
$hours=($cur/3600)
$cur=%mod( $cur, 60)
$time=%trim( %concat( $time, " ", $hours, "h"))
}
($cur > 60) {
$mins=($cur / 60)
$cur=%mod( $cur, 60)
$time=%trim( %concat( $time, " ", $mins, "m"))
}
{$time=%trim( %concat( $time, " ", %pop( $cur), "s"))}}
//#PRINT $time $tot |
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4765 Location: Pensacola, FL, USA
|
Posted: Mon Apr 07, 2025 3:15 pm |
I think you are just missing a closing brcket for the while?
Did you use the check syntax (ctrl+k) option under the Editor menu? |
|
_________________ Discord: Shalimarwildcat |
|
|
 |
chris123zugg Adept
Joined: 23 Aug 2013 Posts: 221
|
Posted: Thu Jun 19, 2025 8:35 pm |
10h 31s 37711 <-- is the printout of the working function you made...
im not sure why the d, h, m, s arent displayed with $timer.. but its showing what i supplied above. |
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4765 Location: Pensacola, FL, USA
|
Posted: Sun Jun 22, 2025 3:54 am |
if the value for those increments is 0, they don't show
this is expected behavior |
|
_________________ Discord: Shalimarwildcat |
|
|
 |
chris123zugg Adept
Joined: 23 Aug 2013 Posts: 221
|
Posted: Wed Jun 25, 2025 9:32 pm |
hrrrm some variable is trying to play games with me! ill re-check the base variables... thanks S.
|
|
|
 |
|
|