Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Help understanding claiming land, how to "capture"?

Asked by 5 years ago
Edited 5 years ago

Currently in my game, players can use a tool to place pillars, once 2 pillars are placed it creates a wall. The idea is to claim land by walling off portions of the land.

I'm trying to figure out a way that once a completed area is walled in it would "Claim" that land for the player that built the walls. "Claim" going as far as just getting a numerical value for the amount of land you walled in.

Any articles/docs or just thoughts on this would be helpful.

Thanks for any help!

EDIT: Wondering if a grid system like this would be too laggy because of creating so many parts

local base = game.Workspace.Baseplate
base.Transparency = 1

local model = Instance.new("Model", game.Workspace)
model.Name = "Grid"

for i = 1, 50, 1 do 
    for j =1, 50, 1 do
        local part = Instance.new("Part", model)
        part.Name = i..", "..j
        part.Anchored = true
        part.Size = Vector3.new(8,0.25,8)
        part.Position = Vector3.new(i*8, 0.125, j*8)
    end
end

0
You could create a Region3 by using the farthest extents of the walls and go from there Gey4Jesus69 2705 — 5y
0
Although that would only work effectively if the enclosed area had two sets of parallel sides Gey4Jesus69 2705 — 5y
0
Hmm, yeah any completed "room" could be any number of shapes. I appreciate your thoughts though. I'm stumped atm GoodCallMrOlsen 70 — 5y
0
If you're using a grid-based system, you could try a flood-fill algorithm. RubenKan 3615 — 5y
View all comments (3 more)
1
id like to rephrase gioni01's comment by saying that a region3 only works for rectangles, not all parallelograms theking48989987 2147 — 5y
0
Thank you GoodCallMrOlsen 70 — 5y
0
@RubenKan, Flood-fill looks like a good choice, How would i identify when a walled off area is completed? GoodCallMrOlsen 70 — 5y

Answer this question