Advertisement
Guest User

Untitled

a guest
Feb 5th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.62 KB | None | 0 0
  1. local assets=
  2. {
  3.     Asset("ANIM", "anim/wodbhat.zip"),
  4.         Asset("IMAGE", "images/inventoryimages/wodbhat.tex"),
  5.     Asset("ATLAS", "images/inventoryimages/wodbhat.xml"),
  6. }
  7.  
  8. --this is what happens when you equip the hat
  9. local function onequip(inst, owner)
  10.     owner.AnimState:OverrideSymbol("swap_hat", "wodbhat", "swap_hat")
  11.     owner.AnimState:Show("HAT")
  12.     owner.AnimState:Show("HAT_HAIR")
  13.     owner.AnimState:Hide("HAIR_NOHAT")
  14.     owner.AnimState:Hide("HAIR")
  15.  
  16.     owner.components.health:SetAbsorptionAmount(.375)
  17.    
  18.     owner.components.health.maxhealth = 25
  19.     owner.components.health:DoDelta(0, true)  -- this updates the health badge
  20.  
  21.    
  22.  
  23.     --this tells it to start losing durability when you equip it
  24.     if inst.components.fueled then
  25.         inst.components.fueled:StartConsuming()        
  26.     end
  27.    
  28.     inst.temperatureTask = inst:DoTaskInTime(5, function(inst)
  29.         if TheWorld.state.temperature > 35 then
  30.    
  31.     if not TheWorld.ismastersim then
  32.          return inst
  33.         end
  34.             inst.components.insulator:SetSummer()
  35.    
  36.         else
  37.     if not TheWorld.ismastersim then
  38.             return inst
  39.         end
  40.             inst.components.insulator:SetWinter()
  41.  
  42.         end
  43.     end)
  44.    
  45. end
  46.  
  47.                
  48.  
  49. --this is what happens when you unequip the hat
  50. local function onunequip(inst, owner)
  51.     owner.AnimState:Hide("HAT")
  52.     owner.AnimState:Hide("HAT_HAIR")
  53.     owner.AnimState:Show("HAIR_NOHAT")
  54.     owner.AnimState:Show("HAIR")
  55.    
  56.    
  57.     owner.components.health:SetAbsorptionAmount(0)
  58.  
  59.     owner.components.health.maxhealth = 5
  60.     owner.components.health:DoDelta(0, true)  -- this updates the health badge
  61.  
  62.     if owner:HasTag("player") then
  63.         owner.AnimState:Show("HEAD")
  64.         owner.AnimState:Hide("HEAD_HAIR")
  65.     end
  66.  
  67.     --this tells it to stop losing durability when you unequip it
  68.     if inst.components.fueled then
  69.         inst.components.fueled:StopConsuming()
  70.     end
  71.  
  72.    
  73. end
  74.  
  75.                
  76.  
  77. --I have no idea why this is called spider_perish but it helps the hat perish!
  78. -- 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.
  79.     local function spider_perish(inst)
  80.         --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.
  81.         inst:Remove()
  82.         -- This destroys it.
  83.     end
  84.  
  85.  
  86.  
  87. local function fn(Sim)
  88.         local inst = CreateEntity()
  89.         local trans = inst.entity:AddTransform()
  90.         local anim = inst.entity:AddAnimState()
  91.     MakeInventoryPhysics(inst)
  92.      
  93.      inst:AddComponent("insulator")
  94.      inst.entity:SetPristine()
  95.  
  96.      
  97.     if not TheWorld.ismastersim then
  98.         return inst
  99.     end
  100.      
  101.  
  102.     inst:AddTag("hat")
  103.    
  104.         --it is important that you use the original hat's prefab name for bank (if you used wodbhat then leave it featherhat)
  105.     anim:SetBank("featherhat")
  106.        
  107.         --this is what you put in the build.bin when making the hat's .zip file
  108.     anim:SetBuild("wodbhat")
  109.        
  110.         --this is just the animation it plays leave it where it's at unless you use a different hat and run into problems
  111.     anim:PlayAnimation("anim")  
  112.        
  113.     --you want to be able to be examined it right?
  114.     inst:AddComponent("inspectable")
  115.    
  116.         --to be honest I don't know what this does
  117.     inst:AddTag("irreplaceable")
  118.  -- I think it means lureplants can't eat it, or something. Nik Mik.
  119.    
  120.         --this is so you can carry it in your inventory
  121.     inst:AddComponent("inventoryitem")
  122.     inst.components.inventoryitem.atlasname = "images/inventoryimages/wodbhat.xml"
  123.    
  124.         --this adds a sanity boost to your hat! this is half of what top hat gives
  125.     inst:AddComponent("waterproofer")
  126.     inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_LARGE)
  127.    
  128.    
  129.         --this is so the game knows to put it on your head
  130.     inst:AddComponent("equippable")
  131.     inst.components.equippable.equipslot = EQUIPSLOTS.HEAD
  132. -- You can also do EQUIPSLOTS.BODY or EQUIPSLOTS.HANDS to make it use different slots.
  133.    
  134.  
  135.   inst.components.insulator:SetInsulation(TUNING.INSULATION_LARGE)
  136.        
  137.        
  138.  
  139.         --this is so the game knows there is a onequip and onunequip function
  140.     inst.components.equippable:SetOnEquip( onequip )
  141.     inst.components.equippable:SetOnUnequip( onunequip )
  142.        
  143.        
  144.     return inst
  145. end
  146.  
  147. return Prefab( "common/inventory/wodbhat", fn, assets)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement