You’re using multiple sets of if-elseif statements for mutually exclusive conditions on the top level, particularly line 80 and line 96 using if despite being alternatives to the if-elseif statement starting at line 7.
I think that isn’t the problem in this case, but it makes it harder to be sure exactly what path it’s following through the code; it means you could theoretically trigger one of the ifs and the final else in one go. It looks like you’d always get some text from the first if in that case, though.
pronoun = hehim
romance = male
harry = 46
draco = 33
hermione = 100
luna = 19
The ending I want to reach with these variables should be that first “Harry” ending since his number is higher than Draco’s in this case. However when I run the test I end up in the “theythem” “either” Hermione GG ending. Which is… totally off course.
I’ve saved my old code in a different file and now I’m trying to build it a different way to see if I can isolate where it’s getting off course.
There are no *elses for the larger *if sections up to line 96, so once the bigger conditions are not being met, it will end up there; the game will at the very least reach line 175 if no conditions are met.
Anyway I tested your code with the values you sent and it worked fine, but I added a few conditions. Can you try replacing lines 7 through 23 with the excerpt below?
*if ((pronoun = "hehim") and (romance = "male"))
*if (harry = draco)
harry and draco Ending A
*elseif (harry > draco)
harry Ending B
*elseif (draco > harry)
draco Ending C
ERROR ELSE #1
ERROR ELSE #2
Using the values you described to me, it worked just fine.
Well, I recommend you switch to using tabs instead of spaces for your indentation; a lot more visible with little key presses (one tab goes as far as like 4 spaces but with only 1 press for each indentation, a lot easier to handle).
I also recommend using CSIDE to make your coding and testing easier, if you aren’t using it already.
Hmm what do you mean? Like in the code if it reaches the end or in the game?
While playing the game it line wraps automatically; if you’re talking about the code it depends if the editor you are using has line wrap on or not. If it doesn’t, it will keep going endlessly and you’ll need to scroll horizontally which is a pain. If line wrap is on it will automatically move the code to the next line (without requiring pressing the return key). So you don’t have to worry about indenting a lot if you use tabs, it will work fine.
CSIDE has an option to turn code line wrapping on or off.
I was asking about the second instance of text wrap that you described. Good to know. CSIDE is what I’ll try out in a bit. Right not though I have to go through and fill in all the actual text and story so I can turn this project in.
I’m sort of kicking myself for not playing around and figuring out how to work with *goto and *label earlier. That probably would have made some of the code neater, but I’ll know to experiment with it next time.
Edit: CSIDE COLORS THE SCRIPT. YES. That’s so useful oh man.
Well, I’d at least advise making there be only one if at each level when you only want to do one of the things, especially if you are using a final else. Essentially, if you didn’t have the *ending you’d get the Harry Ending then the Hermonie Ending with the variables you’d listed (“male” being correct). Which meant I had to examine the whole body of the first if to make sure it wasn’t that you’d missed a case in there so you went into that if and did nothing then got to the final else.
For a great many things in programming, including this, there are many ways to write code to obtain more-or-less the same result (performance may vary, but for choicescript I wouldn’t bother worrying about it) but some are preferred for readability and being easier to avoid screwing up.
As for nesting, I would have recommended doing it for this one and it would’ve revealed it was “romance” and not “pronoun” that had the problem, but now that it’s written I wouldn’t bother rewriting it.
It’s self published for free because it’s an interactive fan-fiction built with the choice script system. Fair use laws alone make this a viable method, and I read through the choice script terms and since it’s not published through their site it doesn’t seem to be an issue. Beyond that it’s also just a school project meant to explore the uses of interactive fiction and the way the text interacts with gender, sexuality, and identity in ways that the canon text and traditional fan-fiction can’t.
Thanks again guys for helping me out with finding the coding error so that I could actually turn this in. I just got my grade and commentary from my Professor. B+ (only because I forgot to support my arguments in my artist’s statement with specific course readings), and she wants to show it to future classes because of the amount of work I put into it.