BakaSchwarz Posted March 7, 2018 Share Posted March 7, 2018 Hey, i have a question regarding the unwrappable component. I am trying to access the items in itemdata. When i am ingame and try to access the list via commandline using inst.components.unwrappable.itemdata it works and itemdata is not nil or empty. However, i want to check the Contents of bundles right after they are created, so i tried to solve this using AddPrefabPostInit: local require = GLOBAL.require require "prefabutil" local function CheckItems(inst) if not GLOBAL.TheWorld.ismastersim then return inst end local itemdata = inst.components.unwrappable.itemdata if itemdata ~= nil then for k,v in ipairs(itemdata) do -- Do stuff with item v end end end AddPrefabPostInit("bundle", CheckItems) This does not work. itemdata is always nil. My best guess is that i am trying to access the contents before the game loads them. How can i ensure that my code runs after the bundle is completely loaded? Link to comment https://forums.kleientertainment.com/forums/topic/88399-item-data-from-unwrappable-component-not-accessable/ Share on other sites More sharing options...
IronHunter Posted March 8, 2018 Share Posted March 8, 2018 (edited) Hmm, have you tried running a DoTaskInTime(time, function)? something like inst:DoTaskInTime(0, function(inst) --your code local itemdata = inst.components.unwrappable.itemdata if itemdata ~= nil then for k,v in ipairs(itemdata) do -- Do stuff with item v end end end) This makes it run your code on the frame immediately after the rest of the bundle code is run. I believe by default AddPostInit stuff runs your code before the default code is run. That is how we are able to hook into existing functions to inject code. Cheers, Iron_Hunter Edited March 8, 2018 by IronHunter Link to comment https://forums.kleientertainment.com/forums/topic/88399-item-data-from-unwrappable-component-not-accessable/#findComment-1012237 Share on other sites More sharing options...
BakaSchwarz Posted March 8, 2018 Author Share Posted March 8, 2018 Good call, that works. Thanks a lot! Link to comment https://forums.kleientertainment.com/forums/topic/88399-item-data-from-unwrappable-component-not-accessable/#findComment-1012634 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now