- Feature Name: require
- Start Date: 11/11/2016
A feature to include external GTA3script files into the compilation process.
File inclusion is essential for modularity, unfortunately custom scripts do not have access to file includers such as GOSUB_FILE
or LAUNCH_MISSION
. As such, REQUIRE
is proposed.
ID | Command Name | Command Hash | Params |
---|---|---|---|
None | REQUIRE | 0x75ebc48c | LABEL |
REQUIRE
is a command which requests its first argument (which is parsed as a filename, independenty of the current compiling script type) to be added to the compilation process. The REQUIRE
command itself does not get compiled into the resulting bytecode.
The bytecode of required scripts should be appended after the requiring script or of the main script if required by multiple source files. If multiple require scripts are to be appeneded, the order of request should be respected.
If a mission/streamed script requires a source file which is also required by another mission/streamed script but not a main script/extension or subscript, an error should occur.
Any symbols introduced by required scripts (e.g. used objects and variables) should have their indices respecting the offset on which the required script was compiled into.
Using REQUIRE
inside a required file is forbidden.
main.sc:
REQUIRE file.sc
PRINT_HELP HELLO
GOSUB mysub
TERMINATE_THIS_SCRIPT
main/file.sc
mysub:
PRINT_HELP WORLD
RETURN
once compiled, the decompiled script looks like the following:
PRINT_HELP HELLO
GOSUB mysub
TERMINATE_THIS_SCRIPT
mysub:
PRINT_HELP WORLD
RETURN
Why should we not do this?
Any other alternative?
- Is "end of main script" the end of
main.sc
or the end of the last subscript?