Solved Random teleport : Avoid certains biome

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

Aralwen

Active Member
May 26, 2017
164
14
18
25
Hello,

I try to make an command allowing to teleport randomly, but avoiding certain biomes, i do not know how to do to relaunch the loop, but without having to use command "make player execute command ...".

Have you a idea ? @Donut

My actual skript :

code_language.skript:
command /rtp:
    trigger:
        loop all players:
            remove resistance from the loop-player
            apply resistance 10 to loop-player for 30 seconds
            set {_test} to location(random number from -1500 to 1500, 100, random number from -1500 to 1500, world("world"))
            set {_biome} to biome at {_test}
            if biome at {_test} is not desert or desert hills or jungle or jungle hills or mesa or ocean or mushroom island or deep ocean or frozen ocean or frozen river or cold beach or stone beach or ice plains or ice mountains or ice plains spikes:
                loop blocks above {_test}:
                    if loop-block is air:
                        if block above loop-block is air:
                            if block 2 above loop-block is air:
                                set {_randomlocation} to location of loop-block
                                teleport loop-player to {_randomlocation}
            else:
                send "teleport the player until have a good biome" #Here I do not know how to do


Thank's everyone for helping me !


Skript Version: 2.2
Skript Author: ?
Minecraft Version: 1.8.8


Errors on Reload : Nothing
Console Errors : Nothing


Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums ? Yes
 
Last edited:
If you're saying that you want it to keep searching until it finds a valid location then use a while loop. So something like this:

code_language.skript:
command /rtp:
    trigger:
        set {SkyDefender.Statut} to 0
        loop all players:
            set {searching_for_location.%loop-player%} to true
            while {searching_for_location.%loop-player%} is true:
                remove resistance from the loop-player
                apply resistance 10 to loop-player for 30 seconds
                set {_test} to location(random number from -1500 to 1500, 100, random number from -1500 to 1500, world("world"))
                set {_biome} to biome at {_test}
                if biome at {_test} is not desert or desert hills or jungle or jungle hills or mesa or ocean or mushroom island or deep ocean or frozen ocean or frozen river or cold beach or stone beach or ice plains or ice mountains or ice plains spikes:
                    loop blocks above {_test}:
                        if loop-block is air:
                            if block above loop-block is air:
                                if block 2 above loop-block is air:
                                    set {_randomlocation} to location of loop-block
                                    teleport loop-player to {_randomlocation}
                                    set {searching_for_location.%loop-player%} to false
                wait 1 tick
 
  • Like
Reactions: Aralwen
If you're saying that you want it to keep searching until it finds a valid location then use a while loop. So something like this:

code_language.skript:
command /rtp:
    trigger:
        set {SkyDefender.Statut} to 0
        loop all players:
            set {searching_for_location.%loop-player%} to true
            while {searching_for_location.%loop-player%} is true:
                remove resistance from the loop-player
                apply resistance 10 to loop-player for 30 seconds
                set {_test} to location(random number from -1500 to 1500, 100, random number from -1500 to 1500, world("world"))
                set {_biome} to biome at {_test}
                if biome at {_test} is not desert or desert hills or jungle or jungle hills or mesa or ocean or mushroom island or deep ocean or frozen ocean or frozen river or cold beach or stone beach or ice plains or ice mountains or ice plains spikes:
                    loop blocks above {_test}:
                        if loop-block is air:
                            if block above loop-block is air:
                                if block 2 above loop-block is air:
                                    set {_randomlocation} to location of loop-block
                                    teleport loop-player to {_randomlocation}
                                    set {searching_for_location.%loop-player%} to false
                wait 1 tick
Ah yes, really not stupid!
As long as you are there, I have a small question : How to differentiate the inventory of the player, and its action bar and armor?
For example, I would like that with the command /invsave it saves the action bar, and the armor of the player, but not inventory.
I have done several searches, I think there is no way with Skript
 
Skellet has an expression for it. From the docs:

Inventory clicked slot type
Addon: Skellett
Patterns:
click[ed] slot type
Returns the type of slot that was clicked in the `on inventory click:` event

Clicked slot types:

ARMOR
An armour slot in the player's inventory.
CONTAINER
A regular slot in the container or the player's inventory; anything not covered by the other enum values.
CRAFTING
A slot in the crafting matrix, or the input slot in a furnace inventory, the potion slot in the brewing stand, or the enchanting slot.
FUEL
The fuel slot in a furnace inventory, or the ingredient slot in a brewing stand inventory.
OUTSIDE
A pseudo-slot representing the area outside the inventory window.
QUICKBAR
A slot in the bottom row or quickbar.
RESULT
A result slot in a furnace or crafting inventory.
Example:
on inventory click:
broadcast "Slot type: &b%clicked slot type%"
if clicked slot type is ARMOR:
broadcast "You clicked your armor"
[doublepost=1496700694,1496700574][/doublepost]Well that's for when someone clicks their inventory but you said you need it for a command so I'm not sure
 
  • Like
Reactions: Aralwen
Skellet has an expression for it. From the docs:

Inventory clicked slot type
Addon: Skellett
Patterns:
click[ed] slot type
Returns the type of slot that was clicked in the `on inventory click:` event

Clicked slot types:

ARMOR
An armour slot in the player's inventory.
CONTAINER
A regular slot in the container or the player's inventory; anything not covered by the other enum values.
CRAFTING
A slot in the crafting matrix, or the input slot in a furnace inventory, the potion slot in the brewing stand, or the enchanting slot.
FUEL
The fuel slot in a furnace inventory, or the ingredient slot in a brewing stand inventory.
OUTSIDE
A pseudo-slot representing the area outside the inventory window.
QUICKBAR
A slot in the bottom row or quickbar.
RESULT
A result slot in a furnace or crafting inventory.
Example:
on inventory click:
broadcast "Slot type: &b%clicked slot type%"
if clicked slot type is ARMOR:
broadcast "You clicked your armor"
[doublepost=1496700694,1496700574][/doublepost]Well that's for when someone clicks their inventory but you said you need it for a command so I'm not sure
Oh yes, thank you!
I saw for clicks, but to record for example the entire bar action I can proceed how?

set {actionbar.%player%} to ... ?
[doublepost=1496701419][/doublepost]Ah, also small problem I just noticed with the teleport : If Player A gets a non-blacklisted biome, and Player B gets a blacklist biome,
it relaunch also the loop for player A, is there a way to avoid this? @Donut
 
For the inventory problem you can just use the numbers of the slots: hot bar is 0-8, the big inventory is 9-35, boot slot is 36, leggings slot is 37, chestplate slot is 38, and helmet slot is 39.
[doublepost=1496712562,1496712320][/doublepost]So to save the hot bar you'd do:

code_language.skript:
set {_item1} to slot 0 of player's inventory 
add {_item1} to {hotbar.%player%::*}
set {_item2} to slot 1 of player's inventory
add {_item2} to {hotbar.%player%::*}
set {_item3} to slot 2 of player's inventory
add {_item3} to {hotbar.%player%::*}
#and so on up until 8
[doublepost=1496712719][/doublepost]Your teleport problem may be caused because you're using local variables although they should work in this situation. It won't hurt to try changing the local variables to a global variable with .%loop-player%
 
  • Like
Reactions: Aralwen
For the inventory problem you can just use the numbers of the slots: hot bar is 0-8, the big inventory is 9-35, boot slot is 36, leggings slot is 37, chestplate slot is 38, and helmet slot is 39.
[doublepost=1496712562,1496712320][/doublepost]So to save the hot bar you'd do:

code_language.skript:
set {_item1} to slot 0 of player's inventory
add {_item1} to {hotbar.%player%::*}
set {_item2} to slot 1 of player's inventory
add {_item2} to {hotbar.%player%::*}
set {_item3} to slot 2 of player's inventory
add {_item3} to {hotbar.%player%::*}
#and so on up until 8
[doublepost=1496712719][/doublepost]Your teleport problem may be caused because you're using local variables although they should work in this situation. It won't hurt to try changing the local variables to a global variable with .%loop-player%
Thank you very much, I will proceed this way! :emoji_wink:

Ah, possible for teleportations, i will check on occasion, but otherwise it is not too annoying :emoji_slight_smile:

~ Solved
 
Status
Not open for further replies.