Subroutines with arguments?

Is it possible to make subroutines that take arguments and parse them with *gosub? If so, how?


Well uh the subroutines are usually *gosubs? What do you mean by parse? Do you mean something like;

*if (choice1)
   Do this

Because if so, yes, yes you can. I generally advise people to use *gosub_scene instead though, and create a separate txt file, as that way you don’t have to copy paste the subroutine into every scene where you’ll be calling it, if you plan to use it more than once obviously. I don’t think you should be calling gosubs within gosubs though, that might mess with things, not sure. As long as there’s no *page_breaks in the second *gosub you’ll probably be fine though. But yeah, need more info on what it is you want to do exactly.

Edit: Nevermind, there’s no problems at all having *gosubs within *gosubs.

do you mean something like

*set renown 50
You look in the mirror.

*gosub famous

So that's how it is...

*label famous
*if (author = "Andrew")`
  *set renown %+50
  *set renown 0

? Then, yes

No, it’s not.
You have to emulate argument/parameter behaviour with separately defined variables, like so:

*temp arg_1 5
*temp arg_2 4
*temp return_val

*gosub func_sum

*label func_sum
*set return_val (arg_1 + arg_2)

You could also reset the argument values and check them under the label code (so you could throw an error if they’ve not been provided). You can do a lot more than you’d think if you’re willing to play around a bit, but no, there’s no native support for arguments.

@CJWThanks. I’ll do that then.