generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: help........... math......

Previous Thread :: Next Thread 
Gladii is not online. 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 is not online. iiEssence
Joined: 18 Jun 2014
Total Posts: 3467
15 Apr 2015 08:05 PM
I don't understand
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
15 Apr 2015 08:07 PM
Please explain more. How exactly is this supposed to look?
Report Abuse
Gladii is not online. 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
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
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 is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
15 Apr 2015 08:13 PM
The number of boxes do change
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
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 is not online. 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 is not online. 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
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image