ACS libraries

From Eternity Wiki
Jump to: navigation, search

This page contains text copied from the ZDoom wiki

A library is a standalone ACS script defining common scripts, functions, and constants which can be used from other ACS scripts. They are distinct from the standard #include directives ACS offers in that the included script is not compiled into the resulting binary.

Using libraries can help save space in your scripts (which is useful if you use a script editor with limited length, such as some old tools), as well as reducing code duplication and copy-paste errors. Any changes in libraries will be reflected automatically across all scripts which use them.

The most common application of libraries are in large scale projects in which multiple maps share ACS, as well as auxiliary gameplay mods including their own ACS using LOADACS.

Creating libraries[edit]

An otherwise standard ACS script is marked as a library using the #library directive, which should be first statement in the script:

#library "LIBNAME"
#include "zcommon.acs"

The name given to the #library directive specifies the name of the library, constrained by standard WAD lump name limitations. Once compiled, the binary lump should be placed in the ACS library namespace with the same name as given in the #library directive. Modern resource editors, such as SLADE, can automate this process.

Note: When using LOADACS, enter and open scripts in your library will execute on every map (as per the rules of their respective script types).

Importing libraries[edit]

Scripts can import libraries by using the #import directive:

#import "libname.acs"

The path given to the #import directive specifies the uncompiled source of the library (as opposed to the compiled binary). The path may be either absolute or relative (e.g. "/doom/levels/mymaps/foomap/lumps/lib/foolib.acs"). The following script elements are imported from the library:

Note: When ACC scans imported libraries, all #include directives are ignored in the library and those files are not scanned.

Example[edit]

Needs an Eternity-specific example. You can view the ZDoom example on their wiki page.