aa444
|
  |
| Joined: 02 Jan 2010 |
| Total Posts: 93 |
|
|
| 05 Dec 2012 07:00 PM |
It's been about 6-7 months sense i have tryed to script on ROBLOX and i have never seen this... Why does this not work and could someone please link to to the wiki page for it or try to explain it, thanks.
Create'Part'{ Name = 'Torso'; Parent = Ghost; Shape = 'Ball'; Size = Vector3.new(2,2,2); Transparency = 0.2; CanCollide = false; CFrame = CFrame.new(Character.Torso.Position + Vector3.new(1,1,1), Character.Torso.Position + Vector3.new(1,1,1) + Character.Torso.CFrame.lookVector); }; -- Create'SpecialMesh'{ MeshId = 'http://www.roblox.com/asset/?id=89391602'; TextureId = 'http://www.roblox.com/asset/?id=89391636'; VertexColor = Vector3.new(0.8, 1.0, 0.8); Scale = Vector3.new(0.8,0.8,0.8); Name = 'Mesh'; }; -- Create'BodyPosition'{ Name = 'Float'; position = Character.Torso.Position + Vector3.new(1,1,1); }; Create'BodyGyro'{ Name = 'Rotate'; cframe = Character.Torso.CFrame; maxTorque = Vector3.new(40000, 20000, 40000); }; Create'BillboardGui'{ Parent = Torso; Size = UDim2.new(0,100,0,100); }; Create'TextLabel'{ Parent = BillboardGui; }; }
This is part of the GhostScript in this item http://www.roblox.com/--item?id=89488524.
I am trying to insert a BillboardGui with a TextLabel in it into Torso and have it say something. |
|
|
| Report Abuse |
|
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
| |
|
Biostream
|
  |
| Joined: 28 Mar 2011 |
| Total Posts: 913 |
|
| |
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 05 Dec 2012 07:04 PM |
| Well.. it looks like someone messing up with Javascript. :3 |
|
|
| Report Abuse |
|
|
lombardo2
|
  |
| Joined: 30 Nov 2008 |
| Total Posts: 1604 |
|
|
| 05 Dec 2012 07:04 PM |
It's lua, create is a function with 1 parameter, the instance you want to create, that returns a function that have 1 parameter, a table containing the proprieties of the object and that finally returns the object. But dude, for the sake of reading use parentheses
Create("Part")({name = "Hello"}) |
|
|
| Report Abuse |
|
|
aa444
|
  |
| Joined: 02 Jan 2010 |
| Total Posts: 93 |
|
|
| 05 Dec 2012 07:05 PM |
| Oh, I just figured it was some kind of new thing, but why would it be there then... |
|
|
| Report Abuse |
|
|
aa444
|
  |
| Joined: 02 Jan 2010 |
| Total Posts: 93 |
|
|
| 05 Dec 2012 07:06 PM |
@lam I did not create that, I was just adding on... |
|
|
| Report Abuse |
|
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 05 Dec 2012 07:06 PM |
@lom since when is Create a function? And since when does Lua use angle brackets besides tables? Instance.new() is the function to create instances, not Create. |
|
|
| Report Abuse |
|
|
aa444
|
  |
| Joined: 02 Jan 2010 |
| Total Posts: 93 |
|
|
| 05 Dec 2012 07:11 PM |
| 1Topcop, put the Gear into edit mode and look at GhostScript. |
|
|
| Report Abuse |
|
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 05 Dec 2012 07:12 PM |
| ROBLOX eats my RAM. I refuse to open! :P |
|
|
| Report Abuse |
|
|
lombardo2
|
  |
| Joined: 30 Nov 2008 |
| Total Posts: 1604 |
|
|
| 05 Dec 2012 07:12 PM |
Create is a user defined function, brackets are the table constructors...
function Create(instance) local object = Instance.new(instance) return function(prop) for k,v in pairs(prop) do object[k] = v end end end
Create'Part'{ Name = "e.e"; Parent = Workspace; Anchored = true; } |
|
|
| Report Abuse |
|
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 05 Dec 2012 07:15 PM |
Alright, well then it would still be something like...
Create("Part")({["Name"] = "Like this",["Parent"] = Workspace,["Anchored"],true}) |
|
|
| Report Abuse |
|
|
lombardo2
|
  |
| Joined: 30 Nov 2008 |
| Total Posts: 1604 |
|
|
| 05 Dec 2012 07:18 PM |
Now let me explains what happens...
First we call Create and pass 1 argument, a string, the name of the object we want to create, then we call another function and pass 1 argument, a table containing the new proprieties of that object.
In the function definition, we create a local variable called object, and assign it to a new object created with Instance.new using the instance parameter as the argument, then we create a return function (a closure) with 1 parameter, then we iterate over the parameter with a foreach loop and change the created object proprieties according to the keys and values of the table. And that's it, we can return the created object if we want but I created this just for the example.
As for the function calls, lua allows calling function without parentheses,
print"hi"
it works as expected. |
|
|
| Report Abuse |
|
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 05 Dec 2012 07:20 PM |
| Well I guess that would work, but try to tidy up. Parentheses make it look not so messy. |
|
|
| Report Abuse |
|
|
aa444
|
  |
| Joined: 02 Jan 2010 |
| Total Posts: 93 |
|
|
| 05 Dec 2012 07:42 PM |
I still don't get it, you posted " Create is a user defined function, brackets are the table constructors... function Create(instance) local object = Instance.new(instance) return function(prop) for k,v in pairs(prop) do object[k] = v end end end Create'Part'{ Name = "e.e"; Parent = Workspace; Anchored = true; } "
But the script in the gear does not have a function like that... |
|
|
| Report Abuse |
|
|
lombardo2
|
  |
| Joined: 30 Nov 2008 |
| Total Posts: 1604 |
|
|
| 05 Dec 2012 07:54 PM |
| It uses RbxUtility.Create which is a similar one. |
|
|
| Report Abuse |
|
|