Code Translation

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

tenten4846g

Member
Nov 12, 2021
1
0
1
17
I need help translating this code to skript, I tried and it keep giving me "<none>"

My python code
Code:
def ulam_spiral_coordinate(n):
    if n == 1:
        return (0, 0)
    k = math.ceil((math.sqrt(n) - 1) / 2)
    t = 2 * k + 1
    m = t ** 2
    if n >= m - t + 1:
        return (k - (m - n), -k)
    else:
        m -= t - 1
        if n >= m - t + 1:
            return (-k, -k + (m - n))
        else:
            m -= t - 1
            if n >= m - t + 1:
                return (-k + (m - n), k)
            else:
                return (k, k - (m - n - t + 1))

My current skript code (doesn't work):
Code:
command /find <number>:
    trigger:
        if arg-1 is equal to 1:
            set {_xresult} to 0
            set {_yresult} to 0
        else:
            set {_n} to arg-1 - 1
            {_k} = ceil((sqrt({_n}) - 1) / 2)
            {_t} = (2 * {_k}) + 1
            {_m} = {_t} ^ 2
            if {_n} is more than or equal to {_m} - {_t} + 1:
                set {_xresult} to {_k} - ({_m} - {_n})
                set {_yresult} to -1 * {_k}
            else:
                subtract {_t} - 1 from {_m}
                if {_n} is more than or equal to {_m} - {_t} + 1:
                    set {_xresult} to -1 * {_k}
                    set {_yresult} to (-1 * {_k}) + ({_m} - {_n})
                else:
                    subtract {_t} - 1 from {_m}
                    if {_n} is more than or equal to {_m} - {_t} + 1:
                        set {_xresult} to (-1 * {_k}) + {_m} - {_n}
                        set {_yresult} to {_k}
                    else:
                        set {_xresult} to {_k}
                        set {_yresult} to {_k} - ({_m} - {_n} - {_t} + 1)
        message "&fX:%{_xresult}%, Y:%{_yresult}%" to player