Sacco Posted November 8, 2023 Share Posted November 8, 2023 I am trying to make maxwell uses double the durability of a book on read, but it just doesn't work. When i enter the game and i read a book it just loses the ordinary durability, the game doesn't even crash or something else. Why? Every advice is appreciated (: Link to comment Share on other sites More sharing options...
ClumsyPenny Posted November 8, 2023 Share Posted November 8, 2023 After looking into it a bit, it seems that the code that the "efficientuser" component needs inside the "finiteuses" component doesn't run in this specific case, specifically in the OnUsedAsItem() function. It's because books don't use SetConsumption() to set an action and the uses it takes, they instead lose durability manually from the "book" component, in the ConsumeUse() function. You definitely had a good idea, unfortunately the code can be a bit messy and confusing. I don't know why Klei didn't just go with SetConsumption() for books as well, but perhaps there's something I'm missing. I tried coding a solution, but I'm not exactly too happy with it. I hooked into the "book" component and made it consume an use again if Maxwell is doing the reading. Maybe that can give you an idea on how to approach this problem, it's up to you! AddComponentPostInit("book", function(self) local _old_interact = self.Interact function self:Interact(fn, reader, ...) local success, reason = _old_interact(self, fn, reader, ...) if success and reader.prefab == "waxwell" then self:ConsumeUse() end return success, reason end end) 1 Link to comment Share on other sites More sharing options...
Sacco Posted November 8, 2023 Author Share Posted November 8, 2023 24 minutes ago, ariadnesGambit said: After looking into it a bit, it seems that the code that the "efficientuser" component needs inside the "finiteuses" component doesn't run in this specific case, specifically in the OnUsedAsItem() function. It's because books don't use SetConsumption() to set an action and the uses it takes, they instead lose durability manually from the "book" component, in the ConsumeUse() function. You definitely had a good idea, unfortunately the code can be a bit messy and confusing. I don't know why Klei didn't just go with SetConsumption() for books as well, but perhaps there's something I'm missing. I tried coding a solution, but I'm not exactly too happy with it. I hooked into the "book" component and made it consume an use again if Maxwell is doing the reading. Maybe that can give you an idea on how to approach this problem, it's up to you! AddComponentPostInit("book", function(self) local _old_interact = self.Interact function self:Interact(fn, reader, ...) local success, reason = _old_interact(self, fn, reader, ...) if success and reader.prefab == "waxwell" then self:ConsumeUse() end return success, reason end end) wow it worked! I don't know how you managed to do it but it actually worked! Thanks a lot! 1 Link to comment Share on other sites More sharing options...
ClumsyPenny Posted November 8, 2023 Share Posted November 8, 2023 11 minutes ago, Sacco said: I don't know how you managed to do it but it actually worked! I tried explaining my thought process, but if something isn't clear, feel free to ask! I'm more than happy to teach people about modding, it's why I visit this section of the forums. 12 minutes ago, Sacco said: Thanks a lot! Any time! 1 Link to comment Share on other sites More sharing options...
Sacco Posted November 8, 2023 Author Share Posted November 8, 2023 11 minutes ago, ariadnesGambit said: I tried explaining my thought process, but if something isn't clear, feel free to ask! I'm more than happy to teach people about modding, it's why I visit this section of the forums. Unfortunately i don't know very well how to mod, i am new to this "world" and for this reason i'm posting on the forum to get some needed help. I'm trying to understand what you wrote but i'm having problems to understand it just because i just don't know how to mod well. Link to comment 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