NoTwistedHere / Figma-to-Roblox

Mozilla Public License 2.0
12 stars 6 forks source link

Symbols break LimitDecimals function #3

Closed crunchbone closed 1 year ago

crunchbone commented 1 year ago

For some Figma designs I had been given, it would not successfully convert them. Looking in console I saw that this function was the culprit. Checking the number input type and returning 0 if it wasn't a number seemed to fix the issue I was having.

function LimitDecimals(Number, Decimals) { // Limit decimals to x places and round up/down
    if(typeof Number === 'number'){
        if (isNaN(Number)) return 0;
        if (Decimals !== undefined && isNaN(Decimals)) Decimals = null;

        return parseFloat(Number.toFixed(Decimals));
    } else {
        return 0;
    }
}

image image

NoTwistedHere commented 1 year ago

Thank you for finding & fixing the bug. - I'll accept this pull and do some testing to make sure Symbols aren't causing inaccurate conversions from an apparent oversight on my part.

After a bunch of testing I feel confident that Symbols (thanks to this fix) don't cause any unexpected issues 👍 (you also motivated me to figure out rotation stuff 😂)