Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Milkable
- --How long the Countdown lasts.
- local beefalo_Countdown = 60
- local function omm_trade_test(inst, item)
- if inst.components.sleeper:IsAsleep() then
- return false
- elseif item.components.tradable and item:HasTag("MILKBUCKET") and inst.components.Countdown:IsReady() then
- return true
- else
- return false
- end
- end
- local function omm_trade_fn(inst, giver, item)
- if GLOBAL.GetPlayer() and GLOBAL.GetPlayer().components.inventory then
- local red_cap = SpawnPrefab("red_cap")
- GLOBAL.GetPlayer().components.inventory:GiveItem(red_cap)
- local blue_cap = SpawnPrefab("blue_cap")
- GLOBAL.GetPlayer().components.inventory:GiveItem(blue_cap)
- --Reset the Countdown.
- inst.components.Countdown:SetCountdown(beefalo_Countdown)
- end
- end
- local function make_milkable(inst)
- inst:AddComponent("trader")
- inst.components.trader:SetAcceptTest(omm_trade_test)
- inst.components.trader.onaccept = omm_trade_fn
- inst.components.trader:Enable()
- inst:AddComponent("Countdown")
- inst.components.Countdown.countdown_max = beefalo_Countdown
- inst.components.Countdown:StartCountdown()
- end
- AddPrefabPostInit("beefalo", make_milkable)
- local milk_items = {"cutgrass","twigs",}
- local function milktag(inst)
- inst:AddTag("MILKBUCKET")
- if not inst.components.tradable then
- inst:AddComponent("tradable")
- end
- end
- for key,prefab in pairs(milk_items) do
- AddPrefabPostInit(prefab, milktag)
- end
- --Milkable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement