bum0303 Posted June 11, 2022 Share Posted June 11, 2022 How to add mod Asset in Vanilla Prefabs? I doing like this but is not working.... AddPrefabPostInit("portablespicer", function(inst) table.insert(GLOBAL.Prefabs['portablespicer'].assets,Asset("ANIM", "anim/water_spice.zip")) table.insert(GLOBAL.Prefabs['portablespicer'].assets,Asset("ANIM", "anim/water_plate_food.zip")) if not GLOBAL.TheWorld.ismastersim then return inst end if inst.components.stewer ~= nil then if inst.components.stewer.ondonecooking ~= nil and inst.components.stewer.ondonecooking_old == nil then inst.components.stewer.ondonecooking_old = inst.components.stewer.ondonecooking end inst:DoTaskInTime(0, function() inst.components.stewer.ondonecooking = changeanim end) end end) Where did I go wrong? Link to comment https://forums.kleientertainment.com/forums/topic/140811-how-to-add-mod-asset-in-vanilla-prefabs/ Share on other sites More sharing options...
Leonidas IV Posted June 11, 2022 Share Posted June 11, 2022 Well, that doesn't work. The Assets table in the prefab is simply to load them into the game, and they don't exactly need to be inside the prefab. You can simply add these assets to the Assets table in modmain. Link to comment https://forums.kleientertainment.com/forums/topic/140811-how-to-add-mod-asset-in-vanilla-prefabs/#findComment-1576438 Share on other sites More sharing options...
bum0303 Posted June 11, 2022 Author Share Posted June 11, 2022 3 hours ago, Leonidas IV said: Well, that doesn't work. The Assets table in the prefab is simply to load them into the game, and they don't exactly need to be inside the prefab. You can simply add these assets to the Assets table in modmain. I'll give it a try. 3 hours ago, Leonidas IV said: Well, that doesn't work. The Assets table in the prefab is simply to load them into the game, and they don't exactly need to be inside the prefab. You can simply add these assets to the Assets table in modmain. Well, if I don't understand it well, I'll write modmain like table.insert(GLOBAL.Prefabs['portablespicer'].assets,Asset("ANIM", "anim/water_spice.zip")) table.insert(GLOBAL.Prefabs['portablespicer'].assets,Asset("ANIM", "anim/water_plate_food.zip")) but i got like bug [00:00:03]: [string "../mods/water_mod/scripts/water_main.lua"]:485: attempt to index field 'portablespicer' (a nil value) LUA ERROR stack traceback: ../mods/water_mod/scripts/water_main.lua(485,1) in function 'result' scripts/mods.lua(330,1) in function 'modimport' ../mods/water_mod/modmain.lua(34,1) in main chunk =[C] in function 'xpcall' scripts/util.lua(780,1) in function 'RunInEnvironment' scripts/mods.lua(563,1) in function 'InitializeModMain' scripts/mods.lua(537,1) in function 'LoadMods' scripts/main.lua(356,1) in function 'ModSafeStartup' scripts/main.lua(477,1) in function 'callback' scripts/modindex.lua(103,1) in function 'BeginStartupSequence' scripts/main.lua(476,1) in function 'callback' scripts/modindex.lua(735,1) =[C] in function 'GetPersistentString' scripts/modindex.lua(709,1) in function 'Load' scripts/main.lua(475,1) in main chunk [00:00:03]: [string "scripts/mainfunctions.lua"]:1485: variable 'global_error_widget' is not declared LUA ERROR stack traceback: =[C] in function 'error' scripts/strict.lua(23,1) scripts/mainfunctions.lua(1485,1) =[C] in function 'GetPersistentString' scripts/quagmire_recipebook.lua(54,1) in function 'Load' scripts/main.lua(374,1) in function 'ModSafeStartup' scripts/main.lua(477,1) in function 'callback' scripts/modindex.lua(103,1) in function 'BeginStartupSequence' scripts/main.lua(476,1) in function 'callback' scripts/modindex.lua(735,1) =[C] in function 'GetPersistentString' scripts/modindex.lua(709,1) in function 'Load' scripts/main.lua(475,1) in main chunk If it is wrong, how should I write it? Link to comment https://forums.kleientertainment.com/forums/topic/140811-how-to-add-mod-asset-in-vanilla-prefabs/#findComment-1576489 Share on other sites More sharing options...
Leonidas IV Posted June 12, 2022 Share Posted June 12, 2022 The mod enviroment looks for assets to load in the variable "Assets" (a table), so you just need to re-create it or insert your assets in it: Assets = { Asset("ANIM","anim/water_spice.zip"), Asset("ANIM", "anim/water_plate_food.zip"), } 2 Link to comment https://forums.kleientertainment.com/forums/topic/140811-how-to-add-mod-asset-in-vanilla-prefabs/#findComment-1576527 Share on other sites More sharing options...
CarlZalph Posted June 15, 2022 Share Posted June 15, 2022 It'd be a lot easier if you made your own prefab with the custom stuff on it. 1 Link to comment https://forums.kleientertainment.com/forums/topic/140811-how-to-add-mod-asset-in-vanilla-prefabs/#findComment-1576941 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