#Block replace skript
1 messages · Page 1 of 1 (latest)
@bitter mirage can you help me here?
Teh's Mug [PING✔] suggests that you read this embed
When you do set {_block} to event-block you are saving a reference to the block at that location. Since the variable is a reference to the block in the world, any changes to the block will also affect the variable. That is why the following code will not set the block back to its original state.
on break:
set {_block} to event-block
wait 5 seconds
set event-block to {_block}
# the block will still be air```
To avoid this issue we can store the blockdata! Blockdata will store all of the important information about the block including its type and rotation. Unfortunately, blockdata does not include the location of the block.
on break:
set {_block} to blockdata of event-block
wait 5 seconds
set event-block to {_block}
# the block will be regenerated```
Sometimes we still need to save the locations of the blocks even if we want to use blockdata. In this case we can use two variables: one with our location and one with the blockdata. Alternatively you could store these in the same list under two different indices ({_blocks::%common index%::location} and {_blocks::%common index%::blockdata})
on right click with apple:
loop blocks in radius 3 of player:
set {_blockdata::%loop-iteration%} to blockdata of loop-block
set {_locations::%loop-iteration%} to location of loop-block
set loop-block to air
wait 5 seconds
loop {_locations::*}:
set block at loop-value to {_blockdata::%loop-iteration%}```
this is info about saving blocks, you can store them in a list variable and then loop over it every 15 mins
Teh's Mug [PING✔] suggests that you read this embed
List variables are a much cleaner way of storing multiple values, especially objects that are unique to something (the money of a player, the warps of the server), as they can be looped, added to, removed from, accessed, and deleted all at once, making variable organization a breeze. A list basically maps objects to their corresponding unique indices.
To make a list, we simply use the list variable separator :: in the variable's name: {money::%uuid of player%}, {warps::%{_warpName}%}, {luckyNumbers::*}.
For example:
set {_list::*} to 1, 2, 3, and 4
set {list::%uuid of player%} to player```
As already mentioned, lists have indices and values. For instance, in set {money::%uuid of player%} to 100 the index is the uuid of the player and the value is 100. We can also access all the values at once by using ::*. This last part means we can replace a lot of common loops with simple lists, like send "You're on team red!" to {team-red::*} instead of looping through all players and checking if each one is on team red.
{%player%.money} -> {money::%player's uuid%}
{home.warps.%player%} -> {warps::%player's uuid%::home}
{%player%.cooldown} -> {cooldown::%player's uuid%}```
okay
thank you
how would I use it without a loop because I don't want to loop blocks I want it to add every broken block THEN it can loop and replace them
nevermind ill just play with it until I understand
on block break, add location of event-block to a list. every 15 minutes, loop that list, then set the block at loop-value (which will be a location)
I would suggest cancelling the event after a certain bit
So some example code would be:
every 1 second:
if {clearMapCooldown} is not equal to 1:
set {clearMapCooldown} to {clearMapCooldown} - 1
if {clearMapCooldown} = 1:
set {clearMapCooldown} to 900
broadcast “&cThe map has been restored!”
thats for cooldown, im on my phone rn so i cant properly indent
and for it to clear heres another segment:
on block break:
wait {clearMapCooldown} seconds
cancel event
you could also replacing the block break event with block place if you desire
Try it out and tell me how it goes
I have a countdown as specified but I'm not in depth into lists so I don't know how I'm supposed to call a specific item out of it or anything like that
It just every second removes from a variable with 840 seconds, technically 14 minutes but I didn't think i would need to specify here
you dont need a list variable for it
You can just do on break wait until the cooldown is over by stating “wait (cooldown) seconds” and then cancel the event
It's not a list but i needed a variable to put in other skripts like scoreboard
variables are universal across all scripts in your scripts folder unless you put an underscore before it
i know I didnt say list in there you just assumed I used a list im correcting you
oh my bad