Zepp Posted August 6, 2021 Share Posted August 6, 2021 I tried to put addclasspostconstruct in modmain.lua to modify scripts/messagebottletreatments.lua, but it didn't work. I guess my addclasspostconstruct may be used incorrectly. AddClassPostConstruct("messagebottletreasures", function(self) local old_templates = self.treasure_templates self.treasure_templates = new_templates end) local new_templates = { --somethingSome treasure_templates content } Thanks all you guys. Link to comment https://forums.kleientertainment.com/forums/topic/132492-how-to-modify-the-product-of-sunken-chest-with-mod-api/ Share on other sites More sharing options...
Monti18 Posted August 11, 2021 Share Posted August 11, 2021 The problem with your code is that messagebottletreasures is not a class, so you can't override it with AddClassPostConstruct. local new_templates = { --somethingSome treasure_templates content } local messagebottletreasures = require "messagebottletreasures" local old_templates = messagebottletreasures.treasure_templates messagebottletreasures.treasure_templates = new_templates But you can access it directly by using require. This code snippet has the effect that you want. 2 Link to comment https://forums.kleientertainment.com/forums/topic/132492-how-to-modify-the-product-of-sunken-chest-with-mod-api/#findComment-1485064 Share on other sites More sharing options...
Zepp Posted August 11, 2021 Author Share Posted August 11, 2021 @Monti18 Thank you very much for your help! But there is a table called weighted_treasure_prefabs in messagebottletreasures, which determines what's in the sunkenchest, weighted_ treasure_ prefabs is a local variable, so still can't customize the content of sunnkenchest in this way. I'm looking for other ways to modify messagebottlemanager. lua or messagebottletreatments.Generatetreatment(). Link to comment https://forums.kleientertainment.com/forums/topic/132492-how-to-modify-the-product-of-sunken-chest-with-mod-api/#findComment-1485085 Share on other sites More sharing options...
Monti18 Posted August 11, 2021 Share Posted August 11, 2021 If you want to modify the treasures of sunkenchest, you can either make your own GenerateTreasure function and replace it with the one from the original file or use rezecibs upvaluehacker to change the local treasure_templates so that the changes are transferred to the GenerateTreasure function. The upvaluehacker method makes it more compatible to future changes but costs more computing power. 2 Link to comment https://forums.kleientertainment.com/forums/topic/132492-how-to-modify-the-product-of-sunken-chest-with-mod-api/#findComment-1485098 Share on other sites More sharing options...
Zepp Posted August 11, 2021 Author Share Posted August 11, 2021 2 minutes ago, Monti18 said: The upvaluehacker method makes it more compatible to future changes but costs more computing power. Thank you very much for your advice. 1 Link to comment https://forums.kleientertainment.com/forums/topic/132492-how-to-modify-the-product-of-sunken-chest-with-mod-api/#findComment-1485099 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