The following warnings occurred:
Warning [2] Undefined array key "lockoutexpiry" - Line: 94 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 94 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "lockoutexpiry" - Line: 573 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 573 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $can_access_moderationqueue - Line: 752 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 752 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 892 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 892 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 892 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 892 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $awaitingusers - Line: 34 - File: global.php(959) : eval()'d code PHP 8.4.12 (Linux)
File Line Function
/global.php(959) : eval()'d code 34 errorHandler->error
/global.php 959 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 1024 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 1024 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5327 - File: inc/functions.php PHP 8.4.12 (Linux)
File Line Function
/inc/functions.php 5327 errorHandler->error
/global.php 1024 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.4.12 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



2DWorlds Forums
I'm having issues with descendants of UIs. - Printable Version

+- 2DWorlds Forums (http://2dworlds.buildism.net/forum)
+-- Forum: 2DWorlds (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=4)
+--- Forum: Bug Reports (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=23)
+--- Thread: I'm having issues with descendants of UIs. (/showthread.php?tid=5386)



I'm having issues with descendants of UIs. - Qwertygiy - 06-05-2011

Here's some code, for example:

[lua]
link(tool.Selected, function()
gui = tool.UIFrame:clone()
gui.Parent = tool.Parent.Parent.UI
chosen = gui:getChild("Chosen")
[/lua]

Doesn't find it.

Also,

[lua]
local stuff = gui:getChildren()
print(#stuff)
[/lua]

prints 0. The UI itself clones into the Player and is visible, but I can't access the descendants.


RE: I'm having issues with descendants of UIs. - Jacob__mybb_import1 - 06-05-2011

Could you PM me the game that this is happening on?


RE: I'm having issues with descendants of UIs. - Qwertygiy - 06-05-2011

It's just a model -- I'll attach it here. It's almost done anyway -- that UI bug is the only thing that I think is stopping it from being fully functional.


RE: I'm having issues with descendants of UIs. - Jacob__mybb_import1 - 06-05-2011

I think I know what the problem is. It has to do with multithreading, which allows a program to do more than one thing at the same time.

In Buildism, the main thread handles physics and input, another thread draws stuff to the screen, and each Lua script is its own thread too. However, a lot of components of the game, like the physics engine and the navigator, don't like being accessed from threads other than the main thread (the physics engine might be asked to add a part while it is in the middle of stepping the simulation, or the navigator might have to add an object while it is already busy adding another.) So instead of doing these things itself, a script thread tells the main thread to do them as soon as it is done with the current frame.

[lua]
game.World.Box.Size = Vec2D(10, 5)
[/lua]

When you change a property (including Parent) with a script, the value of the property is changed immediately (so print(game.World.Box.Size) would always give you 10,5). But the actual change is not guaranteed to be done before the next line in the script, only as soon as possible. Usually this doesn't matter, but when you're cloning a lot of objects and trying to access them immediately afterwards it does.

The solution is to wrap all of the code that needs to access the cloned objects in

[lua]
gameConfusedcheduleTask(function()

end)
[/lua]

This tells the game to run your Lua code on the main thread, and when you change the Parent property it will detect that it's running on the main thread and do the change immediately instead of as soon as possible.