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

Generating Trees/Rocks, etc. on a grid? [closed]

Asked by
legosweat 334 Moderation Voter
8 years ago

I'm making a game like Clash of Clans, and I need somewhere to start on the map generating aspect of it. So basically, I have rocks and trees built, they need to be on a grid (of 5 by 5 bricks). I'm just looking for feedback on how I would generate the items on the grid.

I just need some advice on how'd I would do that, I'm not requesting, don't get me wrong, I just need help on how I could make this, all I need is to know how to generate something on a grid.

No, I don't have any example code, as I said I need somewhere to start.

Closed as Not Constructive by TheHospitalDev, Azmidium, theCJarmy7, and General_Scripter

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
1
Answered by
Prioxis 673 Moderation Voter
8 years ago

This is interesting idea as I haven't really seen much of this done on roblox my thinking would be is to make a bunch of 5x5 parts and then store their positions within a table

using

table.insert

and then pick a random position from that table to place a tree at btw if you are moving a model doing

local model = game.Lighting.MODELNAME -- this would be a tree or rock
local table = {} -- create a empty table

local children = workspace:GetChildren()
for i = 1, #children do
    if children[i].Name == node then
    print(i, children[i].Position)
    table.insert(children[i].Position)
    else
end

local chosenposition = table[math.random(1, #table)] -- pick random position from the table
local c = model:Clone() -- copy the model
c.Parent = game.Workspace -- move the copied model to the workspace
c:Move(vector3.new(chosenposition)) -- move the model to the position of the part
table.remove(table, chosenposition)

I think that's roughly how it would work hope it helps :)

0
I'd recommend game:GetService("ServerStorage") to deal with hidden storages and such rather than Lighting MBacon15 97 — 8y
0
It all just comes down to preference in the end and what the developer wants with their game but you are right Prioxis 673 — 8y
0
Thank you, this helps a lot. legosweat 334 — 8y
0
@Du_k no problem glad to help :) Prioxis 673 — 8y
Ad