人気のある MMORPG の自動スクリプトを作成しています。次のエラーが表示されます。
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
startFishing()
File "C:\Python27\DG\RS\RS bot.py", line 56, in startFishing
if inv == "full":
NameError: global name 'inv' is not defined
以下に機能の詳細を示します。
def isMyInventoryFull():
s = screenGrab()
a = s.getpixel((1173,591))
b = s.getpixel((1222,591))
c = s.getpixel((1271,591))
d = s.getpixel((1320,591))
if a == b == c == d:
print "Inventory is full! Time to go back home."
inv = "full"
print inv
else:
print "Inventory is not full."
inv = "notfull"
time.sleep(3)
def startFishing():
mousePos((530,427))
leftClick()
time.sleep(0)
inv = 'full'
openUpInventory()
isMyInventoryFull()
if inv == "full":
time.sleep(0.01)
else:
isMyInventoryFull()
mousePos((844,420))
rightClick()
time.sleep(1)
問題は、'isMyInventoryFull' 関数で 'inv' を定義しましたが、'inv' が既に定義されていることに気付きませんか? ここで間違いなく何かが欠けています。誰か助けてもらえますか?