2DWorlds Forums
[ Suggestion ] - Make the connections like roblox style and add findFirstChild - Printable Version

+- 2DWorlds Forums (http://2dworlds.buildism.net/forum)
+-- Forum: 2DWorlds (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=4)
+--- Forum: 2DWorlds Discussion (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=10)
+--- Thread: [ Suggestion ] - Make the connections like roblox style and add findFirstChild (/showthread.php?tid=1081)



[ Suggestion ] - Make the connections like roblox style and add findFirstChild - ptown2 - 10-16-2010

since this script

Code:
while true do
p = create("Box");
p.Position = Vec2D(math.random(400,600),100)
p.Size = Vec2D(5, 5)
p.Color = Color(math.random(0, 255), math.random(0, 255), math.random(0, 255))
p.Parent = game.World
p.Fixed = false
s = create("Script")
s.Source = "sleep(5); while script.Parent.Transparency < 1 do script.Parent.Transparency = script.Parent.Transparency + 0.2; sleep(0.1); end; script.Parent:remove();"
s.Parent = p
sa = create("Script")
sa.Source = "link(script.Parent.Collided, function(touch) if touch.Name ~= "Ground" and touch.Score ~= nil then script.Parent:remove(); end end)"
sa.Parent = p
tex = create("Texture")
tex.Image "http://image.shutterstock.com/display_pic_with_logo/251461/251461,1236423088,1/stock-photo-closeup-waffle-texture-to-background-26195983.jpg"
tex.Parent = p
sleep(1)
end

requires findFirstChild, it is needed in the LUA Database and can you make the connections similar in ROBLOX, so it can be more easier?


RE: [ Suggestion ] - Make the connections like roblox style and add findFirstChild - Jacob__mybb_import1 - 10-16-2010

The latest update has a getChild() that works like findFirstChild() in Roblox.

And the connections will have to stay this way for now. Roblox uses one Lua environment with multiple threads; the Lua library I used doesn't support threads so each script has a separate Lua environment. If a member function was used to connect events, then the game wouldn't know what Lua environment to run the event script on, if that makes any sense.


RE: [ Suggestion ] - Make the connections like roblox style and add findFirstChild - ptown2 - 10-16-2010

well that fixes everything about the connectors, but what bugs me most is this:

[2010-10-16 17:34:14] Tried to call nil

when you do a if not statement

example:
Code:
sa.Source = "link(script.Parent.Collided, function(touch) if touch.Name ~= "Ground" and touch.Score ~= nil then script.Parent:remove(); end end)"



RE: [ Suggestion ] - Make the connections like roblox style and add findFirstChild - Jacob__mybb_import1 - 10-16-2010

Is Score a value object? If it is you have to get the Value property (touch.Score.Value).

Not statements shouldn't cause errors.


RE: [ Suggestion ] - Make the connections like roblox style and add findFirstChild - ptown2 - 10-17-2010

even with the score out, it still says the same error


RE: [ Suggestion ] - Make the connections like roblox style and add findFirstChild - Jacob__mybb_import1 - 10-17-2010

I finally realized what the problem is, you have to escape quotes in strings with backslashes, otherwise it gets confused.

Code:
sa.Source = "link(script.Parent.Collided, function(touch) if touch.Name ~= \"Ground\" and touch.Score ~= nil then script.Parent:remove(); end end)



RE: [ Suggestion ] - Make the connections like roblox style and add findFirstChild - zeyan12 - 12-30-2010

[spam removed]