Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Thu Oct 22, 2020 6:17 am   

calculating buff duration based on %time
 
I have two triggers to execute %time("hh:nn:ss") when buff is activated and when it falls off.

I record or attempt to record these values as $local to store the total converted into seconds value, so I can sub the end value with start value and use %mod to convert that to a time value for how much time had passed... if that makes any sense...
Needless to say it doesn't work... it just #SHOWS 0

All I need to do is take TimeStamp B and subtract TimeStamp A to get the difference in minutes... but I don't know how to go about that in cmud.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Thu Oct 22, 2020 8:20 pm   
 
You will need to use a normal variable to store the start time, as $localVars only exist in the script that calls them.
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Fri Oct 23, 2020 12:21 am   
 
I thought I had... I may need to post my code for the two trigs in question and maybe you can spot my mistake...
** expect edit with code shortly **

Code:
Pattern : ^(?:|(\d+):(\d+):(\d+)\s)You have mastered control of your breathing.

charStats.CB=1
#SUB {%time("hh:nn:ss") You have mastered control of your breathing.}
#ALARM CBDur {+720} {#ECHO {Controlled Breathing Ends Soon!!!}}
NRG

//convert time to numerical value in seconds
guildSkills.ControlledBreathingStart = ((%1*3600)+(%2*60)+%3)

Code:
Pattern: ^(?:|(\d+):(\d+):(\d+)\s)You have lost control of your breathing and your resistance to melee attacks fades.

charStats.CB=0
#SUB {%time("hh:nn:ss") You have lost control of your breathing and your resistance to melee attacks fades.}

//convert time to numerical value in seconds
guildSkills.ControlledBreathingEnd = ((%1*3600)+(%2*60)+%3)

//calculate time differance
guildSkills.ControlledBreathingDuration = (@guildSkills.ControlledBreathingEnd - @guildSkills.ControlledBreathingStart)
#SHOW {Controlled Breathing Duration : hours:%eval(@guildSkills.ControlledBreathingDuration/3600) mins:%mod(@guildSkills.ControlledBreathingDuration/60,60) secs:%mod(@guildSkills.ControlledBreathingDuration,60)}

both charStats and guildSkills variables already existed with pre-defined keys.

** and I see half of my problem... this is the trigger that "adds" the timestamp to the spam of text so how can is store those values to run the calculation unless I have a second trigg for that purpose... *facepalm*
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Fri Oct 23, 2020 2:47 pm   
 
Wow I seriously over complicated this... little google-fu and I found a solution. Works as Desired.

Code:
Pattern: AS ABOVE

charStats.CB=1
#SUB {%time("hh:nn:ss") You have mastered control of your breathing.}
NRG
#UNT {Your skill fails.}
//convert time to numerical value in seconds
guildSkills.ControlledBreathingStart = %ctime

Code:
Pattern: AS ABOVE

charStats.CB=0
#SUB {%time("hh:nn:ss") %ansi(blink,red)You have lost control of your breathing and your resistance to melee attacks fades.%ansi(reset)}

//convert time to numerical value in seconds
guildSkills.ControlledBreathingEnd = %ctime

//calculate time differance
guildSkills.ControlledBreathingDuration = %eval(@guildSkills.ControlledBreathingEnd - @guildSkills.ControlledBreathingStart)
#SHOW {Controlled Breathing Duration : hours:%eval(@guildSkills.ControlledBreathingDuration/3600) mins:%mod(@guildSkills.ControlledBreathingDuration/60,60) secs:%mod(@guildSkills.ControlledBreathingDuration,60)}
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net