Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI('utils')
- os.loadAPI('registry')
- --[[
- utils.do_chunk_loaders(
- registry.computer,
- registry.CATALOG_AREA.x ,
- registry.CATALOG_AREA.y + 10,
- registry.CATALOG_AREA.z,
- registry.CATALOG_AREA.dx,
- registry.CATALOG_AREA.dz
- )
- --]]
- ll_DEFAULT_ELEMENTS_SETTINGS = {
- {element_id=1, element_name="element",reward_emeralds=0,reward_blocks={{block = "minecraft:wool", data = 0, count=1},{block = "minecraft:wool", data = 10, count=10}}, metric_1=0, metric_2=0, metric_3=0, metric_4=0},
- {element_id=2, element_name="element",reward_emeralds=1,reward_blocks={}, metric_1=0, metric_2=0, metric_3=0, metric_4=0},
- {element_id=3, element_name="element",reward_emeralds=0,reward_blocks={{block = "minecraft:wool", data = 0, count=1}}, metric_1=0, metric_2=0, metric_3=0, metric_4=0}
- }
- DEFAULT_ELEMENTS_SETTINGS = {
- {{______________________________element_start______________________________="______________________________"},{element_id=1}, {element_name="element"}, {{metric_1=0}, {metric_2=0}, {metric_3=0}, {metric_4=0}}, {reward_emeralds=0},{reward_blocks={{block = "minecraft:wool", data = 0, count=1},{block = "minecraft:wool", data = 10, count=10}}},{______________________________element_end______________________________="____________________________________________________________"}},
- {{______________________________element_start______________________________="______________________________"},{element_id=2}, {element_name="element"}, {{metric_1=0}, {metric_2=0}, {metric_3=0}, {metric_4=0}}, {reward_emeralds=1},{reward_blocks={}},{______________________________element_end______________________________="____________________________________________________________"}},
- {{______________________________element_start______________________________="______________________________"},{element_id=3}, {element_name="element"}, {{metric_1=0}, {metric_2=0}, {metric_3=0}, {metric_4=0}}, {reward_emeralds=0},{reward_blocks={{block = "minecraft:wool", data = 0, count=1}}},{______________________________element_end______________________________="____________________________________________________________"}}
- }
- -- function to check if settings file exist and if not create it using the default settings in registry
- --if settings file exists then read it and change the variables to reflect the settings there
- function loadCustomElementSettings()
- -- does json file exist?
- --local result = nil
- --fs.makeDir("/records")
- local filename = "element_settings"
- local settings = {}
- if utils.file_exists(filename) then
- ---read from file and change the settings
- settings = json.decodeFromFile(filename)
- --set the settings to the ones found in the file
- else
- --create the file with default settings
- local file = fs.open(filename,"w")
- settings = DEFAULT_ELEMENTS_SETTINGS
- file.write(json.encodePretty(settings))
- file.close()
- end
- return settings
- end
- --loadCustomElementSettings()
- --- Clones an area even if it is bigger than the minecraft limit
- -- @param maskMode from registry.CLONE_MASK_MODE
- -- @param cloneMode from registry.CLONE_MODE
- -- @param filteredMaterial table with .block and .variant
- function cloneSmart(from_x,from_y,from_z,sizeX,sizeY,sizeZ, to_x, to_y, to_z, maskMode, cloneMode, filteredMaterial)
- -- clone command works as this: https://www.digminecraft.com/game_commands/clone_command.php
- -- /clone <x1> <y1> <z1> <x2> <y2> <z2> <x> <y> <z> [maskMode] [cloneMode] [tileName] [tileData]
- --check if volume is bigger than maximum blocks 32768
- local limit = registry.FILL_LIMIT
- local w,h,l = sizeX, sizeY, sizeZ
- --print("which is nil?", w,h,l)
- if math.abs(w*l*h) <= limit then
- --if not then do simple fill
- --print("filling in one go:",x,y,z,x+w-(w/math.abs(w)),y+h-(h/math.abs(h)),z+l-(l/math.abs(l)),material)
- --if replace and replace_material then
- --commands.async.fill(x,y,z,x+w-(w/math.abs(w)),y+h-(h/math.abs(h)),z+l-(l/math.abs(l)),fill_material.block, fill_material.variant, "replace", replace_material.block, replace_material.variant)
- if filteredMaterial then
- commands.clone(
- from_x, from_y, from_z,
- from_x+w-(w/math.abs(w)), from_y+h-(h/math.abs(h)), from_z+l-(l/math.abs(l)),
- to_x, to_y, to_z,
- maskMode or registry.CLONE_MASK_MODE.REPLACE, cloneMode or registry.CLONE_MODE.NORMAL, filteredMaterial.block, filteredMaterial.variant)
- else
- commands.clone(
- from_x, from_y, from_z,
- from_x+w-(w/math.abs(w)), from_y+h-(h/math.abs(h)), from_z+l-(l/math.abs(l)),
- to_x, to_y, to_z,
- maskMode or registry.CLONE_MASK_MODE.REPLACE, cloneMode or registry.CLONE_MODE.NORMAL)
- end
- --end
- --else
- --commands.async.fill(x,y,z,x+w-(w/math.abs(w)),y+h-(h/math.abs(h)),z+l-(l/math.abs(l)),fill_material.block, fill_material.variant )
- --end
- return true
- else
- --divide in 8 sub-boxes and run again
- local halfW = math.floor(w/2)
- local restW = w-halfW
- local halfH = math.floor(h/2)
- local restH = h-halfH
- local halfL = math.floor(l/2)
- local restL = l-halfL
- --always run
- cloneSmart(from_x+halfW, from_y+halfH, from_z+halfL, restW, restH, restL, to_x+halfW, to_y+halfH, to_z+halfL, maskMode, cloneMode, filteredMaterial)
- --
- --check if one of the halves is zero
- if math.abs(halfW) > 0 then
- --run if halfW is not zero
- cloneSmart(from_x, from_y+halfH, from_z+halfL, halfW, restH, restL, to_x, to_y+halfH, to_z+halfL, maskMode, cloneMode, filteredMaterial)
- end
- if math.abs(halfH) > 0 then
- --run if halfH is not zero
- cloneSmart(from_x+halfW, from_y, from_z+halfL, restW, halfH, restL, to_x+halfW, to_y, to_z+halfL, maskMode, cloneMode, filteredMaterial)
- end
- if math.abs(halfL) > 0 then
- --run if halfL is not zero
- cloneSmart( from_x+halfW, from_y+halfH, from_z, restW, restH, halfL, to_x+halfW, to_y+halfH, to_z, maskMode, cloneMode, filteredMaterial)
- end
- ---
- if math.abs(halfW) > 0 and math.abs(halfH) > 0 then
- --run if halfs W and H are not zero
- cloneSmart( from_x, from_y, from_z+halfL, halfW, halfH, restL, to_x, to_y, to_z+halfL, maskMode, cloneMode, filteredMaterial)
- end
- if math.abs(halfL) > 0 and math.abs(halfH) > 0 then
- --run if halfH and halfL are not zero
- cloneSmart( from_x+halfW, from_y, from_z, restW, halfH, halfL, to_x+halfW, to_y, to_z, maskMode, cloneMode, filteredMaterial)
- end
- if math.abs(halfW) > 0 and math.abs(halfL) > 0 then
- -- run if half W and L are not zero
- cloneSmart( from_x, from_y+halfH, from_z, halfW, restH, halfL, to_x, to_y+halfH, to_z, maskMode, cloneMode, filteredMaterial)
- end
- ---
- if math.abs(halfW) > 0 and math.abs(halfH) > 0 and math.abs(halfL) > 0 then
- --run if neither half is zero
- cloneSmart( from_x, from_y, from_z, halfW, halfH, halfL, to_x, to_y, to_z, maskMode, cloneMode, filteredMaterial)
- end
- return true
- end
- return false
- end
- cloneSmart(
- -556, 56, -319,
- 27, 29, 27,
- -535-27+21, 56, -330-27+21,
- registry.CLONE_MASK_MODE.REPLACE, registry.CLONE_MODE.MOVE
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement