Giter VIP home page Giter VIP logo

Comments (5)

SmallJoker avatar SmallJoker commented on June 8, 2024 1

@BrunoMine oh, I thought your area would span multiple claim sectors. In this case it's much simpler:

local data, index = s_protect.get_claim({
	x = -42,
	y = 20,
	z = 101
})
data = {
	owner = "yourname",
	shared = {}
}
s_protect.set_claim(data, index)

from simple_protection.

SmallJoker avatar SmallJoker commented on June 8, 2024

Untested

local minp = {x = -100, y = -20, z = 80} -- area start (world coordiantes)
local maxp = {x = 250, y = 120, z = 200} -- area end (world coordiantes)

-- Ensure the loop reaches all mapblocks
local _
minp, _ = s_protect.get_area_bounds(minp)
_, maxp = s_protect.get_area_bounds(maxp)

-- Iterate through the entire volume
local update_table = {}
for z = minp.z, maxp.z, s_protect.claim_size do
for y = minp.y, maxp.y, s_protect.claim_height do
for x = minp.x, maxp.x, s_protect.claim_size do
	local data, index = s_protect.get_claim({
		x = x,
		y = y,
		z = z
	})
	data = {
		owner = "yourname",
		shared = {}
	}
	update_table[index] = data
end
end
end

s_protect.update_claims(update_table)
minetest.log("action", "Protected an area spanning from "
	.. minetest.pos_to_string(minp) .. " to "
	.. minetest.pos_to_string(maxp))

from simple_protection.

BrunoMine avatar BrunoMine commented on June 8, 2024

I do not want to protect a custom area.
I want to claim a normal block like a common player, but for internal use.

from simple_protection.

BrunoMine avatar BrunoMine commented on June 8, 2024

Here are two examples to help you understand what I need.

-- Checks the square where the pos coordinate is inserted.
local minp, maxp = get_square_coordinates(pos)
-- Claim the square for internal use of the mod
protect_this_square("mymod:a_protected_square", minp, maxp)

from simple_protection.

BrunoMine avatar BrunoMine commented on June 8, 2024

Thank you!

from simple_protection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.