Difference between revisions of "Object:type"

(Move example to example section)
(Updated type() output in example)
 
(2 intermediate revisions by one other user not shown)
Line 13: Line 13:
 
<source lang="lua">
 
<source lang="lua">
 
image = love.graphics.newImage("test.png")
 
image = love.graphics.newImage("test.png")
print(image:type()) -- outputs: Image
+
print(image:type()) -- outputs: Texture
 
source = love.audio.newSource("test.ogg")
 
source = love.audio.newSource("test.ogg")
 
print(source:type()) -- outputs: Source
 
print(source:type()) -- outputs: Source
 
</source>
 
</source>
  
An alternate way of printing the type:
 
<source lang="lua">
 
type = tostring(Object)
 
</source>
 
 
== See Also ==
 
== See Also ==
 
* [[parent::Object]]
 
* [[parent::Object]]

Latest revision as of 02:59, 30 November 2022

Gets the type of the object as a string.

Function

Synopsis

type = Object:type()

Arguments

None.

Returns

string type
The type as a string.

Examples

Printing the type of an object

image = love.graphics.newImage("test.png")
print(image:type()) -- outputs: Texture
source = love.audio.newSource("test.ogg")
print(source:type()) -- outputs: Source

See Also

Other Languages