Welcome to the Creatures Wiki! Log in and join the community.

Subroutine

From Creatures Wiki
Jump to: navigation, search

A subroutine is a programming concept which allows us to create discrete chunks of code which can be used at varying times in a complex script, like a timer script. Common subroutines for critters and plants include death subroutines, birth subroutines, growth subroutines, breeding subroutines and movement subroutines.

In the timer script they are 'called' in the appropriate order by the GSUB command. Using an asterisk to comment out the gsub command for that subroutine means that the subroutine will not be executed, even if the code remains in the timer script. The coder generally includes subroutines at the tail end of the timer script, after the basic layout of the timer script has been completed. Subroutines are enclosed by SUBR and RETN commands.

Subroutines have been a feature in CAOS since C1 - the coconuts use them to control some aspects of their growth.

See also[edit]