Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require("re")
- --
- prompt = re.compile ( [[
- prompt <- '<' ( {:Vitals: vdata :} {:TNL: tnl :} {:Gold: gold :} {:Room: room :} ) -> {} space '>'
- room <- ( 'room: ' {:room: name :} -> trim space ) -> '%1'
- gold <- ( 'gold: ' {: num :} space )
- tnl <- ( {: num :} 'tnl' space )
- vdata <- ( {:cHP: num :} '/' {:mHP: num :} 'hp ' {:cMN: num :} '/' {:mMN: num :} 'mn '
- {:cMV: num :} '/' {:mMV: num :} 'mv' space ) -> {}
- name <- [A-Za-z][A-Za-z%s]*
- num <- { %d+ } -> tonumber
- space <- %s*
- ]],
- {
- [ "tonumber" ] = tonumber
- ,trim = function ( s ) return s:match'^()%s*$' and '' or s:match'^%s*(.*%S)' end
- }
- )
- --
- pdata = "<3344/3344hp 2892/3246mn 2382/2382mv 3930tnl gold: 140157 room: The Aardwolf Plaza Hotel >"
- --
- p = prompt:match(pdata) -- test.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement