From 7491c2f6ee90a39a5cccf00a04f3242048bcb64b Mon Sep 17 00:00:00 2001 From: DemnyxOnyxfur <42382613+DemnyxOnyxfur@users.noreply.github.com> Date: Tue, 4 Jul 2023 17:19:07 -0400 Subject: [PATCH] Personal Star Counter EX+ Update (#432) * Update personal-starcount-ex.lua Adds an incompatible tag for gamemodes, as you aren't collecting any stars outside of the main game. Also adds some HUD trickery via djui_hud_set_render_behind_hud to draw underneath screen transitions, and the vanilla pause screen. * Update personal-starcount-ex.lua * Update personal-starcount-ex.lua * Update personal-starcount-ex.lua * Update personal-starcount-ex.lua * Update personal-starcount-ex.lua * Personal Star Counter Update + HUD appears along with the vanilla HUD during the intro cutscene. + Hides and redraws the vanilla star HUD to remove HUD alignment issues. + Red and Green star counts move to the top-left and top-right corners of the screen respectively during the credits. Thought it'd be good for content creators. + Ability to see everyone's PSC on the Player Menu (Tab menu? Select menu?) + Light "anti-cheat" If server cheats are enabled, the Star Dance Star and the Grand Star will have their models changed to, with the permission of Blocky.cmd, the "You Tried" star, and the Green Star total will not increase. I have not encountered any unintended behavior of either of these objects in vanilla, any included romhack, or any other released romhack that I have played at the time of this post. * Delete personal-starcount-ex.lua --- mods/personal-starcount-ex.lua | 185 ----------- .../actors/star_cheater_geo.bin | Bin 0 -> 2511 bytes mods/personal-starcount-ex/main.lua | 289 ++++++++++++++++++ 3 files changed, 289 insertions(+), 185 deletions(-) delete mode 100644 mods/personal-starcount-ex.lua create mode 100644 mods/personal-starcount-ex/actors/star_cheater_geo.bin create mode 100644 mods/personal-starcount-ex/main.lua diff --git a/mods/personal-starcount-ex.lua b/mods/personal-starcount-ex.lua deleted file mode 100644 index 055c1987..00000000 --- a/mods/personal-starcount-ex.lua +++ /dev/null @@ -1,185 +0,0 @@ --- name: Personal Star Counter EX+ --- description: See how many stars you collect!\nIdea by Mr.Needlemouse, created by Sunk\n\nModified by Demnyx. --- incompatible: gamemode arena - -if mod_storage_load("StarCounter") == nil then - mod_storage_save("StarCounter", "0") -end - -local TotalStarCounter = tonumber(mod_storage_load("StarCounter")) -local StarCounter = 0 -local prevNumStars = 0 - -local screenHeight = 0 -local screenWidth = 0 - -local psToggle = 1 - -local fadeTimer = 0 - --- junk -- -cutscenes = { - [ACT_END_PEACH_CUTSCENE] = true, - [ACT_CREDITS_CUTSCENE] = true, - [ACT_END_WAVING_CUTSCENE] = true, - [ACT_INTRO_CUTSCENE] = true, -} - ----@param m MarioState ---Increments an independent counter if a star is collected. -function localStarCounter(m, o, type) - if (m.playerIndex == 0) and (type == INTERACT_STAR_OR_KEY) then - --This ensures that it increments ONLY if a star is collected. - if get_id_from_behavior(o.behavior) ~= id_bhvBowserKey then - --The hook happens after the star count increments, so this allows the independent counter to increment ONLY when YELLOW star is collected. - if m.numStars ~= prevNumStars then - StarCounter = StarCounter + 1 - TotalStarCounter = TotalStarCounter + 1 - mod_storage_save("StarCounter", tostring(TotalStarCounter)) - end - end - end -end - --- Hud alpha stuff from Agent X -function djui_hud_set_adjusted_color(r, g, b, a) - local multiplier = 1 - if djui_hud_is_pause_menu_created() then multiplier = 0.57 end - djui_hud_set_color(r * multiplier, g * multiplier, b * multiplier, a) -end - -function displayStarCounter() - local m = gMarioStates[0] - if psToggle ~= 1 then return end - --if cutscenes[m.action] ~= nil then return end - if obj_get_first_with_behavior_id(id_bhvActSelector) ~= nil - or cutscenes[m.action] ~= nil then - return - end - - djui_hud_set_resolution(RESOLUTION_N64) - djui_hud_set_font(FONT_HUD) - - --I don't want to put this in a seperate function, there's not enough code for it to be worth it. - if m.playerIndex == 0 then - prevNumStars = m.numStars - else - return - end - - screenHeight = djui_hud_get_screen_height() - screenWidth = djui_hud_get_screen_width() - - if a == nil then - a = 255 - end - - local timerValFrames = hud_get_value(HUD_DISPLAY_TIMER) - local timerX = 0 - local timerY = 0 - - -- Move HUD graphics away from the TIMER HUD - if timerValFrames ~= 0 then - timerX = 60 - timerY = 17 - end - - --Normal personal star counter (The red one) - if StarCounter >= 100 then - djui_hud_set_adjusted_color(255, 255, 255, a) - djui_hud_print_text(tostring(StarCounter), screenWidth - 60 - timerX, screenHeight - 208 - timerY, 1) - djui_hud_set_adjusted_color(232, 17, 35, a) - djui_hud_render_texture(gTextures.star, screenWidth - 76 - timerX, screenHeight - 208 - timerY, 1, 1) - else - djui_hud_set_adjusted_color(246, 246, 246, a) - djui_hud_print_text(tostring("X"), screenWidth - 60 - timerX, screenHeight - 208 - timerY, 1) - djui_hud_set_adjusted_color(255, 255, 255, a) - djui_hud_print_text(tostring(StarCounter), screenWidth - 46 - timerX, screenHeight - 208 - timerY, 1) - djui_hud_set_adjusted_color(232, 17, 35, a) - djui_hud_render_texture(gTextures.star, screenWidth - 76 - timerX, screenHeight - 208 - timerY, 1, 1) - end - - --Total star counter (The green one) - if timerValFrames ~= 0 then - timerX = 0 - timerY = -10 - end - - local perceived_total_counter = TotalStarCounter - local milestone_counter = 0 - while perceived_total_counter >= 10000 do - perceived_total_counter = perceived_total_counter - 10000 - milestone_counter = milestone_counter + 1 - end - - if perceived_total_counter >= 100 then - djui_hud_set_adjusted_color(255, 255, 255, a) - djui_hud_print_text(tostring(perceived_total_counter), screenWidth - 60 - timerX, screenHeight - 190 - timerY, 1) - djui_hud_set_adjusted_color(50, 176, 40, a) - djui_hud_render_texture(gTextures.star, screenWidth - 76 - timerX, screenHeight - 190 - timerY, 1, 1) - if milestone_counter ~= 0 then - djui_hud_set_adjusted_color(255, 255, 255, a) - djui_hud_print_text(string.format("x%d", milestone_counter), screenWidth - 76 - timerX, screenHeight - 174 - timerY, 0.5) - end - else - djui_hud_set_adjusted_color(246, 246, 246, a) - djui_hud_print_text(tostring("X"), screenWidth - 60 - timerX, screenHeight - 190 - timerY, 1) - djui_hud_set_adjusted_color(255, 255, 255, a) - djui_hud_print_text(tostring(perceived_total_counter), screenWidth - 46 - timerX, screenHeight - 190 - timerY, 1) - djui_hud_set_adjusted_color(50, 176, 40, a) - djui_hud_render_texture(gTextures.star, screenWidth - 76 - timerX, screenHeight - 190 - timerY, 1, 1) - if milestone_counter ~= 0 then - djui_hud_set_adjusted_color(255, 255, 255, a) - djui_hud_print_text(string.format("x%d", milestone_counter), screenWidth - 76 - timerX, - screenHeight - 174 - timerY, 0.5) - end - end - - -- Trying some HUD trickery here.. - if is_transition_playing() == true then - fadeTimer = 5 - else - if fadeTimer >= 1 then - fadeTimer = fadeTimer - 1 - end - end - - if fadeTimer > 0 - or is_game_paused() == true then - djui_hud_set_render_behind_hud(true) - else - djui_hud_set_render_behind_hud(false) - end - --StarCounter = 120 (Debug thingie) -end - -function PSToggle(msg) - if msg == string.lower("On") or msg == "1" then - psToggle = 1 - return true - elseif msg == string.lower("Off") or msg == "0" then - psToggle = 0 - return true - end -end - ---------- ---Hooks-- ---------- -hook_event(HOOK_ON_INTERACT, localStarCounter) -hook_event(HOOK_ON_HUD_RENDER, displayStarCounter) -hook_chat_command('pstarcount', 'On|Off - Displays stars you"ve collected. Default is On.', PSToggle) - -_G.PersonalStarCounter = { - get_star_counter = function () - return StarCounter - end, - - get_total_star_counter = function () - return TotalStarCounter - end, - - hide_star_counters = function (hide) - if hide then psToggle = 0 else psToggle = 1 end - end, -} diff --git a/mods/personal-starcount-ex/actors/star_cheater_geo.bin b/mods/personal-starcount-ex/actors/star_cheater_geo.bin new file mode 100644 index 0000000000000000000000000000000000000000..c5c6694e8cabc3b6955d4afaf7890a96be2a1a10 GIT binary patch literal 2511 zcmV;=2{86VSx!$=LP<{34gdfE0001Z+Lc#(R1;Skzw^#x7(xUL7)^L6!J;OBG>CFL%X)q z%$crm>iErc#`uT}ZM#j|bC(D-N6>H6i`EoTQKwrkc8Q+LE?6L+3MBS@9t)V9Y+dK> zO^D2OxAVqVIj0|gL8&^vx5o5IybI$Umm<5sLX8j<#q#$3n6??5oG{C3Jm{2^9VVA% zM}Fg&)Ta-=+qEA%h<#cMAMnj`{8c+cYp?KA?2N?4oixUpMPgg$<{C>QfGThUXQ3Pw0Tah*mwK5KO&mjo91Jr^uDRT(Uc7Zj_K=3$TBy5zrY zU6rd>_X2=L4{u!qwBc?Va&je(*ULx|*b{aWo-2`De)%)ct-0THzI8{ za|m`Of)$Z<>G$jHQ0UP#Np~xGN7ZnuBX#ih*o3Us6T}B0$(>A2 ze$>WU;*|FyJs}evQlW0Q-J>mWI9?NY*Z$OP>u*4=zCt;xbcNXUiqN@sC`q_)+@;XC z*>+D*^SER4G&s?5Rtmda_uA=3qs zfn&=hdrn6Xor_$1MMt9b5P`%H&P7h}y=~QP-Mmvr8S5O65?;AS- zw~lGZa3@PA6<4@VZeI(bVK#WDRDKo>bAQ@XS4dr3y9w_f@=cZh04eWXCc=gBy#&$* zmFJY(0v=E^-cJ*KXNSUU)#v!Vdx1XK#CKlLT##TZ;(698W7=nT&j|G1{lVRh&#}qe z6AmejXOlFsO)=WkernU=JiNKsnA>z!xzR=0U;DJx#@8&6e-f{BM>bqb$&U0vTTFSl zE}pos^JW!qUex-)HaStfZnYg*67r^8c584& zq>l{!NV(Cd{jAltqo8;*a{ksk`+H1A`_^U3=N*IOkui!kJ|9|j9y^yWPgPG>*UAg) zq+gOcPe)_a8ma;#K8Iw+LQy2TVY&0eH0Mv(ZPTt3YNfmWB)lCOmmm*1rf8T_+}I|C z8`3jn(*xWY-Nb%uZ7`;pLfcGgqY8Q{C{1p;Vo!`Nbz5np2D{nFw6l8SjFWW9SBaRe zZ7%U9M7&M9)1mx(Lb;|zuGrkFLhmJZM3;U1<^#zYOLL0$y+VBv`N7Un1#dex7C28i z2Lg^XA&tjugq(b*aRit1II3n~-liVQP*xv+oRaNU|syY3_1ty&)%f=_{gA z@aVdt>uc}J33rzx-II)bAs$^q3a8h#Vu6Y#dn@n2OGb0bar3cv!365LKn+zz1z_th z-jm(@u+DDByoGsrb7$gvFp2)f__+tKHmkd5!!1&;FOZku`bv}4zY;IVIaqF)2twK> zihEskg}fKf%MC-CJO2udqpoQ-naY-B=fj=#4Z3<8*=|-GYLzEh($P01iu3jo5q>6O z+XLs#2UKMm(mq4KUUL>I5n_8!Z14tUn%y?Ok+Nrv>Bvyd8nl_3ZixunoXD@1X_B?L z3)zgEYY(|0CEFoy$!wFY_t^N|uVSt>&OZGoj+R8-d^-eoWxcU(zt*vFq{u-PzwQ1r zf8CgsNePC8tjxrz@mZOMg@y%7%h}Ca@X#?t4^;OL(40O&0jodUgqu03M1KA8$Ue@E z74_-U`6JYa-yT*U#M9J(iaTPN;~Y!}$LS$PrQ}03{W*<*hQN8h4M6V$!VYK>1ON|X zFQy{~5X!;WBnW4Ew}Y?&n5?0vfkD6j&(L;X%};=y0mcK?-UTTJD^dVG5yblKyWq3I zm@2^BWdpxB1LV++YC!ieT7vBlpwA6^4^0@{Fd5Jn=pX&@#Y5YCb_CF; z>ErYuW4|}FrvLrj^zW$+6?ck;GI=EKC#en9qiO@jIb>wUu=?OofO1HpocbUslxR Zs*x_wR16rA_L&E;{9*qp{sWY83C(6g+8O`= literal 0 HcmV?d00001 diff --git a/mods/personal-starcount-ex/main.lua b/mods/personal-starcount-ex/main.lua new file mode 100644 index 00000000..564a7f8d --- /dev/null +++ b/mods/personal-starcount-ex/main.lua @@ -0,0 +1,289 @@ +-- name: Personal Star Counter EX+ +-- description: See how many stars you've collected!\n\nCredits:\n\\#097419\\Mr.Needlemouse\\#FFFFFF\\ - Concept\nSunk\\#FFFFFF\\ - Creator\n\\#269A91\\Demnyx\\#FFFFFF\\ - Assistance\n\\#0000FF\\Blocky.cmd\\#FFFFFF\\ - Model\nPeachyPeach\\#FFFFFF\\ - Global Functions +-- incompatible: gamemode arena + +for i = 0, (MAX_PLAYERS - 1) do + gPlayerSyncTable[i].psc = 0 +end + +if mod_storage_load("StarCounter") == nil then + mod_storage_save("StarCounter", "0") +end +E_MODEL_STAR_CHEATER = smlua_model_util_get_id("star_cheater_geo") + +local starCheater = false +local TotalStarCounter = tonumber(mod_storage_load("StarCounter")) +local StarCounter = 0 +local prevNumStars = 0 +local screenHeight = 0 +local screenWidth = 0 +local pscToggle = 1 +local introTimer = 0 + +-- junk -- +cutscenes = { + [ACT_END_PEACH_CUTSCENE] = true, + [ACT_CREDITS_CUTSCENE] = true, + [ACT_END_WAVING_CUTSCENE] = true, +} + +---@param m MarioState +--Increments an independent counter if a star is collected. +function localStarCounter(m, o, type) + if (m.playerIndex == 0) and (type == INTERACT_STAR_OR_KEY) then + --This ensures that it increments ONLY if a star is collected. + if get_id_from_behavior(o.behavior) ~= id_bhvBowserKey then + --The hook happens after the star count increments, so this allows the independent counter to increment ONLY when YELLOW star is collected. + if m.numStars ~= prevNumStars then + StarCounter = StarCounter + 1 + gPlayerSyncTable[0].psc = StarCounter + if starCheater == false then --Only if not cheating + TotalStarCounter = TotalStarCounter + 1 + mod_storage_save("StarCounter", tostring(TotalStarCounter)) + end + end + end + end +end + +-- Hud alpha stuff from Agent X +function djui_hud_set_adjusted_color(r, g, b, a) + local multiplier = 1 + if djui_hud_is_pause_menu_created() then multiplier = 0.57 end --Star Display compatibility + djui_hud_set_color(r * multiplier, g * multiplier, b * multiplier, a) +end + +local function displayStarCounter() + local m = gMarioStates[0] + if pscToggle == 0 then return end + if obj_get_first_with_behavior_id(id_bhvActSelector) ~= nil then + return + end + + --Make HUD appear when the real one does during the intro + if m.action == ACT_INTRO_CUTSCENE then + if introTimer ~= 1195 then + introTimer = introTimer + 1 + end + end + + djui_hud_set_resolution(RESOLUTION_N64) + djui_hud_set_font(FONT_HUD) + --Draw over credits fades + if cutscenes[m.action] ~= true then + djui_hud_set_render_behind_hud(true) + else + djui_hud_set_render_behind_hud(false) + end + + --I don't want to put this in a seperate function, there's not enough code for it to be worth it. + if m.playerIndex == 0 then + prevNumStars = m.numStars + else + return + end + + screenHeight = djui_hud_get_screen_height() + screenWidth = djui_hud_get_screen_width() + + if a == nil then a = 255 end + + local timerValFrames = hud_get_value(HUD_DISPLAY_TIMER) + local timerX = 0 + local timerY = 0 + + -- Move HUD graphics away from the TIMER HUD + if timerValFrames ~= 0 then + timerX = 60 + timerY = 17 + end + + --Normal vanilla star counter (The fake real one) + --Yes Im hiding the hardcoded one because alignment is a pain lmao + if cutscenes[m.action] ~= true then + if introTimer >= 1195 + or m.action ~= ACT_INTRO_CUTSCENE then + if m.numStars >= 100 then + djui_hud_set_adjusted_color(255, 255, 255, a) + djui_hud_print_text(tostring(m.numStars), screenWidth - 60, screenHeight - 225, 1) + djui_hud_set_adjusted_color(255, 255, 255, a) + djui_hud_render_texture(gTextures.star, screenWidth - 76, screenHeight - 225, 1, 1.) + else + djui_hud_set_adjusted_color(246, 246, 246, a) + djui_hud_print_text("X", screenWidth - 60, screenHeight - 225, 1) + djui_hud_set_adjusted_color(255, 255, 255, a) + djui_hud_print_text(tostring(m.numStars), screenWidth - 46, screenHeight - 225, 1) + djui_hud_set_adjusted_color(255, 255, 255, a) + djui_hud_render_texture(gTextures.star, screenWidth - 76, screenHeight - 225, 1, 1) + end + end + end + + --Normal personal star counter (The red one) + if cutscenes[m.action] == true then + if StarCounter >= 100 then + djui_hud_set_adjusted_color(255, 255, 255, a) + djui_hud_print_text(tostring(StarCounter), screenWidth%2 + 38, screenHeight - 235, 1) + djui_hud_set_adjusted_color(232, 17, 35, a) + djui_hud_render_texture(gTextures.star, screenWidth%2 + 22, screenHeight - 235, 1, 1) + else + djui_hud_set_adjusted_color(246, 246, 246, a) + djui_hud_print_text(tostring("X"), screenWidth%2 + 38, screenHeight - 235, 1) + djui_hud_set_adjusted_color(255, 255, 255, a) + djui_hud_print_text(tostring(StarCounter), screenWidth%2 + 54, screenHeight - 235, 1) + djui_hud_set_adjusted_color(232, 17, 35, a) + djui_hud_render_texture(gTextures.star, screenWidth%2 + 22, screenHeight - 235, 1, 1) + end + else + if introTimer >= 1195 + or m.action ~= ACT_INTRO_CUTSCENE then + if StarCounter >= 100 then + djui_hud_set_adjusted_color(255, 255, 255, a) + djui_hud_print_text(tostring(StarCounter), screenWidth - 60 - timerX, screenHeight - 208 - timerY, 1) + djui_hud_set_adjusted_color(232, 17, 35, a) + djui_hud_render_texture(gTextures.star, screenWidth - 76 - timerX, screenHeight - 208 - timerY, 1, 1) + else + djui_hud_set_adjusted_color(246, 246, 246, a) + djui_hud_print_text(tostring("X"), screenWidth - 60 - timerX, screenHeight - 208 - timerY, 1) + djui_hud_set_adjusted_color(255, 255, 255, a) + djui_hud_print_text(tostring(StarCounter), screenWidth - 46 - timerX, screenHeight - 208 - timerY, 1) + djui_hud_set_adjusted_color(232, 17, 35, a) + djui_hud_render_texture(gTextures.star, screenWidth - 76 - timerX, screenHeight - 208 - timerY, 1, 1) + end + end + end + --Total star counter (The green one) + if timerValFrames ~= 0 then + timerX = 0 + timerY = -10 + end + + local perceived_total_counter = TotalStarCounter + local milestone_counter = 0 + while perceived_total_counter >= 10000 do + perceived_total_counter = perceived_total_counter - 10000 + milestone_counter = milestone_counter + 1 + end + + if cutscenes[m.action] == true then + if perceived_total_counter >= 100 then + djui_hud_set_adjusted_color(255, 255, 255, a) + djui_hud_print_text(tostring(perceived_total_counter), screenWidth - 60, screenHeight - 235, 1) + djui_hud_set_adjusted_color(50, 176, 40, a) + djui_hud_render_texture(gTextures.star, screenWidth - 76, screenHeight - 235, 1, 1) + if milestone_counter ~= 0 then + djui_hud_set_adjusted_color(255, 255, 255, a) + djui_hud_print_text(string.format("x%d", milestone_counter), screenWidth - 76, screenHeight - 235, 0.5) + end + else + djui_hud_set_adjusted_color(246, 246, 246, a) + djui_hud_print_text(tostring("X"), screenWidth - 60, screenHeight - 235, 1) + djui_hud_set_adjusted_color(255, 255, 255, a) + djui_hud_print_text(tostring(perceived_total_counter), screenWidth - 46, screenHeight - 235, 1) + djui_hud_set_adjusted_color(50, 176, 40, a) + djui_hud_render_texture(gTextures.star, screenWidth - 76, screenHeight - 235, 1, 1) + if milestone_counter ~= 0 then + djui_hud_set_adjusted_color(255, 255, 255, a) + djui_hud_print_text(string.format("x%d", milestone_counter), screenWidth - 76, screenHeight - 235, 0.5) + end + end + else + if introTimer >= 1195 + or m.action ~= ACT_INTRO_CUTSCENE then + if perceived_total_counter >= 100 then + djui_hud_set_adjusted_color(255, 255, 255, a) + djui_hud_print_text(tostring(perceived_total_counter), screenWidth - 60 - timerX, screenHeight - 190 - timerY, 1) + djui_hud_set_adjusted_color(50, 176, 40, a) + djui_hud_render_texture(gTextures.star, screenWidth - 76 - timerX, screenHeight - 190 - timerY, 1, 1) + if milestone_counter ~= 0 then + djui_hud_set_adjusted_color(255, 255, 255, a) + djui_hud_print_text(string.format("x%d", milestone_counter), screenWidth - 76 - timerX, screenHeight - 174 - timerY, 0.5) + end + else + djui_hud_set_adjusted_color(246, 246, 246, a) + djui_hud_print_text(tostring("X"), screenWidth - 60 - timerX, screenHeight - 190 - timerY, 1) + djui_hud_set_adjusted_color(255, 255, 255, a) + djui_hud_print_text(tostring(perceived_total_counter), screenWidth - 46 - timerX, screenHeight - 190 - timerY, 1) + djui_hud_set_adjusted_color(50, 176, 40, a) + djui_hud_render_texture(gTextures.star, screenWidth - 76 - timerX, screenHeight - 190 - timerY, 1, 1) + if milestone_counter ~= 0 then + djui_hud_set_adjusted_color(255, 255, 255, a) + djui_hud_print_text(string.format("x%d", milestone_counter), screenWidth - 76 - timerX, screenHeight - 174 - timerY, 0.5) + end + end + end + end +end + +--Turn server cheats off, silly! +--Will be updated immediately when individual cheats get flags. +function cheaterStar() + if starCheater == true then return end + if gServerSettings.enableCheats ~= 0 then + djui_popup_create("This server has cheats enabled.\n\\#31AF28\\Total Star Count\\#FFFFFF\\ will not change.", 2) + play_sound_button_change_blocked() + starCheater = true + else + starCheater = false + end +end + +--Changes models for the Star Dance Star and the Grand Star. +function bhv_star_cheater(o) + if starCheater == true then + obj_set_model_extended(o, E_MODEL_STAR_CHEATER) + end +end +id_bhvCelebrationStar = hook_behavior(id_bhvCelebrationStar, OBJ_LIST_LEVEL, false, bhv_star_cheater, bhv_star_cheater) +id_bhvGrandStar = hook_behavior(id_bhvGrandStar, OBJ_LIST_LEVEL, false, bhv_star_cheater, nil) + +--See how many stars everyone gets! +function updatePSC(m) + gPlayerSyncTable[0].psc = StarCounter +end + +--No star text icon yet, also the text gets removed after the second color change? +function update() + for i = 0, (MAX_PLAYERS - 1) do + gPlayerSyncTable[i].psc = gPlayerSyncTable[i].psc + network_player_set_description(gNetworkPlayers[i], "\\#FF0000\\".."Stars"..--[[ "\\#FFFFFF\\".. ]]": " ..tostring(gPlayerSyncTable[i].psc), 255, 255, 255, 255) + end +end + +function pscToggle(msg) + if msg == string.lower("On") or msg == "1" then + pscToggle = 1 + hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) & ~HUD_DISPLAY_FLAG_STAR_COUNT) + return true + elseif msg == string.lower("Off") or msg == "0" then + pscToggle = 0 + hud_set_value(HUD_DISPLAY_FLAGS, hud_get_value(HUD_DISPLAY_FLAGS) | HUD_DISPLAY_FLAG_STAR_COUNT) + return true + end +end + +--------- +--Hooks-- +--------- +hook_event(HOOK_ON_INTERACT, localStarCounter) +hook_event(HOOK_ON_HUD_RENDER, displayStarCounter) +hook_event(HOOK_ON_LEVEL_INIT, cheaterStar) +hook_event(HOOK_UPDATE, update) +hook_event(HOOK_UPDATE, updatePSC) +hook_chat_command('psc', "On|Off - Displays stars you've collected. Default is On.", pscToggle) + +--Global functions for everyone to use! +--Thank you, PeachyPeach! +_G.PersonalStarCounter = { + get_star_counter = function () + return StarCounter + end, + + get_total_star_counter = function () + return TotalStarCounter + end, + + hide_star_counters = function (hide) + if hide then pscToggle = 0 else pscToggle = 1 end + end, +} \ No newline at end of file