├── typescript_defoldlib.lua ├── img ├── logo.jpg ├── vscode.jpg ├── vscode-2.jpg └── vscode-3.jpg ├── .gitattributes ├── README.md ├── defold.additional.d.ts ├── defold_json_to_ts.py └── defold.d.ts /typescript_defoldlib.lua: -------------------------------------------------------------------------------- 1 | go.delete_ = go.delete 2 | window_ = window -------------------------------------------------------------------------------- /img/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dasannikov/DefoldTypeScript/HEAD/img/logo.jpg -------------------------------------------------------------------------------- /img/vscode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dasannikov/DefoldTypeScript/HEAD/img/vscode.jpg -------------------------------------------------------------------------------- /img/vscode-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dasannikov/DefoldTypeScript/HEAD/img/vscode-2.jpg -------------------------------------------------------------------------------- /img/vscode-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dasannikov/DefoldTypeScript/HEAD/img/vscode-3.jpg -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | * linguist-vendored 5 | *.ts linguist-vendored=false -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](img/logo.jpg) 2 | 3 | # TypeScript support for Defold game engine 4 | TypeScript declaration files for Defold API. 5 | 6 | ## How to Install and Use. 7 | ![VS Code Defold TypeScript](img/vscode.jpg?raw=true "VS Code Defold TypeScript") 8 | - This repo has only TypeScript declaration files for Defold API. 9 | - It's **recommended** to download and use Defold project template from [GitHub Releases](https://github.com/dasannikov/DefoldTypeScriptHello/releases) 10 | - Or clone (you have to clone!! it has submodules) this [GitHub repository](https://github.com/dasannikov/DefoldTypeScriptHello) 11 | 12 | ## Code Generation 13 | Using TypeScript you get strong type check, typed arguments, classes, inheritance and more. All reflects to Lua basic constructions. TS to Lua work the same way as TS to JS. Very useful for big projects development. Generated Lua code is very clean and human readable. 14 | 15 | ## TODO 16 | - (DONE) Auto generate `defold.d.ts` file with full Defold support. 17 | - (DONE) Add types to function's arguments where it's possible. 18 | - (DONE) Add build system. 19 | - Further development of [TypeScript to Lua Transpiler](https://github.com/Perryvw/TypescriptToLua) 20 | -------------------------------------------------------------------------------- /defold.additional.d.ts: -------------------------------------------------------------------------------- 1 | 2 | // DEFOLD. Version 1.2.134 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | declare function require(file: string): void 7 | 8 | type hash = {} 9 | type url = {} 10 | type node = {} 11 | 12 | /////////////////////////////////////////////////////////////////////////////// 13 | // Build-Ins 14 | 15 | /** 16 | All ids in the engine are represented as hashes, so a string needs to be hashed before it can be compared with an id. 17 | @param s string string to hash 18 | @return hash a hashed string 19 | **/ 20 | declare function hash(s: string): hash 21 | 22 | /** 23 | Returns a hexadecimal representation of a hash value. The returned string is always padded with leading zeros. 24 | @param h hash value to get hex string for 25 | @return string hex representation of the hash 26 | **/ 27 | declare function hash_to_hex(h: hash): string 28 | 29 | /** 30 | Pretty printing of Lua values. This function prints Lua values in a manner similar to +print()+, but will also recurse into tables and pretty print them. There is a limit to how deep the function will recurse. 31 | @param v any value to print 32 | **/ 33 | declare function pprint(...v: any[]): void 34 | 35 | /////////////////////////////////////////////////////////////////////////////// 36 | 37 | declare namespace vmath { 38 | 39 | type matrix4 = {} 40 | 41 | interface vector3 { 42 | x: number 43 | y: number 44 | z: number 45 | } 46 | 47 | interface vector4 { 48 | x: number 49 | y: number 50 | z: number 51 | w: number 52 | } 53 | 54 | interface quaternion { 55 | x: number 56 | y: number 57 | z: number 58 | w: number 59 | } 60 | } 61 | 62 | /////////////////////////////////////////////////////////////////////////////// 63 | // LUA STANDART LIBs 64 | declare function print(...rest: any[]): void 65 | declare function collectgarbage(opt?:any, arg?:any): any 66 | 67 | declare namespace math { 68 | function cos(x: number): number 69 | function sin(x: number): number 70 | function ceil(x: number): number 71 | function random(m?: number, n?: number): number 72 | } 73 | 74 | declare namespace string { 75 | function format(text: string, ...args: any[]): void; 76 | } 77 | -------------------------------------------------------------------------------- /defold_json_to_ts.py: -------------------------------------------------------------------------------- 1 | import json 2 | import re 3 | import io 4 | import shutil 5 | 6 | JSON_FOLDER = './defold-doc-1.2.134/' 7 | 8 | class DefoldTS: 9 | 10 | def __init__(self, stream, file, namespace): 11 | self.stream = stream 12 | self.file = file 13 | self.namespace = namespace 14 | self.exclude_function_list = [] 15 | self.include_string = "" 16 | 17 | @staticmethod 18 | def __clean_html(raw_html): 19 | clean_re = re.compile('<.*?>') 20 | clean_text = re.sub(clean_re, '', raw_html) 21 | return clean_text 22 | 23 | def __remove_namespace(self, full_name): 24 | if "." not in full_name: 25 | return full_name 26 | ns, value = full_name.split('.', 1) 27 | if ns != self.namespace: 28 | raise Exception(f'Namespace for function {full_name} != {self.namespace}') 29 | return value 30 | 31 | def generate_function_doc(self, elem): 32 | self.stream.write('\t/**\n') 33 | doc = self.__clean_html(elem['description']).replace('\n', '\n\t') 34 | self.stream.write('\t' + doc + '\n') 35 | for param in elem['parameters']: 36 | self.stream.write("\t@param " + param['name'] + " " + self.__clean_html(param['doc']).replace('\n', '\n\t') + '\n') 37 | for ret_val in elem['returnvalues']: 38 | self.stream.write("\t@return " + self.__clean_html(ret_val['doc']).replace('\n', '\n\t') + '\n') 39 | 40 | self.stream.write('\t**/\n') 41 | 42 | def parse_type(self, param_text, param_type): 43 | lent = param_text['doc'].find('') 44 | val = [] 45 | 46 | if param_text['doc'].find('string', 0, lent) >= 0: 47 | val.append('string') 48 | 49 | if param_text['doc'].find('boolean', 0, lent) >= 0: 50 | val.append('boolean') 51 | 52 | if param_text['doc'].find('hash', 0, lent) >= 0: 53 | val.append('hash') 54 | 55 | if param_text['doc'].find('url', 0, lent) >= 0: 56 | val.append('url') 57 | 58 | if param_text['doc'].find('number', 0, lent) >= 0: 59 | val.append('number') 60 | 61 | if param_text['doc'].find('vector3', 0, lent) >= 0: 62 | val.append('vmath.vector3') 63 | 64 | if param_text['doc'].find('vector4', 0, lent) >= 0: 65 | val.append('vmath.vector4') 66 | 67 | if param_text['doc'].find('matrix4', 0, lent) >= 0: 68 | val.append('vmath.matrix4') 69 | 70 | if param_text['doc'].find('quaternion', 0, lent) >= 0: 71 | val.append('vmath.quaternion') 72 | 73 | if param_text['doc'].find('node', 0, lent) >= 0: 74 | val.append('node') 75 | 76 | # Any 77 | if param_text['doc'].find('function', 0, lent) >= 0 or param_text['doc'].find('table', 0, lent) >= 0: 78 | val.clear() 79 | 80 | if len(val) == 0: 81 | param_type.append('any') 82 | else: 83 | first = True 84 | param_str = '' 85 | for i in val: 86 | if not first: 87 | param_str += ' | ' 88 | param_str += i 89 | first = False 90 | 91 | param_type.append(param_str) 92 | 93 | def get_function_param_type(self, elem): 94 | param_type = [] 95 | for param in elem['parameters']: 96 | self.parse_type(param, param_type) 97 | 98 | if len(elem['returnvalues']) > 0: 99 | for param in elem['returnvalues']: 100 | self.parse_type(param, param_type) 101 | else: 102 | param_type.append('void') 103 | 104 | return param_type 105 | 106 | def generate_function_signature(self, elem): 107 | self.stream.write('\tfunction ') 108 | self.stream.write(self.__remove_namespace(elem['name'])) 109 | self.stream.write('(') 110 | first = True 111 | i = 0 112 | param_type = self.get_function_param_type(elem) 113 | param_prev = '' 114 | for param in elem['parameters']: 115 | if not first: 116 | self.stream.write(", ") 117 | first = False 118 | param_cur = param['name'].replace('[', '').replace(']', '?').replace('-', '_') 119 | if param_prev == param_cur: 120 | param_cur += '_' 121 | param_prev = param_cur 122 | self.stream.write(param_cur) 123 | self.stream.write(': ' + param_type[i]) 124 | i += 1 125 | 126 | self.stream.write('): ' + param_type[i] + '\n\n') 127 | 128 | def parse_to_stream(self, with_docs=True): 129 | # load and parse .json file 130 | with open(self.file, encoding='utf-8') as data_file: 131 | data = json.loads(data_file.read()) 132 | 133 | # TS namespace start 134 | namespace_name = self.namespace 135 | if namespace_name == 'window': 136 | namespace_name += '_' 137 | self.stream.write('declare namespace ' + namespace_name + ' {\n\n') 138 | 139 | # TS functions 140 | for elem in data["elements"]: 141 | if elem['type'] == 'FUNCTION' and (self.__remove_namespace(elem['name']) not in self.exclude_function_list): 142 | # doc 143 | if with_docs: 144 | self.generate_function_doc(elem) 145 | # function signature 146 | self.generate_function_signature(elem) 147 | 148 | if elem['type'] == 'VARIABLE' and (self.__remove_namespace(elem['name']) not in self.exclude_function_list): 149 | var_name = self.__remove_namespace(elem['name']) 150 | self.stream.write('\tlet ' + var_name + ': any\n') 151 | 152 | # TS namespace end 153 | self.stream.write(self.include_string) 154 | self.stream.write('}\n\n') 155 | 156 | 157 | # ----------------------------------------------------------------------------- 158 | 159 | 160 | STREAM = io.StringIO() 161 | 162 | # header 163 | STREAM.write(''' 164 | // DEFOLD. Version 1.2.134 165 | 166 | /////////////////////////////////////////////////////////////////////////////// 167 | 168 | ''') 169 | # crash 170 | 171 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'crash_doc.json', 'crash') 172 | PARSER.parse_to_stream(with_docs = True) 173 | 174 | # gui 175 | 176 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'gui_doc.json', 'gui') 177 | PARSER.exclude_function_list.append('final') 178 | PARSER.exclude_function_list.append('init') 179 | PARSER.exclude_function_list.append('on_input') 180 | PARSER.exclude_function_list.append('on_message') 181 | PARSER.exclude_function_list.append('on_reload') 182 | PARSER.exclude_function_list.append('update') 183 | PARSER.parse_to_stream(with_docs=True) 184 | 185 | # go 186 | 187 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'go_doc.json', 'go') 188 | PARSER.exclude_function_list.append('delete') 189 | PARSER.exclude_function_list.append('init') 190 | PARSER.exclude_function_list.append('on_input') 191 | PARSER.exclude_function_list.append('on_message') 192 | PARSER.exclude_function_list.append('on_reload') 193 | PARSER.exclude_function_list.append('update') 194 | PARSER.exclude_function_list.append('final') 195 | PARSER.include_string = ''' 196 | /** 197 | Custom function ("delete" reserved word in TypeScript) 198 | Delete one or more game objects identified by id. Deletion is asynchronous meaning that 199 | the game object(s) are scheduled for deletion which will happen at the end of the current 200 | frame. Note that game objects scheduled for deletion will be counted against 201 | max_instances in "game.project" until they are actually removed. 202 | @param [id] string | hash | url | table optional id or table of id's of the instance(s) to delete, the instance of the calling script is deleted by default 203 | @param [recursive] boolean optional boolean, set to true to recursively delete child hiearchy in child to parent order 204 | **/ 205 | function delete_(id?: any, recursive?: boolean): void 206 | ''' 207 | PARSER.parse_to_stream(with_docs = True) 208 | 209 | # profiler 210 | 211 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'profiler_doc.json', 'profiler') 212 | PARSER.parse_to_stream(with_docs=True) 213 | 214 | # render 215 | 216 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'render_doc.json', 'render') 217 | PARSER.parse_to_stream(with_docs=True) 218 | 219 | # resource 220 | 221 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'resource_doc.json', 'resource') 222 | PARSER.parse_to_stream(with_docs=True) 223 | 224 | # sys 225 | 226 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'sys_doc.json', 'sys') 227 | PARSER.parse_to_stream(with_docs = True) 228 | 229 | # window 230 | 231 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'window_doc.json', 'window') 232 | PARSER.parse_to_stream(with_docs=True) 233 | 234 | # collectionfactory 235 | 236 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'collectionfactory_doc.json', 'collectionfactory') 237 | PARSER.parse_to_stream(with_docs=True) 238 | 239 | # collectionproxy 240 | 241 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'collectionproxy_doc.json', 'collectionproxy') 242 | PARSER.parse_to_stream(with_docs=True) 243 | 244 | # physics (collision object) 245 | 246 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'physics_doc.json', 'physics') 247 | PARSER.parse_to_stream(with_docs=True) 248 | 249 | # factory 250 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'factory_doc.json', 'factory') 251 | PARSER.parse_to_stream(with_docs=True) 252 | 253 | # label 254 | 255 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'label_doc.json', 'label') 256 | PARSER.parse_to_stream(with_docs=True) 257 | 258 | # model 259 | 260 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'model_doc.json', 'model') 261 | PARSER.parse_to_stream(with_docs=True) 262 | 263 | # particlefx 264 | 265 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'particlefx_doc.json', 'particlefx') 266 | PARSER.parse_to_stream(with_docs=True) 267 | 268 | # sound 269 | 270 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'sound_doc.json', 'sound') 271 | PARSER.parse_to_stream(with_docs=True) 272 | 273 | # spine 274 | 275 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'spine_doc.json', 'spine') 276 | PARSER.parse_to_stream(with_docs=True) 277 | 278 | # sprite 279 | 280 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'sprite_doc.json', 'sprite') 281 | PARSER.parse_to_stream(with_docs=True) 282 | 283 | # tilemap 284 | 285 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'tilemap_doc.json', 'tilemap') 286 | PARSER.parse_to_stream(with_docs=True) 287 | 288 | # buffer 289 | 290 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'buffer_doc.json', 'buffer') 291 | PARSER.parse_to_stream(with_docs=True) 292 | 293 | # html5 294 | 295 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'html5_doc.json', 'html5') 296 | PARSER.parse_to_stream(with_docs=True) 297 | 298 | # http 299 | 300 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'http_doc.json', 'http') 301 | PARSER.parse_to_stream(with_docs=True) 302 | 303 | # image 304 | 305 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'image_doc.json', 'image') 306 | PARSER.parse_to_stream(with_docs=True) 307 | 308 | # json 309 | 310 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'json_doc.json', 'json') 311 | PARSER.parse_to_stream(with_docs=True) 312 | 313 | # msg 314 | 315 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'msg_doc.json', 'msg') 316 | PARSER.parse_to_stream(with_docs=True) 317 | 318 | # timer 319 | 320 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'timer_doc.json', 'timer') 321 | PARSER.parse_to_stream(with_docs=True) 322 | 323 | # vmath 324 | 325 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'vmath_doc.json', 'vmath') 326 | PARSER.parse_to_stream(with_docs=True) 327 | 328 | # zlib 329 | 330 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'zlib_doc.json', 'zlib') 331 | PARSER.parse_to_stream(with_docs=True) 332 | 333 | # facebook 334 | 335 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'facebook_doc.json', 'facebook') 336 | PARSER.parse_to_stream(with_docs=True) 337 | 338 | # iap 339 | 340 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'iap_doc.json', 'iap') 341 | PARSER.parse_to_stream(with_docs=True) 342 | 343 | # iac 344 | 345 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'iac_doc.json', 'iac') 346 | PARSER.parse_to_stream(with_docs=True) 347 | 348 | # push 349 | 350 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'push_doc.json', 'push') 351 | PARSER.parse_to_stream(with_docs=True) 352 | 353 | # webview 354 | 355 | PARSER = DefoldTS(STREAM, JSON_FOLDER + 'webview_doc.json', 'webview') 356 | PARSER.parse_to_stream(with_docs=True) 357 | 358 | # Done 359 | 360 | with open('out.temp.ts', 'w') as file: 361 | STREAM.seek(0) 362 | shutil.copyfileobj(STREAM, file) 363 | 364 | STREAM.close() 365 | -------------------------------------------------------------------------------- /defold.d.ts: -------------------------------------------------------------------------------- 1 | 2 | // DEFOLD. Version 1.2.134 3 | 4 | /////////////////////////////////////////////////////////////////////////////// 5 | 6 | declare namespace crash { 7 | 8 | let SYSFIELD_ANDROID_BUILD_FINGERPRINT: any 9 | let SYSFIELD_DEVICE_LANGUAGE: any 10 | let SYSFIELD_DEVICE_MANUFACTURER: any 11 | let SYSFIELD_DEVICE_MODEL: any 12 | let SYSFIELD_ENGINE_HASH: any 13 | let SYSFIELD_ENGINE_VERSION: any 14 | let SYSFIELD_LANGUAGE: any 15 | let SYSFIELD_SYSTEM_NAME: any 16 | let SYSFIELD_SYSTEM_VERSION: any 17 | let SYSFIELD_TERRITORY: any 18 | /** 19 | A table is returned containing the addresses of the call stack. 20 | @param handle number crash dump handle 21 | @return table table containing the backtrace 22 | **/ 23 | function get_backtrace(handle: number): any 24 | 25 | /** 26 | The format of read text blob is platform specific 27 | and not guaranteed 28 | but can be useful for manual inspection. 29 | @param handle number crash dump handle 30 | @return string string with the platform specific data 31 | **/ 32 | function get_extra_data(handle: number): string 33 | 34 | /** 35 | The function returns a table containing entries with sub-tables that 36 | have fields 'name' and 'address' set for all loaded modules. 37 | @param handle number crash dump handle 38 | @return table module table 39 | **/ 40 | function get_modules(handle: number): any 41 | 42 | /** 43 | 44 | @param handle number crash dump handle 45 | @return number signal number 46 | **/ 47 | function get_signum(handle: number): number 48 | 49 | /** 50 | 51 | @param handle number crash dump handle 52 | @param index number system field enum 53 | @return string value recorded in the crash dump 54 | **/ 55 | function get_sys_field(handle: number, index: number): string 56 | 57 | /** 58 | 59 | @param handle number crash dump handle 60 | @param index number user data slot index 61 | @return string user data value recorded in the crash dump 62 | **/ 63 | function get_user_field(handle: number, index: number): string 64 | 65 | /** 66 | The crash dump will be removed from disk upon a successful 67 | load, so loading is one-shot. 68 | @return number handle to the loaded dump, or nil if no dump was found 69 | **/ 70 | function load_previous(): number 71 | 72 | /** 73 | 74 | @param handle number handle to loaded crash dump 75 | **/ 76 | function release(handle: number): void 77 | 78 | /** 79 | Crashes occuring before the path is set will be stored to a default engine location. 80 | @param path string file path to use 81 | **/ 82 | function set_file_path(path: string): void 83 | 84 | /** 85 | Store a user value that will get written to a crash dump when 86 | a crash occurs. This can be user id:s, breadcrumb data etc. 87 | There are 32 slots indexed from 0. Each slot stores at most 255 characters. 88 | @param index number slot index. 0-indexed 89 | @param value string string value to store 90 | **/ 91 | function set_user_field(index: number, value: string): void 92 | 93 | /** 94 | Performs the same steps as if a crash had just occured but 95 | allows the program to continue. 96 | The generated dump can be read by crash.load_previous 97 | **/ 98 | function write_dump(): void 99 | 100 | } 101 | 102 | declare namespace gui { 103 | 104 | let ADJUST_FIT: any 105 | let ADJUST_STRETCH: any 106 | let ADJUST_ZOOM: any 107 | let ANCHOR_BOTTOM: any 108 | let ANCHOR_LEFT: any 109 | let ANCHOR_RIGHT: any 110 | let ANCHOR_TOP: any 111 | let BLEND_ADD: any 112 | let BLEND_ADD_ALPHA: any 113 | let BLEND_ALPHA: any 114 | let BLEND_MULT: any 115 | let CLIPPING_MODE_NONE: any 116 | let CLIPPING_MODE_STENCIL: any 117 | let EASING_INBACK: any 118 | let EASING_INBOUNCE: any 119 | let EASING_INCIRC: any 120 | let EASING_INCUBIC: any 121 | let EASING_INELASTIC: any 122 | let EASING_INEXPO: any 123 | let EASING_INOUTBACK: any 124 | let EASING_INOUTBOUNCE: any 125 | let EASING_INOUTCIRC: any 126 | let EASING_INOUTCUBIC: any 127 | let EASING_INOUTELASTIC: any 128 | let EASING_INOUTEXPO: any 129 | let EASING_INOUTQUAD: any 130 | let EASING_INOUTQUART: any 131 | let EASING_INOUTQUINT: any 132 | let EASING_INOUTSINE: any 133 | let EASING_INQUAD: any 134 | let EASING_INQUART: any 135 | let EASING_INQUINT: any 136 | let EASING_INSINE: any 137 | let EASING_LINEAR: any 138 | let EASING_OUTBACK: any 139 | let EASING_OUTBOUNCE: any 140 | let EASING_OUTCIRC: any 141 | let EASING_OUTCUBIC: any 142 | let EASING_OUTELASTIC: any 143 | let EASING_OUTEXPO: any 144 | let EASING_OUTINBACK: any 145 | let EASING_OUTINBOUNCE: any 146 | let EASING_OUTINCIRC: any 147 | let EASING_OUTINCUBIC: any 148 | let EASING_OUTINELASTIC: any 149 | let EASING_OUTINEXPO: any 150 | let EASING_OUTINQUAD: any 151 | let EASING_OUTINQUART: any 152 | let EASING_OUTINQUINT: any 153 | let EASING_OUTINSINE: any 154 | let EASING_OUTQUAD: any 155 | let EASING_OUTQUART: any 156 | let EASING_OUTQUINT: any 157 | let EASING_OUTSINE: any 158 | let KEYBOARD_TYPE_DEFAULT: any 159 | let KEYBOARD_TYPE_EMAIL: any 160 | let KEYBOARD_TYPE_NUMBER_PAD: any 161 | let KEYBOARD_TYPE_PASSWORD: any 162 | let PIEBOUNDS_ELLIPSE: any 163 | let PIEBOUNDS_RECTANGLE: any 164 | let PIVOT_CENTER: any 165 | let PIVOT_E: any 166 | let PIVOT_N: any 167 | let PIVOT_NE: any 168 | let PIVOT_NW: any 169 | let PIVOT_S: any 170 | let PIVOT_SE: any 171 | let PIVOT_SW: any 172 | let PIVOT_W: any 173 | let PLAYBACK_LOOP_BACKWARD: any 174 | let PLAYBACK_LOOP_FORWARD: any 175 | let PLAYBACK_LOOP_PINGPONG: any 176 | let PLAYBACK_ONCE_BACKWARD: any 177 | let PLAYBACK_ONCE_FORWARD: any 178 | let PLAYBACK_ONCE_PINGPONG: any 179 | let PROP_COLOR: any 180 | let PROP_FILL_ANGLE: any 181 | let PROP_INNER_RADIUS: any 182 | let PROP_OUTLINE: any 183 | let PROP_POSITION: any 184 | let PROP_ROTATION: any 185 | let PROP_SCALE: any 186 | let PROP_SHADOW: any 187 | let PROP_SIZE: any 188 | let PROP_SLICE9: any 189 | let SIZE_MODE_AUTO: any 190 | let SIZE_MODE_MANUAL: any 191 | /** 192 | This starts an animation of a node property according to the specified parameters. 193 | If the node property is already being animated, that animation will be canceled and 194 | replaced by the new one. Note however that several different node properties 195 | can be animated simultaneously. Use gui.cancel_animation to stop the animation 196 | before it has completed. 197 | Composite properties of type vector3, vector4 or quaternion 198 | also expose their sub-components (x, y, z and w). 199 | You can address the components individually by suffixing the name with a dot '.' 200 | and the name of the component. 201 | For instance, "position.x" (the position x coordinate) or "color.w" 202 | (the color alpha value). 203 | If a complete_function (Lua function) is specified, that function will be called 204 | when the animation has completed. 205 | By starting a new animation in that function, several animations can be sequenced 206 | together. See the examples below for more information. 207 | @param node node node to animate 208 | @param property string | constant property to animate 209 | 210 | "position" 211 | "rotation" 212 | "scale" 213 | "color" 214 | "outline" 215 | "shadow" 216 | "size" 217 | "fill_angle" (pie) 218 | "inner_radius" (pie) 219 | "slice9" (slice9) 220 | 221 | The following property constants are defined equaling the corresponding property string names. 222 | 223 | gui.PROP_POSITION 224 | gui.PROP_ROTATION 225 | gui.PROP_SCALE 226 | gui.PROP_COLOR 227 | gui.PROP_OUTLINE 228 | gui.PROP_SHADOW 229 | gui.PROP_SIZE 230 | gui.PROP_FILL_ANGLE 231 | gui.PROP_INNER_RADIUS 232 | gui.PROP_SLICE9 233 | 234 | @param to vector3 | vector4 target property value 235 | @param easing constant | vector easing to use during animation. 236 | Either specify one of the gui.EASING_* constants or provide a 237 | vector with a custom curve. 238 | @param duration number duration of the animation in seconds. 239 | @param [delay] number delay before the animation starts in seconds. 240 | @param [complete_function] function(self, node) function to call when the 241 | animation has completed 242 | @param [playback] constant playback mode 243 | 244 | gui.PLAYBACK_ONCE_FORWARD 245 | gui.PLAYBACK_ONCE_BACKWARD 246 | gui.PLAYBACK_ONCE_PINGPONG 247 | gui.PLAYBACK_LOOP_FORWARD 248 | gui.PLAYBACK_LOOP_BACKWARD 249 | gui.PLAYBACK_LOOP_PINGPONG 250 | 251 | **/ 252 | function animate(node: node, property: string, to: vmath.vector3 | vmath.vector4, easing: any, duration: number, delay?: number, complete_function?: any, playback?: any): void 253 | 254 | /** 255 | If an animation of the specified node is currently running (started by gui.animate), it will immediately be canceled. 256 | @param node node node that should have its animation canceled 257 | @param property string | constant property for which the animation should be canceled 258 | 259 | "position" 260 | "rotation" 261 | "scale" 262 | "color" 263 | "outline" 264 | "shadow" 265 | "size" 266 | "fill_angle" (pie) 267 | "inner_radius" (pie) 268 | "slice9" (slice9) 269 | 270 | **/ 271 | function cancel_animation(node: node, property: string): void 272 | 273 | /** 274 | Cancels any running flipbook animation on the specified node. 275 | @param node node node cancel flipbook animation for 276 | **/ 277 | function cancel_flipbook(node: node): void 278 | 279 | /** 280 | 281 | @param node node spine node that should cancel its animation 282 | **/ 283 | function cancel_spine(node: node): void 284 | 285 | /** 286 | Make a clone instance of a node. 287 | This function does not clone the supplied node's children nodes. 288 | Use gui.clone_tree for that purpose. 289 | @param node node node to clone 290 | @return node the cloned node 291 | **/ 292 | function clone(node: node): node 293 | 294 | /** 295 | Make a clone instance of a node and all its children. 296 | Use gui.clone to clone a node excluding its children. 297 | @param node node root node to clone 298 | @return table a table mapping node ids to the corresponding cloned nodes 299 | **/ 300 | function clone_tree(node: node): any 301 | 302 | /** 303 | Deletes the specified node. Any child nodes of the specified node will be 304 | recursively deleted. 305 | @param node node node to delete 306 | **/ 307 | function delete_node(node: node): void 308 | 309 | /** 310 | Delete a dynamically created texture. 311 | @param texture string | hash texture id 312 | **/ 313 | function delete_texture(texture: string | hash): void 314 | 315 | /** 316 | Returns the adjust mode of a node. 317 | The adjust mode defines how the node will adjust itself to screen 318 | resolutions that differs from the one in the project settings. 319 | @param node node node from which to get the adjust mode (node) 320 | @return constant the current adjust mode 321 | 322 | gui.ADJUST_FIT 323 | gui.ADJUST_ZOOM 324 | gui.ADJUST_STRETCH 325 | 326 | **/ 327 | function get_adjust_mode(node: node): any 328 | 329 | /** 330 | Returns the blend mode of a node. 331 | Blend mode defines how the node will be blended with the background. 332 | @param node node node from which to get the blend mode 333 | @return constant blend mode 334 | 335 | gui.BLEND_ALPHA 336 | gui.BLEND_ADD 337 | gui.BLEND_ADD_ALPHA 338 | gui.BLEND_MULT 339 | 340 | **/ 341 | function get_blend_mode(node: node): any 342 | 343 | /** 344 | If node is set as an inverted clipping node, it will clip anything inside as opposed to outside. 345 | @param node node node from which to get the clipping inverted state 346 | @return boolean true or false 347 | **/ 348 | function get_clipping_inverted(node: node): boolean 349 | 350 | /** 351 | Clipping mode defines how the node will clipping it's children nodes 352 | @param node node node from which to get the clipping mode 353 | @return constant clipping mode 354 | 355 | gui.CLIPPING_MODE_NONE 356 | gui.CLIPPING_MODE_STENCIL 357 | 358 | **/ 359 | function get_clipping_mode(node: node): any 360 | 361 | /** 362 | If node is set as visible clipping node, it will be shown as well as clipping. Otherwise, it will only clip but not show visually. 363 | @param node node node from which to get the clipping visibility state 364 | @return boolean true or false 365 | **/ 366 | function get_clipping_visible(node: node): boolean 367 | 368 | /** 369 | Returns the color of the supplied node. The components 370 | of the returned vector4 contains the color channel values: 371 | 372 | 373 | 374 | Component 375 | Color value 376 | 377 | 378 | 379 | 380 | x 381 | Red value 382 | 383 | 384 | y 385 | Green value 386 | 387 | 388 | z 389 | Blue value 390 | 391 | 392 | w 393 | Alpha value 394 | 395 | 396 | 397 | @param node node node to get the color from 398 | @return vector4 node color 399 | **/ 400 | function get_color(node: node): vmath.vector4 401 | 402 | /** 403 | Returns the sector angle of a pie node. 404 | @param node node node from which to get the fill angle 405 | @return number sector angle 406 | **/ 407 | function get_fill_angle(node: node): number 408 | 409 | /** 410 | Get node flipbook animation. 411 | @param node node node to get flipbook animation from 412 | @return hash animation id 413 | **/ 414 | function get_flipbook(node: node): hash 415 | 416 | /** 417 | This is only useful for text nodes. The font must be mapped to the gui scene in the gui editor. 418 | @param node node node from which to get the font 419 | @return hash font id 420 | **/ 421 | function get_font(node: node): hash 422 | 423 | /** 424 | Returns the scene height. 425 | @return number scene height 426 | **/ 427 | function get_height(): number 428 | 429 | /** 430 | Retrieves the id of the specified node. 431 | @param node node the node to retrieve the id from 432 | @return hash the id of the node 433 | **/ 434 | function get_id(node: node): hash 435 | 436 | /** 437 | Retrieve the index of the specified node. 438 | The index defines the order in which a node appear in a GUI scene. 439 | Higher index means the node is drawn on top of lower indexed nodes. 440 | @param node node the node to retrieve the id from 441 | @return number the index of the node 442 | **/ 443 | function get_index(node: node): number 444 | 445 | /** 446 | 447 | @param node node node from which to get the inherit alpha state 448 | **/ 449 | function get_inherit_alpha(node: node): void 450 | 451 | /** 452 | Returns the inner radius of a pie node. 453 | The radius is defined along the x-axis. 454 | @param node node node from where to get the inner radius 455 | @return number inner radius 456 | **/ 457 | function get_inner_radius(node: node): number 458 | 459 | /** 460 | The layer must be mapped to the gui scene in the gui editor. 461 | @param node node node from which to get the layer 462 | @return hash layer id 463 | **/ 464 | function get_layer(node: node): hash 465 | 466 | /** 467 | 468 | @return hash layout id 469 | **/ 470 | function get_layout(): hash 471 | 472 | /** 473 | Returns the leading value for a text node. 474 | @param node node node from where to get the leading 475 | @return number leading scaling value (default=1) 476 | **/ 477 | function get_leading(node: node): number 478 | 479 | /** 480 | Returns whether a text node is in line-break mode or not. 481 | This is only useful for text nodes. 482 | @param node node node from which to get the line-break for 483 | @return boolean true or false 484 | **/ 485 | function get_line_break(node: node): boolean 486 | 487 | /** 488 | Retrieves the node with the specified id. 489 | @param id string | hash id of the node to retrieve 490 | @return node a new node instance 491 | **/ 492 | function get_node(id: string | hash): node 493 | 494 | /** 495 | Returns the outer bounds mode for a pie node. 496 | @param node node node from where to get the outer bounds mode 497 | @return constant the outer bounds mode of the pie node: 498 | 499 | gui.PIEBOUNDS_RECTANGLE 500 | gui.PIEBOUNDS_ELLIPSE 501 | 502 | **/ 503 | function get_outer_bounds(node: node): any 504 | 505 | /** 506 | Returns the outline color of the supplied node. 507 | See gui.get_color for info how vectors encode color values. 508 | @param node node node to get the outline color from 509 | @return vector4 outline color 510 | **/ 511 | function get_outline(node: node): vmath.vector4 512 | 513 | /** 514 | Returns the parent node of the specified node. 515 | If the supplied node does not have a parent, nil is returned. 516 | @param node node the node from which to retrieve its parent 517 | @return node parent instance or nil 518 | **/ 519 | function get_parent(node: node): node 520 | 521 | /** 522 | Get the paricle fx for a gui node 523 | @param node node node to get particle fx for 524 | @return particle fx id 525 | **/ 526 | function get_particlefx(node: node): any 527 | 528 | /** 529 | Returns the number of generated vertices around the perimeter 530 | of a pie node. 531 | @param node node pie node 532 | @return number vertex count 533 | **/ 534 | function get_perimeter_vertices(node: node): number 535 | 536 | /** 537 | The pivot specifies how the node is drawn and rotated from its position. 538 | @param node node node to get pivot from 539 | @return constant pivot constant 540 | 541 | gui.PIVOT_CENTER 542 | gui.PIVOT_N 543 | gui.PIVOT_NE 544 | gui.PIVOT_E 545 | gui.PIVOT_SE 546 | gui.PIVOT_S 547 | gui.PIVOT_SW 548 | gui.PIVOT_W 549 | gui.PIVOT_NW 550 | 551 | **/ 552 | function get_pivot(node: node): any 553 | 554 | /** 555 | Returns the position of the supplied node. 556 | @param node node node to get the position from 557 | @return vector3 node position 558 | **/ 559 | function get_position(node: node): vmath.vector3 560 | 561 | /** 562 | Returns the rotation of the supplied node. 563 | The rotation is expressed in degree Euler angles. 564 | @param node node node to get the rotation from 565 | @return vector3 node rotation 566 | **/ 567 | function get_rotation(node: node): vmath.vector3 568 | 569 | /** 570 | Returns the scale of the supplied node. 571 | @param node node node to get the scale from 572 | @return vector3 node scale 573 | **/ 574 | function get_scale(node: node): vmath.vector3 575 | 576 | /** 577 | Returns the screen position of the supplied node. This function returns the 578 | calculated transformed position of the node, taking into account any parent node 579 | transforms. 580 | @param node node node to get the screen position from 581 | @return vector3 node screen position 582 | **/ 583 | function get_screen_position(node: node): vmath.vector3 584 | 585 | /** 586 | Returns the shadow color of the supplied node. 587 | See gui.get_color for info how vectors encode color values. 588 | @param node node node to get the shadow color from 589 | @return vector4 node shadow color 590 | **/ 591 | function get_shadow(node: node): vmath.vector4 592 | 593 | /** 594 | Returns the size of the supplied node. 595 | @param node node node to get the size from 596 | @return vector3 node size 597 | **/ 598 | function get_size(node: node): vmath.vector3 599 | 600 | /** 601 | Returns the size of a node. 602 | The size mode defines how the node will adjust itself in size. Automatic 603 | size mode alters the node size based on the node's content. 604 | @param node node node from which to get the size mode (node) 605 | @return constant the current size mode 606 | 607 | gui.SIZE_MODE_MANUAL 608 | gui.SIZE_MODE_AUTO 609 | 610 | **/ 611 | function get_size_mode(node: node): any 612 | 613 | /** 614 | Returns the slice9 configuration values for the node. 615 | @param node node node to manipulate 616 | @return vector4 configuration values 617 | **/ 618 | function get_slice9(node: node): vmath.vector4 619 | 620 | /** 621 | Gets the playing animation on a spine node 622 | @param node node node to get spine skin from 623 | @return hash spine animation id, 0 if no animation is playing 624 | **/ 625 | function get_spine_animation(node: node): hash 626 | 627 | /** 628 | The returned node can be used for parenting and transform queries. 629 | This function has complexity O(n), where n is the number of bones in the spine model skeleton. 630 | @param node node spine node to query for bone node 631 | @param bone_id string | hash id of the corresponding bone 632 | @return node node corresponding to the spine bone 633 | **/ 634 | function get_spine_bone(node: node, bone_id: string | hash): node 635 | 636 | /** 637 | This is only useful for spine nodes. Gets the normalized cursor of the animation on a spine node. 638 | @param node spine node to set the cursor for (node) 639 | @return value number cursor value 640 | **/ 641 | function get_spine_cursor(node: node): number 642 | 643 | /** 644 | This is only useful for spine nodes. Gets the playback rate of the animation on a spine node. 645 | @param node node spine node to set the cursor for 646 | @return number playback rate 647 | **/ 648 | function get_spine_playback_rate(node: node): number 649 | 650 | /** 651 | Returns the spine scene id of the supplied node. 652 | This is currently only useful for spine nodes. 653 | The returned spine scene must be mapped to the gui scene in the gui editor. 654 | @param node node node to get texture from 655 | @return hash spine scene id 656 | **/ 657 | function get_spine_scene(node: node): hash 658 | 659 | /** 660 | Gets the spine skin of a spine node 661 | @param node node node to get spine skin from 662 | @return hash spine skin id, 0 if no explicit skin is set 663 | **/ 664 | function get_spine_skin(node: node): hash 665 | 666 | /** 667 | Returns the text value of a text node. This is only useful for text nodes. 668 | @param node node node from which to get the text 669 | @return string text value 670 | **/ 671 | function get_text(node: node): string 672 | 673 | /** 674 | Get text metrics given the provided font, text and parameters. 675 | @param font string | hash font id 676 | @param text string text to measure 677 | @param width number max-width. Use for line-breaks (default=FLT_MAX) 678 | @param line_break boolean true to break lines accordingly to width (default=false) 679 | @param leading number scale value for line spacing (default=1) 680 | @param tracking number scale value for letter spacing (default=0) 681 | @return table a table with the following fields: 682 | 683 | width 684 | height 685 | max_ascent 686 | max_descent 687 | 688 | **/ 689 | function get_text_metrics(font: string | hash, text: string, width: number, line_break: boolean, leading: number, tracking: number): any 690 | 691 | /** 692 | Get the text metrics from a text node. 693 | @param node node text node to measure text from 694 | @return table a table with the following fields: 695 | 696 | width 697 | height 698 | max_ascent 699 | max_descent 700 | 701 | **/ 702 | function get_text_metrics_from_node(node: node): any 703 | 704 | /** 705 | Returns the texture of a node. 706 | This is currently only useful for box or pie nodes. 707 | The texture must be mapped to the gui scene in the gui editor. 708 | @param node node node to get texture from 709 | @return hash texture id 710 | **/ 711 | function get_texture(node: node): hash 712 | 713 | /** 714 | Returns the tracking value of a text node. 715 | @param node node node from where to get the tracking 716 | @return number tracking scaling number (default=0) 717 | **/ 718 | function get_tracking(node: node): number 719 | 720 | /** 721 | Returns the scene width. 722 | @return number scene width 723 | **/ 724 | function get_width(): number 725 | 726 | /** 727 | The x-anchor specifies how the node is moved when the game is run in a different resolution. 728 | @param node node node to get x-anchor from 729 | @return constant anchor constant 730 | 731 | gui.ANCHOR_NONE 732 | gui.ANCHOR_LEFT 733 | gui.ANCHOR_RIGHT 734 | 735 | **/ 736 | function get_xanchor(node: node): any 737 | 738 | /** 739 | The y-anchor specifies how the node is moved when the game is run in a different resolution. 740 | @param node node node to get y-anchor from 741 | @return constant anchor constant 742 | 743 | gui.ANCHOR_NONE 744 | gui.ANCHOR_TOP 745 | gui.ANCHOR_BOTTOM 746 | 747 | **/ 748 | function get_yanchor(node: node): any 749 | 750 | /** 751 | Hides the on-display touch keyboard on the device. 752 | **/ 753 | function hide_keyboard(): void 754 | 755 | /** 756 | Returns true if a node is enabled and false if it's not. 757 | Disabled nodes are not rendered and animations acting on them are not evaluated. 758 | @param node node node to query 759 | @return boolean whether the node is enabled or not 760 | **/ 761 | function is_enabled(node: node): boolean 762 | 763 | /** 764 | Alters the ordering of the two supplied nodes by moving the first node 765 | above the second. 766 | If the second argument is nil the first node is moved to the top. 767 | @param node node to move 768 | @param node node | nil reference node above which the first node should be moved 769 | **/ 770 | function move_above(node: node, node_: node): void 771 | 772 | /** 773 | Alters the ordering of the two supplied nodes by moving the first node 774 | below the second. 775 | If the second argument is nil the first node is moved to the bottom. 776 | @param node node to move 777 | @param node node | nil reference node below which the first node should be moved 778 | **/ 779 | function move_below(node: node, node_: node): void 780 | 781 | /** 782 | Dynamically create a new box node. 783 | @param pos vector3 | vector4 node position 784 | @param size vector3 node size 785 | @return node new box node 786 | **/ 787 | function new_box_node(pos: vmath.vector3 | vmath.vector4, size: vmath.vector3): node 788 | 789 | /** 790 | Dynamically create a particle fx node. 791 | @param pos vector3 | vector4 node position 792 | @param particlefx hash | string particle fx resource name 793 | @return node new particle fx node 794 | **/ 795 | function new_particlefx_node(pos: vmath.vector3 | vmath.vector4, particlefx: string | hash): node 796 | 797 | /** 798 | Dynamically create a new pie node. 799 | @param pos vector3 | vector4 node position 800 | @param size vector3 node size 801 | @return node new box node 802 | **/ 803 | function new_pie_node(pos: vmath.vector3 | vmath.vector4, size: vmath.vector3): node 804 | 805 | /** 806 | Dynamically create a new spine node. 807 | @param pos vector3 | vector4 node position 808 | @param spine_scene string | hash spine scene id 809 | @return node new spine node 810 | **/ 811 | function new_spine_node(pos: vmath.vector3 | vmath.vector4, spine_scene: string | hash): node 812 | 813 | /** 814 | Dynamically create a new text node. 815 | @param pos vector3 | vector4 node position 816 | @param text string node text 817 | @return node new text node 818 | **/ 819 | function new_text_node(pos: vmath.vector3 | vmath.vector4, text: string): node 820 | 821 | /** 822 | Dynamically create a new texture. 823 | @param texture string | hash texture id 824 | @param width number texture width 825 | @param height number texture height 826 | @param type string | constant texture type 827 | 828 | "rgb" - RGB 829 | "rgba" - RGBA 830 | "l" - LUMINANCE 831 | 832 | @param buffer string texture data 833 | @param flip boolean flip texture vertically 834 | @return boolean texture creation was successful 835 | **/ 836 | function new_texture(texture: string | hash, width: number, height: number, type: string, buffer: string, flip: boolean): boolean 837 | 838 | /** 839 | Tests whether a coordinate is within the bounding box of a 840 | node. 841 | @param node node node to be tested for picking 842 | @param x number x-coordinate (see on_input ) 843 | @param y number y-coordinate (see on_input ) 844 | @return boolean pick result 845 | **/ 846 | function pick_node(node: node, x: number, y: number): boolean 847 | 848 | /** 849 | Play flipbook animation on a box or pie node. 850 | The current node texture must contain the animation. 851 | Use this function to set one-frame still images on the node. 852 | @param node node node to set animation for 853 | @param animation string | hash animation id 854 | @param [complete_function] function(self, node) optional function to call when the animation has completed 855 | 856 | self 857 | 858 | object The current object. 859 | 860 | node 861 | 862 | node The node that is animated. 863 | 864 | 865 | **/ 866 | function play_flipbook(node: node, animation: string | hash, complete_function?: any): void 867 | 868 | /** 869 | Plays the paricle fx for a gui node 870 | @param node node node to play particle fx for 871 | @param [emitter_state_function] function(self, node, emitter, state) optional callback function that will be called when an emitter attached to this particlefx changes state. 872 | 873 | self 874 | object The current object 875 | id 876 | hash The id of the particle fx component 877 | emitter 878 | hash The id of the emitter 879 | state 880 | constant the new state of the emitter: 881 | 882 | 883 | gui.EMITTER_STATE_SLEEPING 884 | gui.EMITTER_STATE_PRESPAWN 885 | gui.EMITTER_STATE_SPAWNING 886 | gui.EMITTER_STATE_POSTSPAWN 887 | 888 | **/ 889 | function play_particlefx(node: node, emitter_state_function?: any): void 890 | 891 | /** 892 | Starts a spine animation. 893 | @param node node spine node that should play the animation 894 | @param animation_id string | hash id of the animation to play 895 | @param playback constant playback mode 896 | 897 | gui.PLAYBACK_ONCE_FORWARD 898 | gui.PLAYBACK_ONCE_BACKWARD 899 | gui.PLAYBACK_ONCE_PINGPONG 900 | gui.PLAYBACK_LOOP_FORWARD 901 | gui.PLAYBACK_LOOP_BACKWARD 902 | gui.PLAYBACK_LOOP_PINGPONG 903 | 904 | @param [play_properties] table optional table with properties 905 | 906 | blend_duration 907 | number The duration of a linear blend between the current and new animation 908 | offset 909 | number The normalized initial value of the animation cursor when the animation starts playing 910 | playback_rate 911 | number The rate with which the animation will be played. Must be positive 912 | 913 | @param [complete_function] function(self, node) function to call when the animation has completed 914 | **/ 915 | function play_spine_anim(node: node, animation_id: string | hash, playback: any, play_properties?: any, complete_function?: any): void 916 | 917 | /** 918 | Resets the input context of keyboard. This will clear marked text. 919 | **/ 920 | function reset_keyboard(): void 921 | 922 | /** 923 | Resets all nodes in the current GUI scene to their initial state. 924 | The reset only applies to static node loaded from the scene. 925 | Nodes that are created dynamically from script are not affected. 926 | **/ 927 | function reset_nodes(): void 928 | 929 | /** 930 | Sets the adjust mode on a node. 931 | The adjust mode defines how the node will adjust itself to screen 932 | resolutions that differs from the one in the project settings. 933 | @param node node node to set adjust mode for 934 | @param adjust_mode constant adjust mode to set 935 | 936 | gui.ADJUST_FIT 937 | gui.ADJUST_ZOOM 938 | gui.ADJUST_STRETCH 939 | 940 | **/ 941 | function set_adjust_mode(node: node, adjust_mode: any): void 942 | 943 | /** 944 | Set the blend mode of a node. 945 | Blend mode defines how the node will be blended with the background. 946 | @param node node node to set blend mode for 947 | @param blend_mode constant blend mode to set 948 | 949 | gui.BLEND_ALPHA 950 | gui.BLEND_ADD 951 | gui.BLEND_ADD_ALPHA 952 | gui.BLEND_MULT 953 | 954 | **/ 955 | function set_blend_mode(node: node, blend_mode: any): void 956 | 957 | /** 958 | If node is set as an inverted clipping node, it will clip anything inside as opposed to outside. 959 | @param node node node to set clipping inverted state for 960 | @param inverted boolean true or false 961 | **/ 962 | function set_clipping_inverted(node: node, inverted: boolean): void 963 | 964 | /** 965 | Clipping mode defines how the node will clipping it's children nodes 966 | @param node node node to set clipping mode for 967 | @param clipping_mode constant clipping mode to set 968 | 969 | gui.CLIPPING_MODE_NONE 970 | gui.CLIPPING_MODE_STENCIL 971 | 972 | **/ 973 | function set_clipping_mode(node: node, clipping_mode: any): void 974 | 975 | /** 976 | If node is set as an visible clipping node, it will be shown as well as clipping. Otherwise, it will only clip but not show visually. 977 | @param node node node to set clipping visibility for 978 | @param visible boolean true or false 979 | **/ 980 | function set_clipping_visible(node: node, visible: boolean): void 981 | 982 | /** 983 | Sets the color of the supplied node. The components 984 | of the supplied vector3 or vector4 should contain the color channel values: 985 | 986 | 987 | 988 | Component 989 | Color value 990 | 991 | 992 | 993 | 994 | x 995 | Red value 996 | 997 | 998 | y 999 | Green value 1000 | 1001 | 1002 | z 1003 | Blue value 1004 | 1005 | 1006 | w vector4 1007 | Alpha value 1008 | 1009 | 1010 | 1011 | @param node node node to set the color for 1012 | @param color vector3 | vector4 new color 1013 | **/ 1014 | function set_color(node: node, color: vmath.vector3 | vmath.vector4): void 1015 | 1016 | /** 1017 | Sets a node to the disabled or enabled state. 1018 | Disabled nodes are not rendered and animations acting on them are not evaluated. 1019 | @param node node node to be enabled/disabled 1020 | @param enabled boolean whether the node should be enabled or not 1021 | **/ 1022 | function set_enabled(node: node, enabled: boolean): void 1023 | 1024 | /** 1025 | Set the sector angle of a pie node. 1026 | @param node node node to set the fill angle for 1027 | @param angle number sector angle 1028 | **/ 1029 | function set_fill_angle(node: node, angle: number): void 1030 | 1031 | /** 1032 | This is only useful for text nodes. 1033 | The font must be mapped to the gui scene in the gui editor. 1034 | @param node node node for which to set the font 1035 | @param font string | hash font id 1036 | **/ 1037 | function set_font(node: node, font: string | hash): void 1038 | 1039 | /** 1040 | Set the id of the specicied node to a new value. 1041 | Nodes created with the gui.new_*_node() functions get 1042 | an empty id. This function allows you to give dynamically 1043 | created nodes an id. 1044 | No checking is done on the uniqueness of supplied ids. 1045 | It is up to you to make sure you use unique ids. 1046 | @param node node node to set the id for 1047 | @param id string | hash id to set 1048 | **/ 1049 | function set_id(node: node, id: string | hash): void 1050 | 1051 | /** 1052 | 1053 | @param node node node from which to set the inherit alpha state 1054 | @param inherit_alpha boolean true or false 1055 | **/ 1056 | function set_inherit_alpha(node: node, inherit_alpha: boolean): void 1057 | 1058 | /** 1059 | Sets the inner radius of a pie node. 1060 | The radius is defined along the x-axis. 1061 | @param node node node to set the inner radius for 1062 | @param radius number inner radius 1063 | **/ 1064 | function set_inner_radius(node: node, radius: number): void 1065 | 1066 | /** 1067 | The layer must be mapped to the gui scene in the gui editor. 1068 | @param node node node for which to set the layer 1069 | @param layer string | hash layer id 1070 | **/ 1071 | function set_layer(node: node, layer: string | hash): void 1072 | 1073 | /** 1074 | Sets the leading value for a text node. This value is used to 1075 | scale the line spacing of text. 1076 | @param node node node for which to set the leading 1077 | @param leading number a scaling value for the line spacing (default=1) 1078 | **/ 1079 | function set_leading(node: node, leading: number): void 1080 | 1081 | /** 1082 | Sets the line-break mode on a text node. 1083 | This is only useful for text nodes. 1084 | @param node node node to set line-break for 1085 | @param line_break boolean true or false 1086 | **/ 1087 | function set_line_break(node: node, line_break: boolean): void 1088 | 1089 | /** 1090 | Sets the outer bounds mode for a pie node. 1091 | @param node node node for which to set the outer bounds mode 1092 | @param bounds_mode constant the outer bounds mode of the pie node: 1093 | 1094 | gui.PIEBOUNDS_RECTANGLE 1095 | gui.PIEBOUNDS_ELLIPSE 1096 | 1097 | **/ 1098 | function set_outer_bounds(node: node, bounds_mode: any): void 1099 | 1100 | /** 1101 | Sets the outline color of the supplied node. 1102 | See gui.set_color for info how vectors encode color values. 1103 | @param node node node to set the outline color for 1104 | @param color vector3 | vector4 new outline color 1105 | **/ 1106 | function set_outline(node: node, color: vmath.vector3 | vmath.vector4): void 1107 | 1108 | /** 1109 | Sets the parent node of the specified node. 1110 | @param node node node for which to set its parent 1111 | @param parent node parent node to set 1112 | **/ 1113 | function set_parent(node: node, parent: node): void 1114 | 1115 | /** 1116 | Set the paricle fx for a gui node 1117 | @param node node node to set particle fx for 1118 | @param particlefx hash | string particle fx id 1119 | **/ 1120 | function set_particlefx(node: node, particlefx: string | hash): void 1121 | 1122 | /** 1123 | Sets the number of generated vertices around the perimeter of a pie node. 1124 | @param node node pie node 1125 | @param vertices number vertex count 1126 | **/ 1127 | function set_perimeter_vertices(node: node, vertices: number): void 1128 | 1129 | /** 1130 | The pivot specifies how the node is drawn and rotated from its position. 1131 | @param node node node to set pivot for 1132 | @param pivot constant pivot constant 1133 | 1134 | gui.PIVOT_CENTER 1135 | gui.PIVOT_N 1136 | gui.PIVOT_NE 1137 | gui.PIVOT_E 1138 | gui.PIVOT_SE 1139 | gui.PIVOT_S 1140 | gui.PIVOT_SW 1141 | gui.PIVOT_W 1142 | gui.PIVOT_NW 1143 | 1144 | **/ 1145 | function set_pivot(node: node, pivot: any): void 1146 | 1147 | /** 1148 | Sets the position of the supplied node. 1149 | @param node node node to set the position for 1150 | @param position vector3 | vector4 new position 1151 | **/ 1152 | function set_position(node: node, position: vmath.vector3 | vmath.vector4): void 1153 | 1154 | /** 1155 | Set the order number for the current GUI scene. 1156 | The number dictates the sorting of the "gui" render predicate, 1157 | in other words in which order the scene will be rendered in relation 1158 | to other currently rendered GUI scenes. 1159 | The number must be in the range 0 to 15. 1160 | @param order number rendering order (0-15) 1161 | **/ 1162 | function set_render_order(order: number): void 1163 | 1164 | /** 1165 | Sets the rotation of the supplied node. 1166 | The rotation is expressed in degree Euler angles. 1167 | @param node node node to set the rotation for 1168 | @param rotation vector3 | vector4 new rotation 1169 | **/ 1170 | function set_rotation(node: node, rotation: vmath.vector3 | vmath.vector4): void 1171 | 1172 | /** 1173 | Sets the scaling of the supplied node. 1174 | @param node node node to set the scale for 1175 | @param scale vector3 | vector4 new scale 1176 | **/ 1177 | function set_scale(node: node, scale: vmath.vector3 | vmath.vector4): void 1178 | 1179 | /** 1180 | Sets the shadow color of the supplied node. 1181 | See gui.set_color for info how vectors encode color values. 1182 | @param node node node to set the shadow color for 1183 | @param color vector3 | vector4 new shadow color 1184 | **/ 1185 | function set_shadow(node: node, color: vmath.vector3 | vmath.vector4): void 1186 | 1187 | /** 1188 | Sets the size of the supplied node. 1189 | You can only set size on nodes with size mode set to SIZE_MODE_MANUAL 1190 | @param node node node to set the size for 1191 | @param size vector3 | vector4 new size 1192 | **/ 1193 | function set_size(node: node, size: vmath.vector3 | vmath.vector4): void 1194 | 1195 | /** 1196 | Sets the size mode of a node. 1197 | The size mode defines how the node will adjust itself in size. Automatic 1198 | size mode alters the node size based on the node's content. 1199 | @param node node node to set size mode for 1200 | @param size_mode constant size mode to set 1201 | 1202 | gui.SIZE_MODE_MANUAL 1203 | gui.SIZE_MODE_AUTO 1204 | 1205 | **/ 1206 | function set_size_mode(node: node, size_mode: any): void 1207 | 1208 | /** 1209 | Set the slice9 configuration values for the node. 1210 | @param node node node to manipulate 1211 | @param values vector4 new values 1212 | **/ 1213 | function set_slice9(node: node, values: vmath.vector4): void 1214 | 1215 | /** 1216 | This is only useful for spine nodes. The cursor is normalized. 1217 | @param node node spine node to set the cursor for 1218 | @param cursor number cursor value 1219 | **/ 1220 | function set_spine_cursor(node: node, cursor: number): void 1221 | 1222 | /** 1223 | This is only useful for spine nodes. Sets the playback rate of the animation on a spine node. Must be positive. 1224 | @param node node spine node to set the cursor for 1225 | @param playback_rate number playback rate 1226 | **/ 1227 | function set_spine_playback_rate(node: node, playback_rate: number): void 1228 | 1229 | /** 1230 | Set the spine scene on a spine node. The spine scene must be mapped to the gui scene in the gui editor. 1231 | @param node node node to set spine scene for 1232 | @param spine_scene string | hash spine scene id 1233 | **/ 1234 | function set_spine_scene(node: node, spine_scene: string | hash): void 1235 | 1236 | /** 1237 | Sets the spine skin on a spine node. 1238 | @param node node node to set the spine skin on 1239 | @param spine_skin string | hash spine skin id 1240 | @param [spine_slot] string | hash optional slot id to only change a specific slot 1241 | **/ 1242 | function set_spine_skin(node: node, spine_skin: string | hash, spine_slot?: string | hash): void 1243 | 1244 | /** 1245 | Set the text value of a text node. This is only useful for text nodes. 1246 | @param node node node to set text for 1247 | @param text string text to set 1248 | **/ 1249 | function set_text(node: node, text: string): void 1250 | 1251 | /** 1252 | Set the texture on a box or pie node. The texture must be mapped to 1253 | the gui scene in the gui editor. The function points out which texture 1254 | the node should render from. If the texture is an atlas, further 1255 | information is needed to select which image/animation in the atlas 1256 | to render. In such cases, use gui.play_flipbook() in 1257 | addition to this function. 1258 | @param node node node to set texture for 1259 | @param texture string | hash texture id 1260 | **/ 1261 | function set_texture(node: node, texture: string | hash): void 1262 | 1263 | /** 1264 | Set the texture buffer data for a dynamically created texture. 1265 | @param texture string | hash texture id 1266 | @param width number texture width 1267 | @param height number texture height 1268 | @param type string | constant texture type 1269 | 1270 | "rgb" - RGB 1271 | "rgba" - RGBA 1272 | "l" - LUMINANCE 1273 | 1274 | @param buffer string texture data 1275 | @param flip boolean flip texture vertically 1276 | @return boolean setting the data was successful 1277 | **/ 1278 | function set_texture_data(texture: string | hash, width: number, height: number, type: string, buffer: string, flip: boolean): boolean 1279 | 1280 | /** 1281 | Sets the tracking value of a text node. This value is used to 1282 | adjust the vertical spacing of characters in the text. 1283 | @param node node node for which to set the tracking 1284 | @param tracking number a scaling number for the letter spacing (default=0) 1285 | **/ 1286 | function set_tracking(node: node, tracking: number): void 1287 | 1288 | /** 1289 | The x-anchor specifies how the node is moved when the game is run in a different resolution. 1290 | @param node node node to set x-anchor for 1291 | @param anchor constant anchor constant 1292 | 1293 | gui.ANCHOR_NONE 1294 | gui.ANCHOR_LEFT 1295 | gui.ANCHOR_RIGHT 1296 | 1297 | **/ 1298 | function set_xanchor(node: node, anchor: any): void 1299 | 1300 | /** 1301 | The y-anchor specifies how the node is moved when the game is run in a different resolution. 1302 | @param node node node to set y-anchor for 1303 | @param anchor constant anchor constant 1304 | 1305 | gui.ANCHOR_NONE 1306 | gui.ANCHOR_TOP 1307 | gui.ANCHOR_BOTTOM 1308 | 1309 | **/ 1310 | function set_yanchor(node: node, anchor: any): void 1311 | 1312 | /** 1313 | Shows the on-display touch keyboard. 1314 | The specified type of keyboard is displayed if it is available on 1315 | the device. 1316 | This function is only available on iOS and Android. . 1317 | @param type constant keyboard type 1318 | 1319 | gui.KEYBOARD_TYPE_DEFAULT 1320 | gui.KEYBOARD_TYPE_EMAIL 1321 | gui.KEYBOARD_TYPE_NUMBER_PAD 1322 | gui.KEYBOARD_TYPE_PASSWORD 1323 | 1324 | @param autoclose boolean if the keyboard should automatically close when clicking outside 1325 | **/ 1326 | function show_keyboard(type: any, autoclose: boolean): void 1327 | 1328 | /** 1329 | Stops the paricle fx for a gui node 1330 | @param node node node to stop particle fx for 1331 | **/ 1332 | function stop_particlefx(node: node): void 1333 | 1334 | } 1335 | 1336 | declare namespace go { 1337 | 1338 | let EASING_INBACK: any 1339 | let EASING_INBOUNCE: any 1340 | let EASING_INCIRC: any 1341 | let EASING_INCUBIC: any 1342 | let EASING_INELASTIC: any 1343 | let EASING_INEXPO: any 1344 | let EASING_INOUTBACK: any 1345 | let EASING_INOUTBOUNCE: any 1346 | let EASING_INOUTCIRC: any 1347 | let EASING_INOUTCUBIC: any 1348 | let EASING_INOUTELASTIC: any 1349 | let EASING_INOUTEXPO: any 1350 | let EASING_INOUTQUAD: any 1351 | let EASING_INOUTQUART: any 1352 | let EASING_INOUTQUINT: any 1353 | let EASING_INOUTSINE: any 1354 | let EASING_INQUAD: any 1355 | let EASING_INQUART: any 1356 | let EASING_INQUINT: any 1357 | let EASING_INSINE: any 1358 | let EASING_LINEAR: any 1359 | let EASING_OUTBACK: any 1360 | let EASING_OUTBOUNCE: any 1361 | let EASING_OUTCIRC: any 1362 | let EASING_OUTCUBIC: any 1363 | let EASING_OUTELASTIC: any 1364 | let EASING_OUTEXPO: any 1365 | let EASING_OUTINBACK: any 1366 | let EASING_OUTINBOUNCE: any 1367 | let EASING_OUTINCIRC: any 1368 | let EASING_OUTINCUBIC: any 1369 | let EASING_OUTINELASTIC: any 1370 | let EASING_OUTINEXPO: any 1371 | let EASING_OUTINQUAD: any 1372 | let EASING_OUTINQUART: any 1373 | let EASING_OUTINQUINT: any 1374 | let EASING_OUTINSINE: any 1375 | let EASING_OUTQUAD: any 1376 | let EASING_OUTQUART: any 1377 | let EASING_OUTQUINT: any 1378 | let EASING_OUTSINE: any 1379 | let PLAYBACK_LOOP_BACKWARD: any 1380 | let PLAYBACK_LOOP_FORWARD: any 1381 | let PLAYBACK_LOOP_PINGPONG: any 1382 | let PLAYBACK_NONE: any 1383 | let PLAYBACK_ONCE_BACKWARD: any 1384 | let PLAYBACK_ONCE_FORWARD: any 1385 | let PLAYBACK_ONCE_PINGPONG: any 1386 | /** 1387 | This is only supported for numerical properties. If the node property is already being 1388 | animated, that animation will be canceled and replaced by the new one. 1389 | If a complete_function (lua function) is specified, that function will be called when the animation has completed. 1390 | By starting a new animation in that function, several animations can be sequenced together. See the examples for more information. 1391 | If you call go.animate() from a game object's final() function, 1392 | any passed complete_function will be ignored and never called upon animation completion. 1393 | See the properties guide for which properties can be animated and the animation guide for how to animate them. 1394 | @param url string | hash | url url of the game object or component having the property 1395 | @param property string | hash id of the property to animate 1396 | @param playback constant playback mode of the animation 1397 | 1398 | go.PLAYBACK_ONCE_FORWARD 1399 | go.PLAYBACK_ONCE_BACKWARD 1400 | go.PLAYBACK_ONCE_PINGPONG 1401 | go.PLAYBACK_LOOP_FORWARD 1402 | go.PLAYBACK_LOOP_BACKWARD 1403 | go.PLAYBACK_LOOP_PINGPONG 1404 | 1405 | @param to number | vector3 | vector4 | quaternion target property value 1406 | @param easing constant | vector easing to use during animation. Either specify a constant, see the animation guide for a complete list, or a vmath.vector with a curve 1407 | @param duration number duration of the animation in seconds 1408 | @param [delay] number delay before the animation starts in seconds 1409 | @param [complete_function] function(self, url, property) optional function to call when the animation has completed 1410 | 1411 | self 1412 | 1413 | object The current object. 1414 | 1415 | url 1416 | 1417 | url The game object or component instance for which the property is animated. 1418 | 1419 | property 1420 | 1421 | hash The id of the animated property. 1422 | 1423 | 1424 | **/ 1425 | function animate(url: string | hash | url, property: string | hash, playback: any, to: number | vmath.vector3 | vmath.vector4 | vmath.quaternion, easing: any, duration: number, delay?: number, complete_function?: any): void 1426 | 1427 | /** 1428 | By calling this function, all stored animations of the given property will be canceled. 1429 | See the properties guide for which properties can be animated and the animation guide for how to animate them. 1430 | @param url string | hash | url url of the game object or component having the property 1431 | @param property string | hash ide of the property to animate 1432 | **/ 1433 | function cancel_animations(url: string | hash | url, property: string | hash): void 1434 | 1435 | /** 1436 | 1437 | @param url string | hash | url url of the game object or component having the property 1438 | @param property string | hash id of the property to retrieve 1439 | @return any the value of the specified property 1440 | **/ 1441 | function get(url: string | hash | url, property: string | hash): any 1442 | 1443 | /** 1444 | Returns or constructs an instance identifier. The instance id is a hash 1445 | of the absolute path to the instance. 1446 | 1447 | If path is specified, it can either be absolute or relative to the instance of the calling script. 1448 | If path is not specified, the id of the game object instance the script is attached to will be returned. 1449 | 1450 | @param [path] string path of the instance for which to return the id 1451 | @return hash instance id 1452 | **/ 1453 | function get_id(path?: string): hash 1454 | 1455 | /** 1456 | The position is relative the parent (if any). Use go.get_world_position to retrieve the global world position. 1457 | @param [id] string | hash | url optional id of the game object instance to get the position for, by default the instance of the calling script 1458 | @return vector3 instance position 1459 | **/ 1460 | function get_position(id?: string | hash | url): vmath.vector3 1461 | 1462 | /** 1463 | The rotation is relative to the parent (if any). Use go.get_world_rotation to retrieve the global world position. 1464 | @param [id] string | hash | url optional id of the game object instance to get the rotation for, by default the instance of the calling script 1465 | @return quaternion instance rotation 1466 | **/ 1467 | function get_rotation(id?: string | hash | url): vmath.quaternion 1468 | 1469 | /** 1470 | The scale is relative the parent (if any). Use go.get_world_scale to retrieve the global world 3D scale factor. 1471 | @param [id] string | hash | url optional id of the game object instance to get the scale for, by default the instance of the calling script 1472 | @return vector3 instance scale factor 1473 | **/ 1474 | function get_scale(id?: string | hash | url): vmath.vector3 1475 | 1476 | /** 1477 | The uniform scale is relative the parent (if any). If the underlying scale vector is non-uniform the min element of the vector is returned as the uniform scale factor. 1478 | @param [id] string | hash | url optional id of the game object instance to get the uniform scale for, by default the instance of the calling script 1479 | @return number uniform instance scale factor 1480 | **/ 1481 | function get_scale_uniform(id?: string | hash | url): number 1482 | 1483 | /** 1484 | Use go.get_position to retrieve the position relative to the parent. 1485 | @param [id] string | hash | url optional id of the game object instance to get the world position for, by default the instance of the calling script 1486 | @return vector3 instance world position 1487 | **/ 1488 | function get_world_position(id?: string | hash | url): vmath.vector3 1489 | 1490 | /** 1491 | Use go.get_rotation to retrieve the rotation relative to the parent. 1492 | @param [id] string | hash | url optional id of the game object instance to get the world rotation for, by default the instance of the calling script 1493 | @return quaternion instance world rotation 1494 | **/ 1495 | function get_world_rotation(id?: string | hash | url): vmath.quaternion 1496 | 1497 | /** 1498 | Use go.get_scale to retrieve the 3D scale factor relative to the parent. 1499 | This vector is derived by decomposing the transformation matrix and should be used with care. 1500 | For most cases it should be fine to use go.get_world_scale_uniform instead. 1501 | @param [id] string | hash | url optional id of the game object instance to get the world scale for, by default the instance of the calling script 1502 | @return vector3 instance world 3D scale factor 1503 | **/ 1504 | function get_world_scale(id?: string | hash | url): vmath.vector3 1505 | 1506 | /** 1507 | Use go.get_scale_uniform to retrieve the scale factor relative to the parent. 1508 | @param [id] string | hash | url optional id of the game object instance to get the world scale for, by default the instance of the calling script 1509 | @return number instance world scale factor 1510 | **/ 1511 | function get_world_scale_uniform(id?: string | hash | url): number 1512 | 1513 | /** 1514 | This function defines a property which can then be used in the script through the self-reference. 1515 | The properties defined this way are automatically exposed in the editor in game objects and collections which use the script. 1516 | Note that you can only use this function outside any callback-functions like init and update. 1517 | @param name string the id of the property 1518 | @param value number | hash | url | vector3 | vector4 | quaternion default value of the property. In the case of a url, only the empty constructor msg.url() is allowed 1519 | **/ 1520 | function property(name: string, value: hash | url | number | vmath.vector3 | vmath.vector4 | vmath.quaternion): void 1521 | 1522 | /** 1523 | 1524 | @param url string | hash | url url of the game object or component having the property 1525 | @param property string | hash id of the property to set 1526 | @param value any the value to set 1527 | **/ 1528 | function set(url: string | hash | url, property: string | hash, value: any): void 1529 | 1530 | /** 1531 | The position is relative to the parent (if any). The global world position cannot be manually set. 1532 | @param position vector3 position to set 1533 | @param [id] string | hash | url optional id of the game object instance to set the position for, by default the instance of the calling script 1534 | **/ 1535 | function set_position(position: vmath.vector3, id?: string | hash | url): void 1536 | 1537 | /** 1538 | The rotation is relative to the parent (if any). The global world rotation cannot be manually set. 1539 | @param rotation quaternion rotation to set 1540 | @param [id] string | hash | url optional id of the game object instance to get the rotation for, by default the instance of the calling script 1541 | **/ 1542 | function set_rotation(rotation: vmath.quaternion, id?: string | hash | url): void 1543 | 1544 | /** 1545 | The scale factor is relative to the parent (if any). The global world scale factor cannot be manually set. 1546 | Physics are currently not affected when setting scale from this function. 1547 | @param scale number | vector3 vector or uniform scale factor, must be greater than 0 1548 | @param [id] string | hash | url optional id of the game object instance to get the scale for, by default the instance of the calling script 1549 | **/ 1550 | function set_scale(scale: number | vmath.vector3, id?: string | hash | url): void 1551 | 1552 | 1553 | /** 1554 | Custom function ("delete" reserved word in TypeScript) 1555 | Delete one or more game objects identified by id. Deletion is asynchronous meaning that 1556 | the game object(s) are scheduled for deletion which will happen at the end of the current 1557 | frame. Note that game objects scheduled for deletion will be counted against 1558 | max_instances in "game.project" until they are actually removed. 1559 | @param [id] string | hash | url | table optional id or table of id's of the instance(s) to delete, the instance of the calling script is deleted by default 1560 | @param [recursive] boolean optional boolean, set to true to recursively delete child hiearchy in child to parent order 1561 | **/ 1562 | function delete_(id?: any, recursive?: boolean): void 1563 | } 1564 | 1565 | declare namespace profiler { 1566 | 1567 | /** 1568 | Get the percent of CPU usage by the application, as reported by the OS. 1569 | This function is not available on HTML5. 1570 | For some platforms ( Android, Linux and Windows), this information is only available 1571 | by default in the debug version of the engine. It can be enabled in release version as well 1572 | by checking track_cpu under profiler in the game.project file. 1573 | (This means that the engine will sample the CPU usage in intervalls during execution even in release mode.) 1574 | @return number of CPU used by the application 1575 | **/ 1576 | function get_cpu_usage(): number 1577 | 1578 | /** 1579 | Get the amount of memory used (resident/working set) by the application in bytes, as reported by the OS. 1580 | This function is not available on HTML5. 1581 | The values are gathered from internal OS functions which correspond to the following; 1582 | 1583 | 1584 | 1585 | OS 1586 | Value 1587 | 1588 | 1589 | 1590 | 1591 | iOS MacOSAndrod Linux 1592 | Resident memory 1593 | 1594 | 1595 | Windows 1596 | Working set 1597 | 1598 | 1599 | HTML5 1600 | Not available 1601 | 1602 | 1603 | 1604 | @return number used by the application 1605 | **/ 1606 | function get_memory_usage(): number 1607 | 1608 | } 1609 | 1610 | declare namespace render { 1611 | 1612 | let BLEND_CONSTANT_ALPHA: any 1613 | let BLEND_CONSTANT_COLOR: any 1614 | let BLEND_DST_ALPHA: any 1615 | let BLEND_DST_COLOR: any 1616 | let BLEND_ONE: any 1617 | let BLEND_ONE_MINUS_CONSTANT_ALPHA: any 1618 | let BLEND_ONE_MINUS_CONSTANT_COLOR: any 1619 | let BLEND_ONE_MINUS_DST_ALPHA: any 1620 | let BLEND_ONE_MINUS_DST_COLOR: any 1621 | let BLEND_ONE_MINUS_SRC_ALPHA: any 1622 | let BLEND_ONE_MINUS_SRC_COLOR: any 1623 | let BLEND_SRC_ALPHA: any 1624 | let BLEND_SRC_ALPHA_SATURATE: any 1625 | let BLEND_SRC_COLOR: any 1626 | let BLEND_ZERO: any 1627 | let BUFFER_COLOR_BIT: any 1628 | let BUFFER_DEPTH_BIT: any 1629 | let BUFFER_STENCIL_BIT: any 1630 | let COMPARE_FUNC_ALWAYS: any 1631 | let COMPARE_FUNC_EQUAL: any 1632 | let COMPARE_FUNC_GEQUAL: any 1633 | let COMPARE_FUNC_GREATER: any 1634 | let COMPARE_FUNC_LEQUAL: any 1635 | let COMPARE_FUNC_LESS: any 1636 | let COMPARE_FUNC_NEVER: any 1637 | let COMPARE_FUNC_NOTEQUAL: any 1638 | let FACE_BACK: any 1639 | let FACE_FRONT: any 1640 | let FACE_FRONT_AND_BACK: any 1641 | let FILTER_LINEAR: any 1642 | let FILTER_NEAREST: any 1643 | let FORMAT_DEPTH: any 1644 | let FORMAT_LUMINANCE: any 1645 | let FORMAT_RGB: any 1646 | let FORMAT_RGBA: any 1647 | let FORMAT_RGBA_DXT1: any 1648 | let FORMAT_RGBA_DXT3: any 1649 | let FORMAT_RGBA_DXT5: any 1650 | let FORMAT_RGB_DXT1: any 1651 | let FORMAT_STENCIL: any 1652 | let STATE_BLEND: any 1653 | let STATE_CULL_FACE: any 1654 | let STATE_DEPTH_TEST: any 1655 | let STATE_POLYGON_OFFSET_FILL: any 1656 | let STATE_STENCIL_TEST: any 1657 | let STENCIL_OP_DECR: any 1658 | let STENCIL_OP_DECR_WRAP: any 1659 | let STENCIL_OP_INCR: any 1660 | let STENCIL_OP_INCR_WRAP: any 1661 | let STENCIL_OP_INVERT: any 1662 | let STENCIL_OP_KEEP: any 1663 | let STENCIL_OP_REPLACE: any 1664 | let STENCIL_OP_ZERO: any 1665 | let WRAP_CLAMP_TO_BORDER: any 1666 | let WRAP_CLAMP_TO_EDGE: any 1667 | let WRAP_MIRRORED_REPEAT: any 1668 | let WRAP_REPEAT: any 1669 | /** 1670 | Clear buffers in the currently enabled render target with specified value. 1671 | @param buffers table table with keys specifying which buffers to clear and values set to clear values. Available keys are: 1672 | 1673 | render.BUFFER_COLOR_BIT 1674 | render.BUFFER_DEPTH_BIT 1675 | render.BUFFER_STENCIL_BIT 1676 | 1677 | **/ 1678 | function clear(buffers: any): void 1679 | 1680 | /** 1681 | Constant buffers are used to set shader program variables and are optionally passed to the render.draw() function. The buffer's constant elements can be indexed like an ordinary Lua table, but you can't iterate over them with pairs() or ipairs(). 1682 | @return constant_buffer new constant buffer 1683 | **/ 1684 | function constant_buffer(): any 1685 | 1686 | /** 1687 | Deletes a previously created render target. 1688 | @param render_target render_target render target to delete 1689 | **/ 1690 | function delete_render_target(render_target: any): void 1691 | 1692 | /** 1693 | If a material is currently enabled, disable it. 1694 | The name of the material must be specified in the ".render" resource set 1695 | in the "game.project" setting. 1696 | **/ 1697 | function disable_material(): void 1698 | 1699 | /** 1700 | Disables a previously enabled render target. Subsequent draw operations 1701 | will be drawn to the frame buffer unless another render target is 1702 | enabled. 1703 | @param render_target render_target render target to disable 1704 | **/ 1705 | function disable_render_target(render_target: any): void 1706 | 1707 | /** 1708 | Disables a render state. 1709 | @param state constant state to disable 1710 | 1711 | render.STATE_DEPTH_TEST 1712 | render.STATE_STENCIL_TEST 1713 | render.STATE_BLEND 1714 | render.STATE_ALPHA_TEST ( not available on iOS and Android) 1715 | render.STATE_CULL_FACE 1716 | render.STATE_POLYGON_OFFSET_FILL 1717 | 1718 | **/ 1719 | function disable_state(state: any): void 1720 | 1721 | /** 1722 | Disables a texture unit for a render target that has previourly been enabled. 1723 | @param unit number texture unit to disable 1724 | **/ 1725 | function disable_texture(unit: number): void 1726 | 1727 | /** 1728 | Draws all objects that match a specified predicate. An optional constant buffer can be 1729 | provided to override the default constants. If no constants buffer is provided, a default 1730 | system constants buffer is used containing constants as defined in materials and set through 1731 | *.set_constant() and *.reset_constant() on visual components. 1732 | @param predicate predicate predicate to draw for 1733 | @param [constants] constant_buffer optional constants to use while rendering 1734 | **/ 1735 | function draw(predicate: any, constants?: any): void 1736 | 1737 | /** 1738 | Draws all 3d debug graphics such as lines drawn with "draw_line" messages and physics visualization. 1739 | **/ 1740 | function draw_debug3d(): void 1741 | 1742 | /** 1743 | If another material was already enabled, it will be automatically disabled 1744 | and the specified material is used instead. 1745 | The name of the material must be specified in the ".render" resource set 1746 | in the "game.project" setting. 1747 | @param material_id string | hash material id to enable 1748 | **/ 1749 | function enable_material(material_id: string | hash): void 1750 | 1751 | /** 1752 | Enables a render target. Subsequent draw operations will be to the 1753 | enabled render target until it is disabled. 1754 | @param render_target render_target render target to enable 1755 | **/ 1756 | function enable_render_target(render_target: any): void 1757 | 1758 | /** 1759 | Enables a particular render state. The state will be enabled until disabled. 1760 | @param state constant state to enable 1761 | 1762 | render.STATE_DEPTH_TEST 1763 | render.STATE_STENCIL_TEST 1764 | render.STATE_BLEND 1765 | render.STATE_ALPHA_TEST ( not available on iOS and Android) 1766 | render.STATE_CULL_FACE 1767 | render.STATE_POLYGON_OFFSET_FILL 1768 | 1769 | **/ 1770 | function enable_state(state: any): void 1771 | 1772 | /** 1773 | Sets the specified render target's specified buffer to be 1774 | used as texture with the specified unit. 1775 | A material shader can then use the texture to sample from. 1776 | @param unit number texture unit to enable texture for 1777 | @param render_target render_target render target from which to enable the specified texture unit 1778 | @param buffer_type constant buffer type from which to enable the texture 1779 | 1780 | render.BUFFER_COLOR_BIT 1781 | render.BUFFER_DEPTH_BIT 1782 | render.BUFFER_STENCIL_BIT 1783 | 1784 | **/ 1785 | function enable_texture(unit: number, render_target: any, buffer_type: any): void 1786 | 1787 | /** 1788 | Returns the logical window height that is set in the "game.project" settings. 1789 | Note that the actual window pixel size can change, either by device constraints 1790 | or user input. 1791 | @return number specified window height 1792 | **/ 1793 | function get_height(): number 1794 | 1795 | /** 1796 | Returns the specified buffer height from a render target. 1797 | @param render_target render_target render target from which to retrieve the buffer height 1798 | @param buffer_type constant which type of buffer to retrieve the height from 1799 | 1800 | render.BUFFER_COLOR_BIT 1801 | render.BUFFER_DEPTH_BIT 1802 | render.BUFFER_STENCIL_BIT 1803 | 1804 | @return number the height of the render target buffer texture 1805 | **/ 1806 | function get_render_target_height(render_target: any, buffer_type: any): number 1807 | 1808 | /** 1809 | Returns the specified buffer width from a render target. 1810 | @param render_target render_target render target from which to retrieve the buffer width 1811 | @param buffer_type constant which type of buffer to retrieve the width from 1812 | 1813 | render.BUFFER_COLOR_BIT 1814 | render.BUFFER_DEPTH_BIT 1815 | render.BUFFER_STENCIL_BIT 1816 | 1817 | @return number the width of the render target buffer texture 1818 | **/ 1819 | function get_render_target_width(render_target: any, buffer_type: any): number 1820 | 1821 | /** 1822 | Returns the logical window width that is set in the "game.project" settings. 1823 | Note that the actual window pixel size can change, either by device constraints 1824 | or user input. 1825 | @return number specified window width (number) 1826 | **/ 1827 | function get_width(): number 1828 | 1829 | /** 1830 | Returns the actual physical window height. 1831 | Note that this value might differ from the logical height that is set in the 1832 | "game.project" settings. 1833 | @return number actual window height 1834 | **/ 1835 | function get_window_height(): number 1836 | 1837 | /** 1838 | Returns the actual physical window width. 1839 | Note that this value might differ from the logical width that is set in the 1840 | "game.project" settings. 1841 | @return number actual window width 1842 | **/ 1843 | function get_window_width(): number 1844 | 1845 | /** 1846 | This function returns a new render predicate for objects with materials matching 1847 | the provided material tags. The provided tags are combined into a bit mask 1848 | for the predicate. If multiple tags are provided, the predicate matches materials 1849 | with all tags ANDed together. 1850 | The current limit to the number of tags that can be defined is 32. 1851 | @param tags table table of tags that the predicate should match. The tags can be of either hash or string type 1852 | @return predicate new predicate 1853 | **/ 1854 | function predicate(tags: any): any 1855 | 1856 | /** 1857 | Creates a new render target according to the supplied 1858 | specification table. 1859 | The table should contain keys specifying which buffers should be created 1860 | with what parameters. Each buffer key should have a table value consisting 1861 | of parameters. The following parameter keys are available: 1862 | 1863 | 1864 | 1865 | Key 1866 | Values 1867 | 1868 | 1869 | 1870 | 1871 | format 1872 | render.FORMAT_LUMINANCErender.FORMAT_RGBrender.FORMAT_RGBA render.FORMAT_RGB_DXT1render.FORMAT_RGBA_DXT1render.FORMAT_RGBA_DXT3 render.FORMAT_RGBA_DXT5render.FORMAT_DEPTHrender.FORMAT_STENCIL 1873 | 1874 | 1875 | width 1876 | number 1877 | 1878 | 1879 | height 1880 | number 1881 | 1882 | 1883 | min_filter 1884 | render.FILTER_LINEARrender.FILTER_NEAREST 1885 | 1886 | 1887 | mag_filter 1888 | render.FILTER_LINEARrender.FILTER_NEAREST 1889 | 1890 | 1891 | u_wrap 1892 | render.WRAP_CLAMP_TO_BORDERrender.WRAP_CLAMP_TO_EDGErender.WRAP_MIRRORED_REPEATrender.WRAP_REPEAT 1893 | 1894 | 1895 | v_wrap 1896 | render.WRAP_CLAMP_TO_BORDERrender.WRAP_CLAMP_TO_EDGErender.WRAP_MIRRORED_REPEATrender.WRAP_REPEAT 1897 | 1898 | 1899 | 1900 | @param name string render target name 1901 | @param parameters table table of buffer parameters, see the description for available keys and values 1902 | @return render_target new render target 1903 | **/ 1904 | function render_target(name: string, parameters: any): any 1905 | 1906 | /** 1907 | Specifies the arithmetic used when computing pixel values that are written to the frame 1908 | buffer. In RGBA mode, pixels can be drawn using a function that blends the source RGBA 1909 | pixel values with the destination pixel values already in the frame buffer. 1910 | Blending is initially disabled. 1911 | source_factor specifies which method is used to scale the source color components. 1912 | destination_factor specifies which method is used to scale the destination color 1913 | components. 1914 | Source color components are referred to as (Rs,Gs,Bs,As). 1915 | Destination color components are referred to as (Rd,Gd,Bd,Ad). 1916 | The color specified by setting the blendcolor is referred to as (Rc,Gc,Bc,Ac). 1917 | The source scale factor is referred to as (sR,sG,sB,sA). 1918 | The destination scale factor is referred to as (dR,dG,dB,dA). 1919 | The color values have integer values between 0 and (kR,kG,kB,kA), where kc = 2mc - 1 and mc is the number of bitplanes for that color. I.e for 8 bit color depth, color values are between 0 and 255. 1920 | Available factor constants and corresponding scale factors: 1921 | 1922 | 1923 | 1924 | Factor constant 1925 | Scale factor (fR,fG,fB,fA) 1926 | 1927 | 1928 | 1929 | 1930 | render.BLEND_ZERO 1931 | (0,0,0,0) 1932 | 1933 | 1934 | render.BLEND_ONE 1935 | (1,1,1,1) 1936 | 1937 | 1938 | render.BLEND_SRC_COLOR 1939 | (Rs/kR,Gs/kG,Bs/kB,As/kA) 1940 | 1941 | 1942 | render.BLEND_ONE_MINUS_SRC_COLOR 1943 | (1,1,1,1) - (Rs/kR,Gs/kG,Bs/kB,As/kA) 1944 | 1945 | 1946 | render.BLEND_DST_COLOR 1947 | (Rd/kR,Gd/kG,Bd/kB,Ad/kA) 1948 | 1949 | 1950 | render.BLEND_ONE_MINUS_DST_COLOR 1951 | (1,1,1,1) - (Rd/kR,Gd/kG,Bd/kB,Ad/kA) 1952 | 1953 | 1954 | render.BLEND_SRC_ALPHA 1955 | (As/kA,As/kA,As/kA,As/kA) 1956 | 1957 | 1958 | render.BLEND_ONE_MINUS_SRC_ALPHA 1959 | (1,1,1,1) - (As/kA,As/kA,As/kA,As/kA) 1960 | 1961 | 1962 | render.BLEND_DST_ALPHA 1963 | (Ad/kA,Ad/kA,Ad/kA,Ad/kA) 1964 | 1965 | 1966 | render.BLEND_ONE_MINUS_DST_ALPHA 1967 | (1,1,1,1) - (Ad/kA,Ad/kA,Ad/kA,Ad/kA) 1968 | 1969 | 1970 | render.BLEND_CONSTANT_COLOR 1971 | (Rc,Gc,Bc,Ac) 1972 | 1973 | 1974 | render.BLEND_ONE_MINUS_CONSTANT_COLOR 1975 | (1,1,1,1) - (Rc,Gc,Bc,Ac) 1976 | 1977 | 1978 | render.BLEND_CONSTANT_ALPHA 1979 | (Ac,Ac,Ac,Ac) 1980 | 1981 | 1982 | render.BLEND_ONE_MINUS_CONSTANT_ALPHA 1983 | (1,1,1,1) - (Ac,Ac,Ac,Ac) 1984 | 1985 | 1986 | render.BLEND_SRC_ALPHA_SATURATE 1987 | (i,i,i,1) where i = min(As, kA - Ad) /kA 1988 | 1989 | 1990 | 1991 | The blended RGBA values of a pixel comes from the following equations: 1992 | 1993 | Rd = min(kR, Rs * sR + Rd * dR) 1994 | Gd = min(kG, Gs * sG + Gd * dR) 1995 | Bd = min(kB, Bs * sB + Bd * dB) 1996 | Ad = min(kA, As * sB + Ad * dA) 1997 | 1998 | Blend function (render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA) is useful for 1999 | drawing with transparency when the drawn objects are sorted from farthest to nearest. 2000 | It is also useful for drawing antialiased points and lines in arbitrary order. 2001 | @param source_factor constant source factor 2002 | @param destination_factor constant destination factor 2003 | **/ 2004 | function set_blend_func(source_factor: any, destination_factor: any): void 2005 | 2006 | /** 2007 | Specifies whether the individual color components in the frame buffer is enabled for writing (true) or disabled (false). For example, if blue is false, nothing is written to the blue component of any pixel in any of the color buffers, regardless of the drawing operation attempted. Note that writing are either enabled or disabled for entire color components, not the individual bits of a component. 2008 | The component masks are all initially true. 2009 | @param red boolean red mask 2010 | @param green boolean green mask 2011 | @param blue boolean blue mask 2012 | @param alpha boolean alpha mask 2013 | **/ 2014 | function set_color_mask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void 2015 | 2016 | /** 2017 | Specifies whether front- or back-facing polygons can be culled 2018 | when polygon culling is enabled. Polygon culling is initially disabled. 2019 | If mode is render.FACE_FRONT_AND_BACK, no polygons are drawn, but other 2020 | primitives such as points and lines are drawn. The initial value for 2021 | face_type is render.FACE_BACK. 2022 | @param face_type constant face type 2023 | 2024 | render.FACE_FRONT 2025 | render.FACE_BACK 2026 | render.FACE_FRONT_AND_BACK 2027 | 2028 | **/ 2029 | function set_cull_face(face_type: any): void 2030 | 2031 | /** 2032 | Specifies the function that should be used to compare each incoming pixel 2033 | depth value with the value present in the depth buffer. 2034 | The comparison is performed only if depth testing is enabled and specifies 2035 | the conditions under which a pixel will be drawn. 2036 | Function constants: 2037 | 2038 | render.COMPARE_FUNC_NEVER (never passes) 2039 | render.COMPARE_FUNC_LESS (passes if the incoming depth value is less than the stored value) 2040 | render.COMPARE_FUNC_LEQUAL (passes if the incoming depth value is less than or equal to the stored value) 2041 | render.COMPARE_FUNC_GREATER (passes if the incoming depth value is greater than the stored value) 2042 | render.COMPARE_FUNC_GEQUAL (passes if the incoming depth value is greater than or equal to the stored value) 2043 | render.COMPARE_FUNC_EQUAL (passes if the incoming depth value is equal to the stored value) 2044 | render.COMPARE_FUNC_NOTEQUAL (passes if the incoming depth value is not equal to the stored value) 2045 | render.COMPARE_FUNC_ALWAYS (always passes) 2046 | 2047 | The depth function is initially set to render.COMPARE_FUNC_LESS. 2048 | @param func constant depth test function, see the description for available values 2049 | **/ 2050 | function set_depth_func(func: any): void 2051 | 2052 | /** 2053 | Specifies whether the depth buffer is enabled for writing. The supplied mask governs 2054 | if depth buffer writing is enabled (true) or disabled (false). 2055 | The mask is initially true. 2056 | @param depth boolean depth mask 2057 | **/ 2058 | function set_depth_mask(depth: boolean): void 2059 | 2060 | /** 2061 | Sets the scale and units used to calculate depth values. 2062 | If render.STATE_POLYGON_OFFSET_FILL is enabled, each fragment's depth value 2063 | is offset from its interpolated value (depending on the depth value of the 2064 | appropriate vertices). Polygon offset can be used when drawing decals, rendering 2065 | hidden-line images etc. 2066 | factor specifies a scale factor that is used to create a variable depth 2067 | offset for each polygon. The initial value is 0. 2068 | units is multiplied by an implementation-specific value to create a 2069 | constant depth offset. The initial value is 0. 2070 | The value of the offset is computed as factor × DZ + r × units 2071 | DZ is a measurement of the depth slope of the polygon which is the change in z (depth) 2072 | values divided by the change in either x or y coordinates, as you traverse a polygon. 2073 | The depth values are in window coordinates, clamped to the range [0, 1]. 2074 | r is the smallest value that is guaranteed to produce a resolvable difference. 2075 | It's value is an implementation-specific constant. 2076 | The offset is added before the depth test is performed and before the 2077 | value is written into the depth buffer. 2078 | @param factor number polygon offset factor 2079 | @param units number polygon offset units 2080 | **/ 2081 | function set_polygon_offset(factor: number, units: number): void 2082 | 2083 | /** 2084 | Sets the projection matrix to use when rendering. 2085 | @param matrix matrix4 projection matrix 2086 | **/ 2087 | function set_projection(matrix: vmath.matrix4): void 2088 | 2089 | /** 2090 | 2091 | @param render_target render_target render target to set size for 2092 | @param width number new render target width 2093 | @param height number new render target height 2094 | **/ 2095 | function set_render_target_size(render_target: any, width: number, height: number): void 2096 | 2097 | /** 2098 | Stenciling is similar to depth-buffering as it enables and disables drawing on a 2099 | per-pixel basis. First, GL drawing primitives are drawn into the stencil planes. 2100 | Second, geometry and images are rendered but using the stencil planes to mask out 2101 | where to draw. 2102 | The stencil test discards a pixel based on the outcome of a comparison between the 2103 | reference value ref and the corresponding value in the stencil buffer. 2104 | func specifies the comparison function. See the table below for values. 2105 | The initial value is render.COMPARE_FUNC_ALWAYS. 2106 | ref specifies the reference value for the stencil test. The value is clamped to 2107 | the range [0, 2n-1], where n is the number of bitplanes in the stencil buffer. 2108 | The initial value is 0. 2109 | mask is ANDed with both the reference value and the stored stencil value when the test 2110 | is done. The initial value is all 1's. 2111 | Function constant: 2112 | 2113 | render.COMPARE_FUNC_NEVER (never passes) 2114 | render.COMPARE_FUNC_LESS (passes if (ref & mask) < (stencil & mask)) 2115 | render.COMPARE_FUNC_LEQUAL (passes if (ref & mask) <= (stencil & mask)) 2116 | render.COMPARE_FUNC_GREATER (passes if (ref & mask) > (stencil & mask)) 2117 | render.COMPARE_FUNC_GEQUAL (passes if (ref & mask) >= (stencil & mask)) 2118 | render.COMPARE_FUNC_EQUAL (passes if (ref & mask) = (stencil & mask)) 2119 | render.COMPARE_FUNC_NOTEQUAL (passes if (ref & mask) != (stencil & mask)) 2120 | render.COMPARE_FUNC_ALWAYS (always passes) 2121 | 2122 | @param func constant stencil test function, see the description for available values 2123 | @param ref number reference value for the stencil test 2124 | @param mask number mask that is ANDed with both the reference value and the stored stencil value when the test is done 2125 | **/ 2126 | function set_stencil_func(func: any, ref: number, mask: number): void 2127 | 2128 | /** 2129 | The stencil mask controls the writing of individual bits in the stencil buffer. 2130 | The least significant n bits of the parameter mask, where n is the number of 2131 | bits in the stencil buffer, specify the mask. 2132 | Where a 1 bit appears in the mask, the corresponding 2133 | bit in the stencil buffer can be written. Where a 0 bit appears in the mask, 2134 | the corresponding bit in the stencil buffer is never written. 2135 | The mask is initially all 1's. 2136 | @param mask number stencil mask 2137 | **/ 2138 | function set_stencil_mask(mask: number): void 2139 | 2140 | /** 2141 | The stencil test discards a pixel based on the outcome of a comparison between the 2142 | reference value ref and the corresponding value in the stencil buffer. 2143 | To control the test, call render.set_stencil_func. 2144 | This function takes three arguments that control what happens to the stored stencil 2145 | value while stenciling is enabled. If the stencil test fails, no change is made to the 2146 | pixel's color or depth buffers, and sfail specifies what happens to the stencil buffer 2147 | contents. 2148 | Operator constants: 2149 | 2150 | render.STENCIL_OP_KEEP (keeps the current value) 2151 | render.STENCIL_OP_ZERO (sets the stencil buffer value to 0) 2152 | render.STENCIL_OP_REPLACE (sets the stencil buffer value to ref, as specified by render.set_stencil_func) 2153 | render.STENCIL_OP_INCR (increments the stencil buffer value and clamp to the maximum representable unsigned value) 2154 | render.STENCIL_OP_INCR_WRAP (increments the stencil buffer value and wrap to zero when incrementing the maximum representable unsigned value) 2155 | render.STENCIL_OP_DECR (decrements the current stencil buffer value and clamp to 0) 2156 | render.STENCIL_OP_DECR_WRAP (decrements the current stencil buffer value and wrap to the maximum representable unsigned value when decrementing zero) 2157 | render.STENCIL_OP_INVERT (bitwise inverts the current stencil buffer value) 2158 | 2159 | dppass and dpfail specify the stencil buffer actions depending on whether subsequent 2160 | depth buffer tests succeed (dppass) or fail (dpfail). 2161 | The initial value for all operators is render.STENCIL_OP_KEEP. 2162 | @param sfail constant action to take when the stencil test fails 2163 | @param dpfail constant the stencil action when the stencil test passes 2164 | @param dppass constant the stencil action when both the stencil test and the depth test pass, or when the stencil test passes and either there is no depth buffer or depth testing is not enabled 2165 | **/ 2166 | function set_stencil_op(sfail: any, dpfail: any, dppass: any): void 2167 | 2168 | /** 2169 | Sets the view matrix to use when rendering. 2170 | @param matrix matrix4 view matrix to set 2171 | **/ 2172 | function set_view(matrix: vmath.matrix4): void 2173 | 2174 | /** 2175 | Set the render viewport to the specified rectangle. 2176 | @param x number left corner 2177 | @param y number bottom corner 2178 | @param width number viewport width 2179 | @param height number viewport height 2180 | **/ 2181 | function set_viewport(x: number, y: number, width: number, height: number): void 2182 | 2183 | } 2184 | 2185 | declare namespace resource { 2186 | 2187 | let LIVEUPDATE_ENGINE_VERSION_MISMATCH: any 2188 | let LIVEUPDATE_INVALID_RESOURCE: any 2189 | let LIVEUPDATE_OK: any 2190 | let LIVEUPDATE_SCHEME_MISMATCH: any 2191 | let LIVEUPDATE_SIGNATURE_MISMATCH: any 2192 | let LIVEUPDATE_VERSION_MISMATCH: any 2193 | let TEXTURE_FORMAT_LUMINANCE: any 2194 | let TEXTURE_FORMAT_RGB: any 2195 | let TEXTURE_FORMAT_RGBA: any 2196 | let TEXTURE_TYPE_2D: any 2197 | /** 2198 | Return a reference to the Manifest that is currently loaded. 2199 | @return number reference to the Manifest that is currently loaded 2200 | **/ 2201 | function get_current_manifest(): number 2202 | 2203 | /** 2204 | Loads the resource data for a specific resource. 2205 | @param path string | hash The path to the resource 2206 | @return buffer Returns the buffer stored on disc 2207 | **/ 2208 | function load(path: string | hash): any 2209 | 2210 | /** 2211 | Sets the resource data for a specific resource 2212 | @param path string | hash The path to the resource 2213 | @param buffer buffer The buffer of precreated data, suitable for the intended resource type 2214 | **/ 2215 | function set(path: string | hash, buffer: any): void 2216 | 2217 | /** 2218 | Sets the pixel data for a specific texture. 2219 | @param path hash | string The path to the resource 2220 | @param table table A table containing info about the texture. Supported entries: 2221 | 2222 | type 2223 | number The texture type. Supported values: 2224 | 2225 | 2226 | resource.TEXTURE_TYPE_2D 2227 | 2228 | 2229 | width 2230 | number The width of the texture (in pixels) 2231 | height 2232 | number The width of the texture (in pixels) 2233 | format 2234 | number The texture format. Supported values: 2235 | 2236 | 2237 | resource.TEXTURE_FORMAT_LUMINANCE 2238 | resource.TEXTURE_FORMAT_RGB 2239 | resource.TEXTURE_FORMAT_RGBA 2240 | 2241 | @param buffer buffer The buffer of precreated pixel data 2242 | Currently, only 1 mipmap is generated. 2243 | **/ 2244 | function set_texture(path: string | hash, table: any, buffer: any): void 2245 | 2246 | /** 2247 | Create a new manifest from a buffer. The created manifest is verified 2248 | by ensuring that the manifest was signed using the bundled public/private 2249 | key-pair during the bundle process and that the manifest supports the current 2250 | running engine version. Once the manifest is verified it is stored on device. 2251 | The next time the engine starts (or is rebooted) it will look for the stored 2252 | manifest before loading resources. Storing a new manifest allows the 2253 | developer to update the game, modify existing resources, or add new 2254 | resources to the game through LiveUpdate. 2255 | @param manifest_buffer string the binary data that represents the manifest 2256 | @param callback function(self, status) the callback function 2257 | executed once the engine has attempted to store the manifest. 2258 | 2259 | self 2260 | object The current object. 2261 | status 2262 | constant the status of the store operation: 2263 | 2264 | 2265 | resource.LIVEUPATE_OK 2266 | resource.LIVEUPATE_INVALID_RESOURCE 2267 | resource.LIVEUPATE_VERSION_MISMATCH 2268 | resource.LIVEUPATE_ENGINE_VERSION_MISMATCH 2269 | resource.LIVEUPATE_SIGNATURE_MISMATCH 2270 | 2271 | **/ 2272 | function store_manifest(manifest_buffer: string, callback: any): void 2273 | 2274 | /** 2275 | add a resource to the data archive and runtime index. The resource will be verified 2276 | internally before being added to the data archive. 2277 | @param manifest_reference number The manifest to check against. 2278 | @param data string The resource data that should be stored. 2279 | @param hexdigest string The expected hash for the resource, 2280 | retrieved through collectionproxy.missing_resources. 2281 | @param callback function(self, hexdigest, status) The callback 2282 | function that is executed once the engine has been attempted to store 2283 | the resource. 2284 | 2285 | self 2286 | object The current object. 2287 | hexdigest 2288 | string The hexdigest of the resource. 2289 | status 2290 | boolean Whether or not the resource was successfully stored. 2291 | 2292 | **/ 2293 | function store_resource(manifest_reference: number, data: string, hexdigest: string, callback: any): void 2294 | 2295 | } 2296 | 2297 | declare namespace sys { 2298 | 2299 | let NETWORK_CONNECTED: any 2300 | let NETWORK_CONNECTED_CELLULAR: any 2301 | let NETWORK_DISCONNECTED: any 2302 | /** 2303 | Returns a table with application information for the requested app. 2304 | On iOS, the app_string is an url scheme for the app that is queried. Your 2305 | game needs to list the schemes that are queried in an LSApplicationQueriesSchemes array 2306 | in a custom "Info.plist". 2307 | On Android, the app_string is the package identifier for the app. 2308 | @param app_string string platform specific string with application package or query, see above for details. 2309 | @return table table with application information in the following fields: 2310 | 2311 | installed 2312 | boolean true if the application is installed, false otherwise. 2313 | 2314 | **/ 2315 | function get_application_info(app_string: string): any 2316 | 2317 | /** 2318 | Get config value from the game.project configuration file. 2319 | @param key string key to get value for. The syntax is SECTION.KEY 2320 | @return string config value as a string. nil if the config key doesn't exists 2321 | **/ 2322 | function get_config(key: string): string 2323 | 2324 | /** 2325 | Get config value from the game.project configuration file with default value 2326 | @param key string key to get value for. The syntax is SECTION.KEY 2327 | @param default_value string default value to return if the value does not exist 2328 | @return string config value as a string. default_value if the config key does not exist 2329 | **/ 2330 | function get_config(key: string, default_value: string): string 2331 | 2332 | /** 2333 | Returns the current network connectivity status 2334 | on mobile platforms. 2335 | On desktop, this function always return sys.NETWORK_CONNECTED. 2336 | @return constant network connectivity status: 2337 | 2338 | sys.NETWORK_DISCONNECTED (no network connection is found) 2339 | sys.NETWORK_CONNECTED_CELLULAR (connected through mobile cellular) 2340 | sys.NETWORK_CONNECTED (otherwise, Wifi) 2341 | 2342 | **/ 2343 | function get_connectivity(): any 2344 | 2345 | /** 2346 | Returns a table with engine information. 2347 | @return table table with engine information in the following fields: 2348 | 2349 | version 2350 | string The current Defold engine version, i.e. "1.2.96" 2351 | version_sha1 2352 | string The SHA1 for the current engine build, i.e. "0060183cce2e29dbd09c85ece83cbb72068ee050" 2353 | is_debug 2354 | boolean If the engine is a debug or release version 2355 | 2356 | **/ 2357 | function get_engine_info(): any 2358 | 2359 | /** 2360 | Returns an array of tables with information on network interfaces. 2361 | @return table an array of tables. Each table entry contain the following fields: 2362 | 2363 | name 2364 | string Interface name 2365 | address 2366 | string IP address. might be nil if not available. 2367 | mac 2368 | string Hardware MAC address. might be nil if not available. 2369 | up 2370 | boolean true if the interface is up (available to transmit and receive data), false otherwise. 2371 | running 2372 | boolean true if the interface is running, false otherwise. 2373 | 2374 | **/ 2375 | function get_ifaddrs(): any 2376 | 2377 | /** 2378 | The save-file path is operating system specific and is typically located under the user's home directory. 2379 | @param application_id string user defined id of the application, which helps define the location of the save-file 2380 | @param file_name string file-name to get path for 2381 | @return string path to save-file 2382 | **/ 2383 | function get_save_file(application_id: string, file_name: string): string 2384 | 2385 | /** 2386 | Returns a table with system information. 2387 | @return table table with system information in the following fields: 2388 | 2389 | device_model 2390 | string Only available on iOS and Android. 2391 | manufacturer 2392 | string Only available on iOS and Android. 2393 | system_name 2394 | string The system OS name: "Darwin", "Linux", "Windows", "HTML5", "Android" or "iPhone OS" 2395 | system_version 2396 | string The system OS version. 2397 | api_version 2398 | string The API version on the system. 2399 | language 2400 | string Two character ISO-639 format, i.e. "en". 2401 | device_language 2402 | string Two character ISO-639 format (i.e. "sr") and, if applicable, followed by a dash (-) and an ISO 15924 script code (i.e. "sr-Cyrl" or "sr-Latn"). Reflects the device preferred language. 2403 | territory 2404 | string Two character ISO-3166 format, i.e. "US". 2405 | gmt_offset 2406 | number The current offset from GMT (Greenwich Mean Time), in minutes. 2407 | device_ident 2408 | string "identifierForVendor" on iOS. "android_id" on Android. 2409 | ad_ident 2410 | string "advertisingIdentifier" on iOS. advertising ID provided by Google Play on Android. 2411 | ad_tracking_enabled 2412 | boolean true if ad tracking is enabled, false otherwise. 2413 | user_agent 2414 | string The HTTP user agent, i.e. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8" 2415 | 2416 | **/ 2417 | function get_sys_info(): any 2418 | 2419 | /** 2420 | If the file exists, it must have been created by sys.save to be loaded. 2421 | @param filename string file to read from 2422 | @return table lua table, which is empty if the file could not be found 2423 | **/ 2424 | function load(filename: string): any 2425 | 2426 | /** 2427 | Loads a custom resource. Specify the full filename of the resource that you want 2428 | to load. When loaded, the file data is returned as a string. 2429 | If loading fails, the function returns nil. 2430 | In order for the engine to include custom resources in the build process, you need 2431 | to specify them in the "custom_resources" key in your "game.project" settings file. 2432 | You can specify single resource files or directories. If a directory is is included 2433 | in the resource list, all files and directories in that directory is recursively 2434 | included: 2435 | For example "main/data/,assets/level_data.json". 2436 | @param filename string resource to load, full path 2437 | @return string loaded data, or nil if the resource could not be loaded 2438 | **/ 2439 | function load_resource(filename: string): string 2440 | 2441 | /** 2442 | Open URL in default application, typically a browser 2443 | @param url string url to open 2444 | @return boolean a boolean indicating if the url could be opened or not 2445 | **/ 2446 | function open_url(url: string): boolean 2447 | 2448 | /** 2449 | The table can later be loaded by sys.load. 2450 | Use sys.get_save_file to obtain a valid location for the file. 2451 | Internally, this function uses a workspace buffer sized output file sized 512kb. 2452 | This size reflects the output file size which must not exceed this limit. 2453 | Additionally, the total number of rows that any one table may contain is limited to 65536 2454 | (i.e. a 16 bit range). When tables are used to represent arrays, the values of 2455 | keys are permitted to fall within a 32 bit range, supporting sparse arrays, however 2456 | the limit on the total number of rows remains in effect. 2457 | @param filename string file to write to 2458 | @param table table lua table to save 2459 | @return boolean a boolean indicating if the table could be saved or not 2460 | **/ 2461 | function save(filename: string, table: any): boolean 2462 | 2463 | /** 2464 | Sets the host that is used to check for network connectivity against. 2465 | @param host string hostname to check against 2466 | **/ 2467 | function set_connectivity_host(host: string): void 2468 | 2469 | /** 2470 | Set the Lua error handler function. 2471 | The error handler is a function which is called whenever a lua runtime error occurs. 2472 | @param error_handler function(source, message, traceback) the function to be called on error 2473 | 2474 | source 2475 | string The runtime context of the error. Currently, this is always "lua". 2476 | message 2477 | string The source file, line number and error message. 2478 | traceback 2479 | string The stack traceback. 2480 | 2481 | **/ 2482 | function set_error_handler(error_handler: any): void 2483 | 2484 | } 2485 | 2486 | declare namespace window_ { 2487 | 2488 | let DIMMING_OFF: any 2489 | let DIMMING_ON: any 2490 | let DIMMING_UNKNOWN: any 2491 | let WINDOW_EVENT_FOCUS_GAINED: any 2492 | let WINDOW_EVENT_FOCUS_LOST: any 2493 | let WINDOW_EVENT_RESIZED: any 2494 | /** 2495 | Returns the current dimming mode set on a mobile device. 2496 | The dimming mode specifies whether or not a mobile device should dim the screen after a period without user interaction. 2497 | On platforms that does not support dimming, window.DIMMING_UNKNOWN is always returned. 2498 | @return constant The mode for screen dimming 2499 | 2500 | window.DIMMING_UNKNOWN 2501 | window.DIMMING_ON 2502 | window.DIMMING_OFF 2503 | 2504 | **/ 2505 | function get_dim_mode(): any 2506 | 2507 | /** 2508 | Sets the dimming mode on a mobile device. 2509 | The dimming mode specifies whether or not a mobile device should dim the screen after a period without user interaction. The dimming mode will only affect the mobile device while the game is in focus on the device, but not when the game is running in the background. 2510 | This function has no effect on platforms that does not support dimming. 2511 | @param mode constant The mode for screen dimming 2512 | 2513 | window.DIMMING_ON 2514 | window.DIMMING_OFF 2515 | 2516 | **/ 2517 | function set_dim_mode(mode: any): void 2518 | 2519 | /** 2520 | Sets a window event listener. 2521 | @param callback function(self, event, data) A callback which receives info about window events. Pass an empty function if you no longer wish to receive callbacks. 2522 | 2523 | self 2524 | object The calling script 2525 | event 2526 | constant The type of event. Can be one of these: 2527 | 2528 | 2529 | window.WINDOW_EVENT_FOCUS_LOST 2530 | window.WINDOW_EVENT_FOCUS_GAINED 2531 | window.WINDOW_EVENT_RESIZED 2532 | 2533 | 2534 | data 2535 | table The callback value data is a table which currently holds these values 2536 | 2537 | 2538 | number width: The width of a resize event. nil otherwise. 2539 | number height: The height of a resize event. nil otherwise. 2540 | 2541 | **/ 2542 | function set_listener(callback: any): void 2543 | 2544 | } 2545 | 2546 | declare namespace collectionfactory { 2547 | 2548 | let STATUS_LOADED: any 2549 | let STATUS_LOADING: any 2550 | let STATUS_UNLOADED: any 2551 | /** 2552 | The URL identifies the collectionfactory component that should do the spawning. 2553 | Spawning is instant, but spawned game objects get their first update calls the following frame. The supplied parameters for position, rotation and scale 2554 | will be applied to the whole collection when spawned. 2555 | Script properties in the created game objects can be overridden through 2556 | a properties-parameter table. The table should contain game object ids 2557 | (hash) as keys and property tables as values to be used when initiating each 2558 | spawned game object. 2559 | See go.property for more information on script properties. 2560 | The function returns a table that contains a key for each game object 2561 | id (hash), as addressed if the collection file was top level, and the 2562 | corresponding spawned instance id (hash) as value with a unique path 2563 | prefix added to each instance. 2564 | Calling collectionfactory.create create on a collection factory that is marked as dynamic without having loaded resources 2565 | using collectionfactory.load will synchronously load and create resources which may affect application performance. 2566 | @param url string | hash | url the collection factory component to be used 2567 | @param [position] vector3 position to assign to the newly spawned collection 2568 | @param [rotation] quaternion rotation to assign to the newly spawned collection 2569 | @param [properties] table table of script properties to propagate to any new game object instances 2570 | @param [scale] number uniform scaling to apply to the newly spawned collection (must be greater than 0). 2571 | @return table a table mapping the id:s from the collection to the new instance id:s 2572 | **/ 2573 | function create(url: string | hash | url, position?: vmath.vector3, rotation?: vmath.quaternion, properties?: any, scale?: number): any 2574 | 2575 | /** 2576 | This returns status of the collection factory. 2577 | Calling this function when the factory is not marked as dynamic loading always returns COMP_COLLECTION_FACTORY_STATUS_LOADED. 2578 | @param [url] string | hash | url the collection factory component to get status from 2579 | @return constant status of the collection factory component 2580 | 2581 | collectionfactory.STATUS_UNLOADED 2582 | collectionfactory.STATUS_LOADING 2583 | collectionfactory.STATUS_LOADED 2584 | 2585 | **/ 2586 | function get_status(url?: string | hash | url): any 2587 | 2588 | /** 2589 | Resources loaded are referenced by the collection factory component until the existing (parent) collection is destroyed or collectionfactory.unload is called. 2590 | Calling this function when the factory is not marked as dynamic loading does nothing. 2591 | @param [url] string | hash | url the collection factory component to load 2592 | @param [complete_function] function(self, url, result)) function to call when resources are loaded. 2593 | 2594 | self 2595 | object The current object. 2596 | url 2597 | url url of the collection factory component 2598 | result 2599 | boolean True if resource were loaded successfully 2600 | 2601 | **/ 2602 | function load(url?: string | hash | url, complete_function?: any): void 2603 | 2604 | /** 2605 | This decreases the reference count for each resource loaded with collectionfactory.load. If reference is zero, the resource is destroyed. 2606 | Calling this function when the factory is not marked as dynamic loading does nothing. 2607 | @param [url] string | hash | url the collection factory component to unload 2608 | **/ 2609 | function unload(url?: string | hash | url): void 2610 | 2611 | } 2612 | 2613 | declare namespace collectionproxy { 2614 | 2615 | /** 2616 | return an indexed table of missing resources for a collection proxy. Each 2617 | entry is a hexadecimal string that represents the data of the specific 2618 | resource. This representation corresponds with the filename for each 2619 | individual resource that is exported when you bundle an application with 2620 | LiveUpdate functionality. It should be considered good practise to always 2621 | check whether or not there are any missing resources in a collection proxy 2622 | before attempting to load the collection proxy. 2623 | @param collectionproxy url the collectionproxy to check for missing 2624 | resources. 2625 | @return table the missing resources 2626 | **/ 2627 | function missing_resources(collectionproxy: url): any 2628 | 2629 | } 2630 | 2631 | declare namespace physics { 2632 | 2633 | /** 2634 | Ray casts are used to test for intersections against collision objects in the physics world. 2635 | Collision objects of types kinematic, dynamic and static are tested against. Trigger objects 2636 | do not intersect with ray casts. 2637 | Which collision objects to hit is filtered by their collision groups and can be configured 2638 | through groups. 2639 | The actual ray cast will be performed during the physics-update. 2640 | 2641 | If an object is hit, the result will be reported via a ray_cast_response message. 2642 | If there is no object hit, the result will be reported via a ray_cast_missed message. 2643 | 2644 | @param from vector3 the world position of the start of the ray 2645 | @param to vector3 the world position of the end of the ray 2646 | @param groups table a lua table containing the hashed groups for which to test collisions against 2647 | @param [request_id] number a number between 0-255 that will be sent back in the response for identification, 0 by default 2648 | **/ 2649 | function ray_cast(from: vmath.vector3, to: vmath.vector3, groups: any, request_id?: number): void 2650 | 2651 | } 2652 | 2653 | declare namespace factory { 2654 | 2655 | let STATUS_LOADED: any 2656 | let STATUS_LOADING: any 2657 | let STATUS_UNLOADED: any 2658 | /** 2659 | The URL identifies which factory should create the game object. 2660 | If the game object is created inside of the frame (e.g. from an update callback), the game object will be created instantly, but none of its component will be updated in the same frame. 2661 | Properties defined in scripts in the created game object can be overridden through the properties-parameter below. 2662 | See go.property for more information on script properties. 2663 | Calling factory.create on a factory that is marked as dynamic without having loaded resources 2664 | using factory.load will synchronously load and create resources which may affect application performance. 2665 | @param url string | hash | url the factory that should create a game object. 2666 | @param [position] vector3 the position of the new game object, the position of the game object calling factory.create() is used by default, or if the value is nil. 2667 | @param [rotation] quaternion the rotation of the new game object, the rotation of the game object calling factory.create() is is used by default, or if the value is nil. 2668 | @param [properties] table the properties defined in a script attached to the new game object. 2669 | @param [scale] number | vector3 the scale of the new game object (must be greater than 0), the scale of the game object containing the factory is used by default, or if the value is nil 2670 | @return hash the global id of the spawned game object 2671 | **/ 2672 | function create(url: string | hash | url, position?: vmath.vector3, rotation?: vmath.quaternion, properties?: any, scale?: number | vmath.vector3): hash 2673 | 2674 | /** 2675 | This returns status of the factory. 2676 | Calling this function when the factory is not marked as dynamic loading always returns 2677 | factory.STATUS_LOADED. 2678 | @param [url] string | hash | url the factory component to get status from 2679 | @return constant status of the factory component 2680 | 2681 | factory.STATUS_UNLOADED 2682 | factory.STATUS_LOADING 2683 | factory.STATUS_LOADED 2684 | 2685 | **/ 2686 | function get_status(url?: string | hash | url): any 2687 | 2688 | /** 2689 | Resources are referenced by the factory component until the existing (parent) collection is destroyed or factory.unload is called. 2690 | Calling this function when the factory is not marked as dynamic loading does nothing. 2691 | @param [url] string | hash | url the factory component to load 2692 | @param [complete_function] function(self, url, result)) function to call when resources are loaded. 2693 | 2694 | self 2695 | object The current object. 2696 | url 2697 | url url of the factory component 2698 | result 2699 | boolean True if resources were loaded successfully 2700 | 2701 | **/ 2702 | function load(url?: string | hash | url, complete_function?: any): void 2703 | 2704 | /** 2705 | This decreases the reference count for each resource loaded with factory.load. If reference is zero, the resource is destroyed. 2706 | Calling this function when the factory is not marked as dynamic loading does nothing. 2707 | @param [url] string | hash | url the factory component to unload 2708 | **/ 2709 | function unload(url?: string | hash | url): void 2710 | 2711 | } 2712 | 2713 | declare namespace label { 2714 | 2715 | /** 2716 | Gets the text metrics from a label component 2717 | @param url string | hash | url the label to get the (unscaled) metrics from 2718 | @return table a table with the following fields: 2719 | 2720 | width 2721 | height 2722 | max_ascent 2723 | max_descent 2724 | 2725 | function init(self) 2726 | local metrics = label.get_text_metrics("#label") 2727 | pprint(metrics) 2728 | end 2729 | 2730 | **/ 2731 | function get_text_metrics(url: string | hash | url): any 2732 | 2733 | /** 2734 | Sets the text of a label component 2735 | @param url string | hash | url the label that should have a constant set 2736 | @param text string the text 2737 | **/ 2738 | function set_text(url: string | hash | url, text: string): void 2739 | 2740 | } 2741 | 2742 | declare namespace model { 2743 | 2744 | /** 2745 | Cancels all animation on a model component. 2746 | @param url string | hash | url the model for which to cancel the animation 2747 | **/ 2748 | function cancel(url: string | hash | url): void 2749 | 2750 | /** 2751 | Gets the id of the game object that corresponds to a model skeleton bone. 2752 | The returned game object can be used for parenting and transform queries. 2753 | This function has complexity O(n), where n is the number of bones in the model skeleton. 2754 | Game objects corresponding to a model skeleton bone can not be individually deleted. 2755 | @param url string | hash | url the model to query 2756 | @param bone_id string | hash id of the corresponding bone 2757 | @return hash id of the game object 2758 | **/ 2759 | function get_go(url: string | hash | url, bone_id: string | hash): hash 2760 | 2761 | /** 2762 | Plays an animation on a model component with specified playback 2763 | mode and parameters. 2764 | An optional completion callback function can be provided that will be called when 2765 | the animation has completed playing. If no function is provided, 2766 | a model_animation_done message is sent to the script that started the animation. 2767 | The callback is not called (or message sent) if the animation is 2768 | cancelled with model.cancel. The callback is called (or message sent) only for 2769 | animations that play with the following playback modes: 2770 | 2771 | go.PLAYBACK_ONCE_FORWARD 2772 | go.PLAYBACK_ONCE_BACKWARD 2773 | go.PLAYBACK_ONCE_PINGPONG 2774 | 2775 | @param url string | hash | url the model for which to play the animation 2776 | @param anim_id string | hash id of the animation to play 2777 | @param playback constant playback mode of the animation 2778 | 2779 | go.PLAYBACK_ONCE_FORWARD 2780 | go.PLAYBACK_ONCE_BACKWARD 2781 | go.PLAYBACK_ONCE_PINGPONG 2782 | go.PLAYBACK_LOOP_FORWARD 2783 | go.PLAYBACK_LOOP_BACKWARD 2784 | go.PLAYBACK_LOOP_PINGPONG 2785 | 2786 | @param [play_properties] table optional table with properties 2787 | Play properties table: 2788 | 2789 | blend_duration 2790 | number Duration of a linear blend between the current and new animation. 2791 | offset 2792 | number The normalized initial value of the animation cursor when the animation starts playing. 2793 | playback_rate 2794 | number The rate with which the animation will be played. Must be positive. 2795 | 2796 | @param [complete_function] function(self, message_id, message, sender)) function to call when the animation has completed. 2797 | 2798 | self 2799 | object The current object. 2800 | message_id 2801 | hash The name of the completion message, "model_animation_done". 2802 | message 2803 | table Information about the completion: 2804 | 2805 | 2806 | hash animation_id - the animation that was completed. 2807 | constant playback - the playback mode for the animation. 2808 | 2809 | 2810 | sender 2811 | url The invoker of the callback: the model component. 2812 | 2813 | **/ 2814 | function play_anim(url: string | hash | url, anim_id: string | hash, playback: any, play_properties?: any, complete_function?: any): void 2815 | 2816 | /** 2817 | Resets a shader constant for a model component. 2818 | The constant must be defined in the material assigned to the model. 2819 | Resetting a constant through this function implies that the value defined in the material will be used. 2820 | Which model to reset a constant for is identified by the URL. 2821 | @param url string | hash | url the model that should have a constant reset. 2822 | @param constant string | hash name of the constant. 2823 | **/ 2824 | function reset_constant(url: string | hash | url, constant: string | hash): void 2825 | 2826 | /** 2827 | Sets a shader constant for a model component. 2828 | The constant must be defined in the material assigned to the model. 2829 | Setting a constant through this function will override the value set for that constant in the material. 2830 | The value will be overridden until model.reset_constant is called. 2831 | Which model to set a constant for is identified by the URL. 2832 | @param url string | hash | url the model that should have a constant set 2833 | @param constant string | hash name of the constant 2834 | @param value vector4 value of the constant 2835 | **/ 2836 | function set_constant(url: string | hash | url, constant: string | hash, value: vmath.vector4): void 2837 | 2838 | } 2839 | 2840 | declare namespace particlefx { 2841 | 2842 | let EMITTER_STATE_POSTSPAWN: any 2843 | let EMITTER_STATE_PRESPAWN: any 2844 | let EMITTER_STATE_SLEEPING: any 2845 | let EMITTER_STATE_SPAWNING: any 2846 | /** 2847 | Starts playing a particle FX component. 2848 | Particle FX started this way need to be manually stopped through particlefx.stop(). 2849 | Which particle FX to play is identified by the URL. 2850 | @param url string | hash | url the particle fx that should start playing. 2851 | @param [emitter_state_function] function(self, id, emitter, state) optional callback function that will be called when an emitter attached to this particlefx changes state. 2852 | 2853 | self 2854 | object The current object 2855 | id 2856 | hash The id of the particle fx component 2857 | emitter 2858 | hash The id of the emitter 2859 | state 2860 | constant the new state of the emitter: 2861 | 2862 | 2863 | particlefx.EMITTER_STATE_SLEEPING 2864 | particlefx.EMITTER_STATE_PRESPAWN 2865 | particlefx.EMITTER_STATE_SPAWNING 2866 | particlefx.EMITTER_STATE_POSTSPAWN 2867 | 2868 | **/ 2869 | function play(url: string | hash | url, emitter_state_function?: any): void 2870 | 2871 | /** 2872 | Resets a shader constant for a particle FX component emitter. 2873 | The constant must be defined in the material assigned to the emitter. 2874 | Resetting a constant through this function implies that the value defined in the material will be used. 2875 | Which particle FX to reset a constant for is identified by the URL. 2876 | @param url string | hash | url the particle FX that should have a constant reset 2877 | @param emitter string | hash the id of the emitter 2878 | @param constant string | hash the name of the constant 2879 | **/ 2880 | function reset_constant(url: string | hash | url, emitter: string | hash, constant: string | hash): void 2881 | 2882 | /** 2883 | Sets a shader constant for a particle FX component emitter. 2884 | The constant must be defined in the material assigned to the emitter. 2885 | Setting a constant through this function will override the value set for that constant in the material. 2886 | The value will be overridden until particlefx.reset_constant is called. 2887 | Which particle FX to set a constant for is identified by the URL. 2888 | @param url string | hash | url the particle FX that should have a constant set 2889 | @param emitter string | hash the id of the emitter 2890 | @param constant string | hash the name of the constant 2891 | @param value vector4 the value of the constant 2892 | **/ 2893 | function set_constant(url: string | hash | url, emitter: string | hash, constant: string | hash, value: vmath.vector4): void 2894 | 2895 | /** 2896 | Stops a particle FX component from playing. 2897 | Stopping a particle FX does not remove already spawned particles. 2898 | Which particle FX to stop is identified by the URL. 2899 | @param url string | hash | url the particle fx that should stop playing 2900 | **/ 2901 | function stop(url: string | hash | url): void 2902 | 2903 | } 2904 | 2905 | declare namespace sound { 2906 | 2907 | /** 2908 | Get mixer group gain 2909 | Note that gain is in linear scale, between 0 and 1. 2910 | To get the dB value from the gain, use the formula 20 * log(gain). 2911 | Inversely, to find the linear value from a dB value, use the formula 2912 | 10db/20. 2913 | @param group string | hash group name 2914 | @return number gain in linear scale 2915 | **/ 2916 | function get_group_gain(group: string | hash): number 2917 | 2918 | /** 2919 | Get a mixer group name as a string. 2920 | This function is to be used for debugging and 2921 | development tooling only. The function does a reverse hash lookup, which does not 2922 | return a proper string value when the game is built in release mode. 2923 | @param group string | hash group name 2924 | @return string group name 2925 | **/ 2926 | function get_group_name(group: string | hash): string 2927 | 2928 | /** 2929 | Get a table of all mixer group names (hashes). 2930 | @return table table of mixer group names 2931 | **/ 2932 | function get_groups(): any 2933 | 2934 | /** 2935 | Get peak value from mixer group. 2936 | Note that gain is in linear scale, between 0 and 1. 2937 | To get the dB value from the gain, use the formula 20 * log(gain). 2938 | Inversely, to find the linear value from a dB value, use the formula 2939 | 10db/20. 2940 | Also note that the returned value might be an approximation and in particular 2941 | the effective window might be larger than specified. 2942 | @param group string | hash group name 2943 | @param window number window length in seconds 2944 | @return number peak value for left channel 2945 | @return number peak value for right channel 2946 | **/ 2947 | function get_peak(group: string | hash, window: number): number 2948 | 2949 | /** 2950 | Get RMS (Root Mean Square) value from mixer group. This value is the 2951 | square root of the mean (average) value of the squared function of 2952 | the instantaneous values. 2953 | For instance: for a sinewave signal with a peak gain of -1.94 dB (0.8 linear), 2954 | the RMS is 0.8 × 1/sqrt(2) which is about 0.566. 2955 | Note the returned value might be an approximation and in particular 2956 | the effective window might be larger than specified. 2957 | @param group string | hash group name 2958 | @param window number window length in seconds 2959 | @return number RMS value for left channel 2960 | @return number RMS value for right channel 2961 | **/ 2962 | function get_rms(group: string | hash, window: number): number 2963 | 2964 | /** 2965 | Checks if background music is playing, e.g. from iTunes. 2966 | On non mobile platforms, 2967 | this function always return false. 2968 | @return boolean true if music is playing, otherwise false. 2969 | **/ 2970 | function is_music_playing(): boolean 2971 | 2972 | /** 2973 | Checks if a phone call is active. If there is an active phone call all 2974 | other sounds will be muted until the phone call is finished. 2975 | On non mobile platforms, 2976 | this function always return false. 2977 | @return boolean true if there is an active phone call, false otherwise. 2978 | **/ 2979 | function is_phone_call_active(): boolean 2980 | 2981 | /** 2982 | Make the sound component play its sound. Multiple voices is supported. The limit is set to 32 voices per sound component. 2983 | Note that gain is in linear scale, between 0 and 1. 2984 | To get the dB value from the gain, use the formula 20 * log(gain). 2985 | Inversely, to find the linear value from a dB value, use the formula 2986 | 10db/20. 2987 | @param url string | hash | url the sound that should play 2988 | @param [play_properties] 2989 | table optional table with properties: 2990 | delay 2991 | number delay in seconds before the sound starts playing, default is 0. 2992 | gain 2993 | number sound gain between 0 and 1, default is 1. The final gain of the sound will be a combination of this gain, the group gain and the master gain. 2994 | 2995 | **/ 2996 | function play(url: string | hash | url, play_properties?: any): void 2997 | 2998 | /** 2999 | Set gain on all active playing voices of a sound. 3000 | Note that gain is in linear scale, between 0 and 1. 3001 | To get the dB value from the gain, use the formula 20 * log(gain). 3002 | Inversely, to find the linear value from a dB value, use the formula 3003 | 10db/20. 3004 | @param url string | hash | url the sound to set the gain of 3005 | @param [gain] number sound gain between 0 and 1. The final gain of the sound will be a combination of this gain, the group gain and the master gain. 3006 | **/ 3007 | function set_gain(url: string | hash | url, gain?: number): void 3008 | 3009 | /** 3010 | Set mixer group gain 3011 | Note that gain is in linear scale, between 0 and 1. 3012 | To get the dB value from the gain, use the formula 20 * log(gain). 3013 | Inversely, to find the linear value from a dB value, use the formula 3014 | 10db/20. 3015 | @param group string | hash group name 3016 | @param gain number gain in linear scale 3017 | **/ 3018 | function set_group_gain(group: string | hash, gain: number): void 3019 | 3020 | /** 3021 | Stop playing all active voices 3022 | @param url string | hash | url the sound that should stop 3023 | **/ 3024 | function stop(url: string | hash | url): void 3025 | 3026 | } 3027 | 3028 | declare namespace spine { 3029 | 3030 | /** 3031 | Cancels all running animations on a specified spine model component. 3032 | @param url string | hash | url the spine model for which to cancel the animation 3033 | **/ 3034 | function cancel(url: string | hash | url): void 3035 | 3036 | /** 3037 | Returns the id of the game object that corresponds to a specified skeleton bone. 3038 | The returned game object can be used for parenting and transform queries. 3039 | This function has complexity O(n), where n is the number of bones in the spine model skeleton. 3040 | Game objects corresponding to a spine model skeleton bone can not be individually deleted. 3041 | @param url string | hash | url the spine model to query 3042 | @param bone_id string | hash id of the corresponding bone 3043 | @return hash id of the game object 3044 | **/ 3045 | function get_go(url: string | hash | url, bone_id: string | hash): hash 3046 | 3047 | /** 3048 | Plays a specified animation on a spine model component with specified playback 3049 | mode and parameters. 3050 | An optional completion callback function can be provided that will be called when 3051 | the animation has completed playing. If no function is provided, 3052 | a spine_animation_done message is sent to the script that started the animation. 3053 | The callback is not called (or message sent) if the animation is 3054 | cancelled with spine.cancel. The callback is called (or message sent) only for 3055 | animations that play with the following playback modes: 3056 | 3057 | go.PLAYBACK_ONCE_FORWARD 3058 | go.PLAYBACK_ONCE_BACKWARD 3059 | go.PLAYBACK_ONCE_PINGPONG 3060 | 3061 | @param url string | hash | url the spine model for which to play the animation 3062 | @param anim_id string | hash id of the animation to play 3063 | @param playback constant playback mode of the animation 3064 | 3065 | go.PLAYBACK_ONCE_FORWARD 3066 | go.PLAYBACK_ONCE_BACKWARD 3067 | go.PLAYBACK_ONCE_PINGPONG 3068 | go.PLAYBACK_LOOP_FORWARD 3069 | go.PLAYBACK_LOOP_BACKWARD 3070 | go.PLAYBACK_LOOP_PINGPONG 3071 | 3072 | @param [play_properties] table optional table with properties: 3073 | 3074 | blend_duration 3075 | number duration of a linear blend between the current and new animation. 3076 | offset 3077 | number the normalized initial value of the animation cursor when the animation starts playing. 3078 | playback_rate 3079 | number the rate with which the animation will be played. Must be positive. 3080 | 3081 | @param [complete_function] function(self, message_id, message, sender)) function to call when the animation has completed. 3082 | 3083 | self 3084 | object The current object. 3085 | message_id 3086 | hash The name of the completion message, "spine_animation_done". 3087 | message 3088 | table Information about the completion: 3089 | 3090 | 3091 | hash animation_id - the animation that was completed. 3092 | constant playback - the playback mode for the animation. 3093 | 3094 | 3095 | sender 3096 | url The invoker of the callback: the spine model component. 3097 | 3098 | **/ 3099 | function play_anim(url: string | hash | url, anim_id: string | hash, playback: any, play_properties?: any, complete_function?: any): void 3100 | 3101 | /** 3102 | Resets a shader constant for a spine model component. 3103 | The constant must be defined in the material assigned to the spine model. 3104 | Resetting a constant through this function implies that the value defined in the material will be used. 3105 | Which spine model to reset a constant for is identified by the URL. 3106 | @param url string | hash | url the spine model that should have a constant reset 3107 | @param constant string | hash name of the constant 3108 | **/ 3109 | function reset_constant(url: string | hash | url, constant: string | hash): void 3110 | 3111 | /** 3112 | Resets any previously set IK target of a spine model, the position will be reset 3113 | to the original position from the spine scene. 3114 | @param url string | hash | url the spine model containing the object 3115 | @param ik_constraint_id string | hash id of the corresponding IK constraint object 3116 | **/ 3117 | function reset_ik_target(url: string | hash | url, ik_constraint_id: string | hash): void 3118 | 3119 | /** 3120 | Sets a shader constant for a spine model component. 3121 | The constant must be defined in the material assigned to the spine model. 3122 | Setting a constant through this function will override the value set for that constant in the material. 3123 | The value will be overridden until spine.reset_constant is called. 3124 | Which spine model to set a constant for is identified by the URL. 3125 | @param url string | hash | url the spine model that should have a constant set 3126 | @param constant string | hash name of the constant 3127 | @param value vector4 value of the constant 3128 | **/ 3129 | function set_constant(url: string | hash | url, constant: string | hash, value: vmath.vector4): void 3130 | 3131 | /** 3132 | Sets a game object as target position of an inverse kinematic (IK) object. As the 3133 | target game object's position is updated, the constraint object is updated with the 3134 | new position. 3135 | @param url string | hash | url the spine model containing the object 3136 | @param ik_constraint_id string | hash id of the corresponding IK constraint object 3137 | @param target_url string | hash | url target game object 3138 | **/ 3139 | function set_ik_target(url: string | hash | url, ik_constraint_id: string | hash, target_url: string | hash | url): void 3140 | 3141 | /** 3142 | Sets a static (vector3) target position of an inverse kinematic (IK) object. 3143 | @param url string | hash | url the spine model containing the object 3144 | @param ik_constraint_id string | hash id of the corresponding IK constraint object 3145 | @param position vector3 target position 3146 | **/ 3147 | function set_ik_target_position(url: string | hash | url, ik_constraint_id: string | hash, position: vmath.vector3): void 3148 | 3149 | /** 3150 | Sets the spine skin on a spine model. 3151 | @param url string | hash | url the spine model for which to set skin 3152 | @param spine_skin string | hash spine skin id 3153 | @param [spine_slot] string | hash optional slot id to only change a specific slot 3154 | **/ 3155 | function set_skin(url: string | hash | url, spine_skin: string | hash, spine_slot?: string | hash): void 3156 | 3157 | } 3158 | 3159 | declare namespace sprite { 3160 | 3161 | /** 3162 | Play an animation on a sprite component from its tile set 3163 | An optional completion callback function can be provided that will be called when 3164 | the animation has completed playing. If no function is provided, 3165 | a animation_done message is sent to the script that started the animation. 3166 | @param url string | hash | url the sprite that should play the animation 3167 | @param id hash name hash of the animation to play 3168 | @param [complete_function] function(self, message_id, message, sender)) function to call when the animation has completed. 3169 | 3170 | self 3171 | object The current object. 3172 | message_id 3173 | hash The name of the completion message, "animation_done". 3174 | message 3175 | table Information about the completion: 3176 | 3177 | 3178 | number current_tile - the current tile of the sprite. 3179 | hash id - id of the animation that was completed. 3180 | 3181 | 3182 | sender 3183 | url The invoker of the callback: the sprite component. 3184 | 3185 | **/ 3186 | function play_flipbook(url: string | hash | url, id: hash, complete_function?: any): void 3187 | 3188 | /** 3189 | Resets a shader constant for a sprite component. 3190 | The constant must be defined in the material assigned to the sprite. 3191 | Resetting a constant through this function implies that the value defined in the material will be used. 3192 | Which sprite to reset a constant for is identified by the URL. 3193 | @param url string | hash | url the sprite that should have a constant reset 3194 | @param constant string | hash name of the constant 3195 | **/ 3196 | function reset_constant(url: string | hash | url, constant: string | hash): void 3197 | 3198 | /** 3199 | Sets a shader constant for a sprite component. 3200 | The constant must be defined in the material assigned to the sprite. 3201 | Setting a constant through this function will override the value set for that constant in the material. 3202 | The value will be overridden until sprite.reset_constant is called. 3203 | Which sprite to set a constant for is identified by the URL. 3204 | @param url string | hash | url the sprite that should have a constant set 3205 | @param constant string | hash name of the constant 3206 | @param value vector4 of the constant 3207 | **/ 3208 | function set_constant(url: string | hash | url, constant: string | hash, value: vmath.vector4): void 3209 | 3210 | /** 3211 | Sets horizontal flipping of the provided sprite's animations. 3212 | The sprite is identified by its URL. 3213 | If the currently playing animation is flipped by default, flipping it again will make it appear like the original texture. 3214 | @param url string | hash | url the sprite that should flip its animations 3215 | @param flip boolean true if the sprite should flip its animations, false if not 3216 | **/ 3217 | function set_hflip(url: string | hash | url, flip: boolean): void 3218 | 3219 | /** 3220 | Sets vertical flipping of the provided sprite's animations. 3221 | The sprite is identified by its URL. 3222 | If the currently playing animation is flipped by default, flipping it again will make it appear like the original texture. 3223 | @param url string | hash | url the sprite that should flip its animations 3224 | @param flip boolean true if the sprite should flip its animations, false if not 3225 | **/ 3226 | function set_vflip(url: string | hash | url, flip: boolean): void 3227 | 3228 | } 3229 | 3230 | declare namespace tilemap { 3231 | 3232 | /** 3233 | Get the bounds for a tile map. This function returns multiple values: 3234 | The lower left corner index x and y coordinates (1-indexed), 3235 | the tile map width and the tile map height. 3236 | The resulting values take all tile map layers into account, meaning that 3237 | the bounds are calculated as if all layers were collapsed into one. 3238 | @param url string | hash | url the tile map 3239 | @return number x coordinate of the bottom left corner 3240 | @return number y coordinate of the bottom left corner 3241 | @return number number of columns (width) in the tile map 3242 | @return number number of rows (height) in the tile map 3243 | **/ 3244 | function get_bounds(url: string | hash | url): number 3245 | 3246 | /** 3247 | Get the tile set at the specified position in the tilemap. 3248 | The position is identified by the tile index starting at origo 3249 | with index 1, 1. (see tilemap.set_tile()) 3250 | Which tile map and layer to query is identified by the URL and the 3251 | layer name parameters. 3252 | @param url string | hash | url the tile map 3253 | @param layer string | hash name of the layer for the tile 3254 | @param x number x-coordinate of the tile 3255 | @param y number y-coordinate of the tile 3256 | @return number index of the tile 3257 | **/ 3258 | function get_tile(url: string | hash | url, layer: string | hash, x: number, y: number): number 3259 | 3260 | /** 3261 | Resets a shader constant for a tile map component. 3262 | The constant must be defined in the material assigned to the tile map. 3263 | Resetting a constant through this function implies that the value defined in the material will be used. 3264 | Which tile map to reset a constant for is identified by the URL. 3265 | @param url string | hash | url the tile map that should have a constant reset 3266 | @param constant string | hash name of the constant 3267 | **/ 3268 | function reset_constant(url: string | hash | url, constant: string | hash): void 3269 | 3270 | /** 3271 | Sets a shader constant for a tile map component. 3272 | The constant must be defined in the material assigned to the tile map. 3273 | Setting a constant through this function will override the value set for that constant in the material. 3274 | The value will be overridden until tilemap.reset_constant is called. 3275 | Which tile map to set a constant for is identified by the URL. 3276 | @param url string | hash | url the tile map that should have a constant set 3277 | @param constant string | hash name of the constant 3278 | @param value vector4 value of the constant 3279 | **/ 3280 | function set_constant(url: string | hash | url, constant: string | hash, value: vmath.vector4): void 3281 | 3282 | /** 3283 | Replace a tile in a tile map with a new tile. 3284 | The coordinates of the tiles are indexed so that the "first" tile just 3285 | above and to the right of origo has coordinates 1,1. 3286 | Tiles to the left of and below origo are indexed 0, -1, -2 and so forth. 3287 | 3288 | +-------+-------+------+------+ 3289 | | 0,3 | 1,3 | 2,3 | 3,3 | 3290 | +-------+-------+------+------+ 3291 | | 0,2 | 1,2 | 2,2 | 3,2 | 3292 | +-------+-------+------+------+ 3293 | | 0,1 | 1,1 | 2,1 | 3,1 | 3294 | +-------O-------+------+------+ 3295 | | 0,0 | 1,0 | 2,0 | 3,0 | 3296 | +-------+-------+------+------+ 3297 | 3298 | 3299 | The coordinates must be within the bounds of the tile map as it were created. 3300 | That is, it is not possible to extend the size of a tile map by setting tiles outside the edges. 3301 | To clear a tile, set the tile to number 0. Which tile map and layer to manipulate is identified by the URL and the layer name parameters. 3302 | @param url string | hash | url the tile map 3303 | @param layer string | hash name of the layer for the tile 3304 | @param x number x-coordinate of the tile 3305 | @param y number y-coordinate of the tile 3306 | @param tile number index of new tile to set 3307 | @param [h-flipped] boolean optional if the tile should be horizontally flipped 3308 | @param [v-flipped] boolean optional i the tile should be vertically flipped 3309 | **/ 3310 | function set_tile(url: string | hash | url, layer: string | hash, x: number, y: number, tile: number, h_flipped?: boolean, v_flipped?: boolean): void 3311 | 3312 | } 3313 | 3314 | declare namespace buffer { 3315 | 3316 | let VALUE_TYPE_FLOAT32: any 3317 | let VALUE_TYPE_INT16: any 3318 | let VALUE_TYPE_INT32: any 3319 | let VALUE_TYPE_INT64: any 3320 | let VALUE_TYPE_INT8: any 3321 | let VALUE_TYPE_UINT16: any 3322 | let VALUE_TYPE_UINT32: any 3323 | let VALUE_TYPE_UINT64: any 3324 | let VALUE_TYPE_UINT8: any 3325 | /** 3326 | Copy all data streams from one buffer to another, element wise. 3327 | Each of the source streams must have a matching stream in the 3328 | destination buffer. The streams must match in both type and size. 3329 | The source and destination buffer can be the same. 3330 | @param dst buffer the destination buffer 3331 | @param dstoffset number the offset to start copying data to 3332 | @param src buffer the source data buffer 3333 | @param srcoffset number the offset to start copying data from 3334 | @param count number the number of elements to copy 3335 | **/ 3336 | function copy_buffer(dst: any, dstoffset: number, src: any, srcoffset: number, count: number): void 3337 | 3338 | /** 3339 | Copy a specified amount of data from one stream to another. 3340 | The value type and size must match between source and destination streams. 3341 | The source and destination streams can be the same. 3342 | @param dst bufferstream the destination stream 3343 | @param dstoffset number the offset to start copying data to (measured in value type) 3344 | @param src bufferstream the source data stream 3345 | @param srcoffset number the offset to start copying data from (measured in value type) 3346 | @param count number the number of values to copy (measured in value type) 3347 | **/ 3348 | function copy_stream(dst: any, dstoffset: number, src: any, srcoffset: number, count: number): void 3349 | 3350 | /** 3351 | Create a new data buffer containing a specified set of streams. A data buffer 3352 | can contain one or more streams with typed data. This is useful for managing 3353 | compound data, for instance a vertex buffer could contain separate streams for 3354 | vertex position, color, normal etc. 3355 | @param element_count number The number of elements the buffer should hold 3356 | @param declaration table A table where each entry (table) describes a stream 3357 | 3358 | hash | string name: The name of the stream 3359 | constant type: The data type of the stream 3360 | number count: The number of values each element should hold 3361 | 3362 | **/ 3363 | function create(element_count: number, declaration: any): void 3364 | 3365 | /** 3366 | Get a copy of all the bytes from a specified stream as a Lua string. 3367 | @param buffer buffer the source buffer 3368 | @param stream_name hash the name of the stream 3369 | @return string the buffer data as a Lua string 3370 | **/ 3371 | function get_bytes(buffer: any, stream_name: hash): string 3372 | 3373 | /** 3374 | Get a specified stream from a buffer. 3375 | @param buffer buffer the buffer to get the stream from 3376 | @param stream_name hash | string the stream name 3377 | @return bufferstream the data stream 3378 | **/ 3379 | function get_stream(buffer: any, stream_name: string | hash): any 3380 | 3381 | } 3382 | 3383 | declare namespace html5 { 3384 | 3385 | /** 3386 | Executes the supplied string as JavaScript inside the browser. 3387 | A call to this function is blocking, the result is returned as-is, as a string. 3388 | (Internally this will execute the string using the eval() JavaScript function.) 3389 | @param code string Javascript code to run 3390 | @return string result as string 3391 | **/ 3392 | function run(code: string): string 3393 | 3394 | } 3395 | 3396 | declare namespace http { 3397 | 3398 | /** 3399 | Perform a HTTP/HTTPS request. 3400 | If no timeout value is passed, the configuration value "network.http_timeout" is used. If that is not set, the timeout value is 0 (which blocks indefinitely). 3401 | @param url string target url 3402 | @param method string HTTP/HTTPS method, e.g. "GET", "PUT", "POST" etc. 3403 | @param callback function(self, id, response) response callback function 3404 | 3405 | self 3406 | object The current object 3407 | id 3408 | hash Internal message identifier. Do not use! 3409 | response 3410 | table The response data. Contains the fields: 3411 | 3412 | 3413 | number status: the status of the response 3414 | string response: the response data 3415 | table headers: all the returned headers 3416 | 3417 | @param [headers] table optional table with custom headers 3418 | @param [post_data] string optional data to send 3419 | @param [options] table optional table with request parameters. Supported entries: 3420 | 3421 | number timeout: timeout in seconds 3422 | 3423 | **/ 3424 | function request(url: string, method: string, callback: any, headers?: any, post_data?: string, options?: any): void 3425 | 3426 | } 3427 | 3428 | declare namespace image { 3429 | 3430 | let TYPE_LUMINANCE: any 3431 | let TYPE_RGB: any 3432 | let TYPE_RGBA: any 3433 | /** 3434 | Load image (PNG or JPEG) from buffer. 3435 | @param buffer string image data buffer 3436 | @param [premult] boolean optional flag if alpha should be premultiplied. Defaults to false 3437 | @return table object or nil if loading fails. The object is a table with the following fields: 3438 | 3439 | number width: image width 3440 | number height: image height 3441 | constant type: image type 3442 | image.TYPE_RGB 3443 | image.TYPE_RGBA 3444 | image.TYPE_LUMINANCE 3445 | 3446 | 3447 | string buffer: the raw image data 3448 | 3449 | **/ 3450 | function load(buffer: string, premult?: boolean): any 3451 | 3452 | } 3453 | 3454 | declare namespace json { 3455 | 3456 | /** 3457 | Decode a string of JSON data into a Lua table. 3458 | A Lua error is raised for syntax errors. 3459 | @param json string json data 3460 | @return table decoded json 3461 | **/ 3462 | function decode(json: string): any 3463 | 3464 | } 3465 | 3466 | declare namespace msg { 3467 | 3468 | /** 3469 | Post a message to a receiving URL. The most common case is to send messages 3470 | to a component. If the component part of the receiver is omitted, the message 3471 | is broadcast to all components in the game object. 3472 | The following receiver shorthands are available: 3473 | 3474 | "." the current game object 3475 | "#" the current component 3476 | 3477 | There is a 2 kilobyte limit to the message parameter table size. 3478 | @param receiver string | url | hash | nil The receiver must be a string in URL-format, a URL object, a hashed string or nil. 3479 | @param message_id string | hash The id must be a string or a hashed string. 3480 | @param [message] table a lua table with message parameters to send. 3481 | **/ 3482 | function post(receiver: string | hash | url, message_id: string | hash, message?: any): void 3483 | 3484 | /** 3485 | This is equivalent to msg.url(nil) or msg.url("#"), which creates an url to the current 3486 | script component. 3487 | @return url a new URL 3488 | **/ 3489 | function url(): url 3490 | 3491 | /** 3492 | The format of the string must be [socket:][path][#fragment], which is similar to a HTTP URL. 3493 | When addressing instances: 3494 | 3495 | socket is the name of a valid world (a collection) 3496 | path is the id of the instance, which can either be relative the instance of the calling script or global 3497 | fragment would be the id of the desired component 3498 | 3499 | In addition, the following shorthands are available: 3500 | 3501 | "." the current game object 3502 | "#" the current component 3503 | 3504 | @param urlstring string string to create the url from 3505 | @return url a new URL 3506 | **/ 3507 | function url(urlstring: string): url 3508 | 3509 | /** 3510 | 3511 | @param [socket] string | hash socket of the URL 3512 | @param [path] string | hash path of the URL 3513 | @param [fragment] string | hash fragment of the URL 3514 | @return url a new URL 3515 | **/ 3516 | function url(socket?: string | hash, path?: string | hash, fragment?: string | hash): url 3517 | 3518 | } 3519 | 3520 | declare namespace timer { 3521 | 3522 | let INVALID_TIMER_HANDLE: any 3523 | /** 3524 | You may cancel a timer from inside a timer callback. 3525 | Cancelling a timer that is already executed or cancelled is safe. 3526 | @param handle the timer handle returned by timer.delay() 3527 | @return if the timer was active, false if the timer is already cancelled / complete 3528 | **/ 3529 | function cancel(handle: any): any 3530 | 3531 | /** 3532 | Adds a timer and returns a unique handle 3533 | You may create more timers from inside a timer callback. 3534 | Using a delay of 0 will result in a timer that triggers at the next frame just before 3535 | script update functions. 3536 | If you want a timer that triggers on each frame, set delay to 0.0f and repeat to true. 3537 | Timers created within a script will automatically die when the script is deleted. 3538 | @param delay time interval in seconds 3539 | @param repeat true = repeat timer until cancel, false = one-shot timer 3540 | @param callback function(self, handle, time_elapsed) timer callback function 3541 | 3542 | self 3543 | object The current object 3544 | handle 3545 | number The handle of the timer 3546 | time_elapsed 3547 | number The elapsed time - on first trigger it is time since timer.delay call, otherwise time since last trigger 3548 | 3549 | @return identifier for the create timer, returns timer.INVALID_TIMER_HANDLE if the timer can not be created 3550 | **/ 3551 | function delay(delay: any, repeat: any, callback: any): any 3552 | 3553 | } 3554 | 3555 | declare namespace vmath { 3556 | 3557 | /** 3558 | Calculates the conjugate of a quaternion. The result is a 3559 | quaternion with the same magnitudes but with the sign of 3560 | the imaginary (vector) parts changed: 3561 | q* = [w, -v] 3562 | @param q1 quatertion quaternion of which to calculate the conjugate 3563 | @return quatertion the conjugate 3564 | **/ 3565 | function conj(q1: any): any 3566 | 3567 | /** 3568 | Given two linearly independent vectors P and Q, the cross product, 3569 | P × Q, is a vector that is perpendicular to both P and Q and 3570 | therefore normal to the plane containing them. 3571 | If the two vectors have the same direction (or have the exact 3572 | opposite direction from one another, i.e. are not linearly independent) 3573 | or if either one has zero length, then their cross product is zero. 3574 | @param v1 vector3 first vector 3575 | @param v2 vector3 second vector 3576 | @return vector3 a new vector representing the cross product 3577 | **/ 3578 | function cross(v1: vmath.vector3, v2: vmath.vector3): vmath.vector3 3579 | 3580 | /** 3581 | The returned value is a scalar defined as: 3582 | P ⋅ Q = |P| |Q| cos θ 3583 | where θ is the angle between the vectors P and Q. 3584 | 3585 | If the dot product is positive then the angle between the vectors is below 90 degrees. 3586 | If the dot product is zero the vectors are perpendicular (at right-angles to each other). 3587 | If the dot product is negative then the angle between the vectors is more than 90 degrees. 3588 | 3589 | @param v1 vector3 | vector4 first vector 3590 | @param v2 vector3 | vector4 second vector 3591 | @return number dot product 3592 | **/ 3593 | function dot(v1: vmath.vector3 | vmath.vector4, v2: vmath.vector3 | vmath.vector4): number 3594 | 3595 | /** 3596 | The resulting matrix is the inverse of the supplied matrix. 3597 | For ortho-normal matrices, e.g. regular object transformation, 3598 | use vmath.ortho_inv() instead. 3599 | The specialized inverse for ortho-normalized matrices is much faster 3600 | than the general inverse. 3601 | @param m1 matrix4 matrix to invert 3602 | @return matrix4 inverse of the supplied matrix 3603 | **/ 3604 | function inv(m1: vmath.matrix4): vmath.matrix4 3605 | 3606 | /** 3607 | Returns the length of the supplied vector or quaternion. 3608 | If you are comparing the lengths of vectors or quaternions, you should compare 3609 | the length squared instead as it is slightly more efficient to calculate 3610 | (it eliminates a square root calculation). 3611 | @param v vector3 | vector4 | quat value of which to calculate the length 3612 | @return number length 3613 | **/ 3614 | function length(v: vmath.vector3 | vmath.vector4): number 3615 | 3616 | /** 3617 | Returns the squared length of the supplied vector or quaternion. 3618 | @param v vector3 | vector4 | quat value of which to calculate the squared length 3619 | @return number squared length 3620 | **/ 3621 | function length_sqr(v: vmath.vector3 | vmath.vector4): number 3622 | 3623 | /** 3624 | Linearly interpolate between two vectors. The function 3625 | treats the vectors as positions and interpolates between 3626 | the positions in a straight line. Lerp is useful to describe 3627 | transitions from one place to another over time. 3628 | The function does not clamp t between 0 and 1. 3629 | @param t number interpolation parameter, 0-1 3630 | @param v1 vector3 | vector4 vector to lerp from 3631 | @param v2 vector3 | vector4 vector to lerp to 3632 | @return vector3 | vector4 the lerped vector 3633 | **/ 3634 | function lerp(t: number, v1: vmath.vector3 | vmath.vector4, v2: vmath.vector3 | vmath.vector4): vmath.vector3 | vmath.vector4 3635 | 3636 | /** 3637 | Linearly interpolate between two quaternions. Linear 3638 | interpolation of rotations are only useful for small 3639 | rotations. For interpolations of arbitrary rotations, 3640 | vmath.slerp yields much better results. 3641 | The function does not clamp t between 0 and 1. 3642 | @param t number interpolation parameter, 0-1 3643 | @param q1 quaternion quaternion to lerp from 3644 | @param q2 quaternion quaternion to lerp to 3645 | @return quaternion the lerped quaternion 3646 | **/ 3647 | function lerp(t: number, q1: vmath.quaternion, q2: vmath.quaternion): vmath.quaternion 3648 | 3649 | /** 3650 | Linearly interpolate between two values. Lerp is useful 3651 | to describe transitions from one value to another over time. 3652 | The function does not clamp t between 0 and 1. 3653 | @param t number interpolation parameter, 0-1 3654 | @param n1 number number to lerp from 3655 | @param n2 number number to lerp to 3656 | @return number the lerped number 3657 | **/ 3658 | function lerp(t: number, n1: number, n2: number): number 3659 | 3660 | /** 3661 | The resulting identity matrix describes a transform with 3662 | no translation or rotation. 3663 | @return matrix4 identity matrix 3664 | **/ 3665 | function matrix4(): vmath.matrix4 3666 | 3667 | /** 3668 | Creates a new matrix with all components set to the 3669 | corresponding values from the supplied matrix. I.e. 3670 | the function creates a copy of the given matrix. 3671 | @param m1 matrix4 existing matrix 3672 | @return matrix4 matrix which is a copy of the specified matrix 3673 | **/ 3674 | function matrix4(m1: vmath.matrix4): vmath.matrix4 3675 | 3676 | /** 3677 | The resulting matrix describes a rotation around the axis by the specified angle. 3678 | @param v vector3 axis 3679 | @param angle number angle in radians 3680 | @return matrix4 matrix represented by axis and angle 3681 | **/ 3682 | function matrix4_axis_angle(v: vmath.vector3, angle: number): vmath.matrix4 3683 | 3684 | /** 3685 | The resulting matrix describes the same rotation as the quaternion, but does not have any translation (also like the quaternion). 3686 | @param q quaternion quaternion to create matrix from 3687 | @return matrix4 matrix represented by quaternion 3688 | **/ 3689 | function matrix4_from_quat(q: vmath.quaternion): vmath.matrix4 3690 | 3691 | /** 3692 | Constructs a frustum matrix from the given values. The left, right, 3693 | top and bottom coordinates of the view cone are expressed as distances 3694 | from the center of the near clipping plane. The near and far coordinates 3695 | are expressed as distances from the tip of the view frustum cone. 3696 | @param left number coordinate for left clipping plane 3697 | @param right number coordinate for right clipping plane 3698 | @param bottom number coordinate for bottom clipping plane 3699 | @param top number coordinate for top clipping plane 3700 | @param near number coordinate for near clipping plane 3701 | @param far number coordinate for far clipping plane 3702 | @return matrix4 matrix representing the frustum 3703 | **/ 3704 | function matrix4_frustum(left: number, right: number, bottom: number, top: number, near: number, far: number): vmath.matrix4 3705 | 3706 | /** 3707 | The resulting matrix is created from the supplied look-at parameters. 3708 | This is useful for constructing a view matrix for a camera or 3709 | rendering in general. 3710 | @param eye vector3 eye position 3711 | @param look_at vector3 look-at position 3712 | @param up vector3 up vector 3713 | @return matrix4 look-at matrix 3714 | **/ 3715 | function matrix4_look_at(eye: vmath.vector3, look_at: vmath.vector3, up: vmath.vector3): vmath.matrix4 3716 | 3717 | /** 3718 | Creates an orthographic projection matrix. 3719 | This is useful to construct a projection matrix for a camera or rendering in general. 3720 | @param left number coordinate for left clipping plane 3721 | @param right number coordinate for right clipping plane 3722 | @param bottom number coordinate for bottom clipping plane 3723 | @param top number coordinate for top clipping plane 3724 | @param near number coordinate for near clipping plane 3725 | @param far number coordinate for far clipping plane 3726 | @return matrix4 orthographic projection matrix 3727 | **/ 3728 | function matrix4_orthographic(left: number, right: number, bottom: number, top: number, near: number, far: number): vmath.matrix4 3729 | 3730 | /** 3731 | Creates a perspective projection matrix. 3732 | This is useful to construct a projection matrix for a camera or rendering in general. 3733 | @param fov number angle of the full vertical field of view in radians 3734 | @param aspect number aspect ratio 3735 | @param near number coordinate for near clipping plane 3736 | @param far number coordinate for far clipping plane 3737 | @return matrix4 perspective projection matrix 3738 | **/ 3739 | function matrix4_perspective(fov: number, aspect: number, near: number, far: number): vmath.matrix4 3740 | 3741 | /** 3742 | The resulting matrix describes a rotation around the x-axis 3743 | by the specified angle. 3744 | @param angle number angle in radians around x-axis 3745 | @return matrix4 matrix from rotation around x-axis 3746 | **/ 3747 | function matrix4_rotation_x(angle: number): vmath.matrix4 3748 | 3749 | /** 3750 | The resulting matrix describes a rotation around the y-axis 3751 | by the specified angle. 3752 | @param angle number angle in radians around y-axis 3753 | @return matrix4 matrix from rotation around y-axis 3754 | **/ 3755 | function matrix4_rotation_y(angle: number): vmath.matrix4 3756 | 3757 | /** 3758 | The resulting matrix describes a rotation around the z-axis 3759 | by the specified angle. 3760 | @param angle number angle in radians around z-axis 3761 | @return matrix4 matrix from rotation around z-axis 3762 | **/ 3763 | function matrix4_rotation_z(angle: number): vmath.matrix4 3764 | 3765 | /** 3766 | Performs an element wise multiplication between two vectors of the same type 3767 | The returned value is a vector defined as (e.g. for a vector3): 3768 | v = vmath.mul_per_elem(a, b) = vmath.vector3(a.x * b.x, a.y * b.y, a.z * b.z) 3769 | @param v1 vector3 | vector4 first vector 3770 | @param v2 vector3 | vector4 second vector 3771 | @return vector3 | vector4 multiplied vector 3772 | **/ 3773 | function mul_per_elem(v1: vmath.vector3 | vmath.vector4, v2: vmath.vector3 | vmath.vector4): vmath.vector3 | vmath.vector4 3774 | 3775 | /** 3776 | Normalizes a vector, i.e. returns a new vector with the same 3777 | direction as the input vector, but with length 1. 3778 | The length of the vector must be above 0, otherwise a 3779 | division-by-zero will occur. 3780 | @param v1 vector3 | vector4 | quat vector to normalize 3781 | @return vector3 | vector4 | quat new normalized vector 3782 | **/ 3783 | function normalize(v1: vmath.vector3 | vmath.vector4): vmath.vector3 | vmath.vector4 3784 | 3785 | /** 3786 | The resulting matrix is the inverse of the supplied matrix. 3787 | The supplied matrix has to be an ortho-normal matrix, e.g. 3788 | describe a regular object transformation. 3789 | For matrices that are not ortho-normal 3790 | use the general inverse vmath.inv() instead. 3791 | @param m1 matrix4 ortho-normalized matrix to invert 3792 | @return matrix4 inverse of the supplied matrix 3793 | **/ 3794 | function ortho_inv(m1: vmath.matrix4): vmath.matrix4 3795 | 3796 | /** 3797 | Calculates the extent the projection of the first vector onto the second. 3798 | The returned value is a scalar p defined as: 3799 | p = |P| cos θ / |Q| 3800 | where θ is the angle between the vectors P and Q. 3801 | @param v1 vector3 vector to be projected on the second 3802 | @param v2 vector3 vector onto which the first will be projected, must not have zero length 3803 | @return number the projected extent of the first vector onto the second 3804 | **/ 3805 | function project(v1: vmath.vector3, v2: vmath.vector3): number 3806 | 3807 | /** 3808 | Creates a new identity quaternion. The identity 3809 | quaternion is equal to: 3810 | vmath.quat(0, 0, 0, 1) 3811 | @return quaternion new identity quaternion 3812 | **/ 3813 | function quat(): vmath.quaternion 3814 | 3815 | /** 3816 | Creates a new quaternion with all components set to the 3817 | corresponding values from the supplied quaternion. I.e. 3818 | This function creates a copy of the given quaternion. 3819 | @param q1 quaternion existing quaternion 3820 | @return quaternion new quaternion 3821 | **/ 3822 | function quat(q1: vmath.quaternion): vmath.quaternion 3823 | 3824 | /** 3825 | Creates a new quaternion with the components set 3826 | according to the supplied parameter values. 3827 | @param x number x coordinate 3828 | @param y number y coordinate 3829 | @param z number z coordinate 3830 | @param w number w coordinate 3831 | @return quaternion new quaternion 3832 | **/ 3833 | function quat(x: number, y: number, z: number, w: number): vmath.quaternion 3834 | 3835 | /** 3836 | The resulting quaternion describes a rotation of angle 3837 | radians around the axis described by the unit vector v. 3838 | @param v vector3 axis 3839 | @param angle number angle 3840 | @return quaternion quaternion representing the axis-angle rotation 3841 | **/ 3842 | function quat_axis_angle(v: vmath.vector3, angle: number): vmath.quaternion 3843 | 3844 | /** 3845 | The resulting quaternion describes the rotation from the 3846 | identity quaternion (no rotation) to the coordinate system 3847 | as described by the given x, y and z base unit vectors. 3848 | @param x vector3 x base vector 3849 | @param y vector3 y base vector 3850 | @param z vector3 z base vector 3851 | @return quaternion quaternion representing the rotation of the specified base vectors 3852 | **/ 3853 | function quat_basis(x: vmath.vector3, y: vmath.vector3, z: vmath.vector3): vmath.quaternion 3854 | 3855 | /** 3856 | The resulting quaternion describes the rotation that, 3857 | if applied to the first vector, would rotate the first 3858 | vector to the second. The two vectors must be unit 3859 | vectors (of length 1). 3860 | The result is undefined if the two vectors point in opposite directions 3861 | @param v1 vector3 first unit vector, before rotation 3862 | @param v2 vector3 second unit vector, after rotation 3863 | @return quaternion quaternion representing the rotation from first to second vector 3864 | **/ 3865 | function quat_from_to(v1: vmath.vector3, v2: vmath.vector3): vmath.quaternion 3866 | 3867 | /** 3868 | The resulting quaternion describes a rotation of angle 3869 | radians around the x-axis. 3870 | @param angle number angle in radians around x-axis 3871 | @return quaternion quaternion representing the rotation around the x-axis 3872 | **/ 3873 | function quat_rotation_x(angle: number): vmath.quaternion 3874 | 3875 | /** 3876 | The resulting quaternion describes a rotation of angle 3877 | radians around the y-axis. 3878 | @param angle number angle in radians around y-axis 3879 | @return quaternion quaternion representing the rotation around the y-axis 3880 | **/ 3881 | function quat_rotation_y(angle: number): vmath.quaternion 3882 | 3883 | /** 3884 | The resulting quaternion describes a rotation of angle 3885 | radians around the z-axis. 3886 | @param angle number angle in radians around z-axis 3887 | @return quaternion quaternion representing the rotation around the z-axis 3888 | **/ 3889 | function quat_rotation_z(angle: number): vmath.quaternion 3890 | 3891 | /** 3892 | Returns a new vector from the supplied vector that is 3893 | rotated by the rotation described by the supplied 3894 | quaternion. 3895 | @param q quatertion quaternion 3896 | @param v1 vector3 vector to rotate 3897 | @return vector3 the rotated vector 3898 | **/ 3899 | function rotate(q: any, v1: vmath.vector3): vmath.vector3 3900 | 3901 | /** 3902 | Spherically interpolates between two vectors. The difference to 3903 | lerp is that slerp treats the vectors as directions instead of 3904 | positions in space. 3905 | The direction of the returned vector is interpolated by the angle 3906 | and the magnitude is interpolated between the magnitudes of the 3907 | from and to vectors. 3908 | Slerp is computationally more expensive than lerp. 3909 | The function does not clamp t between 0 and 1. 3910 | @param t number interpolation parameter, 0-1 3911 | @param v1 vector3 | vector4 vector to slerp from 3912 | @param v2 vector3 | vector4 vector to slerp to 3913 | @return vector3 | vector4 the slerped vector 3914 | **/ 3915 | function slerp(t: number, v1: vmath.vector3 | vmath.vector4, v2: vmath.vector3 | vmath.vector4): vmath.vector3 | vmath.vector4 3916 | 3917 | /** 3918 | Slerp travels the torque-minimal path maintaining constant 3919 | velocity, which means it travels along the straightest path along 3920 | the rounded surface of a sphere. Slerp is useful for interpolation 3921 | of rotations. 3922 | Slerp travels the torque-minimal path, which means it travels 3923 | along the straightest path the rounded surface of a sphere. 3924 | The function does not clamp t between 0 and 1. 3925 | @param t number interpolation parameter, 0-1 3926 | @param q1 quaternion quaternion to slerp from 3927 | @param q2 quaternion quaternion to slerp to 3928 | @return quaternion the slerped quaternion 3929 | **/ 3930 | function slerp(t: number, q1: vmath.quaternion, q2: vmath.quaternion): vmath.quaternion 3931 | 3932 | /** 3933 | Creates a vector of arbitrary size. The vector is initialized 3934 | with numeric values from a table. 3935 | The table values are converted to floating point 3936 | values. If a value cannot be converted, a 0 is stored in that 3937 | value position in the vector. 3938 | @param t table table of numbers 3939 | @return vector new vector 3940 | **/ 3941 | function vector(t: any): any 3942 | 3943 | /** 3944 | Creates a new zero vector with all components set to 0. 3945 | @return vector3 new zero vector 3946 | **/ 3947 | function vector3(): vmath.vector3 3948 | 3949 | /** 3950 | Creates a new vector with all components set to the 3951 | supplied scalar value. 3952 | @param n number scalar value to splat 3953 | @return vector3 new vector 3954 | **/ 3955 | function vector3(n: number): vmath.vector3 3956 | 3957 | /** 3958 | Creates a new vector with all components set to the 3959 | corresponding values from the supplied vector. I.e. 3960 | This function creates a copy of the given vector. 3961 | @param v1 vector3 existing vector 3962 | @return vector3 new vector 3963 | **/ 3964 | function vector3(v1: vmath.vector3): vmath.vector3 3965 | 3966 | /** 3967 | Creates a new vector with the components set to the 3968 | supplied values. 3969 | @param x number x coordinate 3970 | @param y number y coordinate 3971 | @param z number z coordinate 3972 | @return vector3 new vector 3973 | **/ 3974 | function vector3(x: number, y: number, z: number): vmath.vector3 3975 | 3976 | /** 3977 | Creates a new zero vector with all components set to 0. 3978 | @return vector4 new zero vector 3979 | **/ 3980 | function vector4(): vmath.vector4 3981 | 3982 | /** 3983 | Creates a new vector with all components set to the 3984 | supplied scalar value. 3985 | @param n number scalar value to splat 3986 | @return vector4 new vector 3987 | **/ 3988 | function vector4(n: number): vmath.vector4 3989 | 3990 | /** 3991 | Creates a new vector with all components set to the 3992 | corresponding values from the supplied vector. I.e. 3993 | This function creates a copy of the given vector. 3994 | @param v1 vector4 existing vector 3995 | @return vector4 new vector 3996 | **/ 3997 | function vector4(v1: vmath.vector4): vmath.vector4 3998 | 3999 | /** 4000 | Creates a new vector with the components set to the 4001 | supplied values. 4002 | @param x number x coordinate 4003 | @param y number y coordinate 4004 | @param z number z coordinate 4005 | @param w number w coordinate 4006 | @return vector4 new vector 4007 | **/ 4008 | function vector4(x: number, y: number, z: number, w: number): vmath.vector4 4009 | 4010 | } 4011 | 4012 | declare namespace zlib { 4013 | 4014 | /** 4015 | A lua error is raised is on error 4016 | @param buf string buffer to deflate 4017 | @return string deflated buffer 4018 | **/ 4019 | function deflate(buf: string): string 4020 | 4021 | /** 4022 | A lua error is raised is on error 4023 | @param buf string buffer to inflate 4024 | @return string inflated buffer 4025 | **/ 4026 | function inflate(buf: string): string 4027 | 4028 | } 4029 | 4030 | declare namespace facebook { 4031 | 4032 | let AUDIENCE_EVERYONE: any 4033 | let AUDIENCE_FRIENDS: any 4034 | let AUDIENCE_NONE: any 4035 | let AUDIENCE_ONLYME: any 4036 | let EVENT_ADDED_PAYMENT_INFO: any 4037 | let EVENT_ADDED_TO_CART: any 4038 | let EVENT_ADDED_TO_WISHLIST: any 4039 | let EVENT_COMPLETED_REGISTRATION: any 4040 | let EVENT_COMPLETED_TUTORIAL: any 4041 | let EVENT_INITIATED_CHECKOUT: any 4042 | let EVENT_PURCHASED: any 4043 | let EVENT_RATED: any 4044 | let EVENT_SEARCHED: any 4045 | let EVENT_SPENT_CREDITS: any 4046 | let EVENT_TIME_BETWEEN_SESSIONS: any 4047 | let EVENT_UNLOCKED_ACHIEVEMENT: any 4048 | let EVENT_VIEWED_CONTENT: any 4049 | let GAMEREQUEST_ACTIONTYPE_ASKFOR: any 4050 | let GAMEREQUEST_ACTIONTYPE_NONE: any 4051 | let GAMEREQUEST_ACTIONTYPE_SEND: any 4052 | let GAMEREQUEST_ACTIONTYPE_TURN: any 4053 | let GAMEREQUEST_FILTER_APPNONUSERS: any 4054 | let GAMEREQUEST_FILTER_APPUSERS: any 4055 | let GAMEREQUEST_FILTER_NONE: any 4056 | let PARAM_CONTENT_ID: any 4057 | let PARAM_CONTENT_TYPE: any 4058 | let PARAM_CURRENCY: any 4059 | let PARAM_DESCRIPTION: any 4060 | let PARAM_LEVEL: any 4061 | let PARAM_MAX_RATING_VALUE: any 4062 | let PARAM_NUM_ITEMS: any 4063 | let PARAM_PAYMENT_INFO_AVAILABLE: any 4064 | let PARAM_REGISTRATION_METHOD: any 4065 | let PARAM_SEARCH_STRING: any 4066 | let PARAM_SOURCE_APPLICATION: any 4067 | let PARAM_SUCCESS: any 4068 | let STATE_CLOSED_LOGIN_FAILED: any 4069 | let STATE_OPEN: any 4070 | /** 4071 | This function returns the currently stored access token after a previous 4072 | sucessful login. If it returns nil no access token exists and you need 4073 | to perform a login to get the wanted permissions. 4074 | @return string the access token or nil if the user is not logged in 4075 | **/ 4076 | function access_token(): string 4077 | 4078 | /** 4079 | This function will disable event usage for Facebook Analytics which means 4080 | that Facebook won't be able to use event data for ad-tracking. Events will 4081 | still be sent to Facebook for insights. 4082 | Event usage cannot be controlled and is always enabled for the 4083 | Facebook Canvas platform, therefore this function has no effect on Facebook 4084 | Canvas. 4085 | **/ 4086 | function disable_event_usage(): void 4087 | 4088 | /** 4089 | This function will enable event usage for Facebook Analytics which means 4090 | that Facebook will be able to use event data for ad-tracking. 4091 | Event usage cannot be controlled and is always enabled for the 4092 | Facebook Canvas platform, therefore this function has no effect on Facebook 4093 | Canvas. 4094 | **/ 4095 | function enable_event_usage(): void 4096 | 4097 | /** 4098 | Login to Facebook and request a set of publish permissions. The user is 4099 | prompted to authorize the application using the login dialog of the specific 4100 | platform. Even if the user is already logged in to Facebook this function 4101 | can still be used to request additional publish permissions. 4102 | Note that this function cannot be used to request read permissions. 4103 | If the application requires both publish and read permissions, individual 4104 | calls to both login_with_publish_permissions 4105 | and login_with_read_permissions has to be made. 4106 | A comprehensive list of permissions can be found in the Facebook documentation, 4107 | as well as a guide to best practises for login management. 4108 | @param permissions table Table with the requested publish permission strings. 4109 | @param audience constant | number The audience that should be able to see the publications. 4110 | 4111 | facebook.AUDIENCE_NONE 4112 | facebook.AUDIENCE_ONLYME 4113 | facebook.AUDIENCE_FRIENDS 4114 | facebook.AUDIENCE_EVERYONE 4115 | 4116 | @param callback function(self, data) Callback function that is executed when the permission request dialog is closed. 4117 | 4118 | self 4119 | object The context of the calling script 4120 | data 4121 | table A table that contains the response 4122 | 4123 | **/ 4124 | function login_with_publish_permissions(permissions: any, audience: number, callback: any): void 4125 | 4126 | /** 4127 | Login to Facebook and request a set of read permissions. The user is 4128 | prompted to authorize the application using the login dialog of the specific 4129 | platform. Even if the user is already logged in to Facebook this function 4130 | can still be used to request additional read permissions. 4131 | Note that this function cannot be used to request publish permissions. 4132 | If the application requires both read and publish permissions, individual 4133 | calls to both login_with_publish_permissions 4134 | and login_with_read_permissions has to be made. 4135 | A comprehensive list of permissions can be found in the Facebook documentation, 4136 | as well as a guide to best practises for login management. 4137 | @param permissions table Table with the requested read permission strings. 4138 | @param callback function(self, data) callback function that is executed when the permission request dialog is closed. 4139 | 4140 | self 4141 | object The context of the calling script 4142 | data 4143 | table A table that contains the response 4144 | 4145 | **/ 4146 | function login_with_read_permissions(permissions: any, callback: any): void 4147 | 4148 | /** 4149 | Logout from Facebook. 4150 | **/ 4151 | function logout(): void 4152 | 4153 | /** 4154 | This function returns a table with all the currently granted permission strings. 4155 | @return table the permissions 4156 | **/ 4157 | function permissions(): any 4158 | 4159 | /** 4160 | This function will post an event to Facebook Analytics where it can be used 4161 | in the Facebook Insights system. 4162 | @param event constant | string An event can either be one of the predefined 4163 | constants below or a text string which can be used to define a custom event that is 4164 | registered with Facebook Analytics. 4165 | 4166 | facebook.EVENT_ACHIEVED_LEVEL 4167 | facebook.EVENT_ACTIVATED_APP 4168 | facebook.EVENT_ADDED_PAYMENT_INFO 4169 | facebook.EVENT_ADDED_TO_CART 4170 | facebook.EVENT_ADDED_TO_WISHLIST 4171 | facebook.EVENT_COMPLETED_REGISTRATION 4172 | facebook.EVENT_COMPLETED_TUTORIAL 4173 | facebook.EVENT_DEACTIVATED_APP 4174 | facebook.EVENT_INITIATED_CHECKOUT 4175 | facebook.EVENT_PURCHASED 4176 | facebook.EVENT_RATED 4177 | facebook.EVENT_SEARCHED 4178 | facebook.EVENT_SESSION_INTERRUPTIONS 4179 | facebook.EVENT_SPENT_CREDITS 4180 | facebook.EVENT_TIME_BETWEEN_SESSIONS 4181 | facebook.EVENT_UNLOCKED_ACHIEVEMENT 4182 | facebook.EVENT_VIEWED_CONTENT 4183 | 4184 | @param value number a numeric value for the event. This should 4185 | represent the value of the event, such as the level achieved, price for an 4186 | item or number of orcs killed. 4187 | @param [params] table optional table with parameters and their values. A key in the 4188 | table can either be one of the predefined constants below or a text which 4189 | can be used to define a custom parameter. 4190 | 4191 | facebook.PARAM_CONTENT_ID 4192 | facebook.PARAM_CONTENT_TYPE 4193 | facebook.PARAM_CURRENCY 4194 | facebook.PARAM_DESCRIPTION 4195 | facebook.PARAM_LEVEL 4196 | facebook.PARAM_MAX_RATING_VALUE 4197 | facebook.PARAM_NUM_ITEMS 4198 | facebook.PARAM_PAYMENT_INFO_AVAILABLE 4199 | facebook.PARAM_REGISTRATION_METHOD 4200 | facebook.PARAM_SEARCH_STRING 4201 | facebook.PARAM_SOURCE_APPLICATION 4202 | facebook.PARAM_SUCCESS 4203 | 4204 | **/ 4205 | function post_event(event: string, value: number, params?: any): void 4206 | 4207 | /** 4208 | Display a Facebook web dialog of the type specified in the dialog parameter. 4209 | The param table should be set up according to the requirements of each dialog 4210 | type. Note that some parameters are mandatory. Below is the list of available dialogs and 4211 | where to find Facebook's developer documentation on parameters and response data. 4212 | "apprequests" 4213 | Shows a Game Request dialog. Game Requests allows players to invite their friends to play a 4214 | game. Available parameters: 4215 | 4216 | string title 4217 | string message 4218 | number action_type 4219 | number filters 4220 | string data 4221 | string object_id 4222 | table suggestions 4223 | table recipients 4224 | string to 4225 | 4226 | On success, the "result" table parameter passed to the callback function will include the following fields: 4227 | 4228 | string request_id 4229 | table to 4230 | 4231 | Details for each parameter: https://developers.facebook.com/docs/games/services/gamerequests/v2.6#dialogparameters 4232 | "feed" 4233 | The Feed Dialog allows people to publish individual stories to their timeline. 4234 | 4235 | string caption 4236 | string description 4237 | string picture 4238 | string link 4239 | table people_ids 4240 | string place_id 4241 | string ref 4242 | 4243 | On success, the "result" table parameter passed to the callback function will include the following fields: 4244 | 4245 | string post_id 4246 | 4247 | Details for each parameter: https://developers.facebook.com/docs/sharing/reference/feed-dialog/v2.6#params 4248 | "appinvite" 4249 | The App Invite dialog is available only on iOS and Android. 4250 | Note that the url parameter 4251 | corresponds to the appLinkURL (iOS) and setAppLinkUrl (Android) properties. 4252 | 4253 | string url 4254 | string preview_image 4255 | 4256 | Details for each parameter: https://developers.facebook.com/docs/reference/ios/current/class/FBSDKAppInviteContent/ 4257 | @param dialog string dialog to show. 4258 | - "apprequests" 4259 | - "feed" 4260 | - "appinvite" 4261 | @param param table table with dialog parameters 4262 | @param callback function(self, result, error) callback function that is called when the dialog is closed. 4263 | 4264 | self 4265 | object The context of the calling script 4266 | result 4267 | table Table with dialog specific results. See above. 4268 | error 4269 | table Error message. If there is no error, error is nil. 4270 | 4271 | **/ 4272 | function show_dialog(dialog: string, param: any, callback: any): void 4273 | 4274 | } 4275 | 4276 | declare namespace iap { 4277 | 4278 | let PROVIDER_ID_AMAZON: any 4279 | let PROVIDER_ID_APPLE: any 4280 | let PROVIDER_ID_FACEBOOK: any 4281 | let PROVIDER_ID_GAMEROOM: any 4282 | let PROVIDER_ID_GOOGLE: any 4283 | let REASON_UNSPECIFIED: any 4284 | let REASON_USER_CANCELED: any 4285 | let TRANS_STATE_FAILED: any 4286 | let TRANS_STATE_PURCHASED: any 4287 | let TRANS_STATE_PURCHASING: any 4288 | let TRANS_STATE_RESTORED: any 4289 | let TRANS_STATE_UNVERIFIED: any 4290 | /** 4291 | Perform a product purchase. 4292 | Calling iap.finish() is required on a successful transaction if 4293 | auto_finish_transactions is disabled in project settings. 4294 | @param id string product to buy 4295 | @param [options] table optional parameters as properties. The following parameters can be set: 4296 | 4297 | request_id ( Facebook only. Optional custom unique request id to 4298 | set for this transaction. The id becomes attached to the payment within the Graph API.) 4299 | 4300 | **/ 4301 | function buy(id: string, options?: any): void 4302 | 4303 | /** 4304 | Performs a purchase of a premium game license. The purchase transaction 4305 | is handled like regular iap purchases; calling the currently set iap_listener with the 4306 | transaction results. 4307 | This function does not work when testing the application 4308 | locally in the Gameroom client. 4309 | **/ 4310 | function buy_premium(): void 4311 | 4312 | /** 4313 | Explicitly finish a product transaction. 4314 | Calling iap.finish is required on a successful transaction 4315 | if auto_finish_transactions is disabled in project settings. Calling this function 4316 | with auto_finish_transactions set will be ignored and a warning is printed. 4317 | The transaction.state field must equal iap.TRANS_STATE_PURCHASED. 4318 | @param transaction table transaction table parameter as supplied in listener callback 4319 | **/ 4320 | function finish(transaction: any): void 4321 | 4322 | /** 4323 | 4324 | @return constant provider id. 4325 | 4326 | iap.PROVIDER_ID_GOOGLE 4327 | iap.PROVIDER_ID_AMAZON 4328 | iap.PROVIDER_ID_APPLE 4329 | iap.PROVIDER_ID_FACEBOOK 4330 | iap.PROVIDER_ID_GAMEROOM 4331 | 4332 | **/ 4333 | function get_provider_id(): any 4334 | 4335 | /** 4336 | Checks if a license for the game has been purchased by the user. 4337 | You should provide a callback function that will be called with the result of the check. 4338 | This function does not work when testing the application 4339 | locally in the Gameroom client. 4340 | @param callback function(self, has_premium) result callback 4341 | 4342 | self 4343 | object The current object. 4344 | has_premium 4345 | boolean true if the user has premium license, false otherwise. 4346 | 4347 | **/ 4348 | function has_premium(callback: any): void 4349 | 4350 | /** 4351 | Get a list of all avaliable iap products. Products are described as a table 4352 | with the following fields: 4353 | 4354 | ident 4355 | The product identifier. 4356 | title 4357 | The product title. 4358 | description 4359 | The product description. 4360 | price 4361 | The price of the product. 4362 | price_string 4363 | The price of the product, as a formatted string (amount and currency symbol). 4364 | currency_code 4365 | The currency code. On Google Play, this reflects the merchant's locale, instead of the user's. 4366 | 4367 | Nested calls, that is calling iap.list() from within the callback is 4368 | not supported. Doing so will result in call being ignored with the engine reporting 4369 | "Unexpected callback set". 4370 | @param ids table table (array) of identifiers to get products from 4371 | @param callback function(self, products, error) result callback 4372 | 4373 | self 4374 | object The current object. 4375 | products 4376 | table Table describing the available iap products. See above for details. 4377 | error 4378 | table a table containing error information. nil if there is no error. 4379 | - error (the error message) 4380 | 4381 | **/ 4382 | function list(ids: any, callback: any): void 4383 | 4384 | /** 4385 | Restore previously purchased products. 4386 | @return boolean true if current store supports handling 4387 | restored transactions, otherwise false. 4388 | **/ 4389 | function restore(): boolean 4390 | 4391 | /** 4392 | Set the callback function to receive purchase transaction events. Transactions are 4393 | described as a table with the following fields: 4394 | 4395 | ident 4396 | The product identifier. 4397 | state 4398 | The transaction state. See iap.TRANS_STATE_*. 4399 | date 4400 | The date and time for the transaction. 4401 | trans_ident 4402 | The transaction identifier. This field is only set when state is TRANS_STATE_RESTORED, 4403 | TRANS_STATE_UNVERIFIED or TRANS_STATE_PURCHASED. 4404 | receipt 4405 | The transaction receipt. This field is only set when state is TRANS_STATE_PURCHASED 4406 | or TRANS_STATE_UNVERIFIED. 4407 | original_trans 4408 | Apple only. The original transaction. This field is only set when state is 4409 | TRANS_STATE_RESTORED. 4410 | signature 4411 | Google Play only. A string containing the signature of the purchase data that was signed 4412 | with the private key of the developer. 4413 | request_id 4414 | Facebook only. This field is set to the optional custom unique request id request_id 4415 | if set in the iap.buy() call parameters. 4416 | purchase_token 4417 | Facebook Gameroom only. The purchase token. 4418 | currency 4419 | Facebook Gameroom only. The currency used for the purchase. 4420 | amount 4421 | Facebook Gameroom only. The amount the player will be charged for a single unit 4422 | of this product. 4423 | quantity 4424 | Facebook Gameroom only. The quantity of this item the user is purchasing. 4425 | user_id 4426 | Amazon Pay only. The user ID. 4427 | is_sandbox_mode 4428 | Amazon Pay only. If true, the SDK is running in Sandbox mode. This only allows 4429 | interactions with the Amazon AppTester. Use this mode only for testing locally. 4430 | cancel_date 4431 | Amazon Pay only. The cancel date for the purchase. This field is only set if the 4432 | purchase is canceled. 4433 | canceled 4434 | Amazon Pay only. Is set to true if the receipt was canceled or has expired; 4435 | otherwise false. 4436 | 4437 | @param listener function(self, transaction, error) listener callback function. 4438 | Pass an empty function if you no longer wish to receive callbacks. 4439 | 4440 | self 4441 | object The current object. 4442 | transaction 4443 | table a table describing the transaction. See above for details. 4444 | error 4445 | table a table containing error information. nil if there is no error. 4446 | - error (the error message) 4447 | - reason (the reason for the error, see iap.REASON_*) 4448 | 4449 | **/ 4450 | function set_listener(listener: any): void 4451 | 4452 | } 4453 | 4454 | declare namespace iac { 4455 | 4456 | let TYPE_INVOCATION: any 4457 | /** 4458 | Sets the listener function for inter-app communication events. 4459 | @param listener function(self, payload, type) listener callback function. 4460 | Pass an empty function if you no longer wish to receive callbacks. 4461 | 4462 | self 4463 | 4464 | object The current object. 4465 | 4466 | payload 4467 | 4468 | table The iac payload. 4469 | 4470 | type 4471 | 4472 | constant The type of iac, an iac.TYPE_ enumeration. 4473 | 4474 | 4475 | **/ 4476 | function set_listener(listener: any): void 4477 | 4478 | } 4479 | 4480 | declare namespace push { 4481 | 4482 | let NOTIFICATION_ALERT: any 4483 | let NOTIFICATION_BADGE: any 4484 | let NOTIFICATION_SOUND: any 4485 | let ORIGIN_LOCAL: any 4486 | let PRIORITY_DEFAULT: any 4487 | let PRIORITY_HIGH: any 4488 | let PRIORITY_LOW: any 4489 | let PRIORITY_MAX: any 4490 | let PRIORITY_MIN: any 4491 | /** 4492 | Use this function to cancel a previously scheduled local push notification. The 4493 | notification is identified by a numeric id as returned by push.schedule(). 4494 | @param id number the numeric id of the local push notification 4495 | **/ 4496 | function cancel(id: number): void 4497 | 4498 | /** 4499 | Returns a table with all data associated with all scheduled local push notifications. 4500 | The table contains key, value pairs where the key is the push notification id and the 4501 | value is a table with the notification data, corresponding to the data given by 4502 | push.get_scheduled(id). 4503 | @return table table with all data associated with all scheduled notifications 4504 | **/ 4505 | function get_all_scheduled(): any 4506 | 4507 | /** 4508 | Returns a table with all data associated with a specified local push notification. 4509 | The notification is identified by a numeric id as returned by push.schedule(). 4510 | @param id number the numeric id of the local push notification 4511 | @return table table with all data associated with the notification 4512 | **/ 4513 | function get_scheduled(id: number): any 4514 | 4515 | /** 4516 | Send a request for push notifications. Note that the notifications table parameter 4517 | is iOS only and will be ignored on Android. 4518 | @param notifications table the types of notifications to listen to. 4519 | @param callback function(self, token, error) register callback function. 4520 | 4521 | self 4522 | 4523 | object The current object. 4524 | 4525 | token 4526 | 4527 | string The returned push token if registration is successful. 4528 | 4529 | error 4530 | 4531 | table A table containing eventual error information. 4532 | 4533 | 4534 | **/ 4535 | function register(notifications: any, callback: any): void 4536 | 4537 | /** 4538 | Local push notifications are scheduled with this function. 4539 | The returned id value is uniquely identifying the scheduled notification 4540 | and can be stored for later reference. 4541 | @param time number number of seconds into the future until the notification should be triggered 4542 | @param title string localized title to be displayed to the user if the application is not running 4543 | @param alert string localized body message of the notification to be displayed to the user if the application is not running 4544 | @param payload string JSON string to be passed to the registered listener function 4545 | @param notification_settings table table with notification and platform specific fields 4546 | 4547 | action 4548 | string 4549 | The alert action string to be used as the title of the right button of the 4550 | alert or the value of the unlock slider, where the value replaces 4551 | "unlock" in "slide to unlock" text. 4552 | badge_count 4553 | number The numeric value of the icon badge. 4554 | badge_number 4555 | Deprecated! Use badge_count instead 4556 | priority 4557 | number 4558 | The priority is a hint to the device UI about how the notification 4559 | should be displayed. There are five priority levels, from -2 to 2 where -1 is the 4560 | lowest priority and 2 the highest. Unless specified, a default priority level of 2 4561 | is used. 4562 | 4563 | @return number unique id that can be used to cancel or inspect the notification 4564 | @return string error string if something went wrong, otherwise nil 4565 | **/ 4566 | function schedule(time: number, title: string, alert: string, payload: string, notification_settings: any): number 4567 | 4568 | /** 4569 | Set the badge count for application icon. 4570 | This function is only available on iOS. 4571 | @param count number badge count 4572 | **/ 4573 | function set_badge_count(count: number): void 4574 | 4575 | /** 4576 | Sets a listener function to listen to push notifications. 4577 | @param listener function(self, payload, origin, activated) listener callback function. 4578 | Pass an empty function if you no longer wish to receive callbacks. 4579 | 4580 | self 4581 | object The current object 4582 | payload 4583 | function the push payload 4584 | origin 4585 | constant push.ORIGIN_LOCAL or push.ORIGIN_REMOTE 4586 | activated 4587 | boolean true or false depending on if the application was 4588 | activated via the notification. 4589 | 4590 | **/ 4591 | function set_listener(listener: any): void 4592 | 4593 | } 4594 | 4595 | declare namespace webview { 4596 | 4597 | /** 4598 | Creates a webview instance. It can show HTML pages as well as evaluate Javascript. 4599 | The view remains hidden until the first call. There can exist a maximum of 4 webviews at the same time. 4600 | On iOS, the callback will never get a webview.CALLBACK_RESULT_EVAL_ERROR, 4601 | due to the iOS SDK implementation. 4602 | @param callback function(self, webview_id, request_id, type, data) A callback which receives info about finished requests taking the following parameters 4603 | 4604 | self 4605 | object The calling script 4606 | webview_id 4607 | number The webview id 4608 | request_id 4609 | number The request id 4610 | type 4611 | number The type of the callback. Can be one of these: 4612 | 4613 | 4614 | webview.CALLBACK_RESULT_URL_OK 4615 | webview.CALLBACK_RESULT_URL_ERROR 4616 | webview.CALLBACK_RESULT_EVAL_OK 4617 | webview.CALLBACK_RESULT_EVAL_ERROR 4618 | 4619 | 4620 | data 4621 | table A table holding the data. The table has these fields: 4622 | 4623 | 4624 | string url: The url used in the webview.open() call. nil otherwise. 4625 | string result: Holds the result of either: a failed url open, a successful eval request or a failed eval. nil otherwise 4626 | 4627 | @return number The id number of the webview 4628 | **/ 4629 | function create(callback: any): number 4630 | 4631 | /** 4632 | Destroys an instance of a webview. 4633 | @param webview_id number The webview id (returned by the webview.create() call) 4634 | **/ 4635 | function destroy(webview_id: number): void 4636 | 4637 | /** 4638 | Evaluates java script within the context of the currently loaded page (if any). 4639 | Once the request is done, the callback (registered in webview.create()) 4640 | is invoked. The callback will get the result in the data["result"] field. 4641 | @param webview_id number The webview id 4642 | @param code string The java script code to evaluate 4643 | @return number The id number of the request 4644 | **/ 4645 | function eval(webview_id: number, code: string): number 4646 | 4647 | /** 4648 | Returns the visibility state of the webview. 4649 | @param webview_id number The webview id (returned by the webview.create() call) 4650 | @return number Returns 0 if not visible, 1 if it is visible 4651 | **/ 4652 | function is_visible(webview_id: number): number 4653 | 4654 | /** 4655 | Opens a web page in the webview, using an url. Once the request is done, the 4656 | callback (registered in webview.create()) is invoked. 4657 | @param webview_id number The webview id 4658 | @param url string The url to open 4659 | @param options table A table of options for the request. Currently it holds these options 4660 | 4661 | hidden 4662 | boolean If true, the webview will stay hidden (default=false) 4663 | 4664 | @return number The id number of the request 4665 | **/ 4666 | function open(webview_id: number, url: string, options: any): number 4667 | 4668 | /** 4669 | Opens a web page in the webview, using html data. Once the request is done, 4670 | the callback (registered in webview.create()) is invoked. 4671 | @param webview_id number The webview id 4672 | @param html string The html data to display 4673 | @param options table A table of options for the request. See webview.open() 4674 | @return number The id number of the request 4675 | **/ 4676 | function open_raw(webview_id: number, html: string, options: any): number 4677 | 4678 | /** 4679 | Sets the size of the webview 4680 | @param webview_id number The webview id (returned by the webview.create() call) 4681 | @return number The width of the webview 4682 | @return number The height of the webview 4683 | **/ 4684 | function set_size(webview_id: number): number 4685 | 4686 | /** 4687 | Shows or hides a web view 4688 | @param webview_id number The webview id (returned by the webview.create() call) 4689 | @param visible number If 0, hides the webview. If non zero, shows the view 4690 | **/ 4691 | function set_visible(webview_id: number, visible: number): void 4692 | 4693 | } 4694 | --------------------------------------------------------------------------------