Your browser does not support JavaScript or its disabled!
Please turn it on, or be aware that some features on this website will not work correctly.
1.3K
Colour Names #78
This will colour monster names based on the names and values you set in the list.
1.37kb | 40 lines.
 --[[
  Script made by Lee (Discord: l33_) - www.trainorcreations.com
  If you want to support my work, feel free to donate at https://trainorcreations.com/donate
  PS. Stop ripping off my work and selling it as your own.
 ]]--
local colorTable = {
  ['Dragon'] = {'#008C9A', '#00707B', '#00545C', '#00383E', '#000E0F', '#000000'},
  ['Dragon Lord'] = {'#F59E03', '#C47E02', '#935F02', '#623F01', '#191000', '#000000'},
  ['Default'] = {'#D5082F', '#AA0626', '#80051C', '#550313', '#150105', '#000000'},
}

function doChangeColor(creature, healthPercent)
  if creature:isMonster() then
    local name = creature:getName()
    local color = colorTable[name]
    if not color then
      color = colorTable['Default']
    end
    if color then
      if healthPercent >= 95 then
        creature:setInformationColor(color[1])
      elseif healthPercent > 60 then
        creature:setInformationColor(color[2])
      elseif healthPercent > 30 then
        creature:setInformationColor(color[3])
      elseif healthPercent > 10 then
        creature:setInformationColor(color[4])
      elseif healthPercent > 3 then
        creature:setInformationColor(color[5])
      elseif healthPercent >= 0 then
        creature:setInformationColor(color[6])
      end
    end
  end
end

local monstercolor = macro(20000, "Coloured names", function() end)
onCreatureAppear(function(creature)
  if monstercolor:isOff() then return end
    doChangeColor(creature, creature:getHealthPercent())
end)

onCreatureHealthPercentChange(function(creature, healthPercent)
  doChangeColor(creature, healthPercent)
end)

19 Feb 2022
Ads