-- name: You Got A Star! Text -- description: You Got A Star! Text v1.0 by MegAmi\nShows the name of a star when you grab it. local text_alpha = 0 local text_timer = 0 local function on_interact(m, o, interactType, interactValue) -- Show the text when collecting a star in non-stop mode if m.playerIndex == 0 and obj_has_behavior_id(o, id_bhvBowserKey) == 1 and (o.oInteractionSubtype & INT_SUBTYPE_GRAND_STAR) == 0 and interactType == INTERACT_STAR_OR_KEY and m.health >= 0x100 and gServerSettings.stayInLevelAfterStar == 2 then text_timer = 30 * 4 -- Four seconds end end hook_event(HOOK_ON_INTERACT, on_interact) local function on_hud_render() -- Handle fading text_timer = text_timer - 1 if gMarioStates[0].action == ACT_STAR_DANCE_EXIT or gMarioStates[0].action == ACT_STAR_DANCE_NO_EXIT or gMarioStates[0].action == ACT_STAR_DANCE_WATER or text_timer > 0 then if text_alpha < 255 then text_alpha = text_alpha + 8 if text_alpha > 255 then text_alpha = 255 end end else if text_alpha > 0 then text_alpha = text_alpha - 8 if text_alpha < 0 then text_alpha = 0 end end end if text_alpha == 0 then return end djui_hud_set_resolution(RESOLUTION_N64); djui_hud_set_color(255, 255, 255, text_alpha); -- Draw "YOU GOT A STAR!" local text = "YOU GOT A STAR!" if get_last_star_or_key() == 1 then text = "YOU GOT A KEY!" end djui_hud_set_font(FONT_HUD) local drawX = djui_hud_get_screen_width() / 2 - (djui_hud_measure_text(text) / 2) local drawY = 180 djui_hud_print_text(text, drawX, drawY, 1) -- Get the name of the star/key local draw_star_num = false if get_last_star_or_key() == 0 then if get_last_completed_course_num() > 15 then -- Bonus/Bowser course -- All Bonus/Bowser course stars are simply named "Star #" -- That doesn't look very good here, especially since most of these courses only have 1 star each (at least in vanilla) -- Use the fallback "A Secret Star!" text instead. I'll remove this if Coop DX gives these stars actual names text = "A Secret Star!" elseif get_last_completed_star_num() == 7 then local courseNum = get_last_completed_course_num() text = string.format("%d Coins in %s", gLevelValues.coinsRequiredForCoinStar, get_level_name(courseNum, get_level_num_from_course_num(courseNum), 1)) else draw_star_num = true text = get_star_name(get_last_completed_course_num(), get_last_completed_star_num()) end else local courseNum = get_last_completed_course_num() text = get_level_name(courseNum, get_level_num_from_course_num(courseNum), 1) end -- Init star name djui_hud_set_font(FONT_NORMAL) drawX = djui_hud_get_screen_width() / 2 - djui_hud_measure_text(text) / 4 drawY = drawY + 20 -- Draw star icon djui_hud_set_font(FONT_HUD) local star_num = "*" if get_last_star_or_key() == 1 then star_num = "^" elseif draw_star_num == true then star_num = string.format("*%d", get_last_completed_star_num()) end local star_num_offset = djui_hud_measure_text(star_num) / 2 + 4 djui_hud_print_text(star_num, drawX - star_num_offset, drawY, 1) drawX = drawX + star_num_offset -- Draw star name djui_hud_set_font(FONT_NORMAL) djui_hud_print_text(text, drawX, drawY, 0.5) end hook_event(HOOK_ON_HUD_RENDER_BEHIND, on_hud_render) local function on_level_init() -- Reset text so it isn't visible after a screen transition text_alpha = 0 text_timer = 0 end hook_event(HOOK_ON_LEVEL_INIT, on_level_init)