Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Complete Roman Numeral Translator (REQUIRES VERY BIG BRAIN) --
- --[[ Some terminology you need to know:
- Numerals with || as shown in |IX| means the number is in the thousands.
- Numerals with () as shown in (IX) means the number is in the hundreds of thousands or millions
- For larger numbers that will be added in the future, [] means tens to hundreds of millions, {} for hundreds of millions to billions, <> for tens to hundreds of billions.
- Fractional Numerals are divisions of 12 and split into halves or "s"
- For more terminologies, I recommend learning how the complete Roman Numerals work!
- ]]
- local startValue = 1 -- I
- local increment = 1 -- I
- local duration = 10^4 -- |X| or 10,000 [max is 10 million or (X) or 10^7]
- local tickSpeed = 0.01 -- seconds for the next increment
- -- Function to convert a number to extended Roman numerals with subtraction rule and fractions
- local function toRoman(num)
- local values = {
- 10000000, 9000000, 5000000, 4000000, 1000000, 900000, 500000, 400000, 100000, 90000,
- 50000, 40000, 10000, 9000, 5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1
- }
- local numerals = {
- "(X)", "(IX)", "(V)", "(IV)", "(I)", "|IX)", "|D|", "|CD|", "|C|", "|XC|",
- "|L|", "|XL|", "|X|", "|IX|", "|V|", "|IV|", "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"
- }
- local fractionSymbols = {"s:·:", "s::", "s∴", "s:", "s·", "s", ":·:", "::", "∴", ":", "·"}
- local fractionValues = {11/12, 5/6, 3/4, 2/3, 7/12, 1/2, 5/12, 1/3, 1/4, 1/6, 1/12}
- local result = ""
- local fractionPart = num % 1 -- Get the fractional part of the number
- num = num - fractionPart -- Remove the fractional part from the number
- -- Convert the whole number part to Roman numerals
- for i, value in ipairs(values) do
- while num >= value do
- num = num - value
- if numerals[i] then -- Check if the numeral exists for the index
- result = result .. numerals[i]
- else
- print("Error: Index out of bounds for numerals array or Mismatched numerals.") -- Error handler
- break
- end
- end
- end
- -- Convert the fractional part to Roman numerals
- local addedFractions = 0 -- Keep track of added fractions to avoid going over 1
- for i, value in ipairs(fractionValues) do
- while fractionPart >= value and addedFractions + value <= 1 do
- fractionPart = fractionPart - value
- addedFractions = addedFractions + value
- result = result .. fractionSymbols[i]
- end
- end
- return result
- end
- -- Function to perform addition over time
- local function addOverTime(startValue, increment, duration)
- local currentValue = startValue
- print(toRoman(currentValue))
- for i = 1, duration do
- wait(tickSpeed) -- Wait
- currentValue = currentValue + increment
- print(toRoman(currentValue))
- end
- end
- -- Starting Value, Increment, Tick Duration
- addOverTime(startValue, increment, duration)
Advertisement
Comments
-
- |IX) means 900 thousand, or 100 thousand before 1 million. if a numeral has two different indicators, its usually the bridge between large numbers like thousand, million, billion and trillions
Add Comment
Please, Sign In to add comment
Advertisement