diff options
author | truebrain <truebrain@openttd.org> | 2009-01-12 17:11:45 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2009-01-12 17:11:45 +0000 |
commit | a3dd7506d377b1434f913bd65c019eed52b64b6e (patch) | |
tree | ced1a262eb143ad6e64ec02f4a4c89835c0c32fd /src/script/squirrel_std.hpp | |
parent | 9294f9616866b9778c22076c19b5a32b4f85f788 (diff) | |
download | openttd-a3dd7506d377b1434f913bd65c019eed52b64b6e.tar.xz |
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
NoAI is an API (a framework) to build your own AIs in. See:
http://wiki.openttd.org/wiki/index.php/AI:Main_Page
With many thanks to:
- glx and Rubidium for their syncing, feedback and hard work
- Yexo for his feedback, patches, and AIs which tested the system very deep
- Morloth for his feedback and patches
- TJIP for hosting a challenge which kept NoAI on track
- All AI authors for testing our AI API, and all other people who helped in one way or another
-Remove: all old AIs and their cheats/hacks
Diffstat (limited to 'src/script/squirrel_std.hpp')
-rw-r--r-- | src/script/squirrel_std.hpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/script/squirrel_std.hpp b/src/script/squirrel_std.hpp new file mode 100644 index 000000000..93d82995a --- /dev/null +++ b/src/script/squirrel_std.hpp @@ -0,0 +1,60 @@ +/* $Id$ */ + +/** @file squirrel_std.hpp defines the Squirrel Standard Function class */ + +#ifndef SQUIRREL_STD_HPP +#define SQUIRREL_STD_HPP + +#if defined(__APPLE__) +/* Which idiotic system makes 'require' a macro? :s Oh well.... */ +#undef require +#endif /* __APPLE__ */ + +/** + * By default we want to give a set of standard commands to a SQ script. + * Most of them are easy wrappers around internal functions. Of course we + * could just as easy include things like the stdmath of SQ, but of those + * functions we are sure they work on all our supported targets. + */ +class SquirrelStd { +public: + /** + * Make an integer absolute. + */ + static SQInteger abs(HSQUIRRELVM vm); + + /** + * Get the lowest of two integers. + */ + static SQInteger min(HSQUIRRELVM vm); + + /** + * Get the highest of two integers. + */ + static SQInteger max(HSQUIRRELVM vm); + + /** + * Load an other file on runtime. + * @note This is always loaded on the root-level, no matter where you call this. + * @note The filename is always relative from the script it is called from. Absolute calls are NOT allowed! + */ + static SQInteger require(HSQUIRRELVM vm); + + /** + * Enable/disable stack trace showing for handled exceptions. + */ + static SQInteger notifyallexceptions(HSQUIRRELVM vm); +}; + +/** + * Register all standard functions we want to give to a script. + */ +void squirrel_register_std(Squirrel *engine); + +/** + * Register all standard functions that are available on first startup. + * @note this set is very limited, and is only ment to load other scripts and things like that. + */ +void squirrel_register_global_std(Squirrel *engine); + +#endif /* SQUIRREL_STD_HPP */ |