Add texture overriding example

This commit is contained in:
Agent X 2023-11-13 09:30:20 -05:00
parent b6d1a8a706
commit 02607a686e
24 changed files with 56 additions and 3 deletions

View file

@ -0,0 +1,55 @@
-- name: Matrix Code
-- description: Run /matrix and a builtin texture name to replace with the digital rain
-- deluxe: true
if SM64COOPDX_VERSION ~= nil then
local first = false
hook_event(HOOK_ON_LEVEL_INIT, function()
if not first then
first = true
play_sound(SOUND_MENU_CAMERA_BUZZ, gMarioStates[0].marioObj.header.gfx.cameraToObject)
djui_chat_message_create("\\#ff7f7f\\Matrix Code is not supported with sm64ex-coop\nas it uses sm64coopdx exclusive Lua functionality.\n\\#dcdcdc\\To use this mod, try out sm64coopdx at\n\\#7f7fff\\https://sm64coopdx.com")
end
end)
return
end
local sMatrixFrames = {}
for i = 0, 10 do
sMatrixFrames[i] = get_texture_info("matrix_" .. i)
end
local matrixFrame = 0
local sOverrideTextures = {}
local globalTimer = 0
local function split(s)
local result = {}
for match in (s):gmatch(string.format("[^%s]+", " ")) do
table.insert(result, match)
end
return result
end
local function update()
globalTimer = globalTimer + 1
if globalTimer % 2 ~= 1 then return end
for _, texture in pairs(sOverrideTextures) do
texture_override_set(texture, sMatrixFrames[matrixFrame])
matrixFrame = (matrixFrame + 1) % 10
end
end
local function on_matrix_command(msg)
local textures = split(msg)
for _, texture in pairs(textures) do
table.insert(sOverrideTextures, texture)
end
return true
end
hook_event(HOOK_UPDATE, update)
hook_chat_command("matrix", "[TEXTURE]", on_matrix_command)

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

View file

@ -67,9 +67,7 @@ All of this is a holdover from when there were only two players. It was a reason
- [Custom Level](examples/custom-level) - [Custom Level](examples/custom-level)
- [Custom HUD Texture](examples/custom-hud-texture) - [Custom HUD Texture](examples/custom-hud-texture)
- [Custom Audio Test](examples/audio-test) - [Custom Audio Test](examples/audio-test)
- [Custom Texture Overriding](examples/texture-override)
## Example Lua mods (large) ## Example Lua mods (large)
- [Extended Moveset](../../mods/extended-moveset.lua)
- [Character Movesets](../../mods/character-movesets.lua)
- [Hide and Seek Gamemode](../../mods/hide-and-seek.lua) - [Hide and Seek Gamemode](../../mods/hide-and-seek.lua)
- [Football (soccer) Gamemode](../../mods/football.lua)