2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								<?xml version="1.0" encoding="UTF-8" ?>  
						 
					
						
							
								
									
										
										
										
											2020-01-31 17:03:48 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<class  name= "@GDScript"  version= "4.0" >  
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									<brief_description > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Built-in GDScript functions.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									</brief_description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<description > 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-18 04:25:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										List of core built-in GDScript functions. Math functions and other utilities. Everything else is provided by objects. (Keywords: builtin, built in, global functions.)
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									</description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<tutorials > 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-14 18:03:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										<link  title= "Random number generation" > https://docs.godotengine.org/en/latest/tutorials/math/random_number_generation.html</link> 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									</tutorials> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<methods > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<method  name= "Color8" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<return  type= "Color" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</return> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<argument  index= "0"  name= "r8"  type= "int" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</argument> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<argument  index= "1"  name= "g8"  type= "int" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</argument> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<argument  index= "2"  name= "b8"  type= "int" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</argument> 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-19 10:47:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											<argument  index= "3"  name= "a8"  type= "int"  default= "255" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</argument> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<description > 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-02 04:48:08 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												Returns a color constructed from integer red, green, blue, and alpha channels. Each channel should have 8 bits of information ranging from 0 to 255.
							 
						 
					
						
							
								
									
										
										
										
											2017-09-18 00:36:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												[code]r8[/code] red channel
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[code]g8[/code] green channel
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[code]b8[/code] blue channel
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[code]a8[/code] alpha channel
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												[codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												red = Color8(255, 0, 0)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[/codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</method> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<method  name= "assert" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<return  type= "void" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</return> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<argument  index= "0"  name= "condition"  type= "bool" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</argument> 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-31 10:39:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											<argument  index= "1"  name= "message"  type= "String"  default= """" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</argument> 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											<description > 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-04 14:33:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												Asserts that the [code]condition[/code] is [code]true[/code]. If the [code]condition[/code] is [code]false[/code], an error is generated. When running from the editor, the running project will also be paused until you resume it. This can be used as a stronger form of [method @GlobalScope.push_error] for reporting errors to project developers or add-on users.
							 
						 
					
						
							
								
									
										
										
										
											2020-11-09 21:48:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												[b]Note:[/b] For performance reasons, the code inside [method assert] is only executed in debug builds or when running the project from the editor. Don't include code that has side effects in an [method assert] call. Otherwise, the project will behave differently when exported in release mode.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-31 10:39:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												The optional [code]message[/code] argument, if given, is shown in addition to the generic "Assertion failed" message. You can use this to provide additional details about why the assertion failed.
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 23:18:51 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												[codeblock]
							 
						 
					
						
							
								
									
										
										
										
											2020-11-09 21:48:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												# Imagine we always want speed to be between 0 and 20.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												var speed = -10
							 
						 
					
						
							
								
									
										
										
										
											2019-06-03 19:27:37 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert(speed <  20) # True, the program will continue
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												assert(speed > = 0) # False, the program will stop
							 
						 
					
						
							
								
									
										
										
										
											2020-11-09 21:48:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert(speed > = 0 and speed <  20) # You can also combine the two conditional statements in one check
							 
						 
					
						
							
								
									
										
										
										
											2020-03-31 10:39:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												assert(speed <  20, "speed = %f, but the speed limit is 20" % speed) # Show a message with clarifying details
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 23:18:51 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												[/codeblock]
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</method> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<method  name= "char" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<return  type= "String" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</return> 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-04 14:33:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											<argument  index= "0"  name= "char"  type= "int" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</argument> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<description > 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-15 11:10:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												Returns a character as a String of the given Unicode code point (which is compatible with ASCII code).
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												[codeblock]
							 
						 
					
						
							
								
									
										
										
										
											2019-06-22 01:04:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												a = char(65)      # a is "A"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												a = char(65 + 32) # a is "a"
							 
						 
					
						
							
								
									
										
										
										
											2019-12-15 11:10:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												a = char(8364)    # a is "€"
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												[/codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</method> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<method  name= "convert" > 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-26 11:56:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											<return  type= "Variant" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</return> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<argument  index= "0"  name= "what"  type= "Variant" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</argument> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<argument  index= "1"  name= "type"  type= "int" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</argument> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<description > 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-06 23:09:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												Converts from a type to another in the best way possible. The [code]type[/code] parameter uses the [enum Variant.Type] values.
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												[codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												a = Vector2(1, 0)
							 
						 
					
						
							
								
									
										
										
										
											2019-06-22 01:04:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												# Prints 1
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												print(a.length())
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												a = convert(a, TYPE_STRING)
							 
						 
					
						
							
								
									
										
										
										
											2019-06-22 01:04:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												# Prints 6 as "(1, 0)" is 6 characters
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												print(a.length())
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[/codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</method> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<method  name= "dict2inst" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<return  type= "Object" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</return> 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-04 14:33:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											<argument  index= "0"  name= "dictionary"  type= "Dictionary" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</argument> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<description > 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-29 17:08:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												Converts a dictionary (previously created with [method inst2dict]) back to an instance. Useful for deserializing.
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</method> 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-26 11:56:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										<method  name= "get_stack" > 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-11 00:18:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											<return  type= "Array" > 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-26 11:56:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											</return> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<description > 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-06 13:57:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												Returns an array of dictionaries representing the current call stack.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												func _ready():
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												    foo()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												func foo():
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												    bar()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												func bar():
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												    print(get_stack())
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[/codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												would print
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[{function:bar, line:12, source:res://script.gd}, {function:foo, line:9, source:res://script.gd}, {function:_ready, line:6, source:res://script.gd}]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[/codeblock]
							 
						 
					
						
							
								
									
										
										
										
											2018-07-26 11:56:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											</description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</method> 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										<method  name= "inst2dict" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<return  type= "Dictionary" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</return> 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-04 14:33:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											<argument  index= "0"  name= "instance"  type= "Object" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</argument> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<description > 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-18 00:36:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												Returns the passed instance converted to a dictionary (useful for serializing).
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												[codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												var foo = "bar"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												func _ready():
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												    var d = inst2dict(self)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												    print(d.keys())
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												    print(d.values())
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[/codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												Prints out:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[@subpath, @path, foo]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[, res://test.gd, bar]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[/codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</method> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<method  name= "len" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<return  type= "int" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</return> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<argument  index= "0"  name= "var"  type= "Variant" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</argument> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<description > 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-28 17:44:58 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												Returns length of Variant [code]var[/code]. Length is the character count of String, element count of Array, size of Dictionary, etc.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[b]Note:[/b] Generates a fatal error if Variant can not provide a length.
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												[codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												a = [1, 2, 3, 4]
							 
						 
					
						
							
								
									
										
										
										
											2019-06-22 01:04:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												len(a) # Returns 4
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												[/codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</method> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<method  name= "load" > 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-26 11:56:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											<return  type= "Resource" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</return> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<argument  index= "0"  name= "path"  type= "String" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</argument> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<description > 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-28 20:51:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												Loads a resource from the filesystem located at [code]path[/code]. The resource is loaded on the method call (unless it's referenced already elsewhere, e.g. in another script or in the scene), which might cause slight delay, especially when loading scenes. To avoid unnecessary delays when loading something multiple times, either store the resource in a variable or use [method preload].
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[b]Note:[/b] Resource paths can be obtained by right-clicking on a resource in the FileSystem dock and choosing "Copy Path" or by dragging the file from the FileSystem dock into the script.
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												[codeblock]
							 
						 
					
						
							
								
									
										
										
										
											2020-06-28 20:51:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												# Load a scene called main located in the root of the project directory and cache it in a variable.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												var main = load("res://main.tscn") # main will contain a PackedScene resource.
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												[/codeblock]
							 
						 
					
						
							
								
									
										
										
										
											2019-12-11 17:14:58 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												[b]Important:[/b] The path must be absolute, a local path will just return [code]null[/code].
							 
						 
					
						
							
								
									
										
										
										
											2020-09-30 23:03:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												This method is a simplified version of [method ResourceLoader.load], which can be used for more advanced scenarios.
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</method> 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-04 14:33:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										<method  name= "preload" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<return  type= "Resource" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</return> 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-04 14:33:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											<argument  index= "0"  name= "path"  type= "String" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</argument> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<description > 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-04 14:33:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												Returns a [Resource] from the filesystem located at [code]path[/code]. The resource is loaded during script parsing, i.e. is loaded with the script and [method preload] effectively acts as a reference to that resource. Note that the method requires a constant path. If you want to load a resource from a dynamic/variable path, use [method load].
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[b]Note:[/b] Resource paths can be obtained by right clicking on a resource in the Assets Panel and choosing "Copy Path" or by dragging the file from the FileSystem dock into the script.
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												[codeblock]
							 
						 
					
						
							
								
									
										
										
										
											2021-01-04 14:33:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												# Instance a scene.
							 
						 
					
						
							
								
									
										
										
										
											2021-06-17 16:03:09 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												var diamond = preload("res://diamond.tscn").instantiate()
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												[/codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</method> 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-04 14:33:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										<method  name= "print_debug"  qualifiers= "vararg" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<return  type= "void" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</return> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<description > 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-04 14:33:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												Like [method @GlobalScope.print], but prints only when used in debug mode.
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</method> 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-04 14:33:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										<method  name= "print_stack" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<return  type= "void" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</return> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<description > 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-04 14:33:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												Prints a stack track at code location, only works when running with debugger turned on.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												Output in the console would look something like this:
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												[codeblock]
							 
						 
					
						
							
								
									
										
										
										
											2021-01-04 14:33:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												Frame 0 - res://test.gd:16 in function '_process'
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												[/codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</method> 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-04 14:33:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										<method  name= "range"  qualifiers= "vararg" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<return  type= "Array" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</return> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<description > 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-18 00:36:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												Returns an array with the given range. Range can be 1 argument N (0 to N-1), two arguments (initial, final-1) or three arguments (initial, final-1, increment).
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 23:18:51 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												[codeblock]
							 
						 
					
						
							
								
									
										
										
										
											2020-09-14 19:19:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												print(range(4))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												print(range(2, 5))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												print(range(0, 6, 2))
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 23:18:51 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												[/codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												Output:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[codeblock]
							 
						 
					
						
							
								
									
										
										
										
											2020-09-14 19:19:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												[0, 1, 2, 3]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[2, 3, 4]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												[0, 2, 4]
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 23:18:51 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												[/codeblock]
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</method> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<method  name= "str"  qualifiers= "vararg" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<return  type= "String" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</return> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<description > 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-18 00:36:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												Converts one or more arguments to string in the best way possible.
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 23:18:51 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												[codeblock]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												var a = [10, 20, 30]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												var b = str(a);
							 
						 
					
						
							
								
									
										
										
										
											2019-06-22 01:04:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												len(a) # Returns 3
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												len(b) # Returns 12
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 23:18:51 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												[/codeblock]
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											</description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</method> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<method  name= "type_exists" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<return  type= "bool" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</return> 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-04 14:33:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											<argument  index= "0"  name= "type"  type= "StringName" > 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-04 19:09:37 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											</argument> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<description > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											</description> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</method> 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									</methods> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<constants > 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-23 17:38:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										<constant  name= "PI"  value= "3.14159265358979" > 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 14:07:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											Constant that represents how many times the diameter of a circle fits around its perimeter. This is equivalent to [code]TAU / 2[/code].
							 
						 
					
						
							
								
									
										
										
										
											2017-11-04 10:34:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										</constant> 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-23 17:38:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										<constant  name= "TAU"  value= "6.28318530717959" > 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 14:07:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											The circle constant, the circumference of the unit circle in radians.
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										</constant> 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-24 23:16:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										<constant  name= "INF"  value= "inf" > 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 14:07:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											Positive infinity. For negative infinity, use -INF.
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										</constant> 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-13 14:42:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										<constant  name= "NAN"  value= "nan" > 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 14:07:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											"Not a Number", an invalid value. [code]NaN[/code] has special properties, including that it is not equal to itself. It is output by some invalid operations, such as dividing zero by zero.
							 
						 
					
						
							
								
									
										
										
										
											2017-09-12 17:42:36 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										</constant> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									</constants> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								</class>