Last_epilogue Posted March 25, 2023 Share Posted March 25, 2023 (edited) So I want to create a bundle and give it inst.name "hostage". I created a file in script/prefab and include comments like local bundle = SpawnPrefab"bundle" bundle.components.unwrappable:WrapItems({inst}, doer) bundle:SetTitle("Hostage") bundle:AddComponent"tradable" inst:Remove() Then I go to the modmain and wrote APPI("bundle", function(inst) local OnLoad, OnSave = inst.OnLoad, inst.OnSave inst.OnLoad = function(inst, data) if data and data.title then inst:SetTitle(data.title) end if OnLoad then return OnLoad(inst, data) end end inst.OnSave = function(inst, data) if inst.title then data.title = inst.title end if OnSave then return OnSave(inst, data) end end inst.SetTitle = function(inst, name) inst.name = name end it worked perfectly, but now I want to give the bundle a tradable component. Put it in script, when log on/off it doesn't work anymore; if put in modmain it makes all bundle tradable (only want bundle with name "hostage"). Can someone help me into how to put the component correctly in my OnLoad/OnSave part? (Its singleyplayer so it may look a little bit weird and don't say post it there its dead lol) Edited March 25, 2023 by Last_epilogue Link to comment https://forums.kleientertainment.com/forums/topic/146739-help-how-to-put-a-component-in-onsaveonload/ Share on other sites More sharing options...
Rickzzs Posted March 26, 2023 Share Posted March 26, 2023 Why don't you create a new prefab using local function fn() local bundle=Prefabs.bundle.fn() return bundle end return Prefab("hostage" 1 Link to comment https://forums.kleientertainment.com/forums/topic/146739-help-how-to-put-a-component-in-onsaveonload/#findComment-1627160 Share on other sites More sharing options...
Last_epilogue Posted March 26, 2023 Author Share Posted March 26, 2023 24 minutes ago, Rickzzs said: Why don't you create a new prefab using local function fn() local bundle=Prefabs.bundle.fn() return bundle end return Prefab("hostage" Are u suggesting me create a new file naming bundle.lua, or I use it to replace what I typed above? Here's my file for u if this can help! I was modding an action called "snare". snarable.lua snaring.lua Link to comment https://forums.kleientertainment.com/forums/topic/146739-help-how-to-put-a-component-in-onsaveonload/#findComment-1627161 Share on other sites More sharing options...
Rickzzs Posted March 26, 2023 Share Posted March 26, 2023 9 hours ago, Last_epilogue said: Are u suggesting me create a new file naming bundle.lua, or I use it to replace what I typed above? Here's my file for u if this can help! I was modding an action called "snare". snarable.lua 1.17 kB · 0 downloads snaring.lua 337 B · 0 downloads I suggest you created a new prefab hostage if you want to rename a bundle that does not have a new component. And if you want to save data, the most convenient way is creating a prefab. Link to comment https://forums.kleientertainment.com/forums/topic/146739-help-how-to-put-a-component-in-onsaveonload/#findComment-1627193 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