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
takke
Beginner


Joined: 11 Oct 2002
Posts: 29
Location: Sweden

PostPosted: Mon Oct 24, 2022 12:04 am   

Calculate change
 
I feel abit retarded and this shouldn't be that hard but have a problem that would be nice if someone could help me with.

I get this string from the mud when i type the command "estimate"

"Your dragons progress in the order of Contezial is 36.2%."

I play for a couple of hours and i go to a certain place and type in "estimate" again
With some luck my dragon has made progress and the percentage have changed.

I want to be able to track that change and present it in the status window.

Something like this:

Contezial: [36.2%] Change: [0%]

How could i manage this?

Thanks in advance
Reply with quote
shalimar
GURU


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

PostPosted: Mon Oct 24, 2022 1:13 pm   
 
You need at least two variables to track changes, so first, we need to capture those:

Code:
#TR {Your dragons progress in the order of Contezial is (%d.%d)~%.} {
  contezialChange=(%1-@contezial)
  contezial=%1
 }


Prolly need to use concatenation to ensure no space between the number and symbol in your desired output:

#STWIN { Contezial: [%concat(@contezial, "%")] Change: [%concat(@contezialChange, "%")]}

Now if you want to display more stuff in the status window, you would need to edit the existing status object rather than make more status window objects.
_________________
Discord: Shalimarwildcat
Reply with quote
takke
Beginner


Joined: 11 Oct 2002
Posts: 29
Location: Sweden

PostPosted: Tue Oct 25, 2022 4:23 am   
 
shalimar wrote:
You need at least two variables to track changes, so first, we need to capture those:

Code:
#TR {Your dragons progress in the order of Contezial is (%d.%d)~%.} {
  contezialChange=(%1-@contezial)
  contezial=%1
 }


Prolly need to use concatenation to ensure no space between the number and symbol in your desired output:

#STWIN { Contezial: [%concat(@contezial, "%")] Change: [%concat(@contezialChange, "%")]}

Now if you want to display more stuff in the status window, you would need to edit the existing status object rather than make more status window objects.


Thanks shlimar, this worked like a charm. I ended up using %format to get it down to 2 decimals :)
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