Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
|
| 15 Apr 2015 08:04 PM |
This doesn't give the desired effect. I want it to fill the entire parent with the level^2 sqaures, but it doesn't do that
for i = 1, level * level do local q = Instance.new("TextButton", script.Parent) q.Name = "square" .. i q.Size = UDim2.new((1/level) - 0.1, 0,(1/level) - 0.1, 0) q.BorderSizePixel = 0 q.Text = "" q.Position = UDim2.new((i/level) - 0.45, 0, (i/level) - 0.45, 0) end |
|
|
| Report Abuse |
|
|
iiEssence
|
  |
| Joined: 18 Jun 2014 |
| Total Posts: 3467 |
|
| |
|
|
| 15 Apr 2015 08:07 PM |
| Please explain more. How exactly is this supposed to look? |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
|
| 15 Apr 2015 08:08 PM |
ok picture format Current: gyazo 8c599bc76a24463e6eee03b995be520c desired: gyazo 9b597ce0f5e8cd991c48079318118326 |
|
|
| Report Abuse |
|
|
|
| 15 Apr 2015 08:12 PM |
Why are you doing the math like that? Is the number of boxes ever going to change?
If not, make a table of which settings you'd like to change for each one, and then run that through the for loop. |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
|
| 15 Apr 2015 08:13 PM |
| The number of boxes do change |
|
|
| Report Abuse |
|
|
|
| 15 Apr 2015 08:17 PM |
I used the following code for something a while ago. Maybe you can change it a bit:
for i=1, 20 do local btn = Instance.new("TextButton", frame) -- youll need a frame to test with btn.Size = UDim2.new(.5, 0, .1, 0) btn.Position = UDim2.new(((i%2)/2), 0, (i/20+((i%2)/20))-.1, 0) end |
|
|
| Report Abuse |
|
|
Ice7
|
  |
| Joined: 26 Jun 2007 |
| Total Posts: 1058 |
|
|
| 15 Apr 2015 08:42 PM |
Do you mean like creating a rectangular grid? Simply make two loops, and which run from m to n, so you have an m*n grid.
for x=1, m do for y=1, n do --stuff end end
|
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 15 Apr 2015 08:48 PM |
local Level = 2; local Padding = 10 -- Pixel padding in between each square local StartingPosition = UDim2.new(0,0,0,0);
for Y = 1, Level do for X = 1, Level do local q = Instance.new("TextButton", script.Parent) q.Name = "Square X: " .. X .. " | Y: " .. Y; q.Size = UDim2.new((1/Level), 0,(1/Level), 0) q.BorderSizePixel = 0 q.Text = "" q.Position = StartingPosition + UDim2.new(0, (q.AbsoluteSize.X + Padding)*(X-1),0, (q.AbsoluteSize.Y + Padding)*(Y-1)) end end |
|
|
| Report Abuse |
|
|
|
| 15 Apr 2015 08:52 PM |
@Ice Ironically he would have to do math over again to get his guis named properly (unless that was a mistake on his part).
Then again that's just n*(x-1)+y |
|
|
| Report Abuse |
|
|