Skip to content

CTexture

Type

CTexture

Represents a (z)doom format composite texture. A composite texture is made up of one or more patches (CTPatch).

For more information, see:

Properties

Property Type Description
patches CTPatch[] The patches that make up the texture
name string The texture name
width integer Width of the texture
height integer Height of the texture
worldPanning boolean If true, use world units instead of pixels for offsets (in map)
extended boolean If true, this is a ZDoom TEXTURES format texture, and contains CTPatchEx patches
type string The type of the texture: texture, sprite, graphic, walltexture or flat
scaleX float Horizontal scale of the texture (multiplier, eg. 0.5 is half size)
scaleY float Vertical scale of the texture (multiplier, eg. 0.5 is half size)
offsetX integer X offset of the texture
offsetY integer Y offset of the texture
optional boolean If true, texture is optional
noDecals boolean If true, no decals will show on this texture
nullTexture boolean If true, this texture is never drawn ingame (like AASHITTY)

Constructors

No Constructors

This type can not be created directly in scripts.

See:

Functions

Overview

General

AsText() -> string Clear() ConvertExtended() ConvertRegular() CopyTexture(other, [keepFormat])

Patch Modification

AddPatch(patch, [x], [y], [index]) DuplicatePatch(index, [offsetX], [offsetY]) RemovePatch(index) -> boolean ReplacePatch(index, newPatch) -> boolean SwapPatches(index1, index2) -> boolean


AsText

Gets the text definition of the texture in ZDoom TEXTURES format.

Returns

  • string: A text representation of the texture

Clear

Clears all texture data.


ConvertExtended

Converts the texture to an 'extended' (ZDoom TEXTURES) texture, and all patches to CTPatchEx.

Does nothing if the texture is already extended format (extended = true).


ConvertRegular

Converts the texture to an 'regular' (Doom TEXTUREx) texture, and all patches to CTPatch.

Does nothing if the texture is already regular format (extended = false).


CopyTexture

Copies another texture.

Parameters

  • other (CTexture): The texture to copy
  • [keepFormat] (boolean): If true, the current texture format (extended property) will be kept, otherwise it will be converted to the format of other. Default is false

AddPatch

Adds a new patch to the texture.

Parameters

  • patch (string): The name of the patch to add
  • [x] (integer, default 0): The x position of the patch within the texture
  • [y] (integer, default 0): The y position of the patch within the texture
  • [index] (integer, default -1): Where to add the patch in the patches array. Patches later in the array are drawn over the top of previous ones. If -1, the patch is added to the end of the array

Notes

The type of patch created depends on this texture's extended property:


DuplicatePatch

Duplicates the patch at index in the texture.

Parameters

  • index (integer): The index of the patch to duplicate
  • [offsetX] (integer): The amount to add to the X offset of the duplicated patch. Default is 8
  • [offsetY] (integer): The amount to add to the Y offset of the duplicated patch. Default is 8

Example

-- Add Patch
texture:AddPatch('patch1', 10, 10)

-- Duplicate Patch
texture:DuplicatePatch(1, 5, 5)

local dupPatch = texture.patches[2]
App.LogMessage('@' .. dupPatch.offsetX .. ',' .. dupPatch.offsetY) -- @15,15

RemovePatch

Removes the patch at index in the texture.

Parameters

  • index (integer): The index of the patch to remove

Returns

  • boolean: false if the given index was invalid (no patch removed)

ReplacePatch

Replaces the patch at index in the texture with newPatch.

Parameters

  • index (integer): The index of the patch to replace
  • newPatch (string): The new patch name

Returns

  • boolean: false if the given index was invalid (no patch replaced)

SwapPatches

Swaps the patch at index1 in the texture with the patch at index2.

Parameters

  • index1 (integer): The index of the first patch to swap
  • index2 (integer): The index of the second patch to swap

Returns

  • boolean: false if either of the given indices were invalid (no patches swapped)