How do I deduct *rand money values?

My game has a lot of randomized options and scenes, but one tricky thing I just ran into was money.

1 Like

I would do it like this:

*create current_money 50

*temp add_money 0
*rand add_money 20 50
*set current_money +add_money

Unless I’m mis-remembering.

EDIT: Or, of course, subtracting instead of adding.

1 Like

That’s slightly confusing to me…
Here’s what I have now, but it keeps giving me errors. These movie prices aren’t actual movie prices. lol! It’s just an example.

In startup the money value is listed as: *create money 0
The movie price randomizes but I get an error when trying to set money as a lower value after seeing a movie because it doesn’t recognize the $ commands. Understandably…but I don’t know how to write them.

*rand movieprice 430 1000
The price for this today is {movieprice}. Would you like to see a movie? *choice #Yes You saw a movie. *set ({money} - ${movieprice})

1 Like

${} is for displaying var outputs in the text. For all “under the hood” operations (like doing math in your case) that syntax is unnecessary.

So, it should be like this:
*set money - movieprice

2 Likes

I think you need to *create or *temp movieprice, before you can *rand it?

1 Like

Thank youuuu! It worked!

1 Like

This might be a weird roundabout way of doing this, but if you’re having trouble getting (dollar sign) to display in text, you might be able to *create m "" (dollar sign in the quotes)
Then, display it in text as (dollarsign here){m}(dollarsign here){money}
I’m not 100% certain this will work, but I suspect that it will.

You’ll also want to account for making sure money doesn’t end up less than 0. How you want to handle it is on you, but you’d probably want to set up a situation where, if there’s not enough money, such as *if movieprice > money
and then a proper message of some sort for not having enough to purchase a movie ticket which circumvents the subtraction of movieprice from money.

1 Like