Code cleanup

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

Vane

Member
May 27, 2019
11
0
1
Code:
command admin_setstructure [<text>] [<num>] [<num>] [<num>] [<num>] [<num>] [<num>]:
    permission: "*"
    trigger:
        set {_s} to structure named arg-1
        set {_l1} to location(arg-2,arg-3,arg-4,"spawn")
        set {_l2} to location(arg-5,arg-6,arg-7,"spawn")
        fill structure {_s} between {_l1} and {_l2}
        save structure {_s}
Instead of using so many arguments for each axis, how would I just use 2 arguments for both locations
 
Does this work?
Only one argument and when you are at the location you want to set as pos1 you type something in the chat
Then move to the other position and type something in the chat to set it as pos2

Code:
function setStructure(p: player):
    set {_s} to structure named {structure.%{_p}%}
    set {_l1} to location(%{coord1.%{_p}%.x}%,%{coord1.%{_p}%.y}%,%{coord1.%{_p}%.z}%,"spawn")
    set {_l2} to location(%{coord2.%{_p}%.x}%,%{coord2.%{_p}%.y}%,%{coord2.%{_p}%.z}%,"spawn")
    fill structure {_s} between {_l1} and {_l2}
    save structure {_s}

command admin_setstructure <text>:
    permission: op
    usage: /admin_setstructure <name>
    trigger:
        if {waiting.%player%} is "Done":
            set {waiting.%player%} to "Set"
        if {waiting.%player%} is "Set":
            send "Send a chat message for location one and two" to player
            set {structure.%player%} to arg-1

on chat:
    if {waiting.%player%} is "Pos2":
        set {coord2.%player%.x} to x-coord of player
        set {coord2.%player%.y} to y-coord of player
        set {coord2.%player%.z} to z-coord of player

        send "&aSecond Position Set!" to player
        set {waiting.%player%} to "Done"
        setStructure(player)
        cancel event

    if {waiting.%player%} is "Set":
        set {coord1.%player%.x} to x-coord of player
        set {coord1.%player%.y} to y-coord of player
        set {coord1.%player%.z} to z-coord of player

        send "&eFirst Position Set.." to player
        set {waiting.%player%} to "Pos2"
        cancel event
 
Status
Not open for further replies.