need help with code for a money system
Posted: Thu Aug 13, 2015 2:35 am
I need some help adding to the money system code, where if you don't have enough money you cant buy something, I can't really think of a way too do that.
Supporting creators of visual novels and story-based games since 2003.
https://lemmasoft.renai.us/forums/
Code: Select all
# assuming money is a global var
def check_money( item_cost ):
if money < item_cost:
return False # cannot buy
return True # can buy, probably add code to add/have the itemCode: Select all
if money < cost:
"You don't have enough money."
else:
"You have enough money."For my game how would I change the code, because I can't keep track of what choices people pick that may give them more money, so that if the amount of money they have is more than the cost they can buy it, and if they have to little they cant? sorry If i sound confusingtrooper6 wrote:I you don't know much about Python, I'd recommend you take the free course over at codeacademy.com
I say this because a money system is mostly just some basic python.
If is an if statement.
You might want to look over this thread I posted in as well. http://lemmasoft.renai.us/forums/viewto ... +inventoryCode: Select all
if money < cost: "You don't have enough money." else: "You have enough money."
But to the code academy python course.
You do not sound like you know anything about how to use basic variables. But you also want to do complicated things that will necessitate understanding how variables work.Lucky1443 wrote: For my game how would I change the code, because I can't keep track of what choices people pick that may give them more money, so that if the amount of money they have is more than the cost they can buy it, and if they have to little they cant? sorry If i sound confusing
I don't know if this question has been asked before, but... What recommendations would anyone make on off-line resources for learning Python? Any books?trooper6 wrote:Lucky1443 wrote: Go to codeacademy.com and take their free basic Python course. The whole hing takes maybe 12 hours. You can do it in a weekend and it will make you much better able to do what you are asking as well as help you with everything else you might want to do with your game.
Thank you for the quick reply, philat! I'm gonna look into this.philat wrote:You can buy Learn Python the Hard Way, which is both more difficult and a bit more tedious...