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: Gui Compilation

Previous Thread :: Next Thread 
ENET is not online. ENET
Joined: 01 Jan 2010
Total Posts: 4820
04 Feb 2012 06:47 PM
In this experiment, we will create functions that are used to create lists, menus, frames, etc similar to my example below and see what all we come up with. Feel free to modify my simple getList function. It creates a list from a table of string values where '/' is used to denote another option.

IE {'hey','test','yes/no/cancel'} would create....

hey being 1 in length
test being 1 in length
yes|no|cancel each being .33 in length

function split(str, val)
local found, members, pos;
found = true;
members = {};
repeat
pos = str:find(val) or str:len()+1;
table.insert(members, str:sub(1, pos-1));
if(pos == str:len()+1)then
found=false;
break;
else
str = str:sub(pos+1);
end
until found==false;
return members;
end

getList = function(list)
local ySize = 1/#list;
local xSize;
local items = {};
for i = 0,#list-1 do
local options = split(list[i+1],'/');
xSize = 1/#options;
for x = 0,#options-1 do
local option = options[x+1];
local option_btn = Instance.new('TextButton');
option_btn.Name = option;
option_btn.Text = option;
option_btn.Size = UDim2.new(xSize,0,ySize,0)
option_btn.Position = UDim2.new(xSize*x, 0, ySize*i);
table.insert(items, option_btn);
end
wait();
end
return items;
end
Report Abuse
LocalChum is not online. LocalChum
Joined: 04 Mar 2011
Total Posts: 6906
04 Feb 2012 06:49 PM
I believe RbxGui can do something like this.
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
05 Feb 2012 01:20 PM
Why shoot yourself in the foot? Why use:

    {'hey','test','yes/no/cancel'}

When you could just use

    {'hey', 'test', {'yes', 'no', 'cancel'}}

Don't create work for yourself!

----

Also, your split function can be simplified greatly (although it probably runs more slowly this way):

    function split(str, on)
        local results = {}
        (str..on):gsub("(.-)"..on, function(r) table.insert(results, r) end)
        return results
    end
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
05 Feb 2012 01:34 PM
As a nice pattern for creating a list using GUI-objects, you can exploit the hierarchical nature of the Roblox GUI system:

Have all of the list items have their Position-Y-Offset be equal to their height, and then put each item as a child of the item which is above it. The Roblox layout engine will do the heavy work of ordering the list items one after another, and it still remains easy to remove a list item, without any special code to re-order the thing, all you have to do is remove the list item and then put it's child list item into it's parent.
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
05 Feb 2012 01:58 PM
I've attempted to make a GUI thing [here](http://wiki.roblox.com/index.php/User:NXTBoy/Scripts/GUI), using stupid amounts of functions returning functions.
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
05 Feb 2012 02:01 PM
[ Content Deleted ]
Report Abuse
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
05 Feb 2012 02:18 PM
Inception.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
07 Feb 2012 09:05 PM
@NXTBoy

Just wondering, why did you put these random brackets and parenthesis there..?
Report Abuse
Intune is not online. Intune
Joined: 02 Feb 2012
Total Posts: 50
07 Feb 2012 10:28 PM
@JulienDethurens

Same reason people like to put them around numbers. (I don't know the actual reason though)
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
08 Feb 2012 04:55 AM
"Same reason people like to put them around numbers. (I don't know the actual reason though)"

What..?
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
08 Feb 2012 01:24 PM
Which random brackets and parentheses? As far as I am aware, almost all of them are required. The only one I could remove would be to replace `item = item({})` with `item = item {}`, but that would be even more crytic!
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