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 » Scripting Helpers
Home Search
 

Help with Gui organization?

Previous Thread :: Next Thread 
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
11 Feb 2014 08:26 PM
A while back, maybe a year or so idk... Anyway a while back a bunch of people got together and helped me out with this:

Quests.ChildAdded:connect(function()
local win = script.Parent.QDisplay:GetChildren()
for u = 1, #win do
if win[u].className == "Frame" then
win[u]:Destroy() end end
for i, v in next, Quests:GetChildren() do
local numQuest = #Quests:GetChildren()
if numQuest <= 6 then
gui = Instance.new("Frame", script.Parent.QDisplay)
gui.Size = UDim2.new(1, 0, 0, Height)
gui.Position = UDim2.new(0, 0, 0, (i*Height)-Height)
end end end)

It helps organize gui frames in a column.


Anyway I want to modify it so that I can organize the frames in a grid instead of a list like this script does.

a grid of 5 across, #down. Basically I wanna organize it so the frames are arranged 5 frames across, but infinitely down.

like 4 items
OOOO

12 items
OOOOO
OOOOO
OO

so on and so forth. Anyone think they can help me out?
Report Abuse
DaMrNelson is not online. DaMrNelson
Joined: 27 Jul 2009
Total Posts: 4405
11 Feb 2014 08:31 PM
Step 1. Define a variable for the y-offset (starts off as zero)

Step 2. Define a variable for the x-offset (starts off as zero. Will be used to bring the GUIs back to the left later)

Step 3. Every time i is a multiple of five (if i % 5 == 0 then), add Height to yOffset. Subtract something from x-offset to bring it back to the far left (where it started)

Step 4. Position the GUIs something like this:
gui.Position = UDim2.new(0, xOffset, 0, yOffset + (i - 1) * Height)

Wiki Profile: http://wiki.roblox.com/index.php/User:Nelson
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
11 Feb 2014 08:37 PM
I'm afraid i only understood step one. o.o
Report Abuse
DaMrNelson is not online. DaMrNelson
Joined: 27 Jul 2009
Total Posts: 4405
11 Feb 2014 08:45 PM
Oop sorry, my script was even glitched for the positioning. This is the new positioning line:
gui.Position = UDim2.new(0, xOffset - (i - 1) * Width, 0, yOffset)

Anywho, just try to read it over carefully. It should be understandable by then.

Wiki Profile: http://wiki.roblox.com/index.php/User:Nelson
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
11 Feb 2014 10:14 PM
Ur right, now I understand step 2! :D






:/




It may sound like a lazy excuse to you but I really do learn better by studying something that's already been done. I'm not proud of it, it's just how it is. If you start me off yourself, I may be able to complete it.
Report Abuse
DaMrNelson is not online. DaMrNelson
Joined: 27 Jul 2009
Total Posts: 4405
12 Feb 2014 12:19 AM
This *should* work: http://pastebin.com/qfT716eD

Wiki Profile: http://wiki.roblox.com/index.php/User:Nelson
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
12 Feb 2014 01:24 PM
I think I understand it now.

if (i % 5 == 0) then

I don't know what this is but judging by the context in which it is used I figure that it calls for the 5th, (if there is a 5th), frame in the loop.

After looking at this, there's not much difference between it and the script I posted myself aside from an extra step. With a few small tweaks I should be able to make it work fantastically as a way of organizing a visible dynamic inventory gui. This is going to work wonders for my rpg game. Thank you so much.
Report Abuse
DaMrNelson is not online. DaMrNelson
Joined: 27 Jul 2009
Total Posts: 4405
12 Feb 2014 02:40 PM
No problemo. Just an FYI, the % is the modulus operator. It gives you the remainder of the first number divided by the second. When you divide 10 by 5, the remainder is zero (therefore 10 % 5 = 0, and 10 is a multiple of 5).
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
12 Feb 2014 02:52 PM
Ok! That makes perfect sense now. % divides the multiple variable into the # variable, where the multiple variable decides how many frames (in this script's case) are in each row. I like this. I'm finally starting to understand the advanced scripting.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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