Limit to Choice length? (*selectable_if falls out of *choice)


#1

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. 


#2
  
                      *set time +60
                        *set bs_status %+20
                        *label Thesameswords
                        *if ((broken_sword = false) and (sword = false))
                              *if (what_sword = 6)
                                 *set wealth - forge_sssword
                                 *set sword_type_temp 6
                              *if (what_sword = 5)
                                 *set wealth - forge_ssword
                                 *set sword_type_temp 5
                              *if (what_sword = 4)
                                 *set wealth - forge_isword
                                 *set sword_type_temp 4
                              *if (what_sword = 3)
                                 *set wealth - forge_pisword
                                 *set sword_type 3
                                 *set sword_hp sword_type
                                 *set sword true
                        *if ((broken_sword) or (sword))
                           I see you've got
                           *if (broken_sword) 
                              a broken 
                           *if (sword)
                              an old 
                           sword as well, let me take that 
                           *if (broken_sword)
                              scrap 
                           off your 
                           hands and I'll give you a discount."
                           *if (((a1_sword_type = 0) or (a2_sword_type = 0)) or (a3_sword_type = 0))


#3

                           *choice
                              *if (a1_sword_type = 0) #No, deposit it to the armory instead.
                                 *label a1_anyways
                                 [b][-Item Deposited-][/b]
                                 *line_break
                                 *line_break
                                 *set a1_broken_sword broken_sword
                                 *set a1_sword sword
                                 *set a1_sword_type sword_type
                                 *set a1_sword_hp sword_hp
                                 *set a1_sword_dull sword_dull
                                 *set a1_swordname swordname
                                 *set broken_sword false
                                 *set sword false
                                 *set sword_type 0
                                 *set sword_hp 0
                                 *set sword_dull false
                                 *set swordname ""
                                 *if (what_sword = 6)
                                    *set wealth - (forge_sssword - (100*sword_type))
                                    *set sword_type_temp 6
                                 *if (what_sword = 5)
                                    *set wealth - (forge_ssword - (100*sword_type))
                                    *set sword_type_temp 5
                                 *if (what_sword = 4)
                                    *set wealth - (forge_isword - (100*sword_type))
                                    *set sword_type_temp 4
                                 *if (what_sword = 3)
                                    *set wealth - (forge_pisword - (100*sword_type))
                                    *set sword_type 3
                                    *set sword_hp sword_type
                                    *set sword true
                                 *goto Onwiththe_swordsales
                              *elseif (a2_sword_type = 0) #No, deposit it to the armory instead.
                                 [b][-Item Deposited-][/b]
                                 *line_break
                                 *line_break
                                 *set a2_broken_sword broken_sword
                                 *set a2_sword sword
                                 *set a2_sword_type sword_type
                                 *set a2_sword_hp sword_hp
                                 *set a2_sword_dull sword_dull
                                 *set a2_swordname swordname
                                 *set broken_sword false
                                 *set sword false
                                 *set sword_type 0
                                 *set sword_hp 0
                                 *set sword_dull false
                                 *set swordname ""
                                 *if (what_sword = 6)
                                    *set wealth - (forge_sssword - (100*sword_type))
                                    *set sword_type_temp 6
                                 *if (what_sword = 5)
                                    *set wealth - (forge_ssword - (100*sword_type))
                                    *set sword_type_temp 5
                                 *if (what_sword = 4)
                                    *set wealth - (forge_isword - (100*sword_type))
                                    *set sword_type_temp 4
                                 *if (what_sword = 3)
                                    *set wealth - (forge_pisword - (100*sword_type))
                                    *set sword_type 3
                                    *set sword_hp sword_type
                                    *set sword true
                                 *goto Onwiththe_swordsales
                              *else #No, deposit it to the armory instead.
                                 [b][-Item Deposited-][/b]


#4

                                 *line_break
                                 *line_break
                                 *set a3_broken_sword broken_sword
                                 *set a3_sword sword
                                 *set a3_sword_type sword_type
                                 *set a3_sword_hp sword_hp
                                 *set a3_sword_dull sword_dull
                                 *set a3_swordname swordname
                                 *set broken_sword false
                                 *set sword false
                                 *set sword_type 0
                                 *set sword_hp 0
                                 *set sword_dull false
                                 *set swordname ""
                                 *if (what_sword = 6)
                                    *set wealth - (forge_sssword - (100*sword_type))
                                    *set sword_type_temp 6
                                 *if (what_sword = 5)
                                    *set wealth - (forge_ssword - (100*sword_type))
                                    *set sword_type_temp 5
                                 *if (what_sword = 4)
                                    *set wealth - (forge_isword - (100*sword_type))
                                    *set sword_type_temp 4
                                 *if (what_sword = 3)
                                    *set wealth - (forge_pisword - (100*sword_type))
                                    *set sword_type 3
                                    *set sword_hp sword_type
                                    *set sword true
                                 *goto Onwiththe_swordsales
                              #Alright, I'll take the discount.
                                 [b][-Item Sold-][/b]
                                 *line_break
                                 *line_break
                                 *if (what_sword = 6)
                                    *set wealth - (forge_sssword - (100*sword_type))
                                    *set sword_type_temp 6
                                 *if (what_sword = 5)
                                    *set wealth - (forge_ssword - (100*sword_type))
                                    *set sword_type_temp 5
                                 *if (what_sword = 4)
                                    *set wealth - (forge_isword - (100*sword_type))
                                    *set sword_type_temp 4
                                 *if (what_sword = 3)
                                    *set wealth - (forge_pisword - (100*sword_type))
                                    *set sword_type 3
                                    *set sword_hp sword_type
                                    *set sword true
                                 *set broken_sword false
                                 *set swordname ""
                                 *goto Onwiththe_swordsales
                           *if (((a1_sword_type != 0) and (a2_sword_type != 0)) and (a3_sword_type != 0))
                              [b][-No Room In Armory-][/b]
                              *line_break
                              [b][-Item Sold-][/b]
                              *line_break
                              *line_break
                              *if (what_sword = 6)
                                 *set wealth - (forge_sssword - (100*sword_type))
                                 *set sword_type_temp 6
                              *if (what_sword = 5)
                                 *set wealth - (forge_ssword - (100*sword_type))
                                 *set sword_type_temp 5
                              *if (what_sword = 4)
                                 *set wealth - (forge_isword - (100*sword_type))
                                 *set sword_type_temp 4
                              *if (what_sword = 3)
                                 *set wealth - (forge_pisword - (100*sword_type))
                                 *set sword_type_temp 3
                              *set broken_sword false
                              *set swordname ""
                              *goto Onwiththe_swordsales
                           *label Onwiththe_swordsales
                           *set bs_forgesword true
                           "Your new sword will be delivered to you within a week mi${title}." Said the blacksmith.
                           *set bs_metbefore true
                           *page_break
                           *goto Blacksmithhut
                  *selectable_if ((wealth >= forge_isword) and (bs_forgesword = false)) #I would like an Iron sword. [b]${forge_isword} daler[/b]
                     "Iron it is. 
                     *set time +30
                     *goto Thesameswords
                  *selectable_if ((wealth >= forge_ssword) and (bs_forgesword = false)) #Make it out of your finest steel! [b]${forge_ssword} daler[/b]
                     "Excellent choice mi${title}, can't got wrong with steel. 
                     *set time +30
                     *goto Thesameswords

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<


#5

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.


#6

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…


#7

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.


#8

@CitizenShawn


               *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. :frowning: 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.


#9

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.


#10

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.

Good luck!


#11

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. :slight_smile: