YN272-智能播种机器人(将独奏乐器扔在地上自动种100棵香蕉树)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二七二.智能播种机器人(将独奏乐器扔在地上自动种100棵香蕉树) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/onemanband.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function ondropped(inst) local player = GetPlayer() if player.components.inventory:Has("goldnugget", 50) then player.components.inventory:ConsumeByName("goldnugget", 50) RemovePhysicsColliders(inst) inst.name = "cave_banana_tree" inst.components.inventoryitem.canbepickedup = false inst:DoTaskInTime(1, function() inst.task = inst:DoPeriodicTask(.5, function() inst.Physics:SetMotorVelOverride(2,0,2) inst.Physics:ClearMotorVelOverride() player.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") SpawnPrefab(inst.name).Transform:SetPosition(inst.Transform:GetWorldPosition()) end) end) inst:DoTaskInTime(11, function() if inst.task then inst.task:Cancel() inst.task = nil end player.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") inst.Physics:SetMotorVelOverride(-3,0,3) inst.Physics:ClearMotorVelOverride() end) inst:DoTaskInTime(12, function() inst.task = inst:DoPeriodicTask(.5, function() inst.Physics:SetMotorVelOverride(-2,0,-2) inst.Physics:ClearMotorVelOverride() player.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") SpawnPrefab(inst.name).Transform:SetPosition(inst.Transform:GetWorldPosition()) end) end) inst:DoTaskInTime(22, function() if inst.task then inst.task:Cancel() inst.task = nil end player.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") inst.Physics:SetMotorVelOverride(-3,0,3) inst.Physics:ClearMotorVelOverride() end) inst:DoTaskInTime(23, function() inst.task = inst:DoPeriodicTask(.5, function() inst.Physics:SetMotorVelOverride(2,0,2) inst.Physics:ClearMotorVelOverride() player.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") SpawnPrefab(inst.name).Transform:SetPosition(inst.Transform:GetWorldPosition()) end) end) inst:DoTaskInTime(33, function() if inst.task then inst.task:Cancel() inst.task = nil end player.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") inst.Physics:SetMotorVelOverride(-3,0,3) inst.Physics:ClearMotorVelOverride() end) inst:DoTaskInTime(34, function() inst.task = inst:DoPeriodicTask(.5, function() inst.Physics:SetMotorVelOverride(-2,0,-2) inst.Physics:ClearMotorVelOverride() player.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") SpawnPrefab(inst.name).Transform:SetPosition(inst.Transform:GetWorldPosition()) end) end) inst:DoTaskInTime(44, function() if inst.task then inst.task:Cancel() inst.task = nil end player.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") inst.Physics:SetMotorVelOverride(-3,0,3) inst.Physics:ClearMotorVelOverride() end) inst:DoTaskInTime(45, function() inst.task = inst:DoPeriodicTask(.5, function() inst.Physics:SetMotorVelOverride(2,0,2) inst.Physics:ClearMotorVelOverride() player.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") SpawnPrefab(inst.name).Transform:SetPosition(inst.Transform:GetWorldPosition()) end) end) inst:DoTaskInTime(55, function() if inst.task then inst.task:Cancel() inst.task = nil end player.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") inst.Physics:SetMotorVelOverride(-3,0,3) inst.Physics:ClearMotorVelOverride() inst.components.inventoryitem.canbepickedup = true end) end end inst:ListenForEvent("ondropped", ondropped) 即可将独奏乐器扔在开阔的空地上,它会自动行驶种下100棵香蕉树(5行,每行20棵),同时收取主角50个黄金,身上黄金不足时不会干活。将其中的cave_banana_tree(洞穴香蕉树)改为其他植物,如flower_cave_triple(三朵洞穴花)等,就可以种其他植物了(见本修改技巧“常用物品中英文名称”)。独奏乐器在魔法选项(画着红骷髅)下,用2个黄金、4个噩梦燃料、2个猪皮制造

2025/04/23 · Bny

YN273-磁悬浮建筑机器人(将针线包扔在地上自动建50块农田)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二七三.磁悬浮建筑机器人(将针线包扔在地上自动建50块农田) 用MT管理器打开游戏目录/assets/scripts/prefabs/sewingkit.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function startbuild(inst) inst.name = "fast_farmplot" local space = 2.1 local row = 10 local num = 0 local num2 = 0 local num3 = 0 local num4 = 0 local num5 = 0 local pt = GetPlayer():GetPosition() inst:StartThread(function() for k = 1,row do num = num + space inst.Transform:SetPosition(pt.x+num, 5, pt.z+num) SpawnPrefab(inst.name).Transform:SetPosition(pt.x+num, 0, pt.z+num) GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/rock_break") Sleep(.5) end for k = 1,row do num2 = num2 + space inst.Transform:SetPosition(pt.x-2.6+num2, 5, pt.z+2.6+num2) SpawnPrefab(inst.name).Transform:SetPosition(pt.x-2.6+num2, 0, pt.z+2.6+num2) GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/rock_break") Sleep(.5) end for k = 1,row do num3 = num3 + space inst.Transform:SetPosition(pt.x-5.2+num3, 5, pt.z+5.2+num3) SpawnPrefab(inst.name).Transform:SetPosition(pt.x-5.2+num3, 0, pt.z+5.2+num3) GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/rock_break") Sleep(.5) end for k = 1,row do num4 = num4 + space inst.Transform:SetPosition(pt.x-7.8+num4, 5, pt.z+7.8+num4) SpawnPrefab(inst.name).Transform:SetPosition(pt.x-7.8+num4, 0, pt.z+7.8+num4) GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/rock_break") Sleep(.5) end for k = 1,row do num5 = num5 + space inst.Transform:SetPosition(pt.x-10.4+num5, 5, pt.z+10.4+num5) SpawnPrefab(inst.name).Transform:SetPosition(pt.x-10.4+num5, 0, pt.z+10.4+num5) GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/rock_break") Sleep(.5) end end) end local function ondropped(inst) if GetPlayer().components.inventory:Has("goldnugget", 100) then GetPlayer().components.inventory:ConsumeByName("goldnugget", 100) GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") inst.components.inventoryitem.canbepickedup = false inst.Physics:SetMotorVelOverride(0,2,0) inst:DoTaskInTime(3, function() startbuild(inst) end) inst:DoTaskInTime(28, function() inst.Physics:ClearMotorVelOverride() inst.components.inventoryitem.canbepickedup = true GetPlayer().components.inventory:GiveItem(inst) end) end end inst:ListenForEvent("ondropped", ondropped) 即可将针线包扔在开阔的空地上,它会悬浮在空中自动建50块农田,同时收取主角100个黄金,身上黄金不足时不会干活。将其中的fast_farmplot(高级农田)改为其他建筑,如cookpot(煮锅)、birdcage(鸟笼)等,就可以建其他建筑了(见本修改技巧“常用物品中英文名称”)。针线包在穿戴选项(画着礼帽)下,用1个木头、8个蛛丝、2个犬牙制造

2025/04/23 · Bny

YN274-电动斧子(拿黄金斧子自动放倒身边的树)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二七四.电动斧子(拿黄金斧子自动放倒身边的树) 用MT管理器打开游戏目录/assets/scripts/prefabs/axe.lua文件, 1.将下列内容: local function onequipgold(inst, owner) owner.AnimState:OverrideSymbol("swap_object", "swap_goldenaxe", "swap_goldenaxe") owner.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end 替换为: local function pickup(inst, owner) local range = 3 local pos = Vector3(owner.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, range) for k,v in pairs(ents) do if v:HasTag("tree") and v.components.workable and v.components.workable.workleft > 0 then v.components.workable:Destroy(GetPlayer()) end end inst.SoundEmitter:PlaySound("dontstarve/forest/treeCrumble") end local function onequipgold(inst, owner) if owner.components.inventory:Has("lightbulb", 1) then inst.task = inst:DoPeriodicTask(.033, function() pickup(inst, owner) end) owner.components.inventory:ConsumeByName("lightbulb", 1) end owner.AnimState:OverrideSymbol("swap_object", "swap_goldenaxe", "swap_goldenaxe") owner.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end local function onunequipgold(inst, owner) owner.AnimState:Hide("ARM_carry") owner.AnimState:Show("ARM_normal") if inst.task then inst.task:Cancel() inst.task = nil end end 2.在inst.components.equippable:SetOnEquip( onequipgold )的下一行插入inst.components.equippable:SetOnUnequip( onunequipgold ) 即可拿黄金斧子自动放倒身边的树(类似电锯),效率极高,且不留树根,方便种新树。电动斧子需要能源,每次装备时自动开启,会消耗1个荧光果,如果身上没有荧光果,则不会开启电动功能,只能手动砍树了

2025/04/23 · Bny

YN275-电动镐(拿黄金镐自动凿开身边的石头)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二七五.电动镐(拿黄金镐自动凿开身边的石头) 1.用MT管理器打开游戏目录/assets/scripts/prefabs/pickaxe.lua文件,将下列内容: local function onequipgold(inst, owner) owner.AnimState:OverrideSymbol("swap_object", "swap_goldenpickaxe", "swap_goldenpickaxe") owner.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end 替换为: local function pickup(inst, owner) local range = 3 local pos = Vector3(owner.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, range) for k,v in pairs(ents) do if v.components.workable and v.components.workable.action == ACTIONS.MINE and v.components.workable.workleft > 0 then v.components.workable:Destroy(GetPlayer()) end end inst.SoundEmitter:PlaySound("dontstarve/wilson/rock_break") end local function onequipgold(inst, owner) if owner.components.inventory:Has("lightbulb", 1) then inst.task = inst:DoPeriodicTask(.033, function() pickup(inst, owner) end) owner.components.inventory:ConsumeByName("lightbulb", 1) end owner.AnimState:OverrideSymbol("swap_object", "swap_goldenpickaxe", "swap_goldenpickaxe") owner.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end local function onunequipgold(inst, owner) owner.AnimState:Hide("ARM_carry") owner.AnimState:Show("ARM_normal") if inst.task then inst.task:Cancel() inst.task = nil end end 2.在inst.components.equippable:SetOnEquip( onequipgold )的下一行插入inst.components.equippable:SetOnUnequip( onunequipgold ) 即可拿黄金镐自动凿开身边的石头,效率极高,连大理石树、蜘蛛洞、远古雕像都可轻松凿平。电动镐需要能源,每次装备时自动开启,会消耗1个荧光果,如果身上没有荧光果,则不会开启电动功能,只能手动开矿了

2025/04/23 · Bny

YN276-电动草叉(拿草叉自动铲起脚下的地皮)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二七六.电动草叉(拿草叉自动铲起脚下的地皮) 用MT管理器打开游戏目录/assets/scripts/prefabs/pitchfork.lua文件,将下列内容: local function onequip(inst, owner) owner.AnimState:OverrideSymbol("swap_object", "swap_pitchfork", "swap_pitchfork") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end local function onunequip(inst, owner) owner.AnimState:Hide("ARM_carry") owner.AnimState:Show("ARM_normal") end 替换为: local function pickup(inst, owner) local pt = owner:GetPosition() inst.components.terraformer:Terraform(pt) inst.SoundEmitter:PlaySound("dontstarve/wilson/dig") end local function onequip(inst, owner) if owner.components.inventory:Has("lightbulb", 1) then inst.task = inst:DoPeriodicTask(.033, function() pickup(inst, owner) end) owner.components.inventory:ConsumeByName("lightbulb", 1) end owner.AnimState:OverrideSymbol("swap_object", "swap_pitchfork", "swap_pitchfork") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end local function onunequip(inst, owner) owner.AnimState:Hide("ARM_carry") owner.AnimState:Show("ARM_normal") if inst.task then inst.task:Cancel() inst.task = nil end end 即可拿草叉自动铲起脚下的地皮,效率极高,铲地的速度只取决于你走多快。电动草叉需要能源,每次装备时自动开启,会消耗1个荧光果,如果身上没有荧光果,则不会开启电动功能,只能手动铲地了

2025/04/23 · Bny

YN277-电动铺路铲(拿黄金铲自动将脚下的空地皮铺成路)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二七七.电动铺路铲(拿黄金铲自动将脚下的空地皮铺成路) 用MT管理器打开游戏目录/assets/scripts/prefabs/shovel.lua文件, 1.将下列内容: local function onequipgold(inst, owner) owner.AnimState:OverrideSymbol("swap_object", "swap_goldenshovel", "swap_goldenshovel") owner.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end 替换为: local function pickup(inst, owner) inst.name = GROUND.ROAD local pt = owner:GetPosition() local ground = GetWorld() local tile = ground.Map:GetTileAtPoint(pt.x, pt.y, pt.z) if ground and tile == GROUND.DIRT then local original_tile_type = ground.Map:GetTileAtPoint(pt.x, pt.y, pt.z) local x, y = ground.Map:GetTileCoordsAtPoint(pt.x, pt.y, pt.z) if x and y then ground.Map:SetTile(x,y, inst.name) ground.Map:RebuildLayer( original_tile_type, x, y ) ground.Map:RebuildLayer( inst.name, x, y ) end local minimap = TheSim:FindFirstEntityWithTag("minimap") if minimap then minimap.MiniMap:RebuildLayer( original_tile_type, x, y ) minimap.MiniMap:RebuildLayer( inst.name, x, y ) end end inst.SoundEmitter:PlaySound("dontstarve/wilson/dig") end local function onequipgold(inst, owner) if owner.components.inventory:Has("lightbulb", 1) then inst.task = inst:DoPeriodicTask(.033, function() pickup(inst, owner) end) owner.components.inventory:ConsumeByName("lightbulb", 1) end owner.AnimState:OverrideSymbol("swap_object", "swap_goldenshovel", "swap_goldenshovel") owner.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end local function onunequipgold(inst, owner) owner.AnimState:Hide("ARM_carry") owner.AnimState:Show("ARM_normal") if inst.task then inst.task:Cancel() inst.task = nil end end 2.在inst.components.equippable:SetOnEquip( onequipgold )的下一行插入inst.components.equippable:SetOnUnequip( onunequipgold ) 即可拿黄金铲自动将脚下的空地皮铺成路,效率极高,铺路的速度只取决于你走多快。电动铺路铲需要能源,每次装备时自动开启,会消耗1个荧光果,如果身上没有荧光果,则不会开启电动功能。将其中GROUND.ROAD(卵石路)替换为其他地皮名称,如GROUND.ROCKY(岩石地皮)、GROUND.DIRT(污垢地皮)、GROUND.SAVANNA(热带草原地皮)、GROUND.GRASS(长草地皮)、GROUND.FOREST(森林地皮)、GROUND.MARSH(沼泽地皮)、GROUND.WOODFLOOR(木质地板)、GROUND.CARPET(地毯地板)、GROUND.CHECKER(棋盘地板)、GROUND.CAVE(鸟粪地皮)、GROUND.FUNGUS(菌类地皮)、GROUND.FUNGUSRED(红菌类地皮)、GROUND.FUNGUSGREEN(绿菌类地皮)、GROUND.SINKHOLE(粘滑地皮)、GROUND.UNDERROCK(洞穴石地地皮)、GROUND.MUD(泥泞地皮),就可以自动铺其他地皮

2025/04/23 · Bny

YN278-地皮改造机(用排箫种地皮改造机,一次铺70块地皮)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二七八.地皮改造机(用排箫种地皮改造机,一次铺70块地皮) 用MT管理器打开游戏目录/assets/scripts/prefabs/panflute.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function itemtest(inst, item, slot) if item.prefab == "turf_road" or item.prefab == "turf_rocky" or item.prefab == "turf_forest" or item.prefab == "turf_marsh" or item.prefab == "turf_grass" or item.prefab == "turf_savanna" or item.prefab == "turf_dirt" or item.prefab == "turf_woodfloor" or item.prefab == "turf_carpetfloor" or item.prefab == "turf_checkerfloor" or item.prefab == "turf_cave" or item.prefab == "turf_fungus" or item.prefab == "turf_fungus_red" or item.prefab == "turf_fungus_green" or item.prefab == "turf_sinkhole" or item.prefab == "turf_underrock" or item.prefab == "turf_mud" then return true end return false end local slotpos = { Vector3(0,-75,0)} local widgetbuttoninfo = { text = "Do", position = Vector3(0, -135, 0), fn = function(inst) if inst:HasTag("turfmachines") then if not inst.components.container:IsEmpty() then for k,v in pairs(inst.components.container.slots) do if v and v.prefab == "turf_road" then inst.rug = GROUND.ROAD end if v and v.prefab == "turf_rocky" then inst.rug = GROUND.ROCKY end if v and v.prefab == "turf_forest" then inst.rug = GROUND.FOREST end if v and v.prefab == "turf_marsh" then inst.rug = GROUND.MARSH end if v and v.prefab == "turf_grass" then inst.rug = GROUND.GRASS end if v and v.prefab == "turf_savanna" then inst.rug = GROUND.SAVANNA end if v and v.prefab == "turf_dirt" then inst.rug = GROUND.DIRT end if v and v.prefab == "turf_woodfloor" then inst.rug = GROUND.WOODFLOOR end if v and v.prefab == "turf_carpetfloor" then inst.rug = GROUND.CARPET end if v and v.prefab == "turf_checkerfloor" then inst.rug = GROUND.CHECKER end if v and v.prefab == "turf_cave" then inst.rug = GROUND.CAVE end if v and v.prefab == "turf_fungus" then inst.rug = GROUND.FUNGUS end if v and v.prefab == "turf_fungus_red" then inst.rug = GROUND.FUNGUSRED end if v and v.prefab == "turf_fungus_green" then inst.rug = GROUND.FUNGUSGREEN end if v and v.prefab == "turf_sinkhole" then inst.rug = GROUND.SINKHOLE end if v and v.prefab == "turf_underrock" then inst.rug = GROUND.UNDERROCK end if v and v.prefab == "turf_mud" then inst.rug = GROUND.MUD end v:Remove() end local pt = GetPlayer():GetPosition() for y = 10, 0, -1 do for x = 0, 10 do local tile = GetWorld().Map:GetTileAtPoint(pt.x-2.1*x+2.1*y-10.5+10.5, pt.y, pt.z+2.1*x+2.1*y-10.5-10.5) if tile ~= GROUND.IMPASSABLE then local original_tile_type = GetWorld().Map:GetTileAtPoint(pt.x-2.1*x+2.1*y-10.5+10.5, pt.y, pt.z+2.1*x+2.1*y-10.5-10.5) local x, y = GetWorld().Map:GetTileCoordsAtPoint(pt.x-2.1*x+2.1*y-10.5+10.5, pt.y, pt.z+2.1*x+2.1*y-10.5-10.5) GetWorld().Map:SetTile(x,y, inst.rug) GetWorld().Map:RebuildLayer( original_tile_type, x, y ) GetWorld().Map:RebuildLayer( inst.rug, x, y ) local minimap = TheSim:FindFirstEntityWithTag("minimap") minimap.MiniMap:RebuildLayer( original_tile_type, x, y ) minimap.MiniMap:RebuildLayer( inst.rug, x, y ) end end end end end end } local function OnDeploy (inst, pt) local turfmachine = SpawnPrefab("panflute") turfmachine.Transform:SetPosition(pt.x, pt.y, pt.z) turfmachine.AnimState:SetBank("researchlab3") turfmachine.AnimState:SetBuild("researchlab3") turfmachine.AnimState:PlayAnimation("idle") turfmachine.Transform:SetScale(0.5, 0.5, 0.5) turfmachine:RemoveComponent("instrument") turfmachine:RemoveComponent("tool") if turfmachine.components.finiteuses then turfmachine:RemoveComponent("finiteuses") end turfmachine:RemoveComponent("deployable") turfmachine.components.container.canbeopened = true turfmachine.components.inventoryitem:ChangeImageName("researchlab3") turfmachine:AddComponent("equippable") turfmachine.components.equippable.equipslot = EQUIPSLOTS.BODY turfmachine.components.equippable:SetOnEquip( function(turfmachine) GetPlayer().components.inventory:SetOverflow(turfmachine) turfmachine.components.container:Open(GetPlayer()) GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/backpack_open", "open") end ) turfmachine.components.equippable:SetOnUnequip( function(turfmachine) turfmachine.components.container:Close(GetPlayer()) GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/backpack_close", "open") end ) turfmachine:AddTag("turfmachines") inst:Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("turfmachines") then data.turfmachines = true end end local function onload(inst, data) if data and data.turfmachines then inst.AnimState:SetBank("researchlab3") inst.AnimState:SetBuild("researchlab3") inst.AnimState:PlayAnimation("idle") inst.Transform:SetScale(0.5, 0.5, 0.5) inst:RemoveComponent("instrument") inst:RemoveComponent("tool") if inst.components.finiteuses then inst:RemoveComponent("finiteuses") end inst:RemoveComponent("deployable") inst.components.container.canbeopened = true inst.components.inventoryitem:ChangeImageName("researchlab3") inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.BODY inst.components.equippable:SetOnEquip( function(inst) GetPlayer().components.inventory:SetOverflow(inst) inst.components.container:Open(GetPlayer()) GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/backpack_open", "open") end ) inst.components.equippable:SetOnUnequip( function(inst) inst.components.container:Close(GetPlayer()) GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/backpack_close", "open") end ) inst:AddTag("turfmachines") end end inst.OnSave = onsave inst.OnLoad = onload inst:AddComponent("container") inst.components.container:SetNumSlots(#slotpos) inst.components.container.widgetslotpos = slotpos inst.components.container.widgetpos = Vector3(-80,150,0) inst.components.container.side_widget = true inst.components.container.itemtestfn = itemtest inst.components.container.widgetbuttoninfo = widgetbuttoninfo inst.components.container.acceptsstacks = false inst.components.container.canbeopened = false 即可用排箫种地皮改造机,装备地皮改造机后,屏幕右侧将出现格子和按钮,在格子中放入1块地皮,按Do按钮,游戏会卡一下(5-10秒),70块地皮就铺好了,方便大面积改造地图。共支持17种地皮,只要可以放入格子的都可以铺。排箫在魔法选项(画着红骷髅)下用5个芦苇、1个曼德拉草、1个绳子制造

2025/04/23 · Bny

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秒后果实变成腐烂食物,可用来快速生产肥料。不想要小型温室时,用锤子砸掉即可,记得先取出里面的物品哦。蝴蝶翅膀可打死蝴蝶获得

2025/04/23 · Bny

YN280-随身灭火器(用寒冬背心种随身灭火器,装备后可灭火)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二八0.随身灭火器(用寒冬背心种随身灭火器,装备后可灭火) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/trunkvest.lua文件,在inst.AnimState:SetBuild("armor_trunkvest_winter")的下一行插入以下内容: local function OnDeploy2(inst, pt) local extinguisher = SpawnPrefab("trunkvest_winter") extinguisher.Transform:SetPosition(pt.x, pt.y, pt.z) extinguisher.AnimState:SetBank("firefighter") extinguisher.AnimState:SetBuild("firefighter") extinguisher.AnimState:PlayAnimation("idle_on_loop") extinguisher.Transform:SetScale(0.5, 0.5, 0.5) extinguisher:RemoveComponent("inventoryitem") extinguisher:RemoveComponent("equippable") extinguisher:RemoveComponent("insulator") extinguisher:RemoveComponent("fueled") extinguisher:RemoveComponent("deployable") extinguisher:AddComponent("workable") extinguisher.components.workable:SetWorkAction(ACTIONS.HAMMER) extinguisher.components.workable:SetWorkLeft(3) extinguisher.components.workable:SetOnFinishCallback(function(extinguisher) SpawnPrefab("collapse_big").Transform:SetPosition(extinguisher.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") extinguisher:Remove() end ) extinguisher:AddComponent("inventoryitem") extinguisher.components.inventoryitem:ChangeImageName("firesuppressor") extinguisher:AddComponent("equippable") extinguisher.components.equippable.equipslot = EQUIPSLOTS.HANDS extinguisher.components.equippable:SetOnEquip(function(extinguisher, owner) extinguisher.task = extinguisher:DoPeriodicTask(1, function(extinguisher) local waterring = SpawnPrefab("groundpoundring_fx") waterring.Transform:SetPosition(owner.Transform:GetWorldPosition()) waterring.AnimState:SetBloomEffectHandle("shaders/anim.ksh") local pos = Vector3(extinguisher.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 10) for k,v in pairs(ents) do if v.components.burnable and v.components.burnable:IsBurning() then if v.prefab == "cactus" or v.prefab == "berrybush" or v.prefab == "berrybush2" or v.prefab == "carrot_planted" or v.prefab == "cave_banana_tree" or v.prefab == "cave_fern" or v.prefab == "deciduoustree" or v.prefab == "deciduoustree_normal" or v.prefab == "deciduoustree_tall" or v.prefab == "deciduoustree_short" or v.prefab == "evergreen" or v.prefab == "evergreen_normal" or v.prefab == "evergreen_tall" or v.prefab == "evergreen_short" or v.prefab == "evergreen_sparse" or v.prefab == "evergreen_sparse_normal" or v.prefab == "evergreen_sparse_tall" or v.prefab == "evergreen_sparse_short" or v.prefab == "flower" or v.prefab == "flower_evil" or v.prefab == "grass" or v.prefab == "marsh_bush" or v.prefab == "red_mushroom" or v.prefab == "green_mushroom" or v.prefab == "blue_mushroom" or v.prefab == "mushtree_tall" or v.prefab == "mushtree_medium" or v.prefab == "mushtree_small" or v.prefab == "sapling" or v.prefab == "flower_cave" or v.prefab == "flower_cave_double" or v.prefab == "flower_cave_triple" or v.prefab == "lichen" or v.prefab == "livingtree" or v.prefab == "marsh_tree" or v.prefab == "reeds" then if v.components.propagator then v.components.propagator.spreading = false end SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition()) SpawnPrefab(v.prefab).Transform:SetPosition(v.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/fireOut") v:Remove() end if v.prefab == "treasurechest" or v.prefab == "slow_farmplot" or v.prefab == "fast_farmplot" or v.prefab == "tent" or v.prefab == "wall_wood" or v.prefab == "wall_hay" or v.prefab == "cookpot" or v.prefab == "beebox" or v.prefab == "homesign" or v.prefab == "researchlab" or v.prefab == "researchlab2" or v.prefab == "researchlab3" or v.prefab == "researchlab4" or v.prefab == "meatrack" or v.prefab == "pighouse" or v.prefab == "rabbithouse" or v.prefab == "pottedfern" or v.prefab == "rainometer" or v.prefab == "winterometer" or v.prefab == "resurrectionstatue" or v.prefab == "siestahut" then SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/fireOut") v.components.burnable:Extinguish(true) end end end end ) end ) extinguisher.components.equippable:SetOnUnequip(function(extinguisher, owner) if extinguisher.task then extinguisher.task:Cancel() extinguisher.task = nil end end ) extinguisher:AddTag("extinguishers") inst:Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy2 local function onsave2(inst, data) if inst:HasTag("extinguishers") then data.extinguishers = true end end local function onload2(inst, data) if data and data.extinguishers then inst.AnimState:SetBank("firefighter") inst.AnimState:SetBuild("firefighter") inst.AnimState:PlayAnimation("idle_on_loop") inst.Transform:SetScale(0.5, 0.5, 0.5) inst:RemoveComponent("inventoryitem") inst:RemoveComponent("equippable") inst:RemoveComponent("insulator") inst:RemoveComponent("fueled") inst:RemoveComponent("deployable") 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:AddComponent("inventoryitem") inst.components.inventoryitem:ChangeImageName("firesuppressor") inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.HANDS inst.components.equippable:SetOnEquip(function(inst, owner) inst.task = inst:DoPeriodicTask(1, function(inst) local waterring = SpawnPrefab("groundpoundring_fx") waterring.Transform:SetPosition(owner.Transform:GetWorldPosition()) waterring.AnimState:SetBloomEffectHandle("shaders/anim.ksh") local pos = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 10) for k,v in pairs(ents) do if v.components.burnable and v.components.burnable:IsBurning() then if v.prefab == "cactus" or v.prefab == "berrybush" or v.prefab == "berrybush2" or v.prefab == "carrot_planted" or v.prefab == "cave_banana_tree" or v.prefab == "cave_fern" or v.prefab == "deciduoustree" or v.prefab == "deciduoustree_normal" or v.prefab == "deciduoustree_tall" or v.prefab == "deciduoustree_short" or v.prefab == "evergreen" or v.prefab == "evergreen_normal" or v.prefab == "evergreen_tall" or v.prefab == "evergreen_short" or v.prefab == "evergreen_sparse" or v.prefab == "evergreen_sparse_normal" or v.prefab == "evergreen_sparse_tall" or v.prefab == "evergreen_sparse_short" or v.prefab == "flower" or v.prefab == "flower_evil" or v.prefab == "grass" or v.prefab == "marsh_bush" or v.prefab == "red_mushroom" or v.prefab == "green_mushroom" or v.prefab == "blue_mushroom" or v.prefab == "mushtree_tall" or v.prefab == "mushtree_medium" or v.prefab == "mushtree_small" or v.prefab == "sapling" or v.prefab == "flower_cave" or v.prefab == "flower_cave_double" or v.prefab == "flower_cave_triple" or v.prefab == "lichen" or v.prefab == "livingtree" or v.prefab == "marsh_tree" or v.prefab == "reeds" then if v.components.propagator then v.components.propagator.spreading = false end SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition()) SpawnPrefab(v.prefab).Transform:SetPosition(v.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/fireOut") v:Remove() end if v.prefab == "treasurechest" or v.prefab == "slow_farmplot" or v.prefab == "fast_farmplot" or v.prefab == "tent" or v.prefab == "wall_wood" or v.prefab == "wall_hay" or v.prefab == "cookpot" or v.prefab == "beebox" or v.prefab == "homesign" or v.prefab == "researchlab" or v.prefab == "researchlab2" or v.prefab == "researchlab3" or v.prefab == "researchlab4" or v.prefab == "meatrack" or v.prefab == "pighouse" or v.prefab == "rabbithouse" or v.prefab == "pottedfern" or v.prefab == "rainometer" or v.prefab == "winterometer" or v.prefab == "resurrectionstatue" or v.prefab == "siestahut" then SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/fireOut") v.components.burnable:Extinguish(true) end end end end ) end ) inst.components.equippable:SetOnUnequip(function(inst, owner) if inst.task then inst.task:Cancel() inst.task = nil end end ) inst:AddTag("extinguishers") end end inst.OnSave = onsave2 inst.OnLoad = onload2 即可用寒冬背心种随身灭火器,装备随身灭火器,可向外吹出强气流,靠近着火的建筑、植物,会自动灭火,让你对燃烧的基地不再束手无策。不想要随身灭火器了,用锤子砸掉即可。夏日背心在穿戴选项(画着帽子)下,用1个蓝色象鼻、8个蛛丝制造、2个牛毛制造

2025/04/23 · Bny

YN281-菜市场(在兔房买卖农产品)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二八一.菜市场(在兔房买卖农产品) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/rabbithouse.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function ShouldAcceptItem(inst, item) if item.prefab == "cave_banana" or 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 == "berries" or item.prefab == "cactus_meat" or item.prefab == "watermelon" or item.prefab == "acorn" or item.prefab == "goldnugget" then return true end return false end local function OnGetItemFromPlayer(inst, giver, item) if item.prefab == "cave_banana" or 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 == "berries" or item.prefab == "cactus_meat" or item.prefab == "watermelon" or item.prefab == "acorn" then local goldnugget = SpawnPrefab("goldnugget") giver.components.inventory:GiveItem(goldnugget) end if item.prefab == "goldnugget" then local names = {"cave_banana","carrot","corn","pumpkin","eggplant","durian","pomegranate","dragonfruit","berries","cactus_meat","watermelon","acorn"} local name = names[math.random(#names)] local veggie = SpawnPrefab(name) giver.components.inventory:GiveItem(veggie) end end inst:AddComponent("trader") inst.components.trader.onaccept = OnGetItemFromPlayer inst.components.trader:SetAcceptTest(ShouldAcceptItem) 即可将种出来的农产品卖给兔房(拿着农产品左键点兔房),获得1个黄金,黄金会自动打入账户(主角物品条)。也可以给兔房黄金,买入随机品种的农产品,可以买卖的农产品包括香蕉、胡萝卜、茄子、南瓜、玉米、榴莲、石榴、火龙果、浆果、仙人掌肉、西瓜、橡果

2025/04/23 · Bny