Jump to content

Recommended Posts

@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.

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 by Crazybait24

@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

@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.

@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?

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 by Crazybait24

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 by Kzisor
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

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.lua

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.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")

@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 

@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.

YES It worked :D

 

 

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 :D 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 here

local 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)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...