Add texture overriding example
55
docs/lua/examples/texture-override/main.lua
Normal 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)
|
BIN
docs/lua/examples/texture-override/textures/matrix_0.png
Normal file
After Width: | Height: | Size: 148 KiB |
BIN
docs/lua/examples/texture-override/textures/matrix_0.tex
Normal file
BIN
docs/lua/examples/texture-override/textures/matrix_1.png
Normal file
After Width: | Height: | Size: 151 KiB |
BIN
docs/lua/examples/texture-override/textures/matrix_1.tex
Normal file
BIN
docs/lua/examples/texture-override/textures/matrix_10.png
Normal file
After Width: | Height: | Size: 152 KiB |
BIN
docs/lua/examples/texture-override/textures/matrix_10.tex
Normal file
BIN
docs/lua/examples/texture-override/textures/matrix_2.png
Normal file
After Width: | Height: | Size: 151 KiB |
BIN
docs/lua/examples/texture-override/textures/matrix_2.tex
Normal file
BIN
docs/lua/examples/texture-override/textures/matrix_3.png
Normal file
After Width: | Height: | Size: 151 KiB |
BIN
docs/lua/examples/texture-override/textures/matrix_3.tex
Normal file
BIN
docs/lua/examples/texture-override/textures/matrix_4.png
Normal file
After Width: | Height: | Size: 151 KiB |
BIN
docs/lua/examples/texture-override/textures/matrix_4.tex
Normal file
BIN
docs/lua/examples/texture-override/textures/matrix_5.png
Normal file
After Width: | Height: | Size: 151 KiB |
BIN
docs/lua/examples/texture-override/textures/matrix_5.tex
Normal file
BIN
docs/lua/examples/texture-override/textures/matrix_6.png
Normal file
After Width: | Height: | Size: 150 KiB |
BIN
docs/lua/examples/texture-override/textures/matrix_6.tex
Normal file
BIN
docs/lua/examples/texture-override/textures/matrix_7.png
Normal file
After Width: | Height: | Size: 151 KiB |
BIN
docs/lua/examples/texture-override/textures/matrix_7.tex
Normal file
BIN
docs/lua/examples/texture-override/textures/matrix_8.png
Normal file
After Width: | Height: | Size: 151 KiB |
BIN
docs/lua/examples/texture-override/textures/matrix_8.tex
Normal file
BIN
docs/lua/examples/texture-override/textures/matrix_9.png
Normal file
After Width: | Height: | Size: 151 KiB |
BIN
docs/lua/examples/texture-override/textures/matrix_9.tex
Normal 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 HUD Texture](examples/custom-hud-texture)
|
||||
- [Custom Audio Test](examples/audio-test)
|
||||
- [Custom Texture Overriding](examples/texture-override)
|
||||
|
||||
## 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)
|
||||
- [Football (soccer) Gamemode](../../mods/football.lua)
|
||||
|
|