Gosub_scene error

Another day, another gremlin :slight_smile:

OK, when I manually play through my story (which is starting to become a pretty major undertaking!) it plays through just fine, no errors pop up at all success! But, when I run Randomtest in CSIDE it comes up with an error. The error is:

RANDOMTEST FAILED: Error: subroutines line 172: invalid return; we’ve already returned from the last gosub

Two things strike me as odd about this. First off (after going through the rather lengthy subroutine) there are no duplicate calls. Second, the path the Randomtest took never called the subroutine. Does anyone have any ideas what could be causing this error? I’m including the section of code that includes the line it refrences (not the whole subroutine though, did I mention it’s pretty big?)

*else
    *if (race = "elf")
        *if (gender = "Male")
            *set greeting "forest lord"
            *set farewell "milord"
            *return
        *elseif (gender = "Female")
            *set greeting "forest lady"
            *set farewell "milady"
            *return
        *else
            *set greeting "deepwood friend"
            *set farewell "respected friend"
            *return
    *elseif (race = "trylle")
        *set greeting "noble one"
        *set farewell "dear friend"
        *return
    *elseif (race = "halfling")
        *set greeting "fairkin"
        *set farewell "close cousin"
        *return
    *elseif (race = "crossborn")
        *if (gender = "Male")
            *set greeting "brother"
            *set farewell "bonded brother"
            *return
        *elseif (gender = "Female")
            *set greeting "sister"
            *set greeting "bonded sister"
            *return
        *else
            *set greeting "sibling"
            *set farewell "bonded one"
            *return
    *else
        *set greeting "nothinglost"
        *set farewell "stranger"
        *return

Any suggestions would be appreciated!

Lessa

if the randomtest (does quicktest call it) doesn’t call a subroutine it might easily be an indent error.

two: how often is this bit called in the scene it’s in? assuming it’s a gosub and not a gosubscene

1 Like

Quicktest doesn’t seem to call it, I have a harder time decoding what Quicktest is doing.

I meant that the path the Randomtest is taking through the story never takes an option that calls that subroutine. I’m only having Randomtest run through one iteration right now. It gets to the end of the run and pops up that error message after it’s finished running through the story.

In that scene (the subroutine is called via gosub_scene) it gets called a total of three possible times, one per merchant. Whether it’s called at all or not depends on whether or not you go to a merchant in that scene, it’s possible to move on to the next scene without ever going to a merchant. I’m using it as a subroutine because I am planning to have other merchants as you travel through the land - and the story :slight_smile:

mhnnn… if quicktest doesn’t call it (quicktest just checks if indents etc are correct) that might mean an indent error.

also a possibility:
do you have the subscene’s file listed on your scenelist?

if yes: where and if at the end check if your last file ends on *ending

if no: are you going to call the subscene only in one major scene or sometime else later on too?

edit:
also you are setting ‘greeting’ twice for female crossborns

I do have the subscene file on my scenelist. I make sure to keep that updated as I add new scenes. Currently the subscene file is about in the center of my scenelist.

I made is a subroutine in a separate scene file because I’m planning to call it in other scenes. For that reason I also have the variables that it’s checking as permanent in the setup file instead of using temp variables.

I just tried adding *ending where the story ends right now, and when I ran Randomtest it didn’t give me any errors. Thank you for suggesting that, I wouldn’t have thought of it!

Thank you for catching that I was setting “greeting” twice, I can’t believe I missed that :smiley:

Ah, there’s the error:

The games will call scenes in the order of the scenelist, meaning if you have a subscene in there in the middle it will call the subscene without anywhere to return to.
e.g.

*scene_list
   scene1
   scene2
   subscene
   scene3

or similar it will NOT go from 2 to 3.

Also, you don’t need subscenes in the scenefile, as long as they are in the folder
try removing it from the scenelist and check then

1 Like

Oh that’s wonderful information to know, thank you so much!

also, question:
you are only setting greetings and farewells here.
How and when do they change?
cause, albeit you got a lot, you could do the same with multireplace or setting it at the race/gender choice maybe, depending on how this is meant to play out

The greetings and farewells (at this point) are going to change based on the race of the shopkeeper and the race chosen for the PC. So, if the shopkeeper is a human, how they greet and say goodbye to you is based on which race you choose at the beginning, Those will be different is the shopkeeper was another elf or a dwarf etc. Can you point me in the direction of how to use multireplace? I’m still learning so much about writing in CS!

basically multireplace works like this:

you have a variable, be it true/false, numeral or a text.

you call it by using @{(var) text for the variable| other text} continued text.

the | separates the various bits of text to use.

for example

True/false:
He @{atesoup ate| didn't eat} the soup.

True/false will need two bits of text. One for the variable used being true, one for it being false.

This here will print as either ‘He ate the soup’ or ‘He didn’t eat the soup’ depending on whether or not the ‘atesoup’ variable is true or false.

numeral variable work like this

@{var 1| 2| 3| 4} further text.

OR

@{(var =3} text for 3| text for all others}

string variables are similar:

@{(var ="variable") text for that specific variable| other text} more text

you can also combine variables

@{((var ="blue") or (var2)) text for that combo| other text}

You can however NOT nest multireplace in multireplace, so there you should use *if trees

*if (var ="first")
   @{var2 1| 2| 3} text
*if (var ="second")
   @{var2 4| 5| 6} text

And for formatting

Word'@{plur re|s}

will print as
Word’re / Word’s (good for pronouns that use plural verbs)

word @{plur are| is}

will print as
word are/ word is

hope that helps

That helps a lot, thank you so much!

1 Like

welcome :3

good luck