Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- In a prefab file, you need to list all the assets it requires.
- -- These can be either standard assets, or custom ones in your mod
- -- folder.
- local Assets =
- {
- Asset("ANIM", "anim/onion2_build.zip"), -- a standard asset
- Asset("ATLAS", "images/inventoryimages/onion2.xml"), -- a custom asset, found in the mod folder
- Asset("IMAGE", "images/inventoryimages/onion2.tex"),
- }
- -- Write a local function that creats, customizes, and returns an instance of the prefab.
- local function fn()
- local inst = CreateEntity()
- inst.entity:AddTransform()
- inst.entity:AddAnimState()
- inst.entity:AddNetwork()
- MakeInventoryPhysics(inst)
- inst:AddComponent("sanityaura")
- inst.components.sanityaura.aura = TUNING.SANITYAURA_TINY
- inst.entity:AddLight()
- inst.Light:SetRadius(.6)
- inst.Light:SetFalloff(1)
- inst.Light:SetIntensity(.5)
- inst.Light:SetColour(235/255,195/255,12/255)
- inst.Light:Enable(true)
- inst.Light:SetDisableOnSceneRemoval(false)
- inst.AnimState:SetBank("onion2")
- inst.AnimState:SetBuild("onion2_build")
- inst.AnimState:PlayAnimation("idle", true)
- if not TheWorld.ismastersim then
- return inst
- end
- inst:AddComponent("inventoryitem")
- inst.components.inventoryitem.atlasname = "images/inventoryimages/onion2.xml"
- inst:AddComponent("inspectable")
- MakeHauntableLaunch(inst)
- inst:AddComponent("hauntable")
- inst.components.hauntable:SetHauntValue(TUNING.HAUNT_INSTANT_REZ)
- return inst
- end
- -- Add some strings for this item
- STRINGS.NAMES.ONION2 = "Magic Onion"
- STRINGS.CHARACTERS.GENERIC.DESCRIBE.ONION2 = "What a strange onion!"
- STRINGS.RECIPE_DESC.ONION2 = "A magical onion."
- -- Finally, return a new prefab with the construction function and assets.
- return Prefab( "common/inventory/onion2", fn, Assets)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement