Nomron Posted June 2, 2018 Share Posted June 2, 2018 Hey! So I'm making a mod and I want to know how to make a custom item that restores sanity when held and can only be crafted by a custom character. Thanks! Link to comment Share on other sites More sharing options...
halfrose Posted June 2, 2018 Share Posted June 2, 2018 15 minutes ago, Nomron said: Hey! So I'm making a mod and I want to know how to make a custom item that restores sanity when held and can only be crafted by a custom character. Thanks! I'm no modding savant, but what I do: To add sanity when held inst.components.equippable.dapperness = TUNING.DAPPERNESS_TINY TINY can be changed to SMALL, MED, HUGE if I remember well. as for craft specific only you might want to create a tag to your character, you do that by adding: inst:AddTag("mytag") In your character 'common_postinit' then in the modmain you do -- Note: if you have this part already, no need to add it. I am not quite sure you need all of those but i have them just for safety local FOODTYPE = GLOBAL.FOODTYPE local CHARACTER_INGREDIENT = GLOBAL.CHARACTER_INGREDIENT local AllRecipes = GLOBAL.AllRecipes local Ingredient = GLOBAL.Ingredient local RECIPETABS = GLOBAL.RECIPETABS local TECH = GLOBAL.TECH -------------------------------------------RECIPES------------------------ AddRecipe("myitemname", { Ingredient("twigs", 3), --Item example Ingredient("rocks", 2), Ingredient("gears", 1) }, RECIPETABS.REFINE, -- Tab recipe will appear TECH.SCIENCE_TWO, -- Tech needed (ex, here it is the alchemy machine) nil, -- If it is a structure, this is where you put the placer nil, nil, nil, "mytag", -- Your character tag "images/myitem.xml", --name of item xml file "myitem.tex") --name of the item tex file STRINGS.NAMES.MYITEMNAME = "My item" --Name of object STRINGS.RECIPE_DESC.MYITEMNAME = "It's a good item." --Item description now keep in mind, I'm not the best person in modding, so maybe I may have forgotten something here or there. Link to comment Share on other sites More sharing options...
Nomron Posted June 2, 2018 Author Share Posted June 2, 2018 16 hours ago, halfrose said: I'm no modding savant, but what I do: To add sanity when held inst.components.equippable.dapperness = TUNING.DAPPERNESS_TINY TINY can be changed to SMALL, MED, HUGE if I remember well. as for craft specific only you might want to create a tag to your character, you do that by adding: inst:AddTag("mytag") In your character 'common_postinit' then in the modmain you do -- Note: if you have this part already, no need to add it. I am not quite sure you need all of those but i have them just for safety local FOODTYPE = GLOBAL.FOODTYPE local CHARACTER_INGREDIENT = GLOBAL.CHARACTER_INGREDIENT local AllRecipes = GLOBAL.AllRecipes local Ingredient = GLOBAL.Ingredient local RECIPETABS = GLOBAL.RECIPETABS local TECH = GLOBAL.TECH -------------------------------------------RECIPES------------------------ AddRecipe("myitemname", { Ingredient("twigs", 3), --Item example Ingredient("rocks", 2), Ingredient("gears", 1) }, RECIPETABS.REFINE, -- Tab recipe will appear TECH.SCIENCE_TWO, -- Tech needed (ex, here it is the alchemy machine) nil, -- If it is a structure, this is where you put the placer nil, nil, nil, "mytag", -- Your character tag "images/myitem.xml", --name of item xml file "myitem.tex") --name of the item tex file STRINGS.NAMES.MYITEMNAME = "My item" --Name of object STRINGS.RECIPE_DESC.MYITEMNAME = "It's a good item." --Item description now keep in mind, I'm not the best person in modding, so maybe I may have forgotten something here or there. Thank you so much! Currently, I can't test this because my mod keeps crashing but none the less thank you!! Link to comment Share on other sites More sharing options...
halfrose Posted June 2, 2018 Share Posted June 2, 2018 2 hours ago, Nomron said: Thank you so much! Currently, I can't test this because my mod keeps crashing but none the less thank you!! if it keeps crashing, upload the log.txt found in Documents\Klei\DoNotStarveTogether Link to comment Share on other sites More sharing options...
Nomron Posted June 2, 2018 Author Share Posted June 2, 2018 3 hours ago, halfrose said: if it keeps crashing, upload the log.txt found in Documents\Klei\DoNotStarveTogether I figured out why it was crashing. Thanks, though! Link to comment Share on other sites More sharing options...
Nomron Posted June 3, 2018 Author Share Posted June 3, 2018 On 6/1/2018 at 9:01 PM, halfrose said: To add sanity when held inst.components.equippable.dapperness = TUNING.DAPPERNESS_TINY Hey! Sorry to bother you again. I tried adding this and it gave me an error message. It said inst was a nil value so I tried changing it to the item name but that was a nil value as well. Here's the log: client_log.txt Link to comment Share on other sites More sharing options...
halfrose Posted June 3, 2018 Share Posted June 3, 2018 11 hours ago, Nomron said: Hey! Sorry to bother you again. I tried adding this and it gave me an error message. It said inst was a nil value so I tried changing it to the item name but that was a nil value as well. Here's the log: client_log.txt it says the error is in the modmain. the Dapperness component needs to be added in the item's FN function in the item's prefab example. local function fn(Sim) local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("swap_hat", "darkingcrown_swap", "swap_hat") owner.AnimState:Show("HAT") owner.AnimState:Show("HAT_HAT") print('A') if owner:HasTag("player") then print('B') owner.AnimState:Hide("HEAD") owner.AnimState:Show("HEAD_HAT") end end local function OnUnequip(inst, owner) owner.AnimState:ClearOverrideSymbol("swap_hat") owner.AnimState:Hide("HAT") owner.AnimState:Hide("HAT_HAT") owner.AnimState:Show("HAIR_NOHAT") owner.AnimState:Show("HAIR") if owner:HasTag("player") then owner.AnimState:Show("HEAD") owner.AnimState:Hide("HEAD_HAT") end end local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() if TheSim:GetGameID() =="DST" then inst.entity:AddNetwork() end MakeInventoryPhysics(inst) MakeSmallBurnable(inst) MakeSmallPropagator(inst) inst.AnimState:SetBank("darkingcrown") inst.AnimState:SetBuild("darkingcrown") inst.AnimState:PlayAnimation("idle") if TheSim:GetGameID()=="DST" then if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() end inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.HEAD inst.components.equippable:SetOnEquip(OnEquip) inst.components.equippable:SetOnUnequip(OnUnequip) inst.components.equippable.dapperness = TUNING.DAPPERNESS_SMALL inst:AddComponent("inspectable") inst:AddComponent("inventoryitem") inst.components.inventoryitem.atlasname = "images/inventoryimages/darkingcrown.xml" return inst end Link to comment Share on other sites More sharing options...
Nomron Posted June 3, 2018 Author Share Posted June 3, 2018 (edited) 2 hours ago, halfrose said: it says the error is in the modmain. the Dapperness component needs to be added in the item's FN function in the item's prefab example. local function fn(Sim) local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("swap_hat", "darkingcrown_swap", "swap_hat") owner.AnimState:Show("HAT") owner.AnimState:Show("HAT_HAT") print('A') if owner:HasTag("player") then print('B') owner.AnimState:Hide("HEAD") owner.AnimState:Show("HEAD_HAT") end end local function OnUnequip(inst, owner) owner.AnimState:ClearOverrideSymbol("swap_hat") owner.AnimState:Hide("HAT") owner.AnimState:Hide("HAT_HAT") owner.AnimState:Show("HAIR_NOHAT") owner.AnimState:Show("HAIR") if owner:HasTag("player") then owner.AnimState:Show("HEAD") owner.AnimState:Hide("HEAD_HAT") end end local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() if TheSim:GetGameID() =="DST" then inst.entity:AddNetwork() end MakeInventoryPhysics(inst) MakeSmallBurnable(inst) MakeSmallPropagator(inst) inst.AnimState:SetBank("darkingcrown") inst.AnimState:SetBuild("darkingcrown") inst.AnimState:PlayAnimation("idle") if TheSim:GetGameID()=="DST" then if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() end inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.HEAD inst.components.equippable:SetOnEquip(OnEquip) inst.components.equippable:SetOnUnequip(OnUnequip) inst.components.equippable.dapperness = TUNING.DAPPERNESS_SMALL inst:AddComponent("inspectable") inst:AddComponent("inventoryitem") inst.components.inventoryitem.atlasname = "images/inventoryimages/darkingcrown.xml" return inst end Wow, I really feel like an idiot. I tried doing this and it doesn't appear. I'm sorry for being dumb but thank you!! Edited June 3, 2018 by Nomron worded it wrong Link to comment Share on other sites More sharing options...
halfrose Posted June 3, 2018 Share Posted June 3, 2018 46 minutes ago, Nomron said: Wow, I really feel like an idiot. I tried doing this and it doesn't appear. I'm sorry for being dumb but thank you!! what is not appearing? the item? Link to comment Share on other sites More sharing options...
Nomron Posted June 3, 2018 Author Share Posted June 3, 2018 6 minutes ago, halfrose said: what is not appearing? the item? Yeah, the item doesn't appear in the crafting list. Link to comment Share on other sites More sharing options...
halfrose Posted June 4, 2018 Share Posted June 4, 2018 20 hours ago, Nomron said: Yeah, the item doesn't appear in the crafting list. it should only appear when you play the character that owns the tag you provided in the recipe, if you added a custom tag in the characters common_postinit and the tag on the recipe, it should appear //or at least crash in some way// if you did that and it is not appearing, I think i would know better how to fix if you provide the mod so I can look into. Link to comment Share on other sites More sharing options...
Nomron Posted June 4, 2018 Author Share Posted June 4, 2018 2 hours ago, halfrose said: it should only appear when you play the character that owns the tag you provided in the recipe, if you added a custom tag in the characters common_postinit and the tag on the recipe, it should appear //or at least crash in some way// if you did that and it is not appearing, I think i would know better how to fix if you provide the mod so I can look into. Here's the mod: extended sample character-DST.zip It's still a heavy WIP, so there's a lot of things missing/that haven't been changed. Link to comment Share on other sites More sharing options...
halfrose Posted June 9, 2018 Share Posted June 9, 2018 On 6/4/2018 at 12:50 PM, Nomron said: Here's the mod: extended sample character-DST.zip It's still a heavy WIP, so there's a lot of things missing/that haven't been changed. you are missing the assets on top of the item prefab, also it seems you are missing renaming some things. You might want to look into this item template since you seem a bit lost on it https://forums.kleientertainment.com/topic/29427-tutorial-creating-a-handslot-equippable-item-from-scratch/ Link to comment Share on other sites More sharing options...
Nomron Posted June 10, 2018 Author Share Posted June 10, 2018 On 6/9/2018 at 2:16 PM, halfrose said: you are missing the assets on top of the item prefab, also it seems you are missing renaming some things. You might want to look into this item template since you seem a bit lost on it https://forums.kleientertainment.com/topic/29427-tutorial-creating-a-handslot-equippable-item-from-scratch/ Thank you! Sorry for being so dumb. 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