SetObjectTexture: Difference between revisions
From Onset Developer Wiki
No edit summary |
No edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Client|1.0}} | {{Info|Function|Client|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Sets a texture on an object. For animated ones check [[SetObjectAnimatedTexture]].}} | ||
{{FuncSyntax|SetObjectTexture(object, TextureFile [, MaterialSlot])}} | {{FuncSyntax|SetObjectTexture(object, TextureFile [, MaterialSlot])}} | ||
Line 8: | Line 8: | ||
{{FuncParam|object|The object identifier.}} | {{FuncParam|object|The object identifier.}} | ||
{{FuncParam|TextureFile|The texture file in your package folder.}} | {{FuncParam|TextureFile|The texture file in your package folder.}} | ||
{{FuncParamOptional|MaterialSlot|The material slot of the object model}} | {{FuncParamOptional|MaterialSlot|The material slot of the object model. Default: 0}} | ||
{{FuncReturnValue| | {{FuncReturnValue|Returns '''true''' on success.}} | ||
== Example == | == Example == | ||
Example taken from the example test scripts: https://github.com/BlueMountainsIO/OnsetLuaScripts/blob/master/horizon/client/world.lua#L81 | |||
<syntaxhighlight lang="Lua"> | |||
function OnObjectStreamIn(object) | |||
local _texture = GetObjectPropertyValue(object, "_texture") | |||
if _texture ~= nil then | |||
local _textureFile = GetObjectPropertyValue(object, "_textureFile") | |||
if _texture == "animated" then | |||
local _textureRowColumns = GetObjectPropertyValue(object, "_textureRowColumns") | |||
SetObjectAnimatedTexture(object, _textureFile, _textureRowColumns[1], _textureRowColumns[2]) | |||
elseif _texture == "static" then | |||
SetObjectTexture(object, _textureFile) | |||
end | |||
end | |||
end | |||
AddEvent("OnObjectStreamIn", OnObjectStreamIn) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
* [[GetObjectCount]] | |||
* [[GetObjectModelCount]] | |||
* [[GetObjectModelGroup]] | |||
* [[GetObjectModelName]] | |||
* [[GetStreamedObjects]] | |||
* [[GetObjectModel]] | |||
* [[GetObjectLocation]] | |||
* [[GetObjectRotation]] | |||
* [[GetObjectScale]] | |||
* [[GetObjectBoundingBox]] | |||
* [[GetObjectSize]] | |||
* [[EnableObjectHitEvents]] | |||
* [[GetObjectMass]] | |||
* [[SetObjectEditorSpeed]] | |||
* [[SetObjectEditable]] | |||
* [[SetObjectOutline]] | |||
* [[SetObjectCastShadow]] | |||
* [[SetObjectColor]] | |||
* [[SetObjectEmissiveColor]] | |||
* [[SetObjectAnimatedTexture]] |
Latest revision as of 11:07, 1 September 2020
Description
Sets a texture on an object. For animated ones check SetObjectAnimatedTexture.
Syntax
SetObjectTexture(object, TextureFile [, MaterialSlot])
Parameters
- object
The object identifier. - TextureFile
The texture file in your package folder. - MaterialSlot (optional)
The material slot of the object model. Default: 0
Return Value
- Returns true on success.
Example
Example taken from the example test scripts: https://github.com/BlueMountainsIO/OnsetLuaScripts/blob/master/horizon/client/world.lua#L81
function OnObjectStreamIn(object)
local _texture = GetObjectPropertyValue(object, "_texture")
if _texture ~= nil then
local _textureFile = GetObjectPropertyValue(object, "_textureFile")
if _texture == "animated" then
local _textureRowColumns = GetObjectPropertyValue(object, "_textureRowColumns")
SetObjectAnimatedTexture(object, _textureFile, _textureRowColumns[1], _textureRowColumns[2])
elseif _texture == "static" then
SetObjectTexture(object, _textureFile)
end
end
end
AddEvent("OnObjectStreamIn", OnObjectStreamIn)
See also
- GetObjectCount
- GetObjectModelCount
- GetObjectModelGroup
- GetObjectModelName
- GetStreamedObjects
- GetObjectModel
- GetObjectLocation
- GetObjectRotation
- GetObjectScale
- GetObjectBoundingBox
- GetObjectSize
- EnableObjectHitEvents
- GetObjectMass
- SetObjectEditorSpeed
- SetObjectEditable
- SetObjectOutline
- SetObjectCastShadow
- SetObjectColor
- SetObjectEmissiveColor
- SetObjectAnimatedTexture