Custom Textures

First we need to choose a name for the texture, we'll just go by Test Texture.

Now you just have to take some image and save it as a PNG file in the mod directory. Let's say our file is named test.png. We'll do this:

-- ... previous code

function register(registerType)
    if registerType == "textures" then
        exdilin.register_and_load_texture("Test Texture", "test.png", "Normal", "OneSideTo1x1")
    end
end

Let's analyze it, we created a register function (more info in Initialization orders), then using an if "block", we check if we are currently registering textures (if we're not, we do nothing, you don't want to make textures while the game is making blocks?).

Then, the exdilin.register_and_load_texture function (which has a long name) has 4 arguments: The first is the name of the texture, as we said above it is Test Texture. The second is the file of the texture, we saved the image as test.png, so that's what we put here. The third is the texture type, it's a Normal texture. The fourth and final is the texture thing, which here is OneSideTo1x1 (which means the texture only shows to one side of a block).

The last step is to make the texture available in the build panel:

-- ... previous code

function pre_init()
    -- whatever code you had in here too
    exdilin.texture_item("Test Texture").register()
end

Nothing complex here, exdilin.texture_item takes the name of the texture, and then we use the register() function. This is like we do for block items except here it is texture items.

Last updated