2DWorlds Forums
I am learning to script and I have a question.. - Printable Version

+- 2DWorlds Forums (http://2dworlds.buildism.net/forum)
+-- Forum: 2DWorlds (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=4)
+--- Forum: Scripting (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=13)
+--- Thread: I am learning to script and I have a question.. (/showthread.php?tid=5932)



I am learning to script and I have a question.. - Fish - 06-18-2011

So if a tool had a fly script in it, I'd be the child and the tool would be the parent? :O


RE: I am learning to script and I have a question.. - Chaos - 06-18-2011

This should be in the scripter's section.


RE: I am learning to script and I have a question.. - Blandflakes - 06-18-2011

Let's say you have a script inside of a box.

Box
VV
Script

The scripts parent is the box. the Box's child is the script.


RE: I am learning to script and I have a question.. - Qwertygiy - 06-18-2011

To find a child inside a parent, you can either go

[lua]
box.[[childsname]]
[/lua]

or, and you have to do this if there's a space in the name,

[lua]
box:getChild("[[childsname]]")
--or in ROBLOX
box:findFirstChild("[[childsname]]")
[/lua][/lua]


RE: I am learning to script and I have a question.. - noob007 - 06-18-2011

Can't you also do,

[lua]

box["childsname"]

[/lua]

Sorry it's been a while since I've scripted in Lua.


RE: I am learning to script and I have a question.. - Qwertygiy - 06-18-2011

I think so, but I've almost never seen it used.


RE: I am learning to script and I have a question.. - Dignity - 06-18-2011

You can't do box.[["childname"]] it's box["childname"].Whatever


RE: I am learning to script and I have a question.. - Jacob__mybb_import1 - 06-18-2011

(06-18-2011, 01:37 AM)noob007 Wrote: Can't you also do,

[lua]

box["childsname"]

[/lua]

Sorry it's been a while since I've scripted in Lua.

The advantage of doing it that way is that you can use variables. box.variableName will give you the child named variableName, but box[variableName] (no quotes) will give you the child with the name that is stored in the variable.