I am new to choicescript, and have begun writing a game, I am focusing on getting a solid code base before I write too much. But have a great outlined idea for a story.
I want to use currency as gold and silver… might add bronze lateron if needed.
I have this in my stats file:
*label wealth_regulater
*if (Silver >= 100)
*set Silver -100
*set Gold +1
*if (Silver >= 100)
*goto wealth_regulater
it seems to work when I add silver, it regulates to gold upon reaching 100 silver.
my question is, do any of you have any experience with multilevel currency?
and what problems might occur.
how would you solve it, if I have for instance, 3 gold, 5 silver. and have to buy something for 10 silver?
My own idea for this, is to have a *choice at the bottom of the stats file, where the player could manually convert gold to silver, but as it cannot be above 100 with my current code, I don’t know how to work around that.
at a shop, I want to use the *selectableif, so the player needs to have enough currency in total, but again, if the player only have 5 silver and needs 10, but have enough gold to cover the expense, how could this be coded?
I hope some of you have a few nuggets of advice for someone new to coding =)
I have just created a quick inventory, as follows.
What would you like to buy?
*choice
*if (dagger=0)
*if not (sword=1) or (warhammer=1)
*selectable_if (Silver >= 5) #A Dagger for 5 Silver
*set silver -5
You have purchased a Dagger
*set dagger 1
*goto merchant
*if (sword=0)
*if not (warhammer=1)
*selectable_if (Silver >= 50) #A Sword for 50 Silver
*set silver -50
You have purchased a Sword
*set sword 1
*goto merchant
*if (warhammer=0)
*selectable_if (Silver >= 100) #A Warhammer for 1 Gold
*set silver -100
You have purchased a Warhammer
*set warhammer 1
*goto merchant
I have the inventory in the stats file, which auto-deletes lesser items.
My idea with this is that certain situation will require a weapon, for instance if it requires a sword, it will be selectable if sword or greater is in the inventory (set to 1).
Do any of you fine people have a better idea? or input for this one?
PS.: if anyone has any cleanup advice in regard to my code, it would be much appreciated. As I have stated, my first encounter with ChoiceScript was yesterday.
Could you just track the wealth in silver, codeside? So it’s always 305 silver in your example.
However when the player wants the wealth displayed, have a separate variable that’ll do a temporary conversion for them? I’m not sure since I’ve never done a money system myself. Do any of the other games use money?
I don’t think you can set choices on the stats screen.
@FairyGodfeather
interesting idea, it would simplify it in the aspect of shopping. but I am not quite sure how to do a temp. conversion for the display in stats.
Several games use currency, but I haven’t seen any that uses it in multiple levels. the ones I have seen all use “Gold”, as the only one, which is quite simple to do.
However, I feel that I can add more depth to the currency system with it being in both gold and silver.
I will try to look into the whole *temp thing, it does sound very promising, and something I hadn’t thought of myself.
Thank you for the input, and if you have any ideas on how to do it, it would be much appreciated.
I’d think using silver as the only real variable is really simplifying you’re job for currency, without devaluing your gold & silver depth. Plus, you’re using base 10, so it’s simple enough to do, I believe.
Your regulater (sic) is pretty good, and you can retool it to simplify coding.
E.G.
choicescript_stats.txt
*temp gold
*label wealth_regulator
*if silver>99
*set silver - 100
*set gold + 1
*goto wealth_regulator
*comment
*if silver<100
*goto finished
*comment Sorry about this bit of code. Vanilla forums hates us all equally.
*label finished
*comment Since you're using levels of currency, I'd recommend opting out of a stat chart for currency - it looks a little funny in my head.
Gold: ${gold} Silver: ${silver}
*comment Side by side makes sense to me, as opposed to Gold on one line, and Silver on the one beneath it. They serve the same purpose, why be on separate lines.
Shop Idea?
*set silver 150
"Lookin' to buy iron or steel?"
*choice
*selectable_if (silver>50) #Iron Sword - 50 Silver
The man takes 50 of silver coin.
You receive an Iron Sword in return.
*set silver - 50
*selectable_if (silver>150) #Steel Sword - 1 Gold and 50 Silver
You give the man a gold coin and 50 of it's silver cousins.
He gives you a Steel sword in return.
*set silver - 150
*comment Players should believe that it's taken away 1 Gold and 50 Silver, but really it's taken away just 150 silver. The wealth_regulator will still show that it's taken 1 Gold though.
#Nevermind. I should save my coin.
You decide to leave empty-handed, but purse-full.
For future reference, try not to double-post while your Edit button is available and if you’d prefer to type out codeboxes, use the tags < pre > and < /pre >, removing the spaces.
I may have overlooked some stuff, but I would of put mine in the choicescript_stats but everytime someone got money in the game I would copy and paste the converting part over, so it doesnt have any errors.
“You can also use the modulo operator “%” to calculate the remainder after taking a division. Modulo is pretty weird, but it’s has two particularly interesting uses. First, you can check whether a number X is evenly divisible by a number Y by checking whether X % Y = 0. Second, you can use it to get the fractional part of a number X, the stuff that comes after the decimal point, by calculating X % 1. For example, 3.14 % 1 = 0.14.”
@CJW could you provide an example of how that can be used? It’s melting my brain currently looking at it. How could you use it in the example to convert gold into silver?
@FairyGodfeather, I tried to figure it out, too. All I could get out of it was that, if you have 563 silver, you could *set silver % 100 and it would end up being 63 silver. I don’t know how to translate that removed 500 into 5 gold.
@Caddmuss I already read that. Actually I read it when I was trying to work out how best to help earlier but I couldn’t make head nor tail of it. My brain’s being math stupid today.
Ooh, I just figured out a random idea for this if you’re doing the multi-level currency!
Whilst traveling through the wood, a band of thieves emerge from the brush.
"Hand over your coin purse, or die."
No way to defend yourself, you toss over the small pouch of currency.
The leader pockets all your gold before tossing you pack a still partly filled sack.
"Have a drink on me when you get out of the forest," he smirks.
*set silver % 100
It’s just off the top of my head, but at least I can think of a use for modulo operations now.
Um. Not sure if this is precisely right. I was fiddling with the tester though and it kind of seems to work.
In this case I’m using wealth as the variable for how much money you have. It’s in silver. I’m using the silver and gold variables just to display to the player how much cash they have and calculating it off their wealth stat.
I have a 8 slot inventory coded but it’s pretty advanced but ill post it for you.
\*create pocketspace
\*set pocketspace 0
\*create backpackspace
\*set backpackspace 0
\*label inventory
\*line_break
\*if (backpackslot1 != "Empty")
\*set pocketspace + 1
\*if (backpackslot2 != "Empty")
\*set pocketspace + 1
\*if (backpackslot3 != "Empty")
\*set backpackspace + 1
\*if (backpackslot4 != "Empty")
\*set backpackspace + 1
\*if (backpackslot5 != "Empty")
\*set backpackspace + 1
\*if (backpackslot6 != "Empty")
\*set backpackspace + 1
\*if (backpackslot7 != "Empty")
\*set backpackspace + 1
\*if (backpackslot8 != "Empty")
\*set backpackspace + 1
\*line_break
\*if ((backpack) and ((pocketspace = 0) and (backpackspace = 0)))
You do not carry anything with you.
\*fake_choice
#Go Back
\*goto_scene choicescript_stats
\*if (backpack) and (pocketspace >= 1)
----------Pocket----------
\*line_break
Pocket Space: ${pocketspace}/2
\*if (backpack) and (backpackspace >= 1)
----------Backpack----------
\*line_break
Backpack Space: ${backpackspace}/6
\*if (pocketspace > 0)
\*fake_choice
\*if (backpackslot1 != "Empty")
#${backpackslot1}
You open up your pack to grab your ${backpackslot1}...
Now the question is what to do with it?
\*fake_choice
\*if (backpackslot1 = "Meal")
#Eat ${backpackslot1}
\*if (hunger = 0)
Your not hungry!
\*goto display
\*if (hunger >= 1)
\*set hunger - 1
\*set backpackslot1 "Empty"
\*goto display
#Discard ${backpackslot1}
\*set backpackslot1 "Empty"
\*goto display
#Back
\*goto display
\*if (backpackslot2 != "Empty")
#${backpackslot2}
You open up your pack to grab your ${backpackslot2}...
Now the question is what to do with it?
\*fake_choice
\*if (backpackslot2 = "Meal")
#Eat ${backpackslot2}
\*if (hunger = 0)
Your not hungry!
\*goto display
\*if (hunger >= 1)
\*set hunger - 1
\*set backpackslot2 "Empty"
\*goto display
#Discard ${backpackslot2}
\*set backpackslot2 "Empty"
\*goto display
#Back
\*goto display
\*if (backpackslot3 != "Empty")
#${backpackslot3}
You open up your pack to grab your ${backpackslot3}...
Now the question is what to do with it?
\*fake_choice
\*if (backpackslot3 = "Meal")
#Eat ${backpackslot3}
\*if (hunger = 0)
Your not hungry!
\*goto display
\*if (hunger >= 1)
\*set hunger - 1
\*set backpackslot3 "Empty"
\*goto display
#Discard ${backpackslot3}
\*set backpackslot3 "Empty"
\*goto display
#Back
\*goto display
\*if (backpackslot4 != "Empty") and (age >= 11)
#${backpackslot4}
You open up your pack to grab your ${backpackslot4}...
Now the question is what to do with it?
\*fake_choice
\*if (backpackslot4 = "Meal")
#Eat ${backpackslot4}
\*if (hunger = 0)
Your not hungry!
\*goto display
\*if (hunger >= 1)
\*set hunger - 1
\*set backpackslot4 "Empty"
\*goto display
#Discard ${backpackslot4}
\*set backpackslot4 "Empty"
\*goto display
#Back
\*goto display
\*if (backpackslot5 != "Empty") and (age >= 11)
#${backpackslot5}
You open up your pack to grab your ${backpackslot5}...
Now the question is what to do with it?
\*fake_choice
\*if (backpackslot5 = "Meal")
#Eat ${backpackslot5}
\*if (hunger = 0)
Your not hungry!
\*goto display
\*if (hunger >= 1)
\*set hunger - 1
\*set backpackslot5 "Empty"
\*goto display
#Discard ${backpackslot5}
\*set backpackslot5 "Empty"
\*goto display
#Back
\*goto display
\*if (backpackslot6 != "Empty") and (age >= 11)
#${backpackslot6}
You open up your pack to grab your ${backpackslot6}...
Now the question is what to do with it?
\*fake_choice
\*if (backpackslot6 = "Meal")
#Eat ${backpackslot6}
\*if (hunger = 0)
Your not hungry!
\*goto display
\*if (hunger >= 1)
\*set hunger - 1
\*set backpackslot6 "Empty"
\*goto display
#Discard ${backpackslot6}
\*set backpackslot6 "Empty"
\*goto display
#Back
\*goto display
\*if (backpackslot7 != "Empty") and (age >= 11)
#${backpackslot7}
You open up your pack to grab your ${backpackslot7}...
Now the question is what to do with it?
\*fake_choice
\*if (backpackslot7 = "Meal")
#Eat ${backpackslot7}
\*if (hunger = 0)
Your not hungry!
\*goto display
\*if (hunger >= 1)
\*set hunger - 1
\*set backpackslot7 "Empty"
\*goto display
#Discard ${backpackslot7}
\*set backpackslot7 "Empty"
\*goto display
#Back
\*goto display
\*if (backpackslot8 != "Empty") and (age >= 11)
#${backpackslot8}
You open up your pack to grab your ${backpackslot8}...
Now the question is what to do with it?
\*fake_choice
\*if (backpackslot8 = "Meal")
#Eat ${backpackslot8}
\*if (hunger = 0)
Your not hungry!
\*goto display
\*if (hunger >= 1)
\*set hunger - 1
\*set backpackslot8 "Empty"
\*goto display
#Discard ${backpackslot8}
\*set backpackslot8 "Empty"
\*goto display
#Back
\*goto display