jraynolds / Glimmer-and-Gloom

A python automated bot to play Flight Rising's Glimmer and Gloom minigame.
MIT License
4 stars 1 forks source link

NoneType object is not subscriptable #2

Open Amsjur opened 2 years ago

Amsjur commented 2 years ago

Running the script at first gave me the list index out of range issue, so I tried to take my own screenshots for the glimmer and gloom tiles as suggested. However the error then just changed into the 'NoneType' object is not subscriptable one, which I assume means that the script still isn't able to correctly read my screen? I've tried chrome, edge and opera so I don't think it's a browser issue unfortunately :(

jraynolds commented 2 years ago

Hey there Amsjur. Can you send me a screenshot of your screen with your game window and the command prompt open showing the error? (You can blur or crop out your Flight Rising username if you like.)

TyzMatty commented 2 years ago

Hope this isn't necroing or intruding but I'm having the same issue, I got the pillow issue fixed (by typing pip install Pillow) but now it's saying 'TypeError: 'NoneType' object is not subscriptable' I tried replacing the glimmer and gloom images with my own screenshots, and I followed the guide carefully. When run in vsc, it gives me the problem "Import 'pyautogui' could not be resolved. Pylance(reportMissingImports) [1, 8]" Even after running 'pip install pyautogui', it sends back the same error. glimgloom

jraynolds commented 2 years ago

Hey @TyzMatty! Sorry for taking so long to get back to you. I'm sorry you're having issues with the program! Can you try running the command prompt as an admin?

TyzMatty commented 2 years ago

Seems to be the same issues, unfortunately. Both cmd and vsc give the same errors. I've tried having the cmd window as split-screen, just off to the side, even minimized while it runs and it always gives the same error. Thanks for any help you can give me, I'm really hoping I can get this working.

jraynolds commented 2 years ago

Me too! Try this if you would. Open up board_solver.py with a text editor (or a code editor) and change the variable CONFIDENCE_VALUE to something lower. Right now it's at .9, but try it at .8, .7, and so on until something changes. If it works correctly, that's great--if it ends up with a different message in the command prompt or bugs out clicking, let me know what the message says and what confidence value it was at.

TyzMatty commented 2 years ago

The first response is changing it down to 8, then at .7 I got a different error back. Going down to 6 changes it back to the first error, which seems odd. image

helioboros commented 2 years ago

Having this problem as well. The autorun has to be played on every new board because it hangs at the end of each, though it runs well the first time I run it each time. image

It runs perfectly on my partner's computer (just installed it and tested before coming to comment here, haha), and the only difference I can imagine is screen resolution.

Update: I'm absolutely silly, got it to stop hanging at the end of each run by saving my own screenshot of the 'Play again' button :)

jraynolds commented 2 years ago

Whew! Good work @helioboros. Glad that worked for you.

hyv1 commented 2 years ago

I am also having this error. I have taken new screenshots of all three buttons, and I had lowered the confidence value to 7 and now have it down to 5.

I also added the code below to autorun.py after the confidence value line per another post here, which did fix the initial autorun error I was having.

NUM_LOOPS = 19 # The maximum number of games we'll play. After this number, the script will quit.
n = 0

print("beginning to play the game. We'll play " + str(NUM_LOOPS) + " games.")
while n < NUM_LOOPS:
    print("beginning game " + str(n) + str(1) + "...")
    time.sleep(GAME_DELAY)
    solve_board()
    time.sleep(GAME_DELAY)
    pyautogui.click(
        pyautogui.center(
            pyautogui.locateOnScreen(
                PLAY_FILE_LOC, 
                confidence=CONFIDENCE_VALUE
            )
        )
    )
    print("ending game " + str(n) + str(1) + "...")
    n += 1
print("Script exiting.")

The bot ran perfectly for several games, then suddenly stopped and is now giving the following errors:

Error when using autorun.py:

C:\Users\*****\Desktop\flight rising\Glimmer-and-Gloom-master>python autorun.py
beginning to play the game. We'll play 19 games.
beginning game 01...
Traceback (most recent call last):
  File "C:\Users\*****\Desktop\flight rising\Glimmer-and-Gloom-master\autorun.py", line 17, in <module>
    solve_board()
  File "C:\Users\*****\Desktop\flight rising\Glimmer-and-Gloom-master\board_solver.py", line 243, in solve_board
    print(gameBoard)
  File "C:\Users\*****\Desktop\flight rising\Glimmer-and-Gloom-master\board_solver.py", line 57, in __str__
    if col[1] == "gloom":
TypeError: 'NoneType' object is not subscriptable

Error when using board_solver.py:

C:\Users\*****\Desktop\flight rising\Glimmer-and-Gloom-master>python board_solver.py
Traceback (most recent call last):
  File "C:\Users\*****\Desktop\flight rising\Glimmer-and-Gloom-master\board_solver.py", line 252, in <module>
    solve_board()
  File "C:\Users\*****\Desktop\flight rising\Glimmer-and-Gloom-master\board_solver.py", line 243, in solve_board
    print(gameBoard)
  File "C:\Users\*****\Desktop\flight rising\Glimmer-and-Gloom-master\board_solver.py", line 57, in __str__
    if col[1] == "gloom":
TypeError: 'NoneType' object is not subscriptable

Sometimes they also give the "Index Error: list assignment out of range" error too though. Any insight is appreciated!