Notant Posted January 16, 2015 Share Posted January 16, 2015 Hey I figured this would be the best place to ask this - Where and how can I find a specific item if I'm looking for code? I have this idea of combining weapons/items/clothes for repairing(Similar to other sandbox type games)instead of having such clutter at times. I know the sewing kit does something like this as it repairs some clothing, I'd like to find that code and some how get that to apply from any weapon/item/cloth to another of the same name. Any help would be appreciated and if any experienced modders want to let me know that this isn't so feasible that's fine as well. Link to comment Share on other sites More sharing options...
tetrified Posted January 16, 2015 Share Posted January 16, 2015 Don't Starve Together Beta\data\scripts\components\sewing.luaDon't Starve Together Beta\data\scripts\prefabs\sewingkit.lua These two should get you started. If you find something and you're wondering where it gets declared, notepad++'s find in files feature works wonders, just set it to Don't Starve Together Beta\data\scripts\ and let it work its magic. Link to comment Share on other sites More sharing options...
outseeker Posted January 18, 2015 Share Posted January 18, 2015 @tetrified, wtf notepad++ has a "find in files" feature!?!? ffffffffffffffuuuu XD TY! Link to comment Share on other sites More sharing options...
Notant Posted January 23, 2015 Author Share Posted January 23, 2015 I've searched pretty hard looking for the connection between the sewing kit.lua and sewing.lua and the items it's used on but I can't figure it out, I don't understand how it's determined what can be sewed and what can't be.local Sewing = Class(function(self, inst) self.inst = inst self.repair_value = 1end)function Sewing:DoSewing(target, doer) if target:HasTag("needssewing") then target.components.fueled:DoDelta(self.repair_value) if self.inst.components.finiteuses then self.inst.components.finiteuses:Use(1) end if self.onsewn then self.onsewn(self.inst, target, doer) end return true endendreturn Sewinglocal function walrus() local inst = simple() if not TheWorld.ismastersim then return inst end inst:AddComponent("dapperness") inst.components.dapperness.dapperness = TUNING.DAPPERNESS_LARGE inst:AddComponent("insulator") inst.components.insulator.insulation = TUNING.INSULATION_MED inst:AddComponent("fueled") inst.components.fueled.fueltype = FUELTYPE.USAGE inst.components.fueled:InitializeFuelLevel(TUNING.WALRUSHAT_PERISHTIME) inst.components.fueled:SetDepletedFn(inst.Remove) return inst endLooking at all of the hats that could be sewn in game I couldn't find out where DoSewing, or onsewn, or needsewing are used .. any help? what part of the code is telling the item it can be sewn? or repaired? Link to comment Share on other sites More sharing options...
Jjmarco Posted January 23, 2015 Share Posted January 23, 2015 @outseeker, this is probably the most useful function of Notepad++! @Notant, using the Find in Files feature they were talking about, I was able to find that:The DoSewing function is actually used to define an action in scripts/actions.lua:ACTIONS.SEW.fn = function(act) if act.target and act.target.components.fueled and act.invobject and act.invobject.components.sewing then return act.invobject.components.sewing:DoSewing(act.target, act.doer) endend which is then used in the stategraph of wilson on both SGwilson.lua and SGwilson_client.lua:ActionHandler(ACTIONS.SEW, "dolongaction"), The needsewing tag is set in the fueled component in components/fueled.lua.onsewn is a function of the sewingkit prefab that is called when DoSewing is called.Hope that helped! Link to comment Share on other sites More sharing options...
Notant Posted January 23, 2015 Author Share Posted January 23, 2015 (edited) @Jjmarco So essentially having the fueled component allows them to be sewn, am I understanding that right? or not that simple? Edited January 23, 2015 by Notant Link to comment Share on other sites More sharing options...
Jjmarco Posted January 23, 2015 Share Posted January 23, 2015 (edited) @Notant: That, and having their fuel type set to FUELTYPE.USAGE, from what I gathered:inst:AddComponent("fueled")inst.components.fueled.fueltype = FUELTYPE.USAGEThis will automatically add the needsewing tag to the item when its durability is lowered, allowing it to be repaired using a sewing kit. Edited January 23, 2015 by Jjmarco Link to comment Share on other sites More sharing options...
Notant Posted January 23, 2015 Author Share Posted January 23, 2015 (edited) @Jjmarco That is what I thought, but I'm having issues actually making it work. I can't really find how to properly test a mod, should I just change the main files and test that way? I've looked all over for proper mod file set ups and how I should go about that but man information seems not that helpful. I'll try testing changing the main files since it's not a lot of work. Thank you for all the help! Edit - Didn't work for me, only added the timer(As if the item could run out but the clock was 0:00)under the pickaxes but didn't allow for sewing when the durability was under 100%, or even at 100%. Maybe a perish time is needed? Btw I'm using this on a pickaxe just to try and figure it out, really want to be able to repair items and I do know that there is a repair and repairable function, not that I could figure out those any better though. Edited January 23, 2015 by Notant Link to comment Share on other sites More sharing options...
Jjmarco Posted January 23, 2015 Share Posted January 23, 2015 (edited) @Notant, Ah yes, you have to add a perish time, I forgot To test a mod, you have to create a new folder in the mods directory of the game's files.Name it whatever you like, then add two files, one named "modmain.lua" and the other "modinfo.lua". In modinfo.lua, put this:name = "<Name of the mod here>"version = "1.0"author = "Notant"description = "This is a test mod."forumthread = ""api_version = 10dst_compatible = trueclient_only_mod = false -- change this if your mod is client-side onlyall_clients_require_mod = false -- change this if everybody on the server needs this mod in order to enterIn modmain.lua, put your mod's actual code. For instance, to add the fueled component to an item and make it sewable:AddPrefabPostInit("<item prefab here>", function(inst) -- Only the host should run this if GLOBAL.TheNet:GetIsServer() then inst:AddComponent("fueled") inst.components.fueled.fueltype = GLOBAL.FUELTYPE.USAGE endend)Note that this only applies to items that have the fueld component. The pickaxe uses the finiteuses component to handle durability. This is different from the fueled component, as it handles losses of durability overtime (Hats, amulets, etc). About your mod idea, you would need to define a function that takes two items, combine their durabilities using whatever logic you want, delete them, then create a new item of the same type on which you set that new durability. This function would be activated when you click on an item with another one of the same type. Edited January 23, 2015 by Jjmarco 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