Crazybait24 Posted January 7, 2015 Share Posted January 7, 2015 I was wondering if there was some code for making custom armor/items have infinite duribility to them Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/ Share on other sites More sharing options...
Kzisor Posted January 7, 2015 Share Posted January 7, 2015 (edited) @Crazybait24, don't add the finiteuses component to the item and it should have infinite uses. Take a look at the walkingcane for an example. Edited January 7, 2015 by Kzisor Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598359 Share on other sites More sharing options...
Crazybait24 Posted January 7, 2015 Author Share Posted January 7, 2015 Well you see I'm more or less talking about armor... I have an armor for my Character but everytime I get hit it takes away percentages... I'm wondering if there is a way to stop that? Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598369 Share on other sites More sharing options...
Kzisor Posted January 7, 2015 Share Posted January 7, 2015 @Crazybait24, the way armor works and the way other items works is different. If you are wanting to change how specific armor works, look at the armor component. You should have to adjust it some in order for it to work properly for your custom armor. Example:local fn(self) self._TakeDamage = self.TakeDamagefunction Armor:TakeDamage(damage_amount) if self.prefab == "CUSTOM PREFAB NAME" then if self.ontakedamage then self.ontakedamage(self.inst, damage_amount) end else self:SetCondition(self.condition - damage_amount) if self.ontakedamage then self.ontakedamage(self.inst, damage_amount) end endendreturn selfendAddComponentPostInit("armor", fn) Remember this is only an example. Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598371 Share on other sites More sharing options...
Crazybait24 Posted January 8, 2015 Author Share Posted January 8, 2015 (edited) I think I figured out how to get it done but I was wondering if the modmain.lua needs something similar to PrefabFiles = { "myarmor",} for the file tuning.lua Edit1: And while I'm here what about components Edited January 8, 2015 by Crazybait24 Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598794 Share on other sites More sharing options...
Kzisor Posted January 8, 2015 Share Posted January 8, 2015 @Crazybait24, components are put into scripts/components/ folder in your mod folder. As for tuning.lua you really shouldn't be overwriting that file. You should be using code like the following in your modmain.lua file. Example:GLOBAL.TUNING.maxhealth = 320000000000 Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598797 Share on other sites More sharing options...
Crazybait24 Posted January 8, 2015 Author Share Posted January 8, 2015 I don't know if I understand correctly... How does the mod load the components if their not in modmain.lua And what about you saying "you really shouldn't be overwriting that file." Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598800 Share on other sites More sharing options...
Kzisor Posted January 8, 2015 Share Posted January 8, 2015 @Crazybait24, overwriting the tuning.lua file is a bad habit as it can change in game updates which will cause incompatibility issues with your mod. The mod loads the components without the need to import them automatically by the client. Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598804 Share on other sites More sharing options...
Crazybait24 Posted January 8, 2015 Author Share Posted January 8, 2015 @Crazybait24, overwriting the tuning.lua file is a bad habit as it can change in game updates which will cause incompatibility issues with your mod. I didn't overwrite existing items in it all I did was add to it. Does that still make the tuning.lua incompatible? Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598810 Share on other sites More sharing options...
Crazybait24 Posted January 8, 2015 Author Share Posted January 8, 2015 (edited) Speaking of which this is what my modmain.lua looks like I think there has to be another way on line 105-118 to only change 1 armor piece.PrefabFiles = { "crazy", "icicle", "brass_lantern", "pigtorch_flame", "iciclevest",}Assets = { Asset( "IMAGE", "images/saveslot_portraits/crazy.tex" ), Asset( "ATLAS", "images/saveslot_portraits/crazy.xml" ), Asset( "IMAGE", "images/saveslot_portraits/icicle.tex" ), Asset( "ATLAS", "images/saveslot_portraits/icicle.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/crazy.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/crazy.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/icicle.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/icicle.xml" ), Asset( "IMAGE", "bigportraits/crazy.tex" ), Asset( "ATLAS", "bigportraits/crazy.xml" ), Asset( "IMAGE", "bigportraits/icicle.tex" ), Asset( "ATLAS", "bigportraits/icicle.xml" ), Asset( "IMAGE", "images/map_icons/crazy.tex" ), Asset( "ATLAS", "images/map_icons/crazy.xml" ), Asset( "IMAGE", "images/map_icons/icicle.tex" ), Asset( "ATLAS", "images/map_icons/icicle.xml" ), Asset( "IMAGE", "images/avatars/avatar_crazy.tex" ), Asset( "ATLAS", "images/avatars/avatar_crazy.xml" ), Asset( "IMAGE", "images/avatars/avatar_icicle.tex" ), Asset( "ATLAS", "images/avatars/avatar_icicle.xml" ), Asset( "IMAGE", "images/avatars/avatar_ghost_crazy.tex" ), Asset( "ATLAS", "images/avatars/avatar_ghost_crazy.xml" ), Asset( "IMAGE", "images/avatars/avatar_ghost_icicle.tex" ), Asset( "ATLAS", "images/avatars/avatar_ghost_icicle.xml" ), Asset("ATLAS", "images/inventoryimages/brass_lantern.xml"), Asset("IMAGE", "images/inventoryimages/iciclevest.tex"), Asset("ATLAS", "images/inventoryimages/iciclevest.xml"),}local require = GLOBAL.requirelocal STRINGS = GLOBAL.STRINGSlocal TUNING = GLOBAL.TUNING-- The character select screen linesSTRINGS.CHARACTER_TITLES.crazy = "Crazy the Bait"STRINGS.CHARACTER_NAMES.crazy = "Crazy"STRINGS.CHARACTER_DESCRIPTIONS.crazy = "*Levels up on Breakfast\n*Fast movement speed(Max level)\n*High damage(Max Level)"STRINGS.CHARACTER_QUOTES.crazy = "\"He's crazier then bait...\""STRINGS.CHARACTER_TITLES.icicle = "Icicle the Polar Bear"STRINGS.CHARACTER_NAMES.icicle = "Icicle"STRINGS.CHARACTER_DESCRIPTIONS.icicle = "*Levels up on Fish Tacos\n*High Damage output(Max level)\n*High Health, Sanity, and Hunger(Max Level)"STRINGS.CHARACTER_QUOTES.icicle = "\"The cold doesn't even touch me...\""-- Custom speech stringsSTRINGS.CHARACTERS.CRAZY = require "speech_crazy"STRINGS.CHARACTERS.ICICLE = require "speech_icicle"-- The character's name as appears in-game STRINGS.NAMES.CRAZY = "Crazy"STRINGS.NAMES.ICICLE = "Icicle"-- The default responses of examining the characterSTRINGS.CHARACTERS.GENERIC.DESCRIBE.CRAZY = { GENERIC = "It's Crazy!", ATTACKER = "That Crazy looks shifty...", MURDERER = "Murderer!", REVIVER = "Crazy, friend of ghosts.", GHOST = "Crazy could use a heart.",}STRINGS.CHARACTERS.GENERIC.DESCRIBE.ICICLE ={ GENERIC = "It's Icicle!", ATTACKER = "That Icicle looks shifty...", MURDERER = "MURDERER!", REVIVER = "Icicle, friend of ghosts.", GHOST = "Icicle could use a heart.",}-- Let the game know character is male, female, or robottable.insert(GLOBAL.CHARACTER_GENDERS.MALE, "crazy")table.insert(GLOBAL.CHARACTER_GENDERS.MALE, "icicle")GLOBAL.STRINGS.NAMES.BRASS_LANTERN = "Crazy's Lantern"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.BRASS_LANTERN = "A Lantern for Crazy the Bait."GLOBAL.STRINGS.NAMES.ICICLEVEST = "Icicle's Vest"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.ICICLEVEST = "A multiple pocket body vest for Icicle."GLOBAL.TUNING.REVIVE_HEALTH_PENALTY_AS_MULTIPLE_OF_EFFIGY = 0-- Configurationlocal ARMORICICLEVEST_DURABILITY = GetModConfigData("ARMORICICLEVEST_DURABILITY")-- Check if the user isn't a client.if not GLOBAL.TheNet:GetIsClient() then if ARMORICICLEVEST_DURABILITY ~= "Infinite" and ARMORICICLEVEST_DURABILITY ~= "100%" then TUNING.ARMORICICLEVEST = TUNING.ARMORICICLEVEST * ARMORICICLEVEST_DURABILITY end if ARMORICICLEVEST_DURABILITY == "Infinite" then function RemoveArmorDurability(inst) inst.TakeDamage = function () end end AddComponentPostInit("armor", RemoveArmorDurability) endend AddMinimapAtlas("images/map_icons/crazy.xml")AddModCharacter("crazy")AddMinimapAtlas("images/map_icons/icicle.xml")AddModCharacter("icicle") Edited January 8, 2015 by Crazybait24 Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598811 Share on other sites More sharing options...
Kzisor Posted January 8, 2015 Share Posted January 8, 2015 (edited) I didn't overwrite existing items in it all I did was add to it. Does that still make the tuning.lua incompatible? Yes, it will still be incompatible if the developers add anything to it. Here is an example:Lets say the developers add a new creature. This new creatures stats would be put into the tuning.lua file by the developers. Well it makes your mod incompatible because your mods tuning.lua file doesn't have those creatures stats in it, which means that your mod will now cause the game to crash. You can instead add the items you added to the tuning.lua inside the modmain.lua and prevent your mod from crashing the game in the future. As far as your second post, if it isn't broken don't fix it. Edited January 8, 2015 by Kzisor Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598824 Share on other sites More sharing options...
Crazybait24 Posted January 8, 2015 Author Share Posted January 8, 2015 You can instead add the items you added to the tuning.lua inside the modmain.lua and prevent your mod from crashing the game in the future. So how would I go about adding those lines from tuning.lua inside the modmain.lua Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598827 Share on other sites More sharing options...
Kzisor Posted January 8, 2015 Share Posted January 8, 2015 @Crazybait24, refer to the example I gave earlier. Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598841 Share on other sites More sharing options...
Crazybait24 Posted January 8, 2015 Author Share Posted January 8, 2015 Ok I attempted what you showed me and I got this error [string "scripts/components/inventory.lua"]:163: bad argument #1 to 'max' (number expected, got function) this is from my modmain.luaPrefabFiles = { "crazy", "icicle", "brass_lantern", "pigtorch_flame", "iciclevest",}Assets = { Asset( "IMAGE", "images/saveslot_portraits/crazy.tex" ), Asset( "ATLAS", "images/saveslot_portraits/crazy.xml" ), Asset( "IMAGE", "images/saveslot_portraits/icicle.tex" ), Asset( "ATLAS", "images/saveslot_portraits/icicle.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/crazy.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/crazy.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/icicle.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/icicle.xml" ), Asset( "IMAGE", "bigportraits/crazy.tex" ), Asset( "ATLAS", "bigportraits/crazy.xml" ), Asset( "IMAGE", "bigportraits/icicle.tex" ), Asset( "ATLAS", "bigportraits/icicle.xml" ), Asset( "IMAGE", "images/map_icons/crazy.tex" ), Asset( "ATLAS", "images/map_icons/crazy.xml" ), Asset( "IMAGE", "images/map_icons/icicle.tex" ), Asset( "ATLAS", "images/map_icons/icicle.xml" ), Asset( "IMAGE", "images/avatars/avatar_crazy.tex" ), Asset( "ATLAS", "images/avatars/avatar_crazy.xml" ), Asset( "IMAGE", "images/avatars/avatar_icicle.tex" ), Asset( "ATLAS", "images/avatars/avatar_icicle.xml" ), Asset( "IMAGE", "images/avatars/avatar_ghost_crazy.tex" ), Asset( "ATLAS", "images/avatars/avatar_ghost_crazy.xml" ), Asset( "IMAGE", "images/avatars/avatar_ghost_icicle.tex" ), Asset( "ATLAS", "images/avatars/avatar_ghost_icicle.xml" ), Asset("ATLAS", "images/inventoryimages/brass_lantern.xml"), Asset("IMAGE", "images/inventoryimages/iciclevest.tex"), Asset("ATLAS", "images/inventoryimages/iciclevest.xml"),}local require = GLOBAL.requirelocal STRINGS = GLOBAL.STRINGS-- The character select screen linesSTRINGS.CHARACTER_TITLES.crazy = "Crazy the Bait"STRINGS.CHARACTER_NAMES.crazy = "Crazy"STRINGS.CHARACTER_DESCRIPTIONS.crazy = "*Levels up on Breakfast\n*Fast movement speed(Max level)\n*High damage(Max Level)"STRINGS.CHARACTER_QUOTES.crazy = "\"He's crazier then bait...\""STRINGS.CHARACTER_TITLES.icicle = "Icicle the Polar Bear"STRINGS.CHARACTER_NAMES.icicle = "Icicle"STRINGS.CHARACTER_DESCRIPTIONS.icicle = "*Levels up on Fish Tacos\n*High Damage output(Max level)\n*High Health, Sanity, and Hunger(Max Level)"STRINGS.CHARACTER_QUOTES.icicle = "\"The cold doesn't even touch me...\""-- Custom speech stringsSTRINGS.CHARACTERS.CRAZY = require "speech_crazy"STRINGS.CHARACTERS.ICICLE = require "speech_icicle"-- The character's name as appears in-game STRINGS.NAMES.CRAZY = "Crazy"STRINGS.NAMES.ICICLE = "Icicle"-- The default responses of examining the characterSTRINGS.CHARACTERS.GENERIC.DESCRIBE.CRAZY = { GENERIC = "It's Crazy!", ATTACKER = "That Crazy looks shifty...", MURDERER = "Murderer!", REVIVER = "Crazy, friend of ghosts.", GHOST = "Crazy could use a heart.",}STRINGS.CHARACTERS.GENERIC.DESCRIBE.ICICLE ={ GENERIC = "It's Icicle!", ATTACKER = "That Icicle looks shifty...", MURDERER = "MURDERER!", REVIVER = "Icicle, friend of ghosts.", GHOST = "Icicle could use a heart.",}-- Let the game know character is male, female, or robottable.insert(GLOBAL.CHARACTER_GENDERS.MALE, "crazy")table.insert(GLOBAL.CHARACTER_GENDERS.MALE, "icicle")GLOBAL.STRINGS.NAMES.BRASS_LANTERN = "Crazy's Lantern"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.BRASS_LANTERN = "A Lantern for Crazy the Bait."GLOBAL.STRINGS.NAMES.ICICLEVEST = "Icicle's Vest"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.ICICLEVEST = "A multiple pocket body vest for Icicle."GLOBAL.TUNING.REVIVE_HEALTH_PENALTY_AS_MULTIPLE_OF_EFFIGY = 0GLOBAL.TUNING.ARMORICICLEVEST = function () endGLOBAL.TUNING.ARMORICICLEVEST_ABSORBTION = 0.70AddMinimapAtlas("images/map_icons/crazy.xml")AddModCharacter("crazy")AddMinimapAtlas("images/map_icons/icicle.xml")AddModCharacter("icicle") Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598848 Share on other sites More sharing options...
Kzisor Posted January 8, 2015 Share Posted January 8, 2015 @Crazybait24, you're trying to push a function when the argument is wanting a number. In your TUNING.ARMORICICLEVEST function you must return a value of a number in order for it to work correctly. EXAMPLE:GLOBAL.TUNING.ARMORICICLEVEST = function() return 0 end Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598857 Share on other sites More sharing options...
Crazybait24 Posted January 8, 2015 Author Share Posted January 8, 2015 I got the same error.. I was wondering if it is possible to set it with fuel and as the durability goes down you can then refuel it with say.... FUELTYPE.BURNABLE or something along those lines? Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598896 Share on other sites More sharing options...
Kzisor Posted January 8, 2015 Share Posted January 8, 2015 @Crazybait24, check out the miner's hat for code on how to refuel it. Should be a simple to manipulate it to work the way you want it. If you're getting the same error make sure you have () behind GLOBAL.TUNING.ARMORICICLEVEST whenever you are calling it. Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598897 Share on other sites More sharing options...
Crazybait24 Posted January 8, 2015 Author Share Posted January 8, 2015 YES It worked I made it refuelable with FUELTYPE.USAGE = Sewing Kit while keeping the armor the same as a snurtle shell which is 0.60 = %60 absorption its finally done! Thank you sooooooo much Kzisor! It worked without errors and I'll be uploading it to the workshop as soon as I finish typing this! Just in case someone wants to use my code I'll leave it herelocal assets ={ Asset("ANIM", "anim/iciclevest.zip"), Asset("IMAGE", "images/inventoryimages/iciclevest.tex"), Asset("ATLAS", "images/inventoryimages/iciclevest.xml"),}local function OnBlocked(owner) owner.SoundEmitter:PlaySound("dontstarve/wilson/hit_armour") endlocal function onequip(inst, owner) owner.AnimState:OverrideSymbol("swap_body", "iciclevest", "swap_body") inst:ListenForEvent("blocked", OnBlocked, owner) if inst.components.fueled then inst.components.fueled:StartConsuming() endendlocal function onunequip(inst, owner) owner.AnimState:ClearOverrideSymbol("swap_body") inst:RemoveEventCallback("blocked", OnBlocked, owner) if inst.components.fueled then inst.components.fueled:StopConsuming() endendlocal function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst.AnimState:SetBank("armor_wood") inst.AnimState:SetBuild("iciclevest") inst.AnimState:PlayAnimation("idle") inst.foleysound = "dontstarve/movement/foley/logarmour" if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() inst:AddComponent("inspectable") inst:AddComponent("inventoryitem") inst.components.inventoryitem.atlasname = "images/inventoryimages/iciclevest.xml" inst:AddComponent("armor") inst.components.armor:SetAbsorption(TUNING.ARMORSNURTLESHELL_ABSORPTION) inst:AddComponent("fueled") inst.components.fueled.fueltype = FUELTYPE.USAGE inst.components.fueled:InitializeFuelLevel(TUNING.WALRUSHAT_PERISHTIME) inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.BODY inst:AddComponent("insulator") inst.components.insulator.insulation = 2000 inst.components.equippable:SetOnEquip(onequip) inst.components.equippable:SetOnUnequip(onunequip) inst:AddComponent("container") inst.components.container:WidgetSetup("krampus_sack") return instendreturn Prefab("common/inventory/iciclevest", fn, assets) Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-598973 Share on other sites More sharing options...
Kzisor Posted January 8, 2015 Share Posted January 8, 2015 @Crazybait24, I'm glad that you were able to get this working. Link to comment https://forums.kleientertainment.com/forums/topic/48650-how-can-i-make-custom-armor-have-infinite-durability/#findComment-599006 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