Page 1 of 1

Interesting concept but... need help.

Posted: Tue May 17, 2016 1:49 pm
by noblestone
Code: [show] | [select all] lua
^ ?\d+\| {0,2}\d+ \w+ {1,2}(\w+) +(?:Stand|Sleep|Rest|Fight|STUN!|DROWN) -?\d+/-?\d+ +-?\d+/-?\d+ +-?\d+/-?\d+ +\d+ +(?:-?\d+|\?\?\?\?\?)$
Set as perl regex and below is:

selectCurrentLine()
copy()
appendBuffer("GroupConsole")
deleteLine()

Outcome is:

1|737 Lord Wolthu Sleep 40009/40009 6607/6607 35827/35827 866 1000

How do I weed it out, I only want to capture and show in miniconsole, Name, 40009/40009, and 866

Ideas?

Thanks

Re: Interesting concept but... need help.

Posted: Tue May 17, 2016 10:19 pm
by SlySven
Have a play on the Regex 101 website, I think '('...')' around "capture groups" (bits you want that are returned in matches[2+] (the entire line is in matches[1] IIRC) might be of use here...

Re: Interesting concept but... need help.

Posted: Wed May 18, 2016 4:14 am
by noblestone
That I know but where to put the matches in box below like :

selectCurrentLine()
copy()
appendBuffer("GroupConsole")
deleteLine()

That is my question. Thanks

Re: Interesting concept but... need help.

Posted: Wed May 18, 2016 6:42 pm
by SlySven
Humm, can you get a few more lines that ARE to match - I am having some difficulty picking through which bits are not essential but may appear in lines that are to match. (Advanced PCRE stuff is a little outside of my current experience-set at the moment - but I am learning all the time...!)

I wonder if you can use:

selectCaptureGroup(...)
copy()
appendBuffer("GroupConsole")

several times to grab each bit of the line and then copy that bit across to the sub-console before you use the deleteLine()?

Re: Interesting concept but... need help.

Posted: Thu May 19, 2016 1:03 am
by noblestone
-------------------------------------------------------------------------------
##| Level Name Pos HitPoints ManaPoints MovePoints TNL Align
-------------------------------------------------------------------------------
1|999 Lord Xuyr Stand 51104/51104 7283/7283 24474/25084 519 1000
2|588 Lord Annihylate Sleep 7123/7123 30891/33669 7808/8520 1046 -1000
3|200 Lord Kiron Sleep 10343/10343 19254/19254 9344/9344 977 1000
4| 21 Lord Drwho Sleep 38433/38433 1080/1080 23805/23805 46 1000
5|999 Lord Caree Stand 17006/17006 66974/66974 16711/16711 668 -1000
6|999 Lord Tulpen Stand 21845/22035 111443/111584 47885/48014 1029 1000
7|740 Lord Wolthu Sleep 40038/40038 6616/6616 35856/35856 638 1000
8|999 Lord Aijimo Sleep 14400/14400 37096/37096 10613/10613 626 1000

Re: Interesting concept but... need help.

Posted: Fri May 20, 2016 9:20 am
by noblestone
BUMP :)

Re: Interesting concept but... need help.

Posted: Sun May 22, 2016 5:35 pm
by Drevarr
Insert capture groups in your regex to align with your desired variables, then build a string from the matches and echo the string to the miniConsole.

myExample:
Code: [show] | [select all] lua

local Hps=tonumber(matches[4])
local Mvs=tonumber(matches[5])
local Name=matches[2]
local CharClass=matches[3]
SetHPcolor()
SetMVcolor()

GUI.Box3Mini:decho(string.format("\n"..HPcolor.."%4s  "..MVcolor.."%4s  "..RGB.W.."%-30s  %-16s", Hps, Mvs, Name, CharClass))