Merge pull request #11376 from RaTi17/gdscript_doc

Added code tags and corrected some lines

[ci skip]
This commit is contained in:
Rémi Verschelde 2017-09-18 10:51:42 +02:00 committed by GitHub
commit 0a5e0b8e39

View file

@ -23,11 +23,11 @@
<argument index="3" name="a8" type="int">
</argument>
<description>
Returns a 32 bit color with red, green, blue and alpha channels. Each channel has 8bits of information ranging from 0 to 255.
'r8' red channel
'g8' green channel
'b8' blue channel
'a8' alpha channel
Returns a 32 bit color with red, green, blue and alpha channels. Each channel has 8 bits of information ranging from 0 to 255.
[code]r8[/code] red channel
[code]g8[/code] green channel
[code]b8[/code] blue channel
[code]a8[/code] alpha channel
[codeblock]
red = Color8(255, 0, 0)
[/codeblock]
@ -41,7 +41,7 @@
<argument index="1" name="alpha" type="float">
</argument>
<description>
Returns color 'name' with alpha ranging from 0 to 1. Note: 'name' is defined in color_names.inc.
Returns color [code]name[/code] with [code]alpha[/code] ranging from 0 to 1. Note: [code]name[/code] is defined in color_names.inc.
[codeblock]
red = ColorN('red')
[/codeblock]
@ -53,7 +53,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Returns the absolute value of parameter 's' (i.e. unsigned value, works for integer and float).
Returns the absolute value of parameter [code]s[/code] (i.e. unsigned value, works for integer and float).
[codeblock]
# a is 1
a = abs(-1)
@ -66,7 +66,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Returns the arc cosine of 's' in radians. Use to get the angle of cosine 's'.
Returns the arc cosine of [code]s[/code] in radians. Use to get the angle of cosine [code]s[/code].
[codeblock]
# c is 0.523599 or 30 degrees if converted with rad2deg(s)
c = acos(0.866025)
@ -79,7 +79,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Returns the arc sine of 's' in radians. Use to get the angle of sine 's'.
Returns the arc sine of [code]s[/code] in radians. Use to get the angle of sine [code]s[/code].
[codeblock]
# s is 0.523599 or 30 degrees if converted with rad2deg(s)
s = asin(0.5)
@ -92,7 +92,7 @@
<argument index="0" name="condition" type="bool">
</argument>
<description>
Assert that the condition is true. If the condition is false a fatal error is generated and the program is halted. Useful for debugging to make sure a value is always true.
Assert that the [code]condition[/code] is true. If the [code]condition[/code] is false a fatal error is generated and the program is halted. Useful for debugging to make sure a value is always true.
[codeblock]
# Speed should always be between 0 and 20
speed = -10
@ -108,7 +108,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Returns the arc tangent of 's' in radians. Use it to get the angle from an angle's tangent in trigonometry: [code]atan(tan(angle)) == angle[/code].
Returns the arc tangent of [code]s[/code] in radians. Use it to get the angle from an angle's tangent in trigonometry: [code]atan(tan(angle)) == angle[/code].
The method cannot know in which quadrant the angle should fall. See [method atan2] if you always want an exact angle.
[codeblock]
a = atan(0.5) # a is 0.463648
@ -123,7 +123,7 @@
<argument index="1" name="y" type="float">
</argument>
<description>
Returns the arc tangent of y/x in radians. Use to get the angle of tangent y/x. To compute the value, the method takes into account the sign of both arguments in order to determine the quadrant.
Returns the arc tangent of [code]y/x[/code] in radians. Use to get the angle of tangent [code]y/x[/code]. To compute the value, the method takes into account the sign of both arguments in order to determine the quadrant.
[codeblock]
a = atan(0,-1) # a is 3.141593
[/codeblock]
@ -135,7 +135,7 @@
<argument index="0" name="bytes" type="PoolByteArray">
</argument>
<description>
Decode a byte array back to a value.
Decodes a byte array back to a value.
</description>
</method>
<method name="ceil">
@ -144,7 +144,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Rounds 's' upward, returning the smallest integral value that is not less than 's'.
Rounds [code]s[/code] upward, returning the smallest integral value that is not less than [code]s[/code].
[codeblock]
i = ceil(1.45) # i is 2
i = ceil(1.001) # i is 2
@ -157,7 +157,7 @@
<argument index="0" name="ascii" type="int">
</argument>
<description>
Returns a character as String of the given ASCII code.
Returns a character as a String of the given ASCII code.
[codeblock]
# a is 'A'
a = char(65)
@ -176,7 +176,7 @@
<argument index="2" name="max" type="float">
</argument>
<description>
Clamp 'val' and return a value not less than 'min' and not more than 'max'.
Clamps [code]val[/code] and returns a value not less than [code]min[/code] and not more than [code]max[/code].
[codeblock]
speed = 1000
# a is 20
@ -196,7 +196,7 @@
<argument index="1" name="type" type="int">
</argument>
<description>
Convert from a type to another in the best way possible. The "type" parameter uses the enum TYPE_* in [@Global Scope].
Converts from a type to another in the best way possible. The [code]type[/code] parameter uses the enum TYPE_* in [@Global Scope].
[codeblock]
a = Vector2(1, 0)
# prints 1
@ -214,7 +214,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Returns the cosine of angle 's' in radians.
Returns the cosine of angle [code]s[/code] in radians.
[codeblock]
# prints 1 and -1
print(cos(PI*2))
@ -228,7 +228,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Returns the hyperbolic cosine of 's' in radians.
Returns the hyperbolic cosine of [code]s[/code] in radians.
[codeblock]
# prints 1.543081
print(cosh(1))
@ -241,7 +241,7 @@
<argument index="0" name="db" type="float">
</argument>
<description>
Convert from decibels to linear energy (audio).
Converts from decibels to linear energy (audio).
</description>
</method>
<method name="decimals">
@ -250,7 +250,7 @@
<argument index="0" name="step" type="float">
</argument>
<description>
Returns the number of digit places after the decimal that the first non-zero digit occurs.
Returns the position of the first non-zero digit, after the decimal point.
[codeblock]
# n is 2
n = decimals(0.035)
@ -267,7 +267,7 @@
<argument index="2" name="step" type="float">
</argument>
<description>
Returns the result of 'value' decreased by 'step' * 'amount'.
Returns the result of [code]value[/code] decreased by [code]step[/code] * [code]amount[/code].
[codeblock]
# a = 59
a = dectime(60, 10, 0.1))
@ -293,7 +293,7 @@
<argument index="0" name="dict" type="Dictionary">
</argument>
<description>
Convert a previously converted instance to dictionary back into an instance. Useful for deserializing.
Converts a previously converted instance to a dictionary, back into an instance. Useful for deserializing.
</description>
</method>
<method name="ease">
@ -313,7 +313,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Raises the Euler's constant [b]e[/b] to the power of 's' and returns it. [b] has an approximate value of 2.71828.
Raises the Euler's constant [b]e[/b] to the power of [code]s[/code] and returns it. [b]e[/b] has an approximate value of 2.71828.
[codeblock]
a = exp(2) # approximately 7.39
[/codeblock]
@ -325,7 +325,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Rounds 's' to the closest smaller integer and returns it.
Rounds [code]s[/code] to the closest smaller integer and returns it.
[codeblock]
# a is 2
a = floor(2.99)
@ -342,11 +342,11 @@
<argument index="1" name="y" type="float">
</argument>
<description>
Returns the floating-point remainder of x/y (rounded towards zero):
Returns the floating-point remainder of [code]x/y[/code].
[codeblock]
fmod = x - tquot * y
# remainder is 1.5
var remainder = fmod(7, 5.5)
[/codeblock]
Where tquot is the truncated (i.e., rounded towards zero) result of: x/y.
</description>
</method>
<method name="fposmod">
@ -357,7 +357,7 @@
<argument index="1" name="y" type="float">
</argument>
<description>
Returns the floating-point remainder of x/y that wraps equally in positive and negative.
Returns the floating-point remainder of [code]x/y[/code] that wraps equally in positive and negative.
[codeblock]
var i = -10;
while i &lt; 0:
@ -387,7 +387,7 @@
<argument index="1" name="funcname" type="String">
</argument>
<description>
Returns a reference to the specified function 'funcname' in the 'instance' node. As functions aren't first-class objects in GDscript, use 'funcref' to store a function in a variable and call it later.
Returns a reference to the specified function [code]funcname[/code] in the [code]instance[/code] node. As functions aren't first-class objects in GDscript, use [code]funcref[/code] to store a [FuncRef] in a variable and call it later.
[codeblock]
func foo():
return("bar")
@ -415,7 +415,7 @@
<argument index="0" name="inst" type="Object">
</argument>
<description>
Returns the passed instance converted a dictionary (useful for serializing).
Returns the passed instance converted to a dictionary (useful for serializing).
[codeblock]
var foo = "bar"
func _ready():
@ -436,7 +436,7 @@
<argument index="0" name="instance_id" type="int">
</argument>
<description>
Returns the Object that corresponds to 'instance_id'. All Objects have a unique instance ID.
Returns the Object that corresponds to [code]instance_id[/code]. All Objects have a unique instance ID.
[codeblock]
var foo = "bar"
func _ready():
@ -468,7 +468,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Returns True/False whether 's' is an infinity value (either positive infinity or negative infinity).
Returns True/False whether [code]s[/code] is an infinity value (either positive infinity or negative infinity).
</description>
</method>
<method name="is_nan">
@ -477,7 +477,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Returns True/False whether 's' is a NaN (Not-A-Number) value.
Returns True/False whether [code]s[/code] is a NaN (Not-A-Number) value.
</description>
</method>
<method name="len">
@ -486,7 +486,7 @@
<argument index="0" name="var" type="Variant">
</argument>
<description>
Returns length of Variant 'var'. Length is the character count of String, element count of Array, size of Dictionary, etc. Note: Generates a fatal error if Variant can not provide a length.
Returns length of Variant [code]var[/code]. Length is the character count of String, element count of Array, size of Dictionary, etc. Note: Generates a fatal error if Variant can not provide a length.
[codeblock]
a = [1, 2, 3, 4]
len(a) # returns 4
@ -503,7 +503,7 @@
<argument index="2" name="weight" type="float">
</argument>
<description>
Linear interpolates between two values by a normalized value.
Linearly interpolates between two values by a normalized value.
[codeblock]
lerp(1, 3, 0.5) # returns 2
[/codeblock]
@ -515,7 +515,7 @@
<argument index="0" name="nrg" type="float">
</argument>
<description>
Convert from linear energy to decibels (audio).
Converts from linear energy to decibels (audio).
</description>
</method>
<method name="load">
@ -524,7 +524,7 @@
<argument index="0" name="path" type="String">
</argument>
<description>
Load a resource from the filesystem located at 'path'. Note: resource paths can be obtained by right clicking on a resource in the Assets Pannel and choosing "Copy Path".
Loads a resource from the filesystem located at 'path'. Note: resource paths can be obtained by right clicking on a resource in the Assets Panel and choosing "Copy Path".
[codeblock]
# load a scene called main located in the root of the project directory
var main = load("res://main.tscn")
@ -537,7 +537,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Natural logarithm. The amount of time needed to reach a certain level of continuous growth. Note: This is not the same as the log funcation on your calculator which is a base 10 logarithm.
Natural logarithm. The amount of time needed to reach a certain level of continuous growth. Note: This is not the same as the log function on your calculator which is a base 10 logarithm.
[codeblock]
log(10) # returns 2.302585
[/codeblock]
@ -579,7 +579,7 @@
<argument index="0" name="val" type="int">
</argument>
<description>
Returns the nearest larger power of 2 for integer 'val'.
Returns the nearest larger power of 2 for integer [code]val[/code].
[codeblock]
nearest_po2(3) # returns 4
nearest_po2(4) # returns 4
@ -594,7 +594,7 @@
</argument>
<description>
Parse JSON text to a Variant (use [method typeof] to check if it is what you expect).
Be aware that the JSON specification does not define integer or float types, but only a number type. Therefore, parsing a JSON text will convert every numerical values to [float] types.
Be aware that the JSON specification does not define integer or float types, but only a number type. Therefore, parsing a JSON text will convert all numerical values to [float] types.
[codeblock]
p = parse_json('["a", "b", "c"]')
if typeof(p) == TYPE_ARRAY:
@ -612,7 +612,7 @@
<argument index="1" name="y" type="float">
</argument>
<description>
Returns the result of 'x' raised to the power of 'y'.
Returns the result of [code]x[/code] raised to the power of [code]y[/code].
[codeblock]
pow(2,5) # returns 32
[/codeblock]
@ -624,7 +624,7 @@
<argument index="0" name="path" type="String">
</argument>
<description>
Returns a resource from the filesystem that is loaded during script parsing. Note: resource paths can be obtained by right clicking on a resource in the Assets Pannel and choosing "Copy Path".
Returns a resource from the filesystem that is loaded during script parsing. Note: resource paths can be obtained by right clicking on a resource in the Assets Panel and choosing "Copy Path".
[codeblock]
# load a scene called main located in the root of the project directory
var main = preload("res://main.tscn")
@ -646,7 +646,7 @@
<return type="void">
</return>
<description>
Print a stack track at code location, only works when running with debugger turned on.
Prints a stack track at code location, only works when running with debugger turned on.
Output in the console would look something like this:
[codeblock]
Frame 0 - res://test.gd:16 in function '_process'
@ -657,7 +657,7 @@
<return type="void">
</return>
<description>
Print one or more arguments to strings in the best way possible to standard error line.
Prints one or more arguments to strings in the best way possible to standard error line.
[codeblock]
printerr("prints to stderr")
[/codeblock]
@ -667,7 +667,7 @@
<return type="void">
</return>
<description>
Print one or more arguments to strings in the best way possible to console. No newline is added at the end.
Prints one or more arguments to strings in the best way possible to console. No newline is added at the end.
[codeblock]
printraw("A")
printraw("B")
@ -679,7 +679,7 @@
<return type="void">
</return>
<description>
Print one or more arguments to the console with a space between each argument.
Prints one or more arguments to the console with a space between each argument.
[codeblock]
prints("A", "B", "C") # prints A B C
[/codeblock]
@ -689,7 +689,7 @@
<return type="void">
</return>
<description>
Print one or more arguments to the console with a tab between each argument.
Prints one or more arguments to the console with a tab between each argument.
[codeblock]
printt("A", "B", "C") # prints A B C
[/codeblock]
@ -701,7 +701,7 @@
<argument index="0" name="rad" type="float">
</argument>
<description>
Convert from radians to degrees.
Converts from radians to degrees.
[codeblock]
rad2deg(0.523599) # returns 30
[/codeblock]
@ -715,7 +715,7 @@
<argument index="1" name="to" type="float">
</argument>
<description>
Random range, any floating point value between 'from' and 'to'.
Random range, any floating point value between [code]from[/code] and [code]to[/code].
[codeblock]
prints(rand_range(0, 1), rand_range(0, 1)) # prints 0.135591 0.405263
[/codeblock]
@ -727,14 +727,14 @@
<argument index="0" name="seed" type="int">
</argument>
<description>
Random from seed: pass a seed, and an array with both number and new seed is returned. "Seed" here refers to the internal state of the pseudo random number generator. The internal state of the current implementation is 64 bits.
Random from seed: pass a [code]seed[/code], and an array with both number and new seed is returned. "Seed" here refers to the internal state of the pseudo random number generator. The internal state of the current implementation is 64 bits.
</description>
</method>
<method name="randf">
<return type="float">
</return>
<description>
Return a random floating point value between 0 and 1.
Returns a random floating point value between 0 and 1.
[codeblock]
randf() # returns 0.375671
[/codeblock]
@ -744,7 +744,7 @@
<return type="int">
</return>
<description>
Return a random 32 bit integer. Use remainder to obtain a random value between 0 and N (where N is smaller than 2^32 -1).
Returns a random 32 bit integer. Use remainder to obtain a random value between 0 and N (where N is smaller than 2^32 -1).
[codeblock]
randi() % 20 # returns random number between 0 and 19
randi() % 100 # returns random number between 0 and 99
@ -756,7 +756,7 @@
<return type="void">
</return>
<description>
Randomize the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
Randomizes the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
[codeblock]
func _ready():
randomize()
@ -767,7 +767,7 @@
<return type="Array">
</return>
<description>
Return 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).
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).
[codeblock]
for i in range(4):
print(i)
@ -807,7 +807,7 @@
<argument index="4" name="ostop" type="float">
</argument>
<description>
Maps a value from range [istart, istop] to [ostart, ostop].
Maps a [code]value[/code] from range [code][istart, istop][/code] to [code][ostart, ostop][/code].
[codeblock]
range_lerp(75, 0, 100, -1, 1) # returns 0.5
[/codeblock]
@ -819,7 +819,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Returns the integral value that is nearest to s, with halfway cases rounded away from zero.
Returns the integral value that is nearest to [code]s[/code], with halfway cases rounded away from zero.
[codeblock]
round(2.6) # returns 3
[/codeblock]
@ -831,7 +831,7 @@
<argument index="0" name="seed" type="int">
</argument>
<description>
Set seed for the random number generator.
Sets seed for the random number generator.
[codeblock]
my_seed = "Godot Rocks"
seed(my_seed.hash())
@ -844,7 +844,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Return sign of 's' -1 or 1.
Returns sign of [code]s[/code] -1 or 1.
[codeblock]
sign(-6) # returns -1
sign(6) # returns 1
@ -857,7 +857,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Return the sine of angle 's' in radians.
Returns the sine of angle [code]s[/code] in radians.
[codeblock]
sin(0.523599) # returns 0.5
[/codeblock]
@ -869,7 +869,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Return the hyperbolic sine of 's'.
Returns the hyperbolic sine of [code]s[/code].
[codeblock]
a = log(2.0) # returns 0.693147
sinh(a) # returns 0.75
@ -882,7 +882,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Return the square root of 's'.
Returns the square root of [code]s[/code].
[codeblock]
sqrt(9) # returns 3
[/codeblock]
@ -896,14 +896,14 @@
<argument index="1" name="step" type="float">
</argument>
<description>
Snap float value to a given step.
Snaps float value [code]s[/code] to a given [code]step[/code].
</description>
</method>
<method name="str" qualifiers="vararg">
<return type="String">
</return>
<description>
Convert one or more arguments to string in the best way possible.
Converts one or more arguments to string in the best way possible.
[codeblock]
var a = [10, 20, 30]
var b = str(a);
@ -918,7 +918,7 @@
<argument index="0" name="string" type="String">
</argument>
<description>
Convert a formatted string that was returned by [method var2str] to the original value.
Converts a formatted string that was returned by [method var2str] to the original value.
[codeblock]
a = '{ "a": 1, "b": 2 }'
b = str2var(a)
@ -932,7 +932,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Return the tangent of angle 's' in radians.
Returns the tangent of angle [code]s[/code] in radians.
[codeblock]
tan( deg2rad(45) ) # returns 1
[/codeblock]
@ -944,7 +944,7 @@
<argument index="0" name="s" type="float">
</argument>
<description>
Returns the hyperbolic tangent of 's'.
Returns the hyperbolic tangent of [code]s[/code].
[codeblock]
a = log(2.0) # returns 0.693147
tanh(a) # returns 0.6
@ -957,7 +957,7 @@
<argument index="0" name="var" type="Variant">
</argument>
<description>
Convert a Variant 'var' to json text and return the result. Useful for serializing data to store or send over the network
Converts a Variant [code]var[/code] to JSON text and return the result. Useful for serializing data to store or send over the network.
[codeblock]
a = { 'a': 1, 'b': 2 }
b = to_json(a)
@ -971,7 +971,7 @@
<argument index="0" name="type" type="String">
</argument>
<description>
Returns whether the given class is exist in [ClassDB].
Returns whether the given class exists in [ClassDB].
[codeblock]
type_exists("Sprite") # returns true
type_exists("Variant") # returns false
@ -984,7 +984,7 @@
<argument index="0" name="what" type="Variant">
</argument>
<description>
Return the internal type of the given Variant object, using the TYPE_* enum in [@Global Scope].
Returns the internal type of the given Variant object, using the TYPE_* enum in [@Global Scope].
[codeblock]
p = parse_json('["a", "b", "c"]')
if typeof(p) == TYPE_ARRAY:
@ -1000,7 +1000,7 @@
<argument index="0" name="json" type="String">
</argument>
<description>
Check that 'json' is valid json data. Return empty string if valid. Return error message if not valid.
Checks that [code]json[/code] is valid JSON data. Returns empty string if valid. Returns error message if not valid.
[codeblock]
j = to_json([1, 2, 3])
v = validate_json(j)
@ -1017,7 +1017,7 @@
<argument index="0" name="var" type="Variant">
</argument>
<description>
Encode a variable value to a byte array.
Encodes a variable value to a byte array.
</description>
</method>
<method name="var2str">
@ -1026,7 +1026,7 @@
<argument index="0" name="var" type="Variant">
</argument>
<description>
Convert a value to a formatted string that can later be parsed using [method str2var].
Converts a Variant [code]var[/code] to a formatted string that can later be parsed using [method str2var].
[codeblock]
a = { 'a': 1, 'b': 2 }
print(var2str(a))
@ -1046,7 +1046,7 @@
<argument index="0" name="obj" type="Object">
</argument>
<description>
Return a weak reference to an object.
Returns a weak reference to an object.
A weak reference to an object is not enough to keep the object alive: when the only remaining references to a referent are weak references, garbage collection is free to destroy the referent and reuse its memory for something else. However, until the object is actually destroyed the weak reference may return the object even if there are no strong references to it.
</description>
</method>
@ -1058,7 +1058,7 @@
<argument index="1" name="signal" type="String">
</argument>
<description>
Stop the function execution and return the current state. Call [method GDFunctionState.resume] on the state to resume execution. This invalidates the state.
Stops the function execution and returns the current state. Call [method GDFunctionState.resume] on the state to resume execution. This invalidates the state.
Returns anything that was passed to the resume function call. If passed an object and a signal, the execution is resumed when the object's signal is emitted.
</description>
</method>