Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --replace wodbhat with your hat's name
- local assets=
- {
- Asset("ANIM", "anim/wodbhat.zip"),
- Asset("IMAGE", "images/inventoryimages/wodbhat.tex"),
- Asset("ATLAS", "images/inventoryimages/wodbhat.xml"),
- }
- --this is what happens when you equip the hat
- local function onequip(inst, owner)
- owner.AnimState:OverrideSymbol("swap_hat", "wodbhat", "swap_hat")
- owner.AnimState:Show("HAT")
- owner.AnimState:Show("HAT_HAIR")
- owner.AnimState:Hide("HAIR_NOHAT")
- owner.AnimState:Hide("HAIR")
- owner.components.health:SetAbsorptionAmount(.375)
- owner.components.health.maxhealth = 20
- owner.components.health:DoDelta(0, true) -- this updates the health badge
- if owner:HasTag("player") then
- owner.AnimState:Hide("HEAD")
- owner.AnimState:Show("HEAD_HAIR")
- end
- --this tells it to start losing durability when you equip it
- if inst.components.fueled then
- inst.components.fueled:StartConsuming()
- end
- inst.temperatureTask = inst:DoTaskInTime(5, function(inst)
- if GetSeasonManager():GetCurrentTemperature() > 35 then
- inst.components.insulator:SetSummer()
- else
- inst.components.insulator:SetWinter()
- end
- end)
- end
- --this is what happens when you unequip the hat
- local function onunequip(inst, owner)
- owner.AnimState:Hide("HAT")
- owner.AnimState:Hide("HAT_HAIR")
- owner.AnimState:Show("HAIR_NOHAT")
- owner.AnimState:Show("HAIR")
- owner.components.health:SetAbsorptionAmount(0)
- owner.components.health.maxhealth = 5
- owner.components.health:DoDelta(0, true) -- this updates the health badge
- if owner:HasTag("player") then
- owner.AnimState:Show("HEAD")
- owner.AnimState:Hide("HEAD_HAIR")
- end
- --this tells it to stop losing durability when you unequip it
- if inst.components.fueled then
- inst.components.fueled:StopConsuming()
- end
- inst.temperatureTask:Cancel()
- end
- --I have no idea why this is called spider_perish but it helps the hat perish!
- -- Nik Mik here! It's because the top hat and spider hat use the same function to be destroyed when they run out of fuel.
- local function spider_perish(inst)
- --spider_disable(inst) ain't needed, Fiddoop. That's telling the item to go to another function. E.G if you had the spider_disable_inst and a function with the same name that made the character fart unicorns, the code on this line would tell it to do that function.
- inst:Remove()
- -- This destroys it.
- end
- local function fn(Sim)
- local inst = CreateEntity()
- local trans = inst.entity:AddTransform()
- local anim = inst.entity:AddAnimState()
- MakeInventoryPhysics(inst)
- inst:AddTag("hat")
- --it is important that you use the original hat's prefab name for bank (if you used wodbhat then leave it featherhat)
- anim:SetBank("featherhat")
- --this is what you put in the build.bin when making the hat's .zip file
- anim:SetBuild("wodbhat")
- --this is just the animation it plays leave it where it's at unless you use a different hat and run into problems
- anim:PlayAnimation("anim")
- --you want to be able to be examined it right?
- inst:AddComponent("inspectable")
- --to be honest I don't know what this does
- inst:AddTag("irreplaceable")
- -- I think it means lureplants can't eat it, or something. Nik Mik.
- --this is so you can carry it in your inventory
- inst:AddComponent("inventoryitem")
- inst.components.inventoryitem.atlasname = "images/inventoryimages/wodbhat.xml"
- --this adds a sanity boost to your hat! this is half of what top hat gives
- inst:AddComponent("waterproofer")
- inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_LARGE)
- --this is so the game knows to put it on your head
- inst:AddComponent("equippable")
- inst.components.equippable.equipslot = EQUIPSLOTS.HEAD
- -- You can also do EQUIPSLOTS.BODY or EQUIPSLOTS.HANDS to make it use different slots.
- inst:AddComponent("insulator")
- inst.components.insulator:SetInsulation(TUNING.INSULATION_LARGE)
- --this is so the game knows there is a onequip and onunequip function
- inst.components.equippable:SetOnEquip( onequip )
- inst.components.equippable:SetOnUnequip( onunequip )
- return inst
- end
- return Prefab( "common/inventory/wodbhat", fn, assets)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement