mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2018
Posts: 2
P
Pinja Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
P
Joined: Mar 2018
Posts: 2
I am sure I am not phrasing this right, and am super new to mIRC as well as coding in general, but essentially I am curious if there is a way to grab a certain part of what one says and make it a variable; Kind of like scanf().

so given: "(Player HP: 82/82)"

I wanted to grab the ##/## and save as a variable which would update when a new ##/## is given (like 73/82) then be called back in if then statements for example:

on *:text:*:?: {
if %hp < 40/82 {
msg $nick , use hp potion!

(Was also not sure if it was possible if you needed to save var an int or not)

Sorry if these are super basic questions or if I am going about this the entirely wrong way, just spent awhile looking and decided to try asking here after giving up.

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
It can also be done with regex, but here's a way to do it with tokens. You can hunt for a wildcard token that matches a pattern, then use $replace to turn the unwanted characters into spaces. It won't recognize a fraction as a number, it treats them like strings:

Code:
//if (2/3 < 3/7) echo -a less


If you're wanting just the 1st number, you can turn the slash into a space and grab that token. Or you can parse to grab the fraction, then use $calc to turn it into decimals:

Code:
//var %a (Player HP: 40/82) | var %b $wildtok(%a,*/* $+ $chr(41) ,1,32) | echo -a %b | var %c $replace(%b,$chr(41),$chr(32)) | echo -a %c | echo -a $calc(%c)


Joined: Mar 2018
Posts: 2
P
Pinja Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
P
Joined: Mar 2018
Posts: 2
Sorry for such a late reply to this, but thanks for the help ^_^


Link Copied to Clipboard