Okay, so to sum it up. I’ve got a *choice, and a *selectable_if that’s tied to a few variables. Now the funny thing is, when one boolean value is true, then it works like it’s supposed to, but when the boolean value is false, then the *selectable_if falls out of the *choice somehow.
The *selectable_if isn’t tied to the boolean value either, but once inside it does check for it. However, while it is selectable, once I do so, it says it doesn’t recognize *selectable_if as a valid command, which must mean that somehow it has managed to fall out of its *choice…Which is really strange because it still displays correctly up until the point I click it.
The choices in question I’m having trouble with, are the two bottom ones. The error outlines the line where the bottom *selectable_ifs are, depending on which I choose. And the mysterious boolean value required for them to arbitrarily work, is; sword.
*choice
*selectable_if (time < 1500) #Visit the blacksmith.
*if (time >= 1500)
"I'm sorry mi${title}, I'm closing up now. You may come back tomorrow."
*line_break
*line_break
With that, he followed you out of his smithy, closed the door and locked it behind you.
*page_break
*goto Marketmain2
*else
*goto Yesblacksmithinhut
*label Yesblacksmithinhut
Blah blacksmith in his smithy.
*label Blacksmithhut
*if ((bs_metbefore = false) and (peopleoppyou <= 0))
"Mi${title}... What a surprise. How may I be of service?"
*if ((bs_metbefore = false) and (peopleoppyou > 0))
"Mi${title}! What an honour to have you in my humble smithy! How may I be of service?"
*if (bs_metbefore)
"Mi${title}, was there anything else?"
*set armor_repaired (bsprice_low + (100 * armor_type))
*choice
*if ((sword_type < 6) and (bs_forgesword = false))
#Have a new sword forged.
"Certainly, mi${title}. What kind of material should I make it of? Iron or steel?"
*choice
*if (star_steel)
*selectable_if (((wealth >= forge_sssword) and (bs_forgesword = false)) and (star_steel)) #Actually, I have a piece of a meteorite with me... [b]${forge_sssword} daler[/b]
"Well I'll be... A piece of star steel. Mi${title} I would be proud to forge a weapon worthy of bardly praise for you.
Apologies for the mountain of code, believe it or not, this has already been cleaned up once, though I’ll probably clean it up even more and put some of it in a *gosub once I figure out what exactly is going wrong with it. So please, heeeelp! [-O<
When I have long or complicated code within a choice, I immediately *goto somewhere.
*choice
*selectable_if (superpowered) #Jump off the building.
*goto JumpOff
*selectable_if ((spellcaster) and (power >= 50)) #Caste a spell to fly.
*goto FlyOff
This makes it easier for me to debug and simpler for CS to read.
Well I have sorta done that, except the place to go was within the *choice this time around… But like I said, it’s a process, I’ve cleaned it up once already and will do so again.
I hadn’t really realized just how long it was until I posted it in here and it kept capping the limit of characters available for a post, and the width of the post window isn’t doing it any favors either. But once I started, I figured I’d might as well finish. And it is an interesting problem, I feel. I’ll take another whack at it, but for anyone interested in the meanwhile I’d suggest copy pasting the whole thing into a document. Kind of embarrasing this, really…
I’ve experienced similar issues with *selectable_ifs. It’s best to keep it to one variable, so if you could add more *ifs before your *selectable_if it might work.
So
*if ((sword_type < 6) and (bs_forgesword = false))
#Have a new sword forged.
"Certainly, mi${title}. What kind of material should I make it of? Iron or steel?"
*choice
*if (star_steel)
*if (wealth >= forge_sssword) and (bs_forgesword = false)
*selectable_if (star_steel) #Actually, I have a piece of a meteorite with me... [b]${forge_sssword} daler[/b]
"Well I'll be... A piece of star steel. Mi${title} I would be proud to forge a weapon worthy of bardly praise for you.
Also, I almost always use *fake_choice. It reduces falling out complaints a lot, and it will just go on to the next thing when the code is done. Just make sure there is a line or a *goto on the same indent level of the *fake_choice directly after the choice.
*choice
*if (star_steel)
*if (bs_forgesword = false)
*selectable_if (wealth >= forge_sssword) #Actually, I have a piece of a meteorite with me... [b]${forge_sssword} daler[/b]
"Well I'll be... A piece of star steel. Mi${title} I would be proud to forge a weapon worthy of bardly praise for you.
*set time +60
Well that didn’t work. I dunno why I’ve gotten this bad habit of indenting too much, it’s a right pain to change something. But I suppose this means there is a bug in the engine somewhere creating this arbitrary fault. I guess I’ll try the fake-choice next.
Alright, it seems like the indents were the culprits. I moved the biggest shebang down to its own label so I could reduce the indents, and now it works. Just need to remember to break it up more in the future.
Yeah copying and pasting my code exactly is a bad idea. Indents are 99% of the problem some days, it seems xD
Also, sometimes the editor I’m using will switch from tabs to spaces (I use tabs so it’s a lot easier to organize) and that might be the problem, though there’s usually a specific error code for that.
Yeah I did C# before this, so I got into the habit of using 3 space indents, obviously this becomes rather troublesome after a few lines of it, but it’s a hard habit to kick.
Thank you, I’m sure I’ll need it. Good luck in your own endeavors as well.