1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Code cleanup

Discussion in 'Skript' started by Vane, Jul 30, 2022.

Thread Status:
Not open for further replies.
  1. Vane

    Vane Member

    Joined:
    May 27, 2019
    Messages:
    11
    Likes Received:
    0
    Code (Text):
    1. command admin_setstructure [<text>] [<num>] [<num>] [<num>] [<num>] [<num>] [<num>]:
    2.     permission: "*"
    3.     trigger:
    4.         set {_s} to structure named arg-1
    5.         set {_l1} to location(arg-2,arg-3,arg-4,"spawn")
    6.         set {_l2} to location(arg-5,arg-6,arg-7,"spawn")
    7.         fill structure {_s} between {_l1} and {_l2}
    8.         save structure {_s}
    9.  
    Instead of using so many arguments for each axis, how would I just use 2 arguments for both locations
     
  2. Sabified

    Sabified Member

    Joined:
    Jun 5, 2022
    Messages:
    30
    Likes Received:
    2
    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 (Text):
    1. function setStructure(p: player):
    2.     set {_s} to structure named {structure.%{_p}%}
    3.     set {_l1} to location(%{coord1.%{_p}%.x}%,%{coord1.%{_p}%.y}%,%{coord1.%{_p}%.z}%,"spawn")
    4.     set {_l2} to location(%{coord2.%{_p}%.x}%,%{coord2.%{_p}%.y}%,%{coord2.%{_p}%.z}%,"spawn")
    5.     fill structure {_s} between {_l1} and {_l2}
    6.     save structure {_s}
    7.  
    8. command admin_setstructure <text>:
    9.     permission: op
    10.     usage: /admin_setstructure <name>
    11.     trigger:
    12.         if {waiting.%player%} is "Done":
    13.             set {waiting.%player%} to "Set"
    14.         if {waiting.%player%} is "Set":
    15.             send "Send a chat message for location one and two" to player
    16.             set {structure.%player%} to arg-1
    17.  
    18. on chat:
    19.     if {waiting.%player%} is "Pos2":
    20.         set {coord2.%player%.x} to x-coord of player
    21.         set {coord2.%player%.y} to y-coord of player
    22.         set {coord2.%player%.z} to z-coord of player
    23.  
    24.         send "&aSecond Position Set!" to player
    25.         set {waiting.%player%} to "Done"
    26.         setStructure(player)
    27.         cancel event
    28.  
    29.     if {waiting.%player%} is "Set":
    30.         set {coord1.%player%.x} to x-coord of player
    31.         set {coord1.%player%.y} to y-coord of player
    32.         set {coord1.%player%.z} to z-coord of player
    33.  
    34.         send "&eFirst Position Set.." to player
    35.         set {waiting.%player%} to "Pos2"
    36.         cancel event
    37.  
    38.  
     
Thread Status:
Not open for further replies.

Share This Page

Loading...