need help with code for a money system
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.
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.
- Lucky1443
- Regular
- Posts: 128
- Joined: Tue Jul 07, 2015 11:59 am
- Projects: SACRIFICE
- Tumblr: Lucky1443
- Deviantart: Lucky1443
- Contact:
need help with code for a money system
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.
OPEN for SPRITE/CG ART viewtopic.php?f=62&t=38654 FREE TO USE ASSETS viewtopic.php?f=52&t=39634
- chocojax
- Miko-Class Veteran
- Posts: 705
- Joined: Sun Oct 25, 2009 11:27 am
- Projects: Umbra, Familiarity, Maleficent Justice
- Tumblr: chocojax
- Location: California
- Contact:
Re: need help with code for a money system
You could do something simple like:
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 item
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: need help with code for a money system
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 ... +inventory
But to the code academy python course.
I say this because a money system is mostly just some basic python.
If is an if statement.
Code: Select all
if money < cost:
"You don't have enough money."
else:
"You have enough money."
But to the code academy python course.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
- Lucky1443
- Regular
- Posts: 128
- Joined: Tue Jul 07, 2015 11:59 am
- Projects: SACRIFICE
- Tumblr: Lucky1443
- Deviantart: Lucky1443
- Contact:
Re: need help with code for a money system
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.
OPEN for SPRITE/CG ART viewtopic.php?f=62&t=38654 FREE TO USE ASSETS viewtopic.php?f=52&t=39634
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: need help with code for a money system
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
What I recommend doing, rather than just asking for some code you don't understand (and what you are asking for is a complete inventory system), you should learn some basic Python so you can do what you want and better understand what help people give you.
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.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
- Lucky1443
- Regular
- Posts: 128
- Joined: Tue Jul 07, 2015 11:59 am
- Projects: SACRIFICE
- Tumblr: Lucky1443
- Deviantart: Lucky1443
- Contact:
Re: need help with code for a money system
Ok thanks
OPEN for SPRITE/CG ART viewtopic.php?f=62&t=38654 FREE TO USE ASSETS viewtopic.php?f=52&t=39634
- mediawriterdude
- Newbie
- Posts: 12
- Joined: Fri Sep 04, 2015 10:55 am
- Completed: None
- Projects: None! Starting from Scratch!
- Organization: V. Valdemar
- Location: Somewhere in New England
- Contact:
Re: need help with code for a money system
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.
I currently lack a dedicated internet connection, and learning on-line would be impossible!
__________________________________
Greatest Retro Show Opening Of All Time:
https://youtu.be/j2PoXfZdYVU
Also, Anime:
https://youtu.be/jjieygKSXpQ
__________________________________
Greatest Retro Show Opening Of All Time:
https://youtu.be/j2PoXfZdYVU
Also, Anime:
https://youtu.be/jjieygKSXpQ
__________________________________
Re: need help with code for a money system
You can buy Learn Python the Hard Way, which is both more difficult and a bit more tedious than the codecademy course, but available with video classes and a full pdf, which you can just download and print out. You can do the practice questions without an internet connection once you set up python and powershell on your computer. You can also just print out the book part only for free, but do consider supporting the author if you find you're benefiting from the book.
- mediawriterdude
- Newbie
- Posts: 12
- Joined: Fri Sep 04, 2015 10:55 am
- Completed: None
- Projects: None! Starting from Scratch!
- Organization: V. Valdemar
- Location: Somewhere in New England
- Contact:
Re: need help with code for a money system
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...
__________________________________
Greatest Retro Show Opening Of All Time:
https://youtu.be/j2PoXfZdYVU
Also, Anime:
https://youtu.be/jjieygKSXpQ
__________________________________
Greatest Retro Show Opening Of All Time:
https://youtu.be/j2PoXfZdYVU
Also, Anime:
https://youtu.be/jjieygKSXpQ
__________________________________
Who is online
Users browsing this forum: No registered users