sphereofnoform

Eval IIDX Grade

Jul 30th, 2025
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.09 KB | None | 0 0
  1. LoadFont("Common Large") .. {
  2.                 Name = "IIDXGrade",
  3.                 InitCommand = function(self)
  4.                     self:xy(frameWidth + frameX - 18, frameY - 152)
  5.                     self:zoom(0.45)
  6.                     self:halign(1)
  7.                     self:queuecommand("Set")
  8.                     self:maxwidth(capWideScale(125, 300))
  9.                 end,
  10.                 BeginCommand = function(self) self:queuecommand("Set") end,
  11.                 ScoreChangedMessageCommand = function(self) self:queuecommand("Set") end,
  12.                 SetCommand = function(self)
  13.                 -- force custom window and rescore replay
  14.                 unloadCustomWindowConfig()
  15.                 loadCurrentCustomWindowConfig()      -- pick up exscore config
  16.                 MESSAGEMAN:Broadcast("RecalculateGraphs", {judge=GetTimingDifficulty()})
  17.  
  18.                 -- pull last replay snapshot
  19.                 local replay   = REPLAYS:GetActiveReplay()
  20.                 replay:LoadAllData()
  21.                 local snap     = replay:GetLastReplaySnapshot()
  22.                 local j        = snap:GetJudgments()
  23.  
  24.                 -- EX = PGREAT*2 + GREAT*1
  25.                 local w1, w2 = j.W1, j.W2
  26.                 local ex     = w1*2 + w2
  27.  
  28.                 -- total taps = sum of all judgments
  29.                 local taps = j.W1 + j.W2 + j.W3 + j.W4 + j.W5 + j.Miss
  30.  
  31.                 -- MAX = taps * 2
  32.                 local max   = taps * 2
  33.                 local ratio = ex / max
  34.  
  35.                 -- gradez
  36.                 local txt
  37.                 local bands = {
  38.                 { name="MAX", pct=9/9 },
  39.                 { name="AAA", pct=8/9 },
  40.                 { name="AA",  pct=7/9 },
  41.                 { name="A",   pct=6/9 },
  42.                 { name="B",   pct=5/9 },
  43.                 { name="C",   pct=4/9 },
  44.                 { name="D",   pct=3/9 },
  45.                 { name="E",   pct=2/9 },
  46.                 }
  47.                
  48.                 local thr = {}
  49.                 for i, band in ipairs(bands) do
  50.                 thr[i] = math.ceil(max * band.pct)
  51.                 end
  52.  
  53.                 if ex == max then
  54.                 txt = "MAX"
  55.                 else
  56.                 for i = 2, #bands do
  57.                     if ex >= thr[i] then
  58.                     -- compare distance above the lower‐band threshold vs.
  59.                     -- distance below the higher‐band threshold
  60.                     local up   = thr[i-1] - ex -- towards the higher band
  61.                     local down = ex - thr[i] -- above this band’s floor
  62.                     if up <= down then
  63.                         -- closer to the top
  64.                         txt = string.format("%s-%d", bands[i-1].name, up)
  65.                     else
  66.                         -- closer to the bottom
  67.                         txt = string.format("%s+%d", bands[i].name, down)
  68.                     end
  69.                     break
  70.                     end
  71.                 end
  72.                 if not txt then txt = "F" end
  73.                 end
  74.  
  75.                 -- display & color
  76.                 self:settext(txt)
  77.                 local c
  78.                     if txt == "MAX" then
  79.                     c = color("0.933,0.933,0.933,1")
  80.                     elseif txt:match("^MAX%-") then
  81.                     c = color("0.400,0.800,1.000,1")
  82.                     elseif txt:match("^AAA%+") then
  83.                     c = color("0.933,0.667,0.000,1")
  84.                     elseif txt:match("^AAA%-") then
  85.                     c = color("0.400,0.800,0.400,1")
  86.                     elseif txt:match("^AA%+") then
  87.                     c = color("0.400,0.800,0.400,1")
  88.                     elseif txt:match("^AA%-") then
  89.                     c = color("0.855,0.341,0.341,1")
  90.                     elseif txt:match("^A[+%-]") then
  91.                     c = color("0.855,0.341,0.341,1")
  92.                     elseif txt:match("^B") then
  93.                     c = color("0.357,0.471,0.733,1")
  94.                     elseif txt:match("^C") then
  95.                     c = color("0.788,0.482,1.000,1")
  96.                     elseif txt:match("^D") then
  97.                     c = color("0.549,0.384,0.224,1")
  98.                     elseif txt == "F" then
  99.                     c = color("0.804,0.804,0.804,1")
  100.                     else
  101.                     c = color("1,1,1,1")
  102.                     end
  103.                     self:diffuse(c)
  104.                     end,
  105.                 },
Advertisement
Add Comment
Please, Sign In to add comment