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.

Solved Mine reset

Discussion in 'Skript' started by Colorlot, Nov 23, 2018.

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

    Colorlot Member

    Joined:
    Nov 18, 2018
    Messages:
    4
    Likes Received:
    0
    I was wondering if there was a way to reset a mine with skript? I am making a server using only PermissionsEx, Skript, addons for skript, and worldedit, so I want to find a way to reset a mine with 50% cobblestone, 20% stone, 5% dirt, 15% iron ore, and 10% gold
     
  2. PatoFrango

    PatoFrango Active Member

    Joined:
    Jul 12, 2017
    Messages:
    240
    Likes Received:
    14
    You mean like, those Prison Break ones? Well, you could use what I like to call a three-axis-loop-building system.
    • Using loops, you could keep filling X-rows with stone and random generated ores. To accomplish this, you would add 1 to the value of x in each loop until the x-coordinate equals the ending coordinate of the row and, each time it looped, it would place a random ore/stone block (using Skript's chance of %percentage% condition) at the current x-coordinate.
    • Then, to fill the next row, you would set the x-coordinate back to it's starting value and add 1 to the z-one.
    Here's neat little a visual for you :emoji_wink:

    upload_2018-11-23_23-43-27.png

    Then, when the z-coordinate reaches the border, we will have a full filled square/rectange. But we don't want any of the two. We want a cube, so it's basically the same process, except we add 1 to the y-coordinate and then the whole process repeats itself until the y-coordinate reaches the full height of the cube.

    It might sound mind-boggling, but in case you're getting started with Skript it would make a really cool system to build.
    Tell me if there's anything else you need.

    P.S.: (I wanted to write text on the images but the software that I was using wouldn't let me lol)
     
  3. Colorlot

    Colorlot Member

    Joined:
    Nov 18, 2018
    Messages:
    4
    Likes Received:
    0
    Example code?
     
  4. PatoFrango

    PatoFrango Active Member

    Joined:
    Jul 12, 2017
    Messages:
    240
    Likes Received:
    14
    Well I’m on my phone right now haha so I wont be able to do that for you today, but tomorrow I’ll try to remember to do it.
    --- Double Post Merged, Nov 24, 2018, Original Post Date: Nov 24, 2018 ---
    Here you go:
    Code (Skript):
    1. function fillCube(startingX: integer, startingY: integer, startingZ: integer):
    2.     set {_loc} to location at {_startingX}, {_startingY}, {_startingZ} in world "cpi"
    3.     loop 30 times:
    4.         loop 30 times:
    5.             loop 30 times:
    6.             # All these thirties are, respectively, the height (y), width (z) and length (x) of the cube.
    7.                 chooseBlock({_loc})
    8.                 add 1 to x-coordinate of {_loc}
    9.             add 1 to z-coordinate of {_loc}
    10.             set x-coordinate of {_loc} to {_startingX}
    11.         add 1 to y-coordinate of {_loc}
    12.         set x-coordinate of {_loc} to {_startingX}
    13.         set z-coordinate of {_loc} to {_startingZ}
    14.  
    15. function chooseBlock(loc: location):
    16.     # The function that handles which blocks are going to be placed. I tried to code something a little more dynamic than long, monotonous 'chance of' blocks
    17.     set {_percentages::*} to 5%, 10%, 15%, 20% and 100%
    18.     set {_blocks::*} to dirt, gold ore, iron ore, stone and cobblestone
    19.     loop {_percentages::*}:
    20.         chance of loop-value:
    21.             set block at {_loc} to {_blocks::%loop-index%}
    22.             stop loop
    23.  
    24. on script load:
    25.     # Usage:
    26.     fillCube(0, 120, 0) # Specify the coordinates of one of the corners of the cube in the parameters.
    27.     # Note that you need to check if it is the right one by looking at the opposite corner of the cube, that is, the one diagonal to it, and check if the x-values and z-values in that direction are positive, since in the function we are constantly ADDING x and z coordinates.
    And with that I was able to create this, which is exactly what you asked:

    upload_2018-11-24_9-10-15.png

    But you do understand the concept right? That's what matters the most.
     
    #4 PatoFrango, Nov 24, 2018
    Last edited: Nov 25, 2018
Thread Status:
Not open for further replies.

Share This Page

Loading...