Editing Module:UtilitiesGive feedback
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 18: | Line 18: | ||
end | end | ||
-- Remove '#' from hashtags, but keep the word (e.g., '#Atlas' becomes 'Atlas') | |||
result = result:gsub("#(%w+)", "%1") | |||
-- Trim any extra whitespace | -- Trim any extra whitespace | ||
result = result:gsub("^%s*(.-)%s*$", "%1") | result = result:gsub("^%s*(.-)%s*$", "%1") | ||
| Line 26: | Line 29: | ||
--round_to_significant_figures(12345.6789, 3) -- Output: 12300 | --round_to_significant_figures(12345.6789, 3) -- Output: 12300 | ||
--round_to_significant_figures(0.0012345, 2) -- Output: 0.0012 | --round_to_significant_figures(0.0012345, 2) -- Output: 0.0012 | ||
--round_to_significant_figures( | --round_to_significant_figures(-98765, 4) -- Output: -98760 | ||
function p.round_to_sig_fig(num, n) | |||
function p.round_to_sig_fig( | |||
if num == 0 then | if num == 0 then | ||
return 0 | return 0 | ||
| Line 111: | Line 108: | ||
local slot_colors = { | local slot_colors = { | ||
["Weapon"] = { | ["Weapon"] = { | ||
hex = " | hex = "c97a03", | ||
rgb = " | rgb = "201,122,3", | ||
hsl = " | hsl = "35,97%,40%", | ||
cmyk = "0%, | cmyk = "0%,39%,98%,21%" | ||
}, | }, | ||
["Armor"] = { | ["Armor"] = { | ||
hex = " | hex = "659818", | ||
rgb = " | rgb = "101,152,24", | ||
hsl = "82, | hsl = "82,73%,34%", | ||
cmyk = " | cmyk = "34%,0%,84%,40%" | ||
}, | }, | ||
["Tech"] = { | ["Tech"] = { | ||
hex = " | hex = "c288f0", -- purple | ||
rgb = " | rgb = "194,136,240", | ||
hsl = " | hsl = "276,79%,74%", | ||
cmyk = " | cmyk = "19%,43%,0%,6%" | ||
} | } | ||
| Line 216: | Line 213: | ||
if value then | if value then | ||
-- Keep only digits (0-9), plus (+), and minus (-) | -- Keep only digits (0-9), plus (+), and minus (-) | ||
value = value:gsub("[^0-9+ | value = value:gsub("[^0-9+-]", "") | ||
-- Return empty string if nothing left, otherwise return the filtered value | -- Return empty string if nothing left, otherwise return the filtered value | ||
return value ~= "" and value or variable_name | return value ~= "" and value or variable_name | ||
| Line 225: | Line 222: | ||
return processed_text | return processed_text | ||
end | end | ||
return p | return p | ||