My Mod Star = Speed
link: Mod STar=Speed
Code :
-- name: \\#FFD700\\Star = Speed V1.0
-- description: Each star you collect increases your speed! +0.5 per star.
-- category: gameplay
-- pausable: true
-- Variables to track stars per player
local starCount = {}
-- Configuration
local SPEED_PER_STAR = 0.5 -- Speed boost per star
local MAX_SPEED = 200.0 -- Maximum speed cap
--- @param m MarioState
local function star_speed_update(m)
local pid = m.playerIndex
-- Initialize player data if needed
if starCount[pid] == nil then
end
-- Apply speed boost if Mario is moving
if starCount[pid] > 0 and m.forwardVel ~= 0 then
local speedBoost = starCount[pid] * SPEED_PER_STAR
m.forwardVel = math.min(m.forwardVel + speedBoost, MAX_SPEED)
end
end
--- Handle star interaction
--- @param m MarioState
--- @param o Object
--- @param interactType number
local function on_star_interact(m, o, interactType)
-- Check if the interacted object is a star or key
if interactType == INTERACT_STAR_OR_KEY then
local pid = m.playerIndex
if starCount[pid] == nil then
starCount[pid] = 0
end
-- Increment the star counter for the session
starCount[pid] = starCount[pid] + 1
end
end
--- Function to render the HUD
local function on_hud_render()
-- Only render for the local player
local m = gMarioStates[0]
local pid = m.playerIndex
-- Ensure data exists
if starCount[pid] == nil then
starCount[pid] = 0
end
-- Use the default built-in font to avoid the 'nil' error
djui_hud_set_font(FONT_NORMAL)
local scale = 1.0
-- Calculate total extra speed
local totalExtraSpeed = starCount[pid] * SPEED_PER_STAR
local extraSpeedStr = string.format("%.1f", totalExtraSpeed)
-- Prepare display text
local starsText = "Stars/Estrellas: " .. tostring(starCount[pid])
local speedText = "Speed extra/Velocidad extra: +" .. extraSpeedStr
-- Get screen dimensions
local screenHeight = djui_hud_get_screen_height()
-- Position at bottom-left corner
local x = 20
local yStart = screenHeight - 100
-- Draw Star count text
djui_hud_set_color(255, 215, 0, 255) -- Gold
djui_hud_print_text(starsText, x, yStart, scale)
-- Draw Extra Speed text
djui_hud_set_color(100, 255, 100, 255) -- Light Green
djui_hud_print_text(speedText, x, yStart + 30, scale)
end
-- Register Hooks
hook_event(HOOK_MARIO_UPDATE, star_speed_update)
hook_event(HOOK_ON_INTERACT, on_star_interact)
hook_event(HOOK_ON_HUD_RENDER, on_hud_render)
link: Mod STar=Speed
Code :
-- name: \\#FFD700\\Star = Speed V1.0
-- description: Each star you collect increases your speed! +0.5 per star.
-- category: gameplay
-- pausable: true
-- Variables to track stars per player
local starCount = {}
-- Configuration
local SPEED_PER_STAR = 0.5 -- Speed boost per star
local MAX_SPEED = 200.0 -- Maximum speed cap
--- @param m MarioState
local function star_speed_update(m)
local pid = m.playerIndex
-- Initialize player data if needed
if starCount[pid] == nil then
-- Apply speed boost if Mario is moving
if starCount[pid] > 0 and m.forwardVel ~= 0 then
local speedBoost = starCount[pid] * SPEED_PER_STAR
m.forwardVel = math.min(m.forwardVel + speedBoost, MAX_SPEED)
end
end
--- Handle star interaction
--- @param m MarioState
--- @param o Object
--- @param interactType number
local function on_star_interact(m, o, interactType)
-- Check if the interacted object is a star or key
if interactType == INTERACT_STAR_OR_KEY then
local pid = m.playerIndex
if starCount[pid] == nil then
starCount[pid] = 0
end
-- Increment the star counter for the session
starCount[pid] = starCount[pid] + 1
end
end
--- Function to render the HUD
local function on_hud_render()
-- Only render for the local player
local m = gMarioStates[0]
local pid = m.playerIndex
-- Ensure data exists
if starCount[pid] == nil then
starCount[pid] = 0
end
-- Use the default built-in font to avoid the 'nil' error
djui_hud_set_font(FONT_NORMAL)
local scale = 1.0
-- Calculate total extra speed
local totalExtraSpeed = starCount[pid] * SPEED_PER_STAR
local extraSpeedStr = string.format("%.1f", totalExtraSpeed)
-- Prepare display text
local starsText = "Stars/Estrellas: " .. tostring(starCount[pid])
local speedText = "Speed extra/Velocidad extra: +" .. extraSpeedStr
-- Get screen dimensions
local screenHeight = djui_hud_get_screen_height()
-- Position at bottom-left corner
local x = 20
local yStart = screenHeight - 100
-- Draw Star count text
djui_hud_set_color(255, 215, 0, 255) -- Gold
djui_hud_print_text(starsText, x, yStart, scale)
-- Draw Extra Speed text
djui_hud_set_color(100, 255, 100, 255) -- Light Green
djui_hud_print_text(speedText, x, yStart + 30, scale)
end
-- Register Hooks
hook_event(HOOK_MARIO_UPDATE, star_speed_update)
hook_event(HOOK_ON_INTERACT, on_star_interact)
hook_event(HOOK_ON_HUD_RENDER, on_hud_render)