I’m working on a section of my game where the player can mine to earn gems using *rand.
I think I’ve got it all working, except for one line which is supposed to increase the item count by one in the player’s inventory, where the items are stored as numeric amounts.
The line in question has the *set command below. All that stuff on the line works out, the problem is that a variable will not work with *set if it starts with a parenthesis, but I need that for proper concatenation.
Any ideas on how to have it accept that variable or ways around it?
Thanks.
Here’s the part with the issue: (I use single space indents)
*if (Mine < 150)
*sound Pickaxe1.wav
Success!
*line_break
You found a [i]${Gem_size} ${Gem_purity} ${Gem_type}[/i]
*set (("$!{Gem_size}"&"_")&("${Gem_purity}"&"_"))&"${Gem_type}" +1
*choice
#Continue mining
*goto Go_mining
#Stop mining
*finish
An example of a possible output would be:
You found a medium chipped topaz
Then the variable Medium_chipped_topaz would be increased by 1.
Thanks for the suggestion. I’m very new to this too, and like you, I’ve recently read the wiki pages.
Directly above the code from my original post is this:
*label Result
*if (Mine >= 150)
You found nothing of use.
*choice
#Continue mining
*goto Go_mining
#Stop mining
*finish
And this part works fine when I run it.
So the *goto and *finish commands inside the *choice command count as end points to the *if I guess.
I’m pretty sure the only problem with it is that single *set line. Seems I just need to find a workaround.
I would need to see you list of gems and maybe come up with a work around for you or you may have to wait to one of the master coders can reply. My work around may not be pretty but should work, I am good at long coding lol.
I’ve been messing with it a bit more after thinking about everyone’s suggestions. I added a variable Gem_found
*if (Mine < 150)
*sound Pickaxe1.wav
Success!
*line_break
You found a [i]${Gem_size} ${Gem_purity} ${Gem_type}[/i]
*set Gem_found (("$!{Gem_size}"&"_")&("${Gem_purity}"&"_"))&"${Gem_type}"
*set Gem_found +1
*choice
#Continue mining
*goto Go_mining
#Stop mining
*finish
The only problem now is that while I can overwrite the variable with a different data type (string to numeric,) I can’t add a number to the string. I feel like I’m closer though!
I am happy you are on the right track, little above my knowledge level, had to stretch my pea brain to grasp the basics. Really good with that but you get into combined var like your doing and it like trying to read Latin upside down in a mirror to me.
Haha, honestly I feel the same way. This is my first experience with any kind of coding, and the only reason I can understand what I wrote is because I’ve been looking at it for so long and reading the Wiki a bunch
The first parameter in a *set statement can’t be a string, but the second parameter can be. You can then set by reference as per the advanced choicescript guide.