Dan - Modder Application

Status
Not open for further replies.

Dan_SM64

Member
Modder
Nov 7, 2024
2
0
200
This is Dan, and I'd be happy to upload some of my works to the server.
Modding for Co-op DX has proved to be great experience toward my programming career.
I've learned to write cleaner, more efficient code, as proven by my works listed below.
I always give credit for code or existing mods that I've borrowed for my projects.
I have uploaded the script for Minimal HUD to demonstrate my coding methodologies.

Noteworthy Works (If these links don't work, just go to the server and search for my mods there):
Hide and Seek DX (To be released this Saturday)
Star Collectathon (48 Stars on #coop-mod-starboard)
Coin Collectathon (43 Stars on #coop-mod-starboard)
Fast Hide and Seek (48 Stars on #coop-mod-starboard)
Minimal HUD (30 Stars on #coop-mod-starboard)

LUA:
-- name: Minimal HUD
-- description: Written by Dan \n\nA small QoL mod which redraws the HUD to be simpler and more space-efficient. \n\nD-PAD Up/Down to adjust the size. \nD-PAD Right to hide/show entire HUD. \nD-PAD Left to hide/show your lives.

local size = 4
local padding = 3

local showHUD = true

local healthAlpha = 0
local healthAlphaSpeed = 0

local showLives = true

local function update()

    if (gMarioStates[0].controller.buttonPressed & D_JPAD) ~= 0 then
        if size > 2 then
            size = size - 2
        end
    end

    if (gMarioStates[0].controller.buttonPressed & U_JPAD) ~= 0 then
        if size < 10 then
            size = size + 2
        end
    end

    if (gMarioStates[0].controller.buttonPressed & L_JPAD) ~= 0 then
        showLives = not showLives
    end

    if (gMarioStates[0].controller.buttonPressed & R_JPAD) ~= 0 then
        showHUD = not showHUD
    end

    if gMarioStates[0].health < 0x800 then
        healthAlpha = 255
        healthAlphaSpeed = 0
    elseif healthAlpha > 0 then
        
        healthAlphaSpeed = healthAlphaSpeed + 8
        healthAlpha = healthAlpha - healthAlphaSpeed

        if healthAlpha < 0 then healthAlpha = 0 end
        
    end

end



--------------
--HUD RENDER--
--------------
local function on_hud_render_behind()

    --HIDE NORMAL HUD
    hud_hide()

    if gNetworkPlayers[0].currActNum == 99 then return end
    if obj_get_first_with_behavior_id(id_bhvActSelector) ~= nil then return end
    if not showHUD then return end

    --SET VARIABLES
    djui_hud_set_resolution(RESOLUTION_DJUI)
    djui_hud_set_font(2)
    djui_hud_set_color(255, 255, 255, 255)

    local row = 1

    --STAR COUNTER
    render_text("*", row, 1)
    render_text(tostring(gMarioStates[0].numStars), row, 2)
    row = row + 1

    --COIN COUNTER
    if
        gNetworkPlayers[0].currLevelNum ~= LEVEL_CASTLE and
        gNetworkPlayers[0].currLevelNum ~= LEVEL_CASTLE_COURTYARD and
        gNetworkPlayers[0].currLevelNum ~= LEVEL_CASTLE_GROUNDS
    then
        render_text("$", row, 1)
        render_text(tostring(gMarioStates[0].numCoins), row, 2)
        row = row + 1
    end

    --LIVES COUNTER
    if showLives then
        djui_hud_render_texture(gMarioStates[0].character.hudHeadTexture, (1-1)*16*size + padding*size*1, (row-1)*16*size + padding*size*row, size, size)
        if gMarioStates[0].numLives < 0 then
            render_text("0", row, 2)
        else
            render_text(tostring(gMarioStates[0].numLives), row, 2)
        end
        
        row = row + 1
    end
    
    --TIMER
    if hud_get_value(HUD_DISPLAY_TIMER) > 0 then
        djui_hud_print_text(convert_time(hud_get_value(HUD_DISPLAY_TIMER)), djui_hud_get_screen_width() - size*(75+padding), djui_hud_get_screen_height() - size*(16+padding), size)
        djui_hud_print_text("'", djui_hud_get_screen_width() - size*(62+padding), djui_hud_get_screen_height() - size*(23+padding), size)
        djui_hud_print_text("\"", djui_hud_get_screen_width() - size*(27+padding), djui_hud_get_screen_height() - size*(23+padding), size)
    end

    --RENDER HEALTH METER
    djui_hud_set_color(255, 255, 255, healthAlpha)
    hud_render_power_meter(gMarioStates[0].health, djui_hud_get_screen_width() - size*(56+padding), size*(-4+padding), size*64, size*64)

    

end

function render_text(message, y, x)

    djui_hud_print_text(message, (x-1)*16*size + padding*size*x, (y-1)*16*size + padding*size*y, size)

end

function convert_time(time)

    local minutes = math.floor(time / 30 / 60 % 60)
    local seconds = math.floor(time / 30 % 60)
    local centiseconds = math.floor(time / 30 % 1 * 10)

    if seconds < 10 then seconds = "0" .. tostring(seconds) end

    return(minutes .. " " .. seconds .. " " .. centiseconds)

end

hook_event(HOOK_ON_HUD_RENDER_BEHIND, on_hud_render_behind)
hook_event(HOOK_UPDATE, update)
 
Status
Not open for further replies.

Users who are viewing this thread