Spaces:
Runtime error
Runtime error
Download utils/lua.py from AngoHF/Formulator: direct link, hf CLI and curl.
- Browser
- Download file 394 Bytes
-
https://huggingface.co/spaces/AngoHF/Formulator/resolve/main/utils/lua.py
- Command line
-
hf download hf://spaces/AngoHF/Formulator/utils/lua.py
-
curl -L -o lua.py https://huggingface.co/spaces/AngoHF/Formulator/resolve/main/utils/lua.py
394 Bytes
| from ast import literal_eval | |
| import re | |
| DAMAGE_RESULT_PATTERN = re.compile(r"\[[0-4]\]=(\d+)") | |
| def parse_player(lua_data): | |
| try: | |
| python_data = lua_data.strip().replace("{", "[").replace("}", "]") | |
| return literal_eval(python_data) | |
| except: | |
| return None | |
| def parse_damage(lua_data): | |
| return sum(int(damage) for damage in DAMAGE_RESULT_PATTERN.findall(lua_data)) | |