Advertisement
Sinaboo

Untitled

Aug 25th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. -- In a prefab file, you need to list all the assets it requires.
  2. -- These can be either standard assets, or custom ones in your mod
  3. -- folder.
  4. local Assets =
  5. {
  6. Asset("ANIM", "anim/onion2_build.zip"), -- a standard asset
  7. Asset("ATLAS", "images/inventoryimages/onion2.xml"), -- a custom asset, found in the mod folder
  8. Asset("IMAGE", "images/inventoryimages/onion2.tex"),
  9. }
  10.  
  11. -- Write a local function that creats, customizes, and returns an instance of the prefab.
  12. local function fn()
  13. local inst = CreateEntity()
  14.  
  15. inst.entity:AddTransform()
  16. inst.entity:AddAnimState()
  17. inst.entity:AddNetwork()
  18.  
  19. MakeInventoryPhysics(inst)
  20.  
  21. inst:AddComponent("sanityaura")
  22. inst.components.sanityaura.aura = TUNING.SANITYAURA_TINY
  23.  
  24. inst.entity:AddLight()
  25. inst.Light:SetRadius(.6)
  26. inst.Light:SetFalloff(1)
  27. inst.Light:SetIntensity(.5)
  28. inst.Light:SetColour(235/255,195/255,12/255)
  29. inst.Light:Enable(true)
  30. inst.Light:SetDisableOnSceneRemoval(false)
  31.  
  32. inst.AnimState:SetBank("onion2")
  33. inst.AnimState:SetBuild("onion2_build")
  34. inst.AnimState:PlayAnimation("idle", true)
  35.  
  36. if not TheWorld.ismastersim then
  37. return inst
  38. end
  39.  
  40. inst:AddComponent("inventoryitem")
  41. inst.components.inventoryitem.atlasname = "images/inventoryimages/onion2.xml"
  42.  
  43. inst:AddComponent("inspectable")
  44.  
  45. MakeHauntableLaunch(inst)
  46. inst:AddComponent("hauntable")
  47. inst.components.hauntable:SetHauntValue(TUNING.HAUNT_INSTANT_REZ)
  48.  
  49. return inst
  50. end
  51.  
  52. -- Add some strings for this item
  53. STRINGS.NAMES.ONION2 = "Magic Onion"
  54. STRINGS.CHARACTERS.GENERIC.DESCRIBE.ONION2 = "What a strange onion!"
  55. STRINGS.RECIPE_DESC.ONION2 = "A magical onion."
  56.  
  57. -- Finally, return a new prefab with the construction function and assets.
  58. return Prefab( "common/inventory/onion2", fn, Assets)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement