Scripting

From Wolfire Games Wiki
Revision as of 20:03, 25 February 2010 by John (talk | contribs)
Jump to: navigation, search

Overgrowth is using AngelScript as its core scripting language. The best AngelScript reference is here: [1]


Checking for Keypresses:

You can check for keypresses by using the boolean check function GetInputDown():

Syntax examples:

GetInputDown("a") returns true if the 'a' key is being pressed, returns false if not
GetInputDown("attack") returns true if the left mouse button is being pressed, returns false if not
GetInputDown("move_left") returns true if the "left key" is being pressed, returns false if not (by default this key is defined in the config.txt to be the 'a' key)


The following controls are designed to be relative to the player's preferences and are given a binding in the config.txt file.

Config.txt Dependent References

Predefined Term Default binding in Config.txt Scripting Reference Name
Left Key a move_left
Right Key d move_right
Up Key w move_up
Down Key s move_down
Crouch Key left shift crouch
Jump Key space jump

Generic Key References

Anything you see between quotes is a valid scripting reference tag. You are looking at the keyTranslator.cpp file which literally interprets scripting key calls and returns their SDLK counterparts.

#include "keyTranslator.h"
3        
4        SDLKey keyToSDL(const std::string &s)
5        {
6                if (s == "backspace")
7                        return SDLK_BACKSPACE;
8                if (s == "tab")
9                        return SDLK_TAB;
10                if (s == "clear")
11                        return SDLK_CLEAR;
12                if (s == "return")
13                        return SDLK_RETURN;
14                if (s == "pause")
15                        return SDLK_PAUSE;
16                if (s == "esc")
17                        return SDLK_ESCAPE;
18                if (s == "space")
19                        return SDLK_SPACE;
20                if (s == "!")
21                        return SDLK_EXCLAIM;
22                if (s == "\"")
23                        return SDLK_QUOTEDBL;
24                if (s == "#")
25                        return SDLK_HASH;
26                if (s == "$")
27                        return SDLK_DOLLAR;
28                if (s == "&")
29                        return SDLK_AMPERSAND;
30                if (s == "\'")
31                        return SDLK_QUOTE;
32                if (s == "(")
33                        return SDLK_LEFTPAREN;
34                if (s == ")")
35                        return SDLK_RIGHTPAREN;
36                if (s == "*")
37                        return SDLK_ASTERISK;
38                if (s == "+")
39                        return SDLK_PLUS;
40                if (s == ",")
41                        return SDLK_COMMA;
42                if (s == "-")
43                        return SDLK_MINUS;
44                if (s == ".")
45                        return SDLK_PERIOD;
46                if (s == "/")
47                        return SDLK_SLASH;
48                if (s == "0")
49                        return SDLK_0;
50                if (s == "1")
51                        return SDLK_1;
52                if (s == "2")
53                        return SDLK_2;
54                if (s == "3")
55                        return SDLK_3;
56                if (s == "4")
57                        return SDLK_4;
58                if (s == "5")
59                        return SDLK_5;
60                if (s == "6")
61                        return SDLK_6;
62                if (s == "7")
63                        return SDLK_7;
64                if (s == "8")
65                        return SDLK_8;
66                if (s == "9")
67                        return SDLK_9;
68                if (s == ":")
69                        return SDLK_COLON;
70                if (s == ";")
71                        return SDLK_SEMICOLON;
72                if (s == "<")
73                        return SDLK_LESS;
74                if (s == "=")
75                        return SDLK_EQUALS;
76                if (s == ">")
77                        return SDLK_GREATER;
78                if (s == "?")
79                        return SDLK_QUESTION;
80                if (s == "@")
81                        return SDLK_AT;
82                if (s == "[")
83                        return SDLK_LEFTBRACKET;
84                if (s == "\\")
85                        return SDLK_BACKSLASH;
86                if (s == "]")
87                        return SDLK_RIGHTBRACKET;
88                if (s == "^")
89                        return SDLK_CARET;
90                if (s == "_")
91                        return SDLK_UNDERSCORE;
92                if (s == "`")
93                        return SDLK_BACKQUOTE;
94                if (s == "a")
95                        return SDLK_a;
96                if (s == "b")
97                        return SDLK_b;
98                if (s == "c")
99                        return SDLK_c;
100                if (s == "d")
101                        return SDLK_d;
102                if (s == "e")
103                        return SDLK_e;
104                if (s == "f")
105                        return SDLK_f;
106                if (s == "g")
107                        return SDLK_g;
108                if (s == "h")
109                        return SDLK_h;
110                if (s == "i")
111                        return SDLK_i;
112                if (s == "j")
113                        return SDLK_j;
114                if (s == "k")
115                        return SDLK_k;
116                if (s == "l")
117                        return SDLK_l;
118                if (s == "m")
119                        return SDLK_m;
120                if (s == "n")
121                        return SDLK_n;
122                if (s == "o")
123                        return SDLK_o;
124                if (s == "p")
125                        return SDLK_p;
126                if (s == "q")
127                        return SDLK_q;
128                if (s == "r")
129                        return SDLK_r;
130                if (s == "s")
131                        return SDLK_s;
132                if (s == "t")
133                        return SDLK_t;
134                if (s == "u")
135                        return SDLK_u;
136                if (s == "v")
137                        return SDLK_v;
138                if (s == "w")
139                        return SDLK_w;
140                if (s == "x")
141                        return SDLK_x;
142                if (s == "y")
143                        return SDLK_y;
144                if (s == "z")
145                        return SDLK_z;
146                if (s == "delete")
147                        return SDLK_DELETE;
148                if (s == "keypad0")
149                        return SDLK_KP0;
150                if (s == "keypad1")
151                        return SDLK_KP1;
152                if (s == "keypad2")
153                        return SDLK_KP2;
154                if (s == "keypad3")
155                        return SDLK_KP3;
156                if (s == "keypad4")
157                        return SDLK_KP4;
158                if (s == "keypad5")
159                        return SDLK_KP5;
160                if (s == "keypad6")
161                        return SDLK_KP6;
162                if (s == "keypad7")
163                        return SDLK_KP7;
164                if (s == "keypad8")
165                        return SDLK_KP8;
166                if (s == "keypad9")
167                        return SDLK_KP9;
168                if (s == "keypad.")
169                        return SDLK_KP_PERIOD;
170                if (s == "keypad/")
171                        return SDLK_KP_DIVIDE;
172                if (s == "keypad*")
173                        return SDLK_KP_MULTIPLY;
174                if (s == "keypad-")
175                        return SDLK_KP_MINUS;
176                if (s == "keypad+")
177                        return SDLK_KP_PLUS;
178                if (s == "keypadenter")
179                        return SDLK_KP_ENTER;
180                if (s == "keypad=")
181                        return SDLK_KP_EQUALS;
182                if (s == "up")
183                        return SDLK_UP;
184                if (s == "down")
185                        return SDLK_DOWN;
186                if (s == "right")
187                        return SDLK_RIGHT;
188                if (s == "left")
189                        return SDLK_LEFT;
190                if (s == "insert")
191                        return SDLK_INSERT;
192                if (s == "home")
193                        return SDLK_HOME;
194                if (s == "end")
195                        return SDLK_END;
196                if (s == "pageup")
197                        return SDLK_PAGEUP;
198                if (s == "pagedown")
199                        return SDLK_PAGEDOWN;
200                if (s == "f1")
201                        return SDLK_F1;
202                if (s == "f2")
203                        return SDLK_F2;
204                if (s == "f3")
205                        return SDLK_F3;
206                if (s == "f4")
207                        return SDLK_F4;
208                if (s == "f5")
209                        return SDLK_F5;
210                if (s == "f6")
211                        return SDLK_F6;
212                if (s == "f7")
213                        return SDLK_F7;
214                if (s == "f8")
215                        return SDLK_F8;
216                if (s == "f9")
217                        return SDLK_F9;
218                if (s == "f10")
219                        return SDLK_F10;
220                if (s == "f11")
221                        return SDLK_F11;
222                if (s == "f12")
223                        return SDLK_F12;
224                if (s == "f13")
225                        return SDLK_F13;
226                if (s == "f14")
227                        return SDLK_F14;
228                if (s == "f15")
229                        return SDLK_F15;
230                if (s == "numlock")
231                        return SDLK_NUMLOCK;
232                if (s == "capslock")
233                        return SDLK_CAPSLOCK;
234                if (s == "scrollock")
235                        return SDLK_SCROLLOCK;
236                if (s == "rshift")
237                        return SDLK_RSHIFT;
238                if (s == "lshift")
239                        return SDLK_LSHIFT;
240                if (s == "rctrl")
241                        return SDLK_RCTRL;
242                if (s == "lctrl")
243                        return SDLK_LCTRL;
244                if (s == "ralt")
245                        return SDLK_RALT;
246                if (s == "lalt")
247                        return SDLK_LALT;
248                if (s == "rmeta")
249                        return SDLK_RMETA;
250                if (s == "lmeta")
251                        return SDLK_LMETA;
252                if (s == "lsuper")
253                        return SDLK_LSUPER;
254                if (s == "rsuper")
255                        return SDLK_RSUPER;
256                if (s == "mode")
257                        return SDLK_MODE;
258                if (s == "compose")
259                        return SDLK_COMPOSE;
260                if (s == "help")
261                        return SDLK_HELP;
262                if (s == "print")
263                        return SDLK_PRINT;
264                if (s == "sysreq")
265                        return SDLK_SYSREQ;
266                if (s == "break")
267                        return SDLK_BREAK;
268                if (s == "menu")
269                        return SDLK_MENU;
270                if (s == "power")
271                        return SDLK_POWER;
272                if (s == "euro")
273                        return SDLK_EURO;
274        
275                return (SDLKey)SDLK_SYSREQ;
276        }