Solved How do I get all integers between two numbers

  • 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.
A maths lesson: There is a infinite amount of numbers between two selected ones. Therefore, I assume you wanted integers
Code:
function betweenInts(a: integer, b: integer) :: text: #assuming that b > a
    set {_nmb} to {_a} +1
    while {_nmb} < {_b}:
        if {_result} is not set:
            set {_result} to "%{_nmb}%"
        else:
            set {_result} to "%{_result}%,%{_nmb}%"
        add 1 to {_nmb}
    return {_result}
Created a rather simple function that returns text, but you may want it as an array (i did not find a way how to return an array).
You can do it inside your command, for instance:
Code:
command /test <integer> <integer>:
    trigger:
        set {_x} to betweenInts(arg-1, arg-2)
        set {_end::*} to {_x} split at ","
        broadcast "%{_end::*}%" #or do whatever you want to do with it
Example of use: /test 1 6 (returns 2, 3, 4 and 5)
Note: I tested it, it works.

If I helped you, consider liking my message, marking the thread as solved and also choosing my answer as the best one :emoji_wink:
 
Status
Not open for further replies.