I am trying to add a function that changes certain booleans value when you click on imagebutton with the right "selected_item"
But I get the error above.
Here are the relevant codes:
Code: Select all
default invbg = True
default invbgopen = False
# testitem = the item we are selecting, rightitem = the right item that will trigger event
# inputvariable1 = the variable that will change if hit with the rightitem, outputvariable1 = inputvariable1 new value
def testItem(testitem, rightitem, inputvariable1, outputvariable1):
if testitem == rightitem:
inputvariable1 = outputvariable1
screen escapesc:
if invbgopen:
imagebutton:
idle "outside.jpg"
if invbg:
imagebutton:
idle "kitchen_match.jpg"
action Function[testItem(selected_item, iHair, invbgopen, True)]
This is the traceback:
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 67, in script
$ renpy.pause(hard=True)
File "game/script.rpy", line 67, in <module>
$ renpy.pause(hard=True)
File "game/script.rpy", line 38, in execute
screen escapesc:
File "game/script.rpy", line 38, in execute
screen escapesc:
File "game/script.rpy", line 44, in execute
if invbg:
File "game/script.rpy", line 45, in execute
imagebutton:
File "game/script.rpy", line 45, in keywords
imagebutton:
TypeError: 'type' object has no attribute '__getitem__'
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 67, in script
$ renpy.pause(hard=True)
File "C:\Users\Business laptop\Downloads\Programs\renpy-7.3.5-sdk\renpy\ast.py", line 914, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "C:\Users\Business laptop\Downloads\Programs\renpy-7.3.5-sdk\renpy\python.py", line 2028, in py_exec_bytecode
exec bytecode in globals, locals
File "game/script.rpy", line 67, in <module>
$ renpy.pause(hard=True)
File "C:\Users\Business laptop\Downloads\Programs\renpy-7.3.5-sdk\renpy\exports.py", line 1480, in pause
rv = renpy.ui.interact(mouse='pause', type='pause', roll_forward=roll_forward)
File "C:\Users\Business laptop\Downloads\Programs\renpy-7.3.5-sdk\renpy\ui.py", line 297, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "C:\Users\Business laptop\Downloads\Programs\renpy-7.3.5-sdk\renpy\display\core.py", line 2702, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
File "C:\Users\Business laptop\Downloads\Programs\renpy-7.3.5-sdk\renpy\display\core.py", line 3094, in interact_core
root_widget.visit_all(lambda i : i.per_interact())
File "C:\Users\Business laptop\Downloads\Programs\renpy-7.3.5-sdk\renpy\display\core.py", line 541, in visit_all
d.visit_all(callback, seen)
File "C:\Users\Business laptop\Downloads\Programs\renpy-7.3.5-sdk\renpy\display\core.py", line 541, in visit_all
d.visit_all(callback, seen)
File "C:\Users\Business laptop\Downloads\Programs\renpy-7.3.5-sdk\renpy\display\core.py", line 541, in visit_all
d.visit_all(callback, seen)
File "C:\Users\Business laptop\Downloads\Programs\renpy-7.3.5-sdk\renpy\display\screen.py", line 430, in visit_all
callback(self)
File "C:\Users\Business laptop\Downloads\Programs\renpy-7.3.5-sdk\renpy\display\core.py", line 3094, in <lambda>
root_widget.visit_all(lambda i : i.per_interact())
File "C:\Users\Business laptop\Downloads\Programs\renpy-7.3.5-sdk\renpy\display\screen.py", line 440, in per_interact
self.update()
File "C:\Users\Business laptop\Downloads\Programs\renpy-7.3.5-sdk\renpy\display\screen.py", line 625, in update
self.screen.function(**self.scope)
File "game/script.rpy", line 38, in execute
screen escapesc:
File "game/script.rpy", line 38, in execute
screen escapesc:
File "game/script.rpy", line 44, in execute
if invbg:
File "game/script.rpy", line 45, in execute
imagebutton:
File "game/script.rpy", line 45, in keywords
imagebutton:
File "<screen language>", line 47, in <module>
TypeError: 'type' object has no attribute '__getitem__'
Windows-8-6.2.9200
Ren'Py 7.3.5.606
inventory tst 5 1.0
Thu Jan 23 20:39:10 2020