Advertisement
Anaristos

Untitled

Feb 1st, 2014
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. require("re")
  2. --
  3. prompt = re.compile ( [[
  4. prompt <- '<' ( {:Vitals: vdata :} {:TNL: tnl :} {:Gold: gold :} {:Room: room :} ) -> {} space '>'
  5. room <- ( 'room: ' {:room: name :} -> trim space ) -> '%1'
  6. gold <- ( 'gold: ' {: num :} space )
  7. tnl <- ( {: num :} 'tnl' space )
  8. vdata <- ( {:cHP: num :} '/' {:mHP: num :} 'hp ' {:cMN: num :} '/' {:mMN: num :} 'mn '
  9. {:cMV: num :} '/' {:mMV: num :} 'mv' space ) -> {}
  10. name <- [A-Za-z][A-Za-z%s]*
  11. num <- { %d+ } -> tonumber
  12. space <- %s*
  13. ]],
  14. {
  15. [ "tonumber" ] = tonumber
  16. ,trim = function ( s ) return s:match'^()%s*$' and '' or s:match'^%s*(.*%S)' end
  17. }
  18. )
  19. --
  20. pdata = "<3344/3344hp 2892/3246mn 2382/2382mv 3930tnl gold: 140157 room: The Aardwolf Plaza Hotel >"
  21. --
  22. p = prompt:match(pdata) -- test.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement