Coding alternate text into options using "if" statements


#1

Please advise on a coding issue that is giving me a headache.

Here is an example of what I am trying to do with alternating text - I can make it work in longer bits of text, e.g. after a label, but it gets confused when I try to alternate text right after options.

   *selectable_if ((Academics >=0) and (Conforming >=40)) # Note-taking materials (including plenty of highlighters), the book for class, and all of the references for the essay I'm working on in my free time. It's important to be prepared, even if it makes my backpack look like a turtle shell. 
      *set Popular -5
      *set Academics +5
      *if (Academics<=5)
         After all, you have a lot of ground to make up in class.
         *goto class_you_slacker
      *else
         *goto class_you_slacker

This didn’t cause any bugs, but with a character with Academics 0 I can select this option (good) but don’t see the low Academic-dependent text (bad). All initial spaces are definitely 3/6/9 etc.

How should I nest this properly? Thanks in advance.


#2

The forum software does allow you to post code. Just highlight the block of code and then click the preformatted text button (it looks like </> and is on the same bar as the smilies, bold, etc).

Okay what do you mean by it gets confused? Can you explain in more detail?

The only think I can note at the moment is that you require Academics >=0 and then +5 things so unless you’re dealing in negative numbers at some point getting Academics <=5 is going to be tough.


#3

Some characters do start out with a negative score in Academics (might re-balance the numbers later to avoid that.) With two of my characters, I raised their Academics from -5 & -10 to 0. Both of them could select the “prepared for class” option.

I added in this:

   *selectable_if ((Academics >=0) and (Conforming >=40)) # Note-taking materials (including plenty of highlighters), the book for class, and all of the references for the essay I'm working on in my free time. It's important to be prepared, even if it makes my backpack look like a turtle shell. 
      *if (Academics<=5)
         *goto class_you_failing_slacker
      *else
         *goto class_you_slacker

Under *label class_you_failing_slacker, I then put the one line “After all, you have a lot of ground to make up in class.” This displays this at the start of a new screen:

Is the best/only workaround for putting that into the option text to set two *if -locked options that are identical except for one sentence?

(I just came up with that while writing this reply, I may have answered my own question…)

And thanks for pointing out the </> button @FairyGodfeather!


#4

I’d suggest against using negative numbers. I think they are only an issue if you’re using the percentage increase and decreases but it’s probably better practice to just stick with positives.

I’m not actually seeing what your issue is. The code works for me when I plug it into the IDE.

Can you copy and paste the entire choice tree here? Not just that one little section. And with your attempts at alternating text.

Incidentally one of my trouble-shooting methods if I can’t get code to work is to use CJW’s ide. https://dl.dropboxusercontent.com/u/7840892/CJW/choicescript/tools/IDE/main.html I’ll plug the section of code in there, and fiddle with it until it works as planned. I probably won’t know what I’m doing, and use a lot of trial and error but I can generally bash it out that way.


#5

I figured it out (the question was how to put my alternate text - that one sentence which should appear if your academics are low - into the body of an option, rather than the text following it.) Some playing around with nesting conditions later, I have this:

   *if (Academics <=10)
      *selectable_if ((Conforming >=40) and (Academics >=0)) # Note-taking materials (including plenty of highlighters), the book for class, and all of the references for the essay I'm working on in my free time. It's important to be prepared, even if it makes my backpack look like a turtle shell. After all, I have a lot of ground to make up in class.
         *set Popular -5
         *set Academics +5
         *goto class_you_slacker
   *if (Academics >10)
      *selectable_if (Conforming >=40) # Note-taking materials (including plenty of highlighters), the book for class, and all of the references for the essay I'm working on in my free time. It's important to be prepared, even if it makes my backpack look like a turtle shell.
         *set Popular -5
         *set Academics +5
         *goto class_you_slacker

#6

Sounds like you may have sorted your problem out already, but I’m curious:

If you take your very first example and have the different sentence in the *if… but have the two branches each *goto different *labels, does it *goto right? Does it show the sentence?

It offends the programmer in me that you have to have 2 sections that are largely identical, especially since you’re doing duplicate stats adjustments… it’ll be so easy to change one and forget to change the other when you’re doing later stat balancing or whatever.


#7

Exactly, I wish there were a simpler way to just branch the text in the middle of the option, but I think this is the way to do it.

Yes, in my first reply, when I sent that one option to two different labels (class_you_slacker) and (class_you_failing_slacker) it worked fine. The sentence displayed at the top of the next screen or it didn’t.


#8

You know… the other way that might be good would be to take it out of the option and put a label. I use really short labels all the time for stuff like this. Honestly, if I’m more than a few tab-depths in, I find it hard to keep it straight and start looking for ways to dedent. Something like:

    *selectable_if ((Academics >=0) and (Conforming >=40)) # Note-taking materials (including plenty of highlighters), the book for class, and all of the references for the essay I'm working on in my free time. It's important to be prepared, even if it makes my backpack look like a turtle shell.
        *goto prepared

.
.
.

*label prepared
*set Popular -5
*set Academics +5
*if (Academics<=5)
    After all, you have a lot of ground to make up in class.
*goto class_you_slacker

If that makes sense.

I also might put the Academics check above the Academics mutation, but maybe you’re doing it that way on purpose.


#9

Yes, I want them to have to have a basic interest in school (Academics not zero or lower) to be able to care about being prepared. If you’ve been working hard to bring your score from negative to zero before this choice, you can raise Academics still further.

I’ve used *goto label in options before (like in the first reply) and it’s great for giving the player feedback on the choice they just made. But if you do that, the text shows up at the top of the next screen, after that option is chosen - it is not in the option itself.

Your idea of putting the stat adjustments after the label makes sense, except that particular label is where non-academic options direct. I think I’ll just keep my alternate-text options next to each other to remind myself to edit the stats in both.

(And yes, I am probably going to adjust my numbers later so that 0 is the lowest skills can go. It’s already the lowest personality stats can go, thanks to a rather irritating capping subroutine I have to keep linking to.)


#10

OH. I totally misunderstood what you were hoping to do… Hah. The length of the label text confused me into thinking it was going to show up after the choice, either way. Huh.

Possibly, you could do like this:

*temp academic_catch_up ""
*if Academics <= 5
    *set academic_catch_up " After all, you have a lot of ground to make up in class."

*choice
    *selectable_if ((Academics >=0) and (Conforming >=40)) # Note-taking materials (including plenty of highlighters), the book for class, and all of the references for the essay I'm working on in my free time. It's important to be prepared, even if it makes my backpack look like a turtle shell.${academic_catch_up}
        *set Popular -5
        *set Academics +5
        *goto class_you_slacker

I have no idea if that’d work, either, though. Also feel free to ignore my over-analyzing of this one little piece of code and move on with your life. As I probably should. :wink:


#11

Ooh, I am terrible at thinking of uses for temp commands, but that might work! I’ll give it a try.