Solved Mine reset

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

Colorlot

Member
Nov 18, 2018
4
0
0
26
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
 
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)
 
Example code?
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.
[doublepost=1543050471,1543021750][/doublepost]
Example code?
Here you go:
code_language.skript:
function fillCube(startingX: integer, startingY: integer, startingZ: integer):
    set {_loc} to location at {_startingX}, {_startingY}, {_startingZ} in world "cpi"
    loop 30 times:
        loop 30 times:
            loop 30 times:
            # All these thirties are, respectively, the height (y), width (z) and length (x) of the cube.
                chooseBlock({_loc})
                add 1 to x-coordinate of {_loc}
            add 1 to z-coordinate of {_loc}
            set x-coordinate of {_loc} to {_startingX}
        add 1 to y-coordinate of {_loc}
        set x-coordinate of {_loc} to {_startingX}
        set z-coordinate of {_loc} to {_startingZ}
 
function chooseBlock(loc: location):
    # 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
    set {_percentages::*} to 5%, 10%, 15%, 20% and 100%
    set {_blocks::*} to dirt, gold ore, iron ore, stone and cobblestone
    loop {_percentages::*}:
        chance of loop-value:
            set block at {_loc} to {_blocks::%loop-index%}
            stop loop
 
on script load:
    # Usage:
    fillCube(0, 120, 0) # Specify the coordinates of one of the corners of the cube in the parameters.
    # 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.
 
Last edited:
Status
Not open for further replies.