In my fight screen:
Code: Select all
imagebutton idle "images/punch.png" hover "images/punch_hover.png" xpos 1356 ypos 588 focus_mask True clicked Jump(fight.attack(20))
Code: Select all
label .attack(atk):
$ enemy.attacked(atk)
Code: Select all
imagebutton idle "images/punch.png" hover "images/punch_hover.png" xpos 1356 ypos 588 focus_mask True clicked Jump(fight.attack(20))
Code: Select all
label .attack(atk):
$ enemy.attacked(atk)
Code: Select all
imagebutton idle "images/punch.png" hover "images/punch_hover.png" xpos 1356 ypos 588 focus_mask True clicked Jump(fight.attack, 20)
Code: Select all
imagebutton idle "images/punch.png" hover "images/punch.png" xpos 1000 ypos 588 focus_mask True clicked Function(enemy.attacked(punch.damages))
Code: Select all
While running game code:
File "game/script.rpy", line 380, in script call
call fight("fight_place",player,enemy)
File "game/fight.rpy", line 9, in script
call screen fight_screen(player,enemy)
File "renpy/common/000statements.rpy", line 471, in execute_call_screen
store._return = renpy.call_screen(name, *args, **kwargs)
File "renpy/common/00action_other.rpy", line 484, in __call__
rv = self.callable(*self.args, **self.kwargs)
TypeError: 'int' object is not callable
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 380, in script call
call fight("fight_place",player,enemy)
File "game/fight.rpy", line 9, in script
call screen fight_screen(player,enemy)
File "C:\Program Files\renpy-6.99.12.4-sdk\renpy\ast.py", line 1706, in execute
self.call("execute")
File "C:\Program Files\renpy-6.99.12.4-sdk\renpy\ast.py", line 1724, in call
return renpy.statements.call(method, parsed, *args, **kwargs)
File "C:\Program Files\renpy-6.99.12.4-sdk\renpy\statements.py", line 145, in call
return method(parsed, *args, **kwargs)
File "renpy/common/000statements.rpy", line 471, in execute_call_screen
store._return = renpy.call_screen(name, *args, **kwargs)
File "C:\Program Files\renpy-6.99.12.4-sdk\renpy\exports.py", line 2526, in call_screen
rv = renpy.ui.interact(mouse="screen", type="screen", roll_forward=roll_forward)
File "C:\Program Files\renpy-6.99.12.4-sdk\renpy\ui.py", line 285, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "C:\Program Files\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2526, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
File "C:\Program Files\renpy-6.99.12.4-sdk\renpy\display\core.py", line 3204, in interact_core
rv = root_widget.event(ev, x, y, 0)
File "C:\Program Files\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 960, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "C:\Program Files\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 960, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "C:\Program Files\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 960, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "C:\Program Files\renpy-6.99.12.4-sdk\renpy\display\screen.py", line 651, in event
rv = self.child.event(ev, x, y, st)
File "C:\Program Files\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 960, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "C:\Program Files\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 889, in event
return handle_click(self.clicked)
File "C:\Program Files\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 824, in handle_click
rv = run(action)
File "C:\Program Files\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 306, in run
return action(*args, **kwargs)
File "renpy/common/00action_other.rpy", line 484, in __call__
rv = self.callable(*self.args, **self.kwargs)
TypeError: 'int' object is not callable
Well, one of the problems is that you haven't formatted your button correctly. You may want to review the imagebutton documentation.ultimate-saiyajin wrote:Thanks trooper6, this seems to work with Function when I use a function without parameters. But when I put parameters like this:
I have this error that appears : TypeError: ‘int’ object is not callableCode: Select all
imagebutton idle "images/punch.png" hover "images/punch.png" xpos 1000 ypos 588 focus_mask True clicked Function(enemy.attacked(punch.damages))
Any ideas for passing parameters?
Code: Select all
imagebutton:
idle "images/punch.png"
hover "images/punch.png"
xpos 1000
ypos 588
focus_mask True
action Function(enemy.attacked, punch.damages)
I don't know what you mean by this. But if you can get Function to work then I suppose it doesn't matter.ultimate-saiyajin wrote:PS : I do not use the SetVariable with a Jump because I want to use ATL. This will leave the screen temporarily and the stats will no longer appear on the screen.
Ren'Py makes me leave the screen...Try making your button like so (I'm going to format it with a colon and a block because I think it look clearer, but you can put it all on one line if you like):
Code: Select all
imagebutton: idle "images/punch.png" hover "images/punch.png" xpos 1000 ypos 588 focus_mask True action Function(enemy.attacked, punch.damages)
I'm not sure what you mean by thisAnd that you declared these variables using default?
Current best practices for declaring variables is to use "default" rather than declaring them in an init block.ultimate-saiyajin wrote:I'm not sure what you mean by thisAnd that you declared these variables using default?
Code: Select all
default punch = Technique("Punch", 5)
default player = Fighter("Player", 500, ([punch]))
default enemy = Fighter("Enemy", 500, ([punch]))
label start:
"Blah blah blah"
Code: Select all
init python:
punch = Technique("Punch", 5)
player = Fighter("Player", 500, ([punch]))
enemy = Fighter("Enemy", 500, ([punch]))
Are you perhaps calling the screen rather than showing it?ultimate-saiyajin wrote: If I run this code:Ren'Py makes me leave the screen...Try making your button like so (I'm going to format it with a colon and a block because I think it look clearer, but you can put it all on one line if you like):
Code: Select all
imagebutton: idle "images/punch.png" hover "images/punch.png" xpos 1000 ypos 588 focus_mask True action Function(enemy.attacked, punch.damages)
Thank you for this advice, I did not know.Current best practices for declaring variables is to use "default" rather than declaring them in an init block.
Yes I used a Call. And even a call to a label that initiated the background then called the fight_screen because I did not find how to put a background in a screen. If you have a solution for that I'm interested.Are you perhaps calling the screen rather than showing it?
Code: Select all
label start():
$ renpy.show_screen("fight_screen",player,enemy)
screen fight_screen(player, enemy):
modal True
imagebutton:
idle "images/button_attack.png"
hover "images/button_attack_hover.png"
xpos 1356
ypos 588
focus_mask True
action Function(enemy.attacked,20)
Code: Select all
label start:
show screen move()
return
Code: Select all
label start:
return
Users browsing this forum: Ahrefs [Bot], AWizardWithWords, Majestic-12 [Bot], piinkpuddiin