For reference, I'm just trying to allow the game to show the money count on screen- and have it cooperate with the inventory system.
EDIT: I'm also getting this error trying to buy anything even if i temporarily remove the main issue of just trying to show the correct money on screen.
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 69, in script
jump buy_more
File "game/script.rpy", line 69, in <module>
jump buy_more
File "game/script.rpy", line 24, in buy
self.money -= item.cost
TypeError: unsupported operand type(s) for -=: 'unicode' and 'int'
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 69, in script
jump buy_more
File "C:\Users\monkey\Downloads\renpy-6.99.14.1-sdk\renpy\ast.py", line 1729, in execute
if renpy.python.py_eval(condition):
File "C:\Users\monkey\Downloads\renpy-6.99.14.1-sdk\renpy\python.py", line 1919, in py_eval
return py_eval_bytecode(code, globals, locals)
File "C:\Users\monkey\Downloads\renpy-6.99.14.1-sdk\renpy\python.py", line 1912, in py_eval_bytecode
return eval(bytecode, globals, locals)
File "game/script.rpy", line 69, in <module>
jump buy_more
File "game/script.rpy", line 24, in buy
self.money -= item.cost
TypeError: unsupported operand type(s) for -=: 'unicode' and 'int'
Windows-8-6.2.9200
Ren'Py 6.99.14.3.3347
test 1.0
Fri May 25 16:44:52 2018
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 43, in script
$ current_money = inventory.money
File "game/script.rpy", line 43, in <module>
$ current_money = inventory.money
NameError: name 'inventory' is not defined
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 43, in script
$ current_money = inventory.money
File "C:\Users\monkey\Downloads\renpy-6.99.14.1-sdk\renpy\ast.py", line 862, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "C:\Users\monkey\Downloads\renpy-6.99.14.1-sdk\renpy\python.py", line 1888, in py_exec_bytecode
exec bytecode in globals, locals
File "game/script.rpy", line 43, in <module>
$ current_money = inventory.money
NameError: name 'inventory' is not defined
Windows-8-6.2.9200
Ren'Py 6.99.14.3.3347
test 1.0
Fri May 25 16:24:54 2018
Code: Select all
screen money:
zorder 999
frame:
background None xalign 0.1 yalign 0.0
text "[inventory.money] g" color "#fff"
######################STUFF FOR SHOP
init python:
class item:
def __init__(self, name, cost):
self.name = name
self.cost = cost
class Inventory:
def __init__(self, goldcoins="200"):
self.money = goldcoins
self.items = []
##ABOVE IS INITIAL STUFF
def buy(self, item):
if self.money >= item.cost:
self.money -= item.cost
self.items.append(item)
return True
else:
return False
##ABOVE IS FOR BUYING STUFF
def earn(self, amount):
self.money += amount
##ABOVE MEANS U EARN MONEY
##items
##FLOWERS
roses = item("Bouquet of Roses", 10)
tulips = item("Bouquet of Tulips", 10)
daisies = item("Bouquet of Daisies", 10)
label start:
$ current_money = inventory.money
$ inventory = Inventory()
pause
jump morning
label morning:
show screen money
label afternoon:
"buy something fuck you."
label shop:
"so many wares.."
menu:
"Flowers":
menu:
"Bouquet of Roses":
show roses at center
" That'll cost $10."
menu:
" I'll buy it.":
if inventory.buy(roses):
" Thanks for your purchase!"
else:
"Not enough money..."
" Eh, nevermind.":
jump buy_more
"Bouquet of Tulips":
show tulips at center
" That'll cost $10."
menu:
" I'll buy it.":
if inventory.buy(tulips):
" Thanks for your purchase!"
else:
"Not enough money..."
" Eh, nevermind.":
jump buy_more
"Bouquet of Daisies":
show daisies at center
" That'll cost $10."
menu:
" I'll buy it.":
if inventory.buy(daisies):
" Thanks for your purchase!"
else:
"Not enough money..."
" Eh, nevermind.":
jump buy_more
label buy_more:
scene store
" Anything else?"
menu:
" No":
" Have a nice day and come back real soon!"
jump leave
"Yes.":
jump shop
label leave:
"you leave.."
return