Storing a variable

Posted by Rinor on Mon 18 Apr 2005 01:40 AM — 3 posts, 16,044 views.

#0
I'm trying to capture the hitpoints in my prompt and store it in a variable. This is the prompt: [DH][MH][sq]:[918hp]-[309m]-[610mv]-[100br]:[v] . I'm using ^\[DH\]\[MH\]\[sq\]\:\[\d+hp\]\-\[309m\]\-\[610mv\]\-\[100br\]\:\[v\] $ for the trigger. The problem is that I don't know what to do after this. %0 would send the whole line to a variable where as I only want the amount of my hitpoints.

Thanks for any help
USA #1
^\[DH\]\[MH\]\[sq\]\:\[\d+hp\]\-\[309m\]\-\[610mv\]\-\[100br\]\:\[v\] $
You should PROBABLY make it:
^\[DH\]\[MH\]\[sq\]\:\[(\d+)hp\]\-\[\d+m\]\-\[\d+mv\]\-\[\d+br\]\:\[v\] $
Since, otherwise it will ONLY match when m=309 mv=610 and br=100 (you might also want to make the other things variable? I dont know, depending on if they change).

And you surround the thing in parenthesis (\d+) and then you can use %# where the number is the parenthesis number (or you can assign them names). In this case your hp (notice the (\d+)hp) will be in %1.

You might also think about making it a little more lax (either by removing the $ or adding a .* to the end) if your commands (or any other output) ever ends up on the prompt line.
#2
Ah perfect, thanks.