Gosub: does the subroutine need to be in each page?

There is a subroutine that I am using in multiple pages in my game. My question is, does the subroutine have to be in each page? Or, can it just be in one page in the game? And, from an organisational point of view, would it thus be better to put all such subroutines (which are used multiple times throughout the game) in one page, or in separate places? What are the pros and cos (loading times of screens, etc…)


*gosub subroutine_restore_hp

Which goes to:

*label subroutine_restore_hp

*if (hp <max_hp)
*if (power_regeneration = 1)
*set hp + daily_regenarion_speed
*goto finish_subroutine
*elseif (first_aid >70)
*set hp +4
*goto finish_subroutine
*elseif (first_aid >40)
*set hp +3
*goto finish_subroutine
*elseif (first_aid >10)
*set hp +2
*goto finish_subroutine
*set hp +1
*goto finish_subroutine
*goto finish_subroutine
*label finish_subroutine


If you have it on a different page, you’d need to use *gosub_scene filename subroutine_name in order to get to it, but it’s easier than having each subroutine cut and pasted to each and every file, since they’re all in a single place, so any change to the subroutine will affect it no matter what page it’s called from.


*gosub_scene will always give you a visible loading bar every time the command is called. *gosub is not.

Regardless, both don’t weigh on the phone’s resource, really.

1 Like

Worth noting that with a compiled game this won’t occur, as everything is pre-loaded. I do this all the time, though, a file called routines.txt or functions.txt that houses all my common utilities. It’s definitely a plus for organisation, but does have the caveat mentioned above on uncompiled games, which need to load the scene everytime you make the call.


Thanks, all that helps a lot!