YN279-小型温室(用蝴蝶翅膀种小型温室,放入种子,10秒长出果实)
代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二七九.小型温室(用蝴蝶翅膀种小型温室,放入种子,10秒长出果实) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/butterflywings.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function OnDeploy (inst, pt) local oven = SpawnPrefab("butterflywings") oven.Transform:SetPosition(pt.x, pt.y, pt.z) oven.AnimState:SetBank("skull_chest") oven.AnimState:SetBuild("skull_chest") oven.AnimState:PlayAnimation("closed") oven.Transform:SetScale(1.5, 1.5, 1.5) oven:AddTag("fridge") oven:AddTag("ovens") oven:RemoveComponent("edible") oven:RemoveComponent("tradable") oven:RemoveComponent("stackable") oven:RemoveComponent("inventoryitem") oven:RemoveComponent("perishable") oven:RemoveComponent("deployable") oven:RemoveTag("cattoy") oven:AddComponent("workable") oven.components.workable:SetWorkAction(ACTIONS.HAMMER) oven.components.workable:SetWorkLeft(3) oven.components.workable:SetOnFinishCallback(function(oven) SpawnPrefab("collapse_big").Transform:SetPosition(oven.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") oven:Remove() end ) oven.components.container.canbeopened = true inst.components.stackable:Get():Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("ovens") then data.ovens = true end end local function onload(inst, data) if data and data.ovens then inst.AnimState:SetBank("skull_chest") inst.AnimState:SetBuild("skull_chest") inst.AnimState:PlayAnimation("closed") inst.Transform:SetScale(1.5, 1.5, 1.5) inst:AddTag("fridge") inst:AddTag("ovens") inst:RemoveComponent("edible") inst:RemoveComponent("tradable") inst:RemoveComponent("stackable") inst:RemoveComponent("inventoryitem") inst:RemoveComponent("perishable") inst:RemoveComponent("deployable") inst:RemoveTag("cattoy") inst:AddComponent("workable") inst.components.workable:SetWorkAction(ACTIONS.HAMMER) inst.components.workable:SetWorkLeft(3) inst.components.workable:SetOnFinishCallback(function(inst) SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") inst:Remove() end ) inst.components.container.canbeopened = true end end local function itemtest(inst, item, slot) if item.prefab == "carrot" or item.prefab == "corn" or item.prefab == "pumpkin" or item.prefab == "eggplant" or item.prefab == "durian" or item.prefab == "pomegranate" or item.prefab == "dragonfruit" or item.prefab == "carrot_seeds" or item.prefab == "corn_seeds" or item.prefab == "pumpkin_seeds" or item.prefab == "eggplant_seeds" or item.prefab == "durian_seeds" or item.prefab == "pomegranate_seeds" or item.prefab == "dragonfruit_seeds" or item.prefab == "seeds" or item.prefab == "spoiled_food" or item.prefab == "lightbulb" or item.prefab == "watermelon_seeds" or item.prefab == "watermelon" then return true end return false end local slotpos = {} for y = 2, 0, -1 do for x = 0, 14 do table.insert(slotpos, Vector3(75*x-75*2+75, 75*y-75*2+75,0)) end end inst.OnSave = onsave inst.OnLoad = onload inst:AddComponent("container") local widgetbuttoninfo = { text = "Start", position = Vector3(450, -150, 0), fn = function(inst) if inst:HasTag("ovens") and inst.components.container:Has("lightbulb", 1) then inst.components.container:ConsumeByName("lightbulb", 1) inst.components.container:Close(GetPlayer()) inst.components.container.canbeopened = false inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") inst:DoTaskInTime(10, function() inst.AnimState:SetBloomEffectHandle("") GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available") inst.components.container.canbeopened = true for k,v in pairs(inst.components.container.slots) do if v and v.prefab == "carrot_seeds" then v:Remove() local carrot = SpawnPrefab("carrot") inst.components.container:GiveItem(carrot) end if v and v.prefab == "corn_seeds" then v:Remove() local corn = SpawnPrefab("corn") inst.components.container:GiveItem(corn) end if v and v.prefab == "pumpkin_seeds" then v:Remove() local pumpkin = SpawnPrefab("pumpkin") inst.components.container:GiveItem(pumpkin) end if v and v.prefab == "eggplant_seeds" then v:Remove() local eggplant = SpawnPrefab("eggplant") inst.components.container:GiveItem(eggplant) end if v and v.prefab == "durian_seeds" then v:Remove() local durian = SpawnPrefab("durian") inst.components.container:GiveItem(durian) end if v and v.prefab == "pomegranate_seeds" then v:Remove() local pomegranate = SpawnPrefab("pomegranate") inst.components.container:GiveItem(pomegranate) end if v and v.prefab == "dragonfruit_seeds" then v:Remove() local dragonfruit = SpawnPrefab("dragonfruit") inst.components.container:GiveItem(dragonfruit) end if v and v.prefab == "watermelon_seeds" then v:Remove() local watermelon = SpawnPrefab("watermelon") inst.components.container:GiveItem(watermelon) end if v and v.prefab == "seeds" then v:Remove() local names = {"carrot","corn","pumpkin","eggplant","durian","pomegranate","dragonfruit","watermelon"} local name = names[math.random(#names)] local fruit = SpawnPrefab(name) inst.components.container:GiveItem(fruit) end if v.prefab == "carrot" or v.prefab == "corn" or v.prefab == "pumpkin" or v.prefab == "eggplant" or v.prefab == "durian" or v.prefab == "pomegranate" or v.prefab == "dragonfruit" or v.prefab == "watermelon" then v:Remove() local spoiled = SpawnPrefab("spoiled_food") inst.components.container:GiveItem(spoiled) end end end ) end end } inst.components.container.widgetbuttoninfo = widgetbuttoninfo inst.components.container.acceptsstacks = false inst.components.container:SetNumSlots(#slotpos) inst.components.container.widgetslotpos = slotpos inst.components.container.widgetpos = Vector3(-250,200,0) inst.components.container.side_align_tip = 160 inst.components.container.canbeopened = false inst.components.container.itemtestfn = itemtest inst.components.container.onopenfn = function(inst) inst.AnimState:PlayAnimation("open") end inst.components.container.onclosefn = function(inst) inst.AnimState:PlayAnimation("close") end 即可用蝴蝶翅膀种小型温室(拿着1个蝴蝶翅膀对地面点鼠标右键,如果拿着多个,则不会种出来),无论冬夏都可种植农作物。鼠标左键点小型温室,可打开格子。将种子放入格子,并放1个荧光果(提供电能)后,点格子下面的Start按钮,植物即开始生长(温室亮灯)。10秒后(温室灯灭)即可打开温室,收获你的果实吧。每次种植都将消耗1个荧光果,格子内没有荧光果时,温室不会工作。如果把果实留在格子内,并点Start按钮(仍须有荧光果),则10秒后果实变成腐烂食物,可用来快速生产肥料。不想要小型温室时,用锤子砸掉即可,记得先取出里面的物品哦。蝴蝶翅膀可打死蝴蝶获得