niSourceTexture⚓︎
A texture that represent both static and dynamic content, as NiSourceTexture data objects can have their pixel data modified on the fly to implement dynamic texture behavior.
This type inherits the following: niTexture, niObjectNET, niObject
Properties⚓︎
controller
⚓︎
Read-only. The first controller available on the object.
Returns:
result
(niTimeController)
extraData
⚓︎
Read-only. The first extra data available on the object.
Returns:
result
(niExtraData)
fileName
⚓︎
Read-only. The platform-independent version of the filename from which the image was created, or nil if the image was created from pixel data.
Returns:
result
(string)
Example: Sampling landscape texture under the crosshair/mouse cursor
local function onEnterFrame()
local cursor = tes3.getCursorPosition()
local camera = tes3.worldController.worldCamera.cameraData.camera
local position, direction = camera:windowPointToRay({ cursor.x, cursor.y })
local hit = tes3.rayTest({
position = position,
direction = direction,
-- Let's ray test agains terrain
root = tes3.game.worldLandscapeRoot
})
if not hit or not hit.object then return end
local texturingProperty = hit.object.texturingProperty
if not texturingProperty then return end
local baseMap = texturingProperty.maps[1]
if not baseMap or not baseMap.texture then return end
tes3.messageBox(baseMap.texture.fileName)
end
local function onLoaded()
if event.isRegistered(tes3.event.enterFrame, onEnterFrame) then return end
event.register(tes3.event.enterFrame, onEnterFrame)
end
event.register(tes3.event.loaded, onLoaded)
formatPrefs
⚓︎
The NiFormatPrefs
of the texture.
Returns:
result
(niFormatPrefs)
height
⚓︎
Read-only. The height of the texture.
Returns:
result
(number)
isStatic
⚓︎
The static flag.
Returns:
result
(boolean)
name
⚓︎
The human-facing name of the given object.
Returns:
result
(string)
pixelData
⚓︎
The app-level pixel data.
Returns:
result
(niPixelData)
platformFilename
⚓︎
Read-only. The platform-specific version of the filename.
Returns:
result
(string)
refCount
⚓︎
Read-only. The number of references that exist for this object. When this value reaches zero, the object will be deleted.
Returns:
result
(number)
RTTI
⚓︎
Read-only. The runtime type information for this object. This is an alias for the .runTimeTypeInformation
property.
Returns:
result
(niRTTI)
runTimeTypeInformation
⚓︎
Read-only. The runtime type information for this object.
Returns:
result
(niRTTI)
width
⚓︎
Read-only. The width of the texture.
Returns:
result
(number)
Methods⚓︎
addExtraData
⚓︎
Appends an extra data to the object.
myObject:addExtraData(extraData)
Parameters:
extraData
(niExtraData)
clearPixelData
⚓︎
Detaches any pixel data associated with this texture. Any render-specific data will be maintained, and remain in the GPU's memory.
myObject:clearPixelData()
clone
⚓︎
Creates a copy of this object.
local result = myObject:clone()
Returns:
result
(niObject)
getGameReference
⚓︎
Searches for an niExtraData on this object to see if it has one that holds a related reference.
local reference = myObject:getGameReference(searchParents)
Parameters:
searchParents
(boolean): Default:false
. If true, all parent objects (if applicable) are also searched.
Returns:
reference
(tes3reference)
getStringDataStartingWith
⚓︎
Searches for an niExtraData on this object to see if it has niStringExtraData that has its string start with the provided value
argument.
local extra = myObject:getStringDataStartingWith(value)
Parameters:
value
(string): The first niStringExtraData starting with this value will be returned.
Returns:
extra
(niStringExtraData)
getStringDataWith
⚓︎
Searches for an niExtraData on this object to see if it has niStringExtraData that has the provided value
argument in its string field.
local extra = myObject:getStringDataWith(value)
Parameters:
value
(string): The first niStringExtraData with this word will be returned.
Returns:
extra
(niStringExtraData)
hasStringDataStartingWith
⚓︎
Searches for an niExtraData on this object to see if it has niStringExtraData that has its string start with the provided value
argument. Returns true if the value was found.
local result = myObject:hasStringDataStartingWith(value)
Parameters:
value
(string): The value to search for.
Returns:
result
(boolean)
hasStringDataWith
⚓︎
Searches for an niExtraData on this object to see if it has niStringExtraData that contains the provided value
argument in its string field. Returns true if the value was found.
local result = myObject:hasStringDataWith(value)
Parameters:
value
(string): The value to search for.
Returns:
result
(boolean)
isInstanceOfType
⚓︎
Determines if the object is of a given type, or of a type derived from the given type.
local result = myObject:isInstanceOfType(type)
Parameters:
Returns:
result
(boolean)
isOfType
⚓︎
Determines if the object is of a given type.
local result = myObject:isOfType(type)
Parameters:
Returns:
result
(boolean)
loadPixelDataFromFile
⚓︎
Loads the file associated with the texture into memory, and makes it accessible from the pixelData property.
myObject:loadPixelDataFromFile()
prependController
⚓︎
Add a controller to the object as the first controller.
myObject:prependController(controller)
Parameters:
controller
(niTimeController)
removeAllControllers
⚓︎
Removes all controllers.
myObject:removeAllControllers()
removeAllExtraData
⚓︎
Removes all extra data.
myObject:removeAllExtraData()
removeController
⚓︎
Removes a controller from the object.
myObject:removeController(controller)
Parameters:
controller
(niTimeController)
removeExtraData
⚓︎
Removes a specific extra data from the object.
myObject:removeExtraData(extraData)
Parameters:
extraData
(niExtraData)
saveBinary
⚓︎
Serializes the object, and writes it to the given file.
local success = myObject:saveBinary(path)
Parameters:
path
(string): The path to write the file at, relative to the Morrowind installation folder.
Returns:
success
(boolean): If true the object was successfully serialized.
setFlag
⚓︎
Sets a given flag in the niObjectNET flag data. The specifics use of the flag is dependent on the real underlying type.
myObject:setFlag(state, index)
Parameters:
state
(boolean)index
(number)
Functions⚓︎
createFromPath
⚓︎
Creates an niSourceTexture from the given filepath.
local texture = niSourceTexture.createFromPath(path, useCached)
Parameters:
path
(string): The filepath of the texture to load. Relative toData Files\
.useCached
(boolean): Default:true
. If true, the texture will be stored in the normal texture source cache, so that multiple calls to the same path will return the same object. This behavior can be disabled if necessary.
Returns:
texture
(niSourceTexture)