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
 

[ Content Deleted ]

Previous Thread :: Next Thread 
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
06 Feb 2012 07:07 PM
[ Content Deleted ]
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
06 Feb 2012 07:18 PM
[ Content Deleted ]
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
06 Feb 2012 07:19 PM
This is known as associative arrays. Things like CodeIgniter use this a lot.
Report Abuse
1Ra is not online. 1Ra
Joined: 02 May 2010
Total Posts: 2400
06 Feb 2012 07:19 PM
*presses F5*

now the mods can see it because in refreshed on my personal computer!
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
06 Feb 2012 07:20 PM
You'll be happy to head that my "Create" function which may be in the next release' RbxUtility library does exactly that.
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
06 Feb 2012 07:24 PM
[ Content Deleted ]
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
06 Feb 2012 07:26 PM
[ Content Deleted ]
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
06 Feb 2012 07:30 PM
[ Content Deleted ]
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
06 Feb 2012 08:15 PM
"Woah that will be cool, but why not just add my idea?"

Because, that would add complexity to vanilla code. The nice thing about libraries is that you don't have to use them, and stuff like my create function will be fairly limited in it's use to more experienced scripters.

Also, it's a very non-obvious technique, so it doesn't make sense to include it in the core API. Some reason stuff like boost::spirit isn't in the C++ standard library.
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
07 Feb 2012 10:31 AM
But couldn't it be made with function like this,
function Create(str,tbl)
s = Instance.new(str)
for i,v in pairs(tbl) do
s[v[1]] = v[2]
end
return s
end
part = Create("Part",{{"Name","Bob the part"},{"Anchored",true},{"Position",Vector3.new(0,10,0)}})
part.Parent = workspace
?
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
07 Feb 2012 10:38 AM
@xlegox

can you make c-side stuff?

if so can you add a :GetProperties() method that returns a key/value table of properties and values in that object?

that'd be like, uber helpfull
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
07 Feb 2012 10:53 AM
[ Content Deleted ]
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
07 Feb 2012 11:54 AM
    local properties = {}
    
    function create(...) --if you'd like; change properties
        local obj = Instance.Part("Part")
        if properties["Parent"] then
            obj.Parent = properties["Parent"]
        elseif not properties["Parent"] then
            obj.Parent = workspace
        end
        for _,v in pairs (properties) do
            obj[_] = v
        end
        for _,v in pairs (...) do
            obj[_] = v
        end
        return obj
    end
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
07 Feb 2012 02:06 PM
@Oysi

"  local p = Instance.new("Part")
  p.Anchored = true
  p.Size = Vector3.new(1, 1, 1)
  p.CFrame = CFrame.new(0, 10, 0)
  p.Parent = workspace
"

or we could alternatively use lQuery :D

local p = _('Part').SetAnchored(true).SetSize(Vector3.new(1,1,1)).SetCFrame(CFrame.new(0, 10, 0).SetParent(Workspace)
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
07 Feb 2012 02:16 PM
[ Content Deleted ]
Report Abuse
TheCapacitor is not online. TheCapacitor
Joined: 19 Jan 2011
Total Posts: 7045
07 Feb 2012 02:24 PM
What about..

Instance.new(string classType[, object parent[, table properties]])?

Like
Instance.new("Part", workspace, {Name = "Hai", Transparency = 0.3}
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
07 Feb 2012 03:22 PM
@cap
Isn't that what he's saying? Also this isn't that difficult of a thing to do

    function create(className,associative)
        local new_object=Instance.new(className);
        for i,v in pairs(associative) do
            pcall(function() new_object[i]=v; end);
        end
        return new_object;
    end
    
    create("Part",{Name="Hai";Transparency=0.3;Parent=workspace});
Report Abuse
pokelover980 is not online. pokelover980
Joined: 12 Jun 2009
Total Posts: 4141
07 Feb 2012 03:47 PM
Ew, only Oysi has posted a nice implementation so far, though I'm biased in that because I've made that same implementation, and I believe stravant has as well. Not having to use parentheses in the function call because of some nice Lua syntax sugar = <3
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
07 Feb 2012 03:48 PM
@Oysi

Not realy, I kinda gave up on it, but it would've eventually had proper vector3 and CFrame manipulation. Vector3 manipulation does work, just not integrated with object manipulation.

it's even got variable hax so you can do this:

local x = _('Part').SetTransparency(lC.GetTransparency + 0.1)
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
07 Feb 2012 03:49 PM
[ Content Deleted ]
Report Abuse
Legend26 is not online. Legend26
Joined: 08 Sep 2008
Total Posts: 10586
07 Feb 2012 03:53 PM
My version of this (although not exactly original):

with (Instance.new"Part") {
Parent = workspace;
Name = "Awesome part";
Anchored = true;
Position = Vector3.new(0,100,0);
}
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
08 Feb 2012 06:00 AM
[ Content Deleted ]
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
08 Feb 2012 06:11 AM
[ Content Deleted ]
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
08 Feb 2012 06:15 AM
[ Content Deleted ]
Report Abuse
22436106 is not online. 22436106
Joined: 19 Dec 2011
Total Posts: 90
08 Feb 2012 06:35 AM
qi = function(ttz)
local qii = it(ttz[1])
table.foreach(ttz,function(oi,oi2)
if oi ~= 1 and oi ~= 2 then
qii[oi] = oi2
end
end)
qii.Parent=ttz[2]
return qii
end

qi({"Part",workspace,Anchored=true,Name="lal",CFrame=CFrame.new(0,10,0)})


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