2015-08-06 06:25:56

Hi, I downloaded pyaudiogame, and I have been making my way through
the tutorials. I ran into a problem with the Dragon game in basic
tutorials / lesson 4: wait, is that math?

The error I am getting is:
note: this error is from the example file provided

Traceback(most recent call back):
  File "ex4.py", line 7, in <module>
    storage = pyaudiogame.cash
AttributeError: 'module' object has no attribute 'cash'

I checked my code multiple times and it is correct, I also tried
running the exe4.py file and I get the same error about cash as you
can see.

Can you help, the tutorials say that the code should be correct.

TJ Breitenfeldt

2015-08-06 07:59:38

Not all that familiar with PyAudioGame, but it seems like the "cash" attribute isn't implemented. Here's a few tweaks that might help:

#ATTACK!!!
import pyaudiogame
spk = pyaudiogame.speak
MyApp = pyaudiogame.App("My Application")

#Lets create a storage box so we can put our dragon's hp in there
dragon_hp = 100

#Now lets make our hero's hit strength
hero_hit = 10

#An attack function
def attack():
    #When the hero attacks he takes the dragon's hp
    dragon_hp = dragon_hp - hero_hit

#Now lets make a way for our hero to attack
def logic(actions):
    key = actions['key']
    if key == "space" and dragon_hp > 0:
        attack()
        spk("You, the hero of our tale swing your sword. You hit the dragon for %s damage! Now our poor dragon has %s hp left" % (hero_hit, dragon_hp))
        if dragon_hp <= 0:
            spk("You, the hero of our story killed the dragon. The whole town thanks you!")
            spk("Press escape to go back home")

MyApp.logic = logic
MyApp.run()

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2015-08-06 08:52:55

I figured it out. It seems the tutorial code and examples were missing a line of code.

All I did was add
from pyaudiogame import cash as storage

right underneath
import pyaudiogame

It works great now.

TJ Breitenfeldt

2015-08-07 02:11:59

change cash to storage sorry!

2015-08-07 02:13:55

it should be cache, but I was silly and put cash. I think it is changed in later versions to just be storage all around.