- Apr 13, 2021
- 1,825
- 1,481
Ok, so this is a code that i found on the internet. Ze Internet.
It's very simple and suits what i want to do.
All it has to do is to give an option (buy) and added it to the inventory. I don't want to make it too complicated for myself and the player.
So no shiny objects and stuff.
So this is using classes and i just can't figure out how to display what is left from the money.
All i see is class.blabla at location... if i use the console.
So there is surely an error that i make how to display that number.
Of course i use what i know which is "you have [money] left but this probably won't fit since it's a class.
I seen some inventory systems but i don't know anything about it, lesser the code itself and it look rather daunting to me.
So i like to still have an inventory system but simple. It shouldn't get in the way for gaming.
But i like to have the MC (player) think how to spend money and if short on money, to do something.
Anyway, that's my question.
(i am sure there is a "oh no, another inventory question."..
It's very simple and suits what i want to do.
All it has to do is to give an option (buy) and added it to the inventory. I don't want to make it too complicated for myself and the player.
So no shiny objects and stuff.
So this is using classes and i just can't figure out how to display what is left from the money.
All i see is class.blabla at location... if i use the console.
So there is surely an error that i make how to display that number.
Of course i use what i know which is "you have [money] left but this probably won't fit since it's a class.
Code:
#script.rpy
init python:#declare a python black so we can write python code
class resource:#this is a convenience class for handling resources
def __init__(self, starting_amount):
self.level = starting_amount
def dec(self):
if self.level > 0: self.level = self.level - 1
def inc(self): self.level = self.level + 1
default coffee = resource(0)
#label.whatever
menu coffeeshop01:
"Coffee?" if money.level >= 1:
"You purchase a coffee."
"You have {self.money} left."
$money.dec()
$beverage = resource(1)
"You don't have enough money" if money.level < 1:
"You sitting without a coffee at the table."
"Maybe you should get a job?"
So i like to still have an inventory system but simple. It shouldn't get in the way for gaming.
But i like to have the MC (player) think how to spend money and if short on money, to do something.
Anyway, that's my question.
(i am sure there is a "oh no, another inventory question."..