SkriptLang / Skript

Skript is a Spigot plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
https://docs.skriptlang.org
GNU General Public License v3.0
1.06k stars 368 forks source link

getting blocks in chunk with list variable #790

Closed xb0t3r closed 7 years ago

xb0t3r commented 7 years ago

Minecraft server version 1.12 ( latest ) Bensku skript - devc30 (Latest)

So if you add a block in a chunk to a list then set that block in the chunk to a different block it'll update the list value?

https://hastebin.com/orupinoqam.rb

Result:

Before - bedrock, bedrock, bedrock, bedrock After - glowstone, glowstone, glowstone, glowstone

The list itself is not being updated with the new values?

Note: the original loop is not being run more than once and this is why the list itself is being updated cause the stop at the end stops it.

TheBentoBox commented 7 years ago

That's normal, you're storing a copy of the block in the list, a snapshot of its current value -- AKA, it passes by value, not by reference.

xb0t3r commented 7 years ago

and how do you copy it by reference?

JeepSmash commented 7 years ago

By storing the value - block at *. You are not storing information about the block type but a location of a block. When stringified it will describe the block at that current location (in the map data file). It can become difficult to make one line of code to record the block types at locations because of inventories and other special block properties that would be missed using - add type of block at . So it depends on what type of blocks and their properties on how you would record them in a list

Another note- using extrememely long variable names for logging info can drastically increase the size of your data file as every value stored in the data file is stored with its corresponding name which generally is larger (byte wise) than the actual value being stored (for most common data types like numbers and integers - but thats just my OCD talking

bensku commented 7 years ago

I think this is working as intended.