spawning an undroppable falling block

  • 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 community!

    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.

doitcmf

New Member
Mar 12, 2017
5
0
0
How do I make it so there will be a beacon that falls from the sky and turns into a chest that I can configure the contents that are inside. been spending the past hour trying to find a way (i am new to skript). any help is good thanks!
 
Okay so this idea is pretty damn cool. First step, this portion I've tested and got to work:
code_language.skript:
command /bchest:
    trigger:
#Spawns a block that falls like sand. Needs SkQuery
        spawn falling beacon 20 meters above and 2 meter horizontally in front of the player
#Waits for the block to fall
        wait 2 seconds
#This get's all the blocks around a player and then checks if one of them is a beacon
        loop blocks in radius 4 of player:
            if loop-block is beacon:
#And then it set's that loop-block beacon to a chest
                set loop-block to chest
There's probably several ways to do the custom inventory, but the way I know of would be to on the click event of the chest - cancel the event. Then open a chest gui to the player like this:
code_language.skript:
open chest with 5 rows named "sweet loots" to player
set slot 0 to item named "namehere" with lore "lorehere"

You could create your own list of loot by adding all the possible items to a list variable such as {loots::*} That would look like this:
code_language.skript:
format slot 0 to a random element out of {loots::*}
I'm not 100 % on the deleting the chest after so here's a few ideas I can think of. You could likely do it with the On Inventory Close event(skquery). Possibly needing to set a location variable when the beacon is turned into a chest to be able to loop the blocks around a player again and delete the blocks with a matching location. Loop-block is equal to "%{location.%location%}%".
 
Okay so this idea is pretty damn cool. First step, this portion I've tested and got to work:
code_language.skript:
command /bchest:
    trigger:
#Spawns a block that falls like sand. Needs SkQuery
        spawn falling beacon 20 meters above and 2 meter horizontally in front of the player
#Waits for the block to fall
        wait 2 seconds
#This get's all the blocks around a player and then checks if one of them is a beacon
        loop blocks in radius 4 of player:
            if loop-block is beacon:
#And then it set's that loop-block beacon to a chest
                set loop-block to chest
There's probably several ways to do the custom inventory, but the way I know of would be to on the click event of the chest - cancel the event. Then open a chest gui to the player like this:
code_language.skript:
open chest with 5 rows named "sweet loots" to player
set slot 0 to item named "namehere" with lore "lorehere"

You could create your own list of loot by adding all the possible items to a list variable such as {loots::*} That would look like this:
code_language.skript:
format slot 0 to a random element out of {loots::*}
I'm not 100 % on the deleting the chest after so here's a few ideas I can think of. You could likely do it with the On Inventory Close event(skquery). Possibly needing to set a location variable when the beacon is turned into a chest to be able to loop the blocks around a player again and delete the blocks with a matching location. Loop-block is equal to "%{location.%location%}%".
Here's a simple function to do what you want more reliably. Requires skript-mirror
code_language.skript:
function fallingChest(location: location, items: items, falltype: itemtype = beacon):
  spawn "falling %{_falltype}%" parsed as an entity type at {_location}
  set {_block} to last spawned entity
  {_block}.setDropItem(false);
  while {_block}.isOnGround() is false:
    wait 1 tick
  {_block}.remove();
  set block at location of {_block} to chest
  wait 1 tick
  set inventory of block at location of {_block} to {_items::*}
 
Last edited by a moderator:
  • Like
Reactions: Wynnevir
Wow! These are actually very clever ways to do this. Thank you for the help!!
[doublepost=1499851089,1499848923][/doublepost]This seems to just drop a chest on the ground. I do not see a beacon falling. I tried to make a beacon fall by it self and it just dropped on the ground when it landed. How do I make it so it stays as a block when it lands?
 
Wow! These are actually very clever ways to do this. Thank you for the help!!
[doublepost=1499851089,1499848923][/doublepost]This seems to just drop a chest on the ground. I do not see a beacon falling. I tried to make a beacon fall by it self and it just dropped on the ground when it landed. How do I make it so it stays as a block when it lands?
Whos code are you using
 
both of them are doing this

I definitely saw it falling with mine. you could increase the wait time so you see the beacon longer, but it falls pretty fast. Pikachu's would be better to try and work with as it is more efficient. I've only just started to tackle functions.
 
Status
Not open for further replies.