fixup luaparser

This commit is contained in:
Semjon Kerner 2021-05-07 14:07:09 +02:00
parent b6a375f486
commit 58457ef798
2 changed files with 8 additions and 8 deletions

View File

@ -10,7 +10,7 @@ import logging
from fishy.engine.semifisher.fishing_event import FishEvent
from fishy.engine.common.window import WindowClient
from fishy.engine.semifisher.fishing_mode import State, FishingMode
from fishy.engine.semifisher.fishing_mode import Colors, FishingMode
from fishy.engine.common.IEngine import IEngine
from fishy.engine.semifisher import fishing_mode, fishing_event
@ -38,7 +38,7 @@ class SemiFisherEngine(IEngine):
# check for game window and stuff
self.gui.bot_started(True)
sv_color_extract(State)
sv_color_extract(Colors)
if self.get_gui:
logging.info("Starting the bot engine, look at the fishing hole to start fishing")

View File

@ -18,7 +18,7 @@ def _sv_parser(path):
EXPRESSIONS: A) List-Start "name=", B) Variable assignment "name=val", C) List End "}"
"""
for old, new in ((",","\n"), ("{","{\n"), ("}","}\n"), ("{",""), (",", ""), ("[", ""), ("]", ""), ('"', ""), (" ", "")):
lua = lua.replace(old, new)
lua = lua.replace(old, new)
lua = lua.lower().split("\n")
lua = [expression for expression in lua if expression]
@ -54,10 +54,10 @@ def _sv_parser(path):
return None
def sv_color_extract(states):
def sv_color_extract(Colors):
root = _sv_parser(os.path.join(get_savedvarsdir(), "Chalutier.lua"))
if root == None:
return states
return Colors
for i in range(4):
name, root = root.popitem()
@ -73,7 +73,7 @@ def sv_color_extract(states):
floor(float(root["colors"][i]["b"])*255)
]
colors.append(rgb)
for i,s in enumerate(states):
states[s] = colors[i]
return states
for i,c in enumerate(Colors):
Colors[c] = colors[i]
return Colors