So I'm using a points system to keep track of cash & I've come to something i don't know...
Basically the cash default is $50, so I've done "default cash = 50" as my code.
When ever I want to add or take cash I use "$ cash +=10" and same for minus.
However, I've come to a scene where someone needs to give all his remaining money to another person, but at the point in the game the user can have either $50 still or $30 ( as he had the option to lend $20 earlier in the game ).
Is their a way to take all the cash off the person without doing "$ cash -=30" or "$ cash -=50"? as if I do it as -30 then the person would be left with 20 if they didn't lend the cash out earlier and would be -20 if I did -50 but if they didn't lend the cash out...if that makes any sense xD
I'd assume i'd use an if statement?
Like:
if $cash >30:
then just -30
elif $cash >30:
then take -50
as the character has over $50...but i'm not sure how to write it xD
Default points?
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.
- mitoky
- Veteran
- Posts: 316
- Joined: Sat Feb 07, 2015 9:12 pm
- Projects: The Purring Demon's Love, circus eterie
- Contact:
Re: Default points?
I am not that good with coding, but wouldnt it work if write:
$ cash = 0
Since you want to give everything away it doesnt matters what you had as you can simply make it zero then.
As said, not that good with coding yet so if someone can confirm it or has a better solution that would be appreticiated.
$ cash = 0
Since you want to give everything away it doesnt matters what you had as you can simply make it zero then.
As said, not that good with coding yet so if someone can confirm it or has a better solution that would be appreticiated.
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3794
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: Default points?
If you're taking all of the cash, you can just do it the simple way:
but for references' sake, lets say you do it the proper way, because it may be useful in future. I'll also show two ways you can test the value.
Code: Select all
$ cash = 0
Code: Select all
# First, we test the biggest number. The following says "if there's more than $49", i.e. $50
if cash > 49:
$ cash -= 50
#Now we test to see if the value is 30. Since this will only happen if the first line fails, it will only happen if there's less than $50
elif cash = 30:
$ cash -= 30
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Re: Default points?
Ahhh, So i was on the right lines with the if's, I put if cash >= 50: and it wasn't work xD now i see what i did wrong, thanks =]
Who is online
Users browsing this forum: Karrion, Nozori_Games