-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathScripts.txt
More file actions
47 lines (34 loc) · 2.9 KB
/
Scripts.txt
File metadata and controls
47 lines (34 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
A script file (.as file) is used to make a script module.
All script files that are put in cfg script lists (such as blob scripts, gamemode scripts, etc) are turned into seperate modules when the game runs.
Every module is an independent unit. Each module contains its own scope of functions, global variables, classes, and funcdefs.
Script modules use #include "ScriptName.as"; to add the functions/global vars/classes etc from the included script file to itself.
#include basically copy pastes stuff from a script file into a module, the modules themselves aren't sharing anything, their scope is still seperate.
If you want to share stuff between modules, you need to use the 'shared' keyword.
When you use the keyword 'shared' before any class/function/etc, that class/function/etc is now shared between the modules that use that script file and will be the same between them. They are now called a shared script entity.
The shared script entity is the same between all modules. ///As there is only one copy of the shared script entity//This may be false///, it takes less memory.
Shared script entities cannot access non-shared entities(functions/classes/global vars/etc). non-shared entities are exclusive to the module they were compiled in, thus the shared script entity cannot access them.
Global variables cannot be shared.
Funcdefs in the current version of kag cannot be shared, but they can in newer versions of angelscript (kag staging has newer versions of angelscript).
Currently in kag, casting classes from other modules(scripts) does not generally work (in my experience). Making each class shared will fix this problem, as it makes sure the classes are the same between modules.
Each blob contains a list of scripts(modules) they use to dictate how they function.
These scripts can execute only under certain conditions, tick more or less often, or be removed on certain conditions.
use `blob.getCurrentScript()` to get the script that is currently being ran.
Here are some things you can do to the current script.
`blob.getCurrentScript().tickIfTag = "active";` Only ticks this script if the blob is tagged with active
`blob.getCurrentScript().removeIfTag = "dead";` Removes script from blob script list if this blob is tagged with dead
`blob.getCurrentScript().runProximityTag = "player"; blob.getCurrentScript().runProximityRadius = 320.0f;` Ticks only if a blob with the tag "player" is within 320
`blob.getCurrentScript().runFlags |= Script::tick_myplayer;` Only ticks this script for the player controlling this blob
`blob.getCurrentScript().tickFrequency = 60;` Only ticks this script every 2 seconds
Possibly useful things
#ifdef STAGING
code here//Only compiled on staging
#endif
#ifndef STAGING
code here//Only compiled on not staging
#endif
#ifndef INCLUDED_PLAYERINFO
#define INCLUDED_PLAYERINFO
code here.
#endif
#BRK
^ Break point. in angelscript. Not tested, thus unsure if it works.