Guest User

Untitled

a guest
Feb 6th, 2015
221
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Milkable
  2. function make_milkable(inst)
  3. inst:AddComponent("trader")
  4. inst.components.trader:SetAcceptTest(trade_test)
  5. inst.components.trader.onaccept = trade_fn
  6. inst.components.trader:Enable()
  7. end
  8. AddPrefabPostInit("beefalo", make_milkable)
  9. --Milkable
  10.  
  11. --Milkable part 2
  12. function trade_test(inst, giver, item)
  13. if inst.components.sleeper:IsAsleep() then
  14. return false
  15. elseif item.components.tradable and item:HasTag("MILKBUCKET") then
  16. return true
  17. else
  18. return false
  19. end
  20. end
  21.  
  22. function trade_fn(inst, giver, item)
  23. if giver and giver.components.inventory then
  24. giver.components.inventory:GiveItem("red_cap")
  25. end
  26. end
  27.  
  28.  
  29.  
  30. function milktag(inst)
  31. inst:AddTag("MILKBUCKET")
  32. inst:AddComponent("tradable")
  33. end
  34. AddPrefabPostInit("cutgrass", milktag)
RAW Paste Data