Advertisement
Guest User

Untitled

a guest
Jan 9th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. local assets =
  2. {
  3. Asset( "ANIM", "anim/wilson.zip" ),
  4. --for every1
  5. Asset( "ANIM", "anim/skins_ground.zip" ),
  6. --inv
  7. Asset("ATLAS", "images/inventoryimages/wilson_switch.xml"),
  8. Asset("IMAGE", "images/inventoryimages/wilson_switch.tex"),
  9. }
  10.  
  11. local function OnEquipWils(inst, builder)
  12.  
  13. local spawn_fx = SpawnPrefab("spawn_fx_medium")
  14. spawn_fx.Transform:SetPosition(inst.Transform:GetWorldPosition() )
  15.  
  16. SetSkinMode(builder.AnimState, "wilson", "wilson", builder.components.skinner:GetClothing(), nil, "wilson")
  17. --inst.soundsname = "wilson"
  18.  
  19. local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner
  20. if owner then
  21. local sanity = owner.components.sanity
  22. if sanity then
  23. sanity:DoDelta(-10,false)
  24. end
  25. end
  26.  
  27. --owner.talker_path_override = "dontstarve_DLC001/characters/"
  28. owner.soundsname = "wilson"
  29. end
  30.  
  31. local function OnUnequip(inst, builder)
  32.  
  33. local spawn_fx = SpawnPrefab("spawn_fx_medium")
  34. spawn_fx.Transform:SetPosition(inst.Transform:GetWorldPosition() )
  35.  
  36. --Возвращаем прежнюю анимацию! (Спасибо DarkKingBoo с форума.)
  37. local player = builder.prefab
  38. builder.AnimState:SetBank("wilson")
  39. builder.AnimState:SetBuild(player)
  40.  
  41. owner.soundsname = (player)
  42. end
  43.  
  44. local function wilson_switch()
  45. local inst = CreateEntity()
  46. inst.entity:AddTransform()
  47. inst.entity:AddAnimState()
  48. inst.entity:AddSoundEmitter()
  49. inst.entity:AddNetwork()
  50.  
  51. inst:AddTag("hat")
  52.  
  53. inst.AnimState:SetBank("skins_ground")
  54. inst.AnimState:SetBuild("skins_ground")
  55. inst.AnimState:PlayAnimation("wilson", true)
  56. inst.Transform:SetScale(1.25, 1.25, 1.25)
  57.  
  58. inst.entity:SetPristine()
  59.  
  60. if not TheWorld.ismastersim then
  61. return inst
  62. end
  63.  
  64. inst:AddComponent("inspectable")
  65.  
  66. inst:AddComponent("inventoryitem")
  67. inst.components.inventoryitem.imagename = "wilson_switch"
  68. inst.components.inventoryitem.atlasname = "images/inventoryimages/wilson_switch.xml"
  69.  
  70. inst:AddComponent("equippable")
  71. inst.components.equippable.equipslot = EQUIPSLOTS.NECK or EQUIPSLOTS.BODY
  72. inst.components.equippable:SetOnEquip(OnEquipWils)
  73. inst.components.equippable:SetOnUnequip(OnUnequip)
  74.  
  75. return inst
  76. end
  77. return
  78. Prefab("wilson_switch", wilson_switch, assets)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement