Veketh Posted July 29, 2019 Share Posted July 29, 2019 (edited) I am making(trying the hardest I can) my own [DST] character mod and I wanted for him to rely on his starter item mainly... is there a way to increase this item durability? etc. pan flute have, I think 10 uses, can I increase this to 100? Edited July 29, 2019 by Veketh Link to comment Share on other sites More sharing options...
Serpens Posted July 30, 2019 Share Posted July 30, 2019 (edited) what kind of item is it? There are several kinds of durability: "Finiteuses" for weapons and tools. "fueled" for lantern and that stuff. "persihable" for hambat and food. "armor" for armors. I guess it is a tool/weapon and therefore using finiteuses? You set the max finiteuses after adding this component with: inst.components.finiteuses:SetMaxUses(val) Is it a new item you made? Then put it into your master-postinit. If it is a item that already exists, you can o this within an AddPrefabPostInit , but this will also change the item for every other player. If you only want it to be changed for your player, it is a bit more complicated, so I will wait for your reply. Edited July 30, 2019 by Serpens 1 Link to comment Share on other sites More sharing options...
Veketh Posted July 30, 2019 Author Share Posted July 30, 2019 @Serpens wow, thanks so much for such long and understandable answer. Well, I wanted for this character to use Pan Flute (I have no idea if it's a weapon or a tool) and in the best scenario, I wanted it to be unlimited use, only for that character. If you could help me with that I would be very grateful. Link to comment Share on other sites More sharing options...
Serpens Posted July 30, 2019 Share Posted July 30, 2019 (edited) AddPrefabPostInit("panflute",function(inst) if inst.components~=nil then local old_Use = inst.components.finiteuses.Use inst.components.finiteuses.Use = function(self,val,...) if self.inst~=nil and self.inst.components~=nil and self.inst.components.inventoryitem~=nil and self.inst.components.inventoryitem.owner~=nil and self.inst.components.inventoryitem.owner.prefab=="mycharacter" then val = 0 -- set usage to 0 if it is in inventory of our character end return old_Use(self,val,...) -- call the original function now end end end) try this in modmain.lua and replace "mycharacter" with you character prefab. It changes the consumed value to 0, if in inventory of your character. Edited July 30, 2019 by Serpens 1 Link to comment Share on other sites More sharing options...
Veketh Posted July 30, 2019 Author Share Posted July 30, 2019 (edited) @SerpensThank you so much...it works perfectly fine. You even wrote all code yourself, thanks once more. Edited July 30, 2019 by Veketh Link to comment Share on other sites More sharing options...
Serpens Posted July 30, 2019 Share Posted July 30, 2019 downside is that if you play it while it is in a chest, the code wont work. I think if in backpack it still should work, but better try. The problem is that finiteuses has no information about the user, so we need other way to find the user and check if it is your character. In this case I used the inventory. Link to comment Share on other sites More sharing options...
Veketh Posted July 30, 2019 Author Share Posted July 30, 2019 (edited) So if I got this right... you can use this item only when it's in your inventory(eventually in a backpack - didn't test yet) and this will work for other players too? In the future, I hoped to do that this item can be used only by that character, but I think there will be a lot of problems in that. Edited July 30, 2019 by Veketh Link to comment Share on other sites More sharing options...
Serpens Posted July 30, 2019 Share Posted July 30, 2019 3 minutes ago, Veketh said: So if I got this right... you can use this item only when it's in your inventory(eventually in a backpack - didn't test yet) and this will work for other players too? In the future, I hoped to do that this item can be used only by that character, but I think there will be a lot of problems in that. no, the code does check for your character. But it only knows that it is you, if the flute is in your inventory. If the flute is in a chest and you play it with your character, it will lose durability. For other characters the flute will work like normal. Link to comment Share on other sites More sharing options...
Veketh Posted July 30, 2019 Author Share Posted July 30, 2019 (edited) Ok, I just misunderstood then... thank you so much for your work. I hope I'll be able to help someone in the future like you. When I get a bit of experience in this of course. Edited July 30, 2019 by Veketh 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