Calling attacks from screen buttons, now with error report!

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Message
Author
squark
Veteran
Posts: 277
Joined: Fri Aug 17, 2007 9:59 am
Completed: Tour de Pharmacy (Proofreader), The Abandoned Land: Book One (Proofreader)
Projects: Raven Hollow (Core Coder, Proofreader), The Universal Hope (Core Coder, Proofreader)
Organization: FlareBlue Entertainment
Location: Always somewhere behind you...
Contact:

Re: Calling attacks from screen buttons, now with error repo

#31 Post by squark »

Been away for a few days, thanks for the replies everyone.
Xela, kankan, you're both stars. Seriously, thank you ^^
Without communication, nothing is possible.
"All we see or seem
Is but a dream within a dream.

I stand amid the roar
Of a surf-tormented shore"
-- Edgar Allen Poe, "A Dream Within A Dream"
Current Projects:
Universal Hope Stalled
Raven Hollow (on hold for now)
Peace and Love,
Squark

squark
Veteran
Posts: 277
Joined: Fri Aug 17, 2007 9:59 am
Completed: Tour de Pharmacy (Proofreader), The Abandoned Land: Book One (Proofreader)
Projects: Raven Hollow (Core Coder, Proofreader), The Universal Hope (Core Coder, Proofreader)
Organization: FlareBlue Entertainment
Location: Always somewhere behind you...
Contact:

Re: Calling attacks from screen buttons, now with error repo

#32 Post by squark »

That didn't mean it's fixed, by the way. If it was, I'd have marked it solved. I do appreciate the help :)
However, as easy to insert as this code seems, the problem it now poses to me is how to rewrite the system so it doesn't call the Execution Phase.
Otherwise it seems absolutely perfect to my predicament.
Without communication, nothing is possible.
"All we see or seem
Is but a dream within a dream.

I stand amid the roar
Of a surf-tormented shore"
-- Edgar Allen Poe, "A Dream Within A Dream"
Current Projects:
Universal Hope Stalled
Raven Hollow (on hold for now)
Peace and Love,
Squark

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Calling attacks from screen buttons, now with error repo

#33 Post by xela »

squark wrote:That didn't mean it's fixed, by the way. If it was, I'd have marked it solved. I do appreciate the help :)
However, as easy to insert as this code seems, the problem it now poses to me is how to rewrite the system so it doesn't call the Execution Phase.
Otherwise it seems absolutely perfect to my predicament.
And once again, you did not post the latest version of the code :)
Like what we're doing? Support us at:
Image

squark
Veteran
Posts: 277
Joined: Fri Aug 17, 2007 9:59 am
Completed: Tour de Pharmacy (Proofreader), The Abandoned Land: Book One (Proofreader)
Projects: Raven Hollow (Core Coder, Proofreader), The Universal Hope (Core Coder, Proofreader)
Organization: FlareBlue Entertainment
Location: Always somewhere behind you...
Contact:

Re: Calling attacks from screen buttons, now with error repo

#34 Post by squark »

I finally have enough free time to work on this again, but the original issue remains. It hasn't been about the Special attacks themselves; but how to get the buttons to use them was the problem.
Unless I've gone horribly blind I haven't seen the function to use.

So let's backtrack slightly. If I have this:

Code: Select all

textbutton "stab" action
what action do I tell it to use?
Also, let's assume that "stab" is defined in much the same manner as kankan's normalSkill piece.
All I want is the right action to call the stab class and resolve it.
Without communication, nothing is possible.
"All we see or seem
Is but a dream within a dream.

I stand amid the roar
Of a surf-tormented shore"
-- Edgar Allen Poe, "A Dream Within A Dream"
Current Projects:
Universal Hope Stalled
Raven Hollow (on hold for now)
Peace and Love,
Squark

squark
Veteran
Posts: 277
Joined: Fri Aug 17, 2007 9:59 am
Completed: Tour de Pharmacy (Proofreader), The Abandoned Land: Book One (Proofreader)
Projects: Raven Hollow (Core Coder, Proofreader), The Universal Hope (Core Coder, Proofreader)
Organization: FlareBlue Entertainment
Location: Always somewhere behind you...
Contact:

Re: Calling attacks from screen buttons, now with error repo

#35 Post by squark »

Okay, I'm really not getting this. I've decided to use classes and defs (which make the a logical choice). But here's my next problem. I learned recently that I can use custom Actions.
But again I run into a stumbling block. Here's a logical rundown of what I thought would happen - with code pieces.

1: Player chooses an action, in this case "Doom".

Code: Select all

textbutton "Doom of Darkness" action (Show("targetChoice", env=env), Doom())
And Doom is contained in this class:

Code: Select all

class Doom(Action):         
        def doomy(self, pEnemy):
            if phi.mp_temp >= 10:
                self.env.describe("Darkness envelopes the enemy...") 
                Enemy.life_temp = int(Enemy.life_temp - (Enemy.life_temp * 0-.33))
                phi.mp_temp -= 10
            else:
                self.env.describe("Phi does not have enough MP to use that!")
                pass
I'm sure someone has already spotted something wrong, but I'll go on anyway.
This piece is supposed to grab the screen action from the gui:

Code: Select all

def preparationPhase(self):
            self.guiAction = renpy.call_screen("Combat", env=self) # Use the GUI to get the player action
            self.setAction()
            for enemy in self.enemies: # Set all enemy actions
                self.guiAction = enemy.ai(self) # Call the ai function to determine the action used
                self.setAction()
            self.que.sort()
            if not self.doEscape:
                self.executionPhase() # After all actions are set, move on to the next phase
            else:
                self.escape()
            
        def setAction(self):
            for entry in self.guiAction:
                self.que.addAction(entry)
But it doesn't seem to work with the way I've set out the classes.
It should then execute the command and continue to resolve the round. Instead, upon clicking, I get this:
traceback wrote: While running game code:
File "game/script.rpy", line 39, in script
python:
File "game/script.rpy", line 42, in python
ybt2.preparationPhase()
File "game/enviroment.rpy", line 35, in python
self.guiAction = renpy.call_screen("Combat", env=self) # Use the GUI to get the player action
TypeError: 'NotImplementedType' object is not callable

-- Full Traceback ------------------------------------------------------------

Full traceback:
File "C:\Games\Dev\renpy\renpy\execution.py", line 261, in run
File "C:\Games\Dev\renpy\renpy\ast.py", line 630, in execute
File "C:\Games\Dev\renpy\renpy\python.py", line 978, in py_exec_bytecode
File "game/script.rpy", line 42, in <module>
File "game/enviroment.rpy", line 35, in preparationPhase
File "C:\Games\Dev\renpy\renpy\exports.py", line 1530, in call_screen
File "C:\Games\Dev\renpy\renpy\ui.py", line 237, in interact
File "C:\Games\Dev\renpy\renpy\display\core.py", line 1798, in interact
File "C:\Games\Dev\renpy\renpy\display\core.py", line 2322, in interact_core
File "C:\Games\Dev\renpy\renpy\display\layout.py", line 714, in event
File "C:\Games\Dev\renpy\renpy\display\layout.py", line 714, in event
File "C:\Games\Dev\renpy\renpy\display\layout.py", line 714, in event
File "C:\Games\Dev\renpy\renpy\display\screen.py", line 297, in event
File "C:\Games\Dev\renpy\renpy\display\layout.py", line 714, in event
File "C:\Games\Dev\renpy\renpy\display\layout.py", line 174, in event
File "C:\Games\Dev\renpy\renpy\display\layout.py", line 714, in event
File "C:\Games\Dev\renpy\renpy\display\behavior.py", line 623, in event
File "C:\Games\Dev\renpy\renpy\display\behavior.py", line 197, in run
File "C:\Games\Dev\renpy\renpy\ui.py", line 56, in __call__
TypeError: 'NotImplementedType' object is not callable

Windows-post2008Server-6.1.7601-SP1
Ren'Py 6.13.7.1646
Combat System Prototype 0.6 0.6
Yes, I'm still using 6.13. That's because I'm happy with it. I may need to to update soon, though. Things appear to be changing and deprecating to the point of total obsoletion into not being used anymore.

(I've tried kankan's method, and while it would work in a different project, I get the feeling that it's just not suitable for this one. Just a gut feeling.)
So, this is the most recent changes I've made to the code. Please help me.
Without communication, nothing is possible.
"All we see or seem
Is but a dream within a dream.

I stand amid the roar
Of a surf-tormented shore"
-- Edgar Allen Poe, "A Dream Within A Dream"
Current Projects:
Universal Hope Stalled
Raven Hollow (on hold for now)
Peace and Love,
Squark

squark
Veteran
Posts: 277
Joined: Fri Aug 17, 2007 9:59 am
Completed: Tour de Pharmacy (Proofreader), The Abandoned Land: Book One (Proofreader)
Projects: Raven Hollow (Core Coder, Proofreader), The Universal Hope (Core Coder, Proofreader)
Organization: FlareBlue Entertainment
Location: Always somewhere behind you...
Contact:

Re: Calling attacks from screen buttons, now with error repo

#36 Post by squark »

Okay, slight alteration.
I'd taken a long, long break to get my head and some other affairs in order. So, I went back and tried something else.
I made a slight change to the character data I'm using:

Code: Select all

   class Characters(Combatant):
        def __init__(self, pName, pInventory, pGear):
            self.name = pName
            # Attributes
            self.life = 100
            self.life_temp = self.life # Temporary
            self.mp = 100
            self.mp_temp = self.mp # Temporary
            self.attack = 45
            self.speed = 30
            self.defense = 20
            self.evade = 15
            self.arcane = 30
            self.inventory = pInventory # Starting Inventory
            self.gear = pGear # Starting Gear object
            self.xp = 0 # Starting experience
            self.level = 1 # Starting level
            self.defending_temp = False
            self.active = True
            # Skills
            self.skills = [ [Slash], [Doomy], [CheapHealing], [Instadoom], [Apaches], [Gamblor] ]
I've probably made a mistake there already. I'm already defined them as classes like so:

Code: Select all

   class Doomy():                
        def Doom(self, pEnemy):
            if phi.mp_temp >= 10:
                self.env.describe("Darkness envelopes the enemy...") 
                phi.attack = int(Enemy.life_temp - (Enemy.life_temp * 0.33))
                phi.mp_temp -= 10
            else:
                self.env.describe("Phi does not have enough MP to use that!")
                pass
Phi is already defined as a character elsewhere, and that much is okay.
Then, I use buttons to attempt to execute the above class actions. (Note that I've already tried class yadayada(Action):, and that also returns errors)

Code: Select all

screen attackChoice:
        modal True
        frame:
            xalign 0.5 yalign 0.95
            vbox:
                textbutton "Sword" action (Show("targetChoice", env=env), Hide("attackChoice"))
                textbutton "Doom of Darkness" action (Show("targetChoice", env=env), Hide("attackChoice"), Doomy())
                textbutton "Cast Into The Shadows" action (Show("targetChoice", env=env), Hide("attackChoice"), Apaches()) 
                textbutton "Sparrow of The Wind" action (Show("targetChoice", env=env), Hide("attackChoice"), Instadoom())
        frame:    
            xalign 0.85 yalign 0.95
            vbox:    
                textbutton "Evening Muster" action (Show("targetChoice", env=env), Hide("attackChoice"), Gamblor())
                textbutton "HOPE it all" action (Show("targetChoice", env=env), Hide("attackChoice"), CheapHealing())
                textbutton "Cancel" action Hide("attackChoice")                           
So, when I try to this, it gives me this:

Code: Select all

While running game code:
  File "game/missionstart.rpy", line 37, in script
        python:
  File "game/missionstart.rpy", line 39, in python
            ybt2.preparationPhase()
  File "game/enviroment.rpy", line 35, in python
                self.guiAction = renpy.call_screen("Combat", env=self) # Use the GUI to get the player action
AttributeError: Apaches instance has no __call__ method
And rightly so, I believe. It's because classes have no call function. So how do I get it to do what I want, which is to determine what to do next, based on the instructions contained in the classes?
Without communication, nothing is possible.
"All we see or seem
Is but a dream within a dream.

I stand amid the roar
Of a surf-tormented shore"
-- Edgar Allen Poe, "A Dream Within A Dream"
Current Projects:
Universal Hope Stalled
Raven Hollow (on hold for now)
Peace and Love,
Squark

Post Reply

Who is online

Users browsing this forum: Amazon [Bot], chesarty, Google [Bot], Semrush [Bot]