YN270-筋斗云(按键盘Z键召唤筋斗云在天上飞行,再按Z键落地)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二七0.筋斗云(按键盘Z键召唤筋斗云在天上飞行,再按Z键落地) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("resurrectable")的下一行插入以下内容: TheInput:AddKeyUpHandler(KEY_Z, function() if not inst:HasTag("flycloud") then inst:AddTag("flycloud") inst.components.locomotor:Stop() inst.components.talker:ShutUp() SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) inst.AnimState:PlayAnimation("give") inst:DoTaskInTime(0.3, function() inst.cloud = SpawnPrefab("corn_cooked") inst.cloud.Physics:SetActive(false) inst.cloud.Transform:SetScale(1.8, 1.8, 1.8) inst.cloud.AnimState:SetMultColour(255/255,255/255,255/255,0.6) inst.cloud.AnimState:SetBloomEffectHandle("shaders/anim.ksh") inst.cloud:RemoveComponent("perishable") inst.cloud:RemoveComponent("edible") inst.cloud:RemoveComponent("stackable") inst.cloud:RemoveComponent("inventoryitem") inst.cloud:RemoveComponent("bait") inst.cloud:RemoveComponent("tradable") inst.cloud:RemoveComponent("burnable") inst.cloud:RemoveComponent("propagator") inst.cloud.persists = false inst.cloud:AddTag("NOCLICK") local follower = inst.cloud.entity:AddFollower() follower:FollowSymbol( inst.GUID, "swap_body", 0, 60, 0 ) local pt = inst:GetPosition() inst.Transform:SetPosition(pt.x, 10, pt.z) local shadow = inst.entity:AddDynamicShadow() shadow:SetSize( 0, 0 ) inst.gogogo = inst:DoPeriodicTask(.01, function() inst.Physics:SetMotorVelOverride(25,1.5,0) end) end ) else inst:RemoveTag("flycloud") inst.components.locomotor:Stop() inst.components.talker:ShutUp() SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) inst.AnimState:PlayAnimation("give") inst:DoTaskInTime(0.3, function() if inst.cloud then inst.cloud:Remove() inst.cloud = nil end if inst.gogogo then inst.gogogo:Cancel() inst.gogogo = nil end local pt = inst:GetPosition() inst.Transform:SetPosition(pt.x, 0, pt.z) local shadow = inst.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) inst.Physics:ClearMotorVelOverride() inst.Physics:ClearMotorVelOverride() end ) end end ) 即可口中默念咒语——“走你”,并按下键盘Z键,召唤筋斗云在天上飞行,用键盘W、S、A、D键控制方向,再次按Z键可落地

2025/04/23 · Bny

YN271-全自动播种机(给避雷针植物,自动种下一百多个)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二七一.全自动播种机(给避雷针植物,自动种下一百多个) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/lightningrod.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local slotpos = { Vector3(0,-75,0)} local function itemtest(inst, item, slot) if item.prefab == "twigs" or item.prefab == "cutgrass" or item.prefab == "petals" or item.prefab == "petals_evil" or item.prefab == "cutreeds" or item.prefab == "red_cap" or item.prefab == "green_cap" or item.prefab == "blue_cap" or item.prefab == "carrot" or item.prefab == "berries" or item.prefab == "mandrake" or item.prefab == "foliage" or item.prefab == "cave_banana" or item.prefab == "cutlichen" or item.prefab == "lightbulb" or item.prefab == "pinecone" or item.prefab == "charcoal" or item.prefab == "acorn" or item.prefab == "cactus_meat" then return true end return false end local widgetbuttoninfo = { text = "Do", position = Vector3(0, -145, 0), fn = function(inst) if GetPlayer().components.inventory:Has("goldnugget", 50) then if inst.components.container:Has("twigs", 1) then inst.components.container:ConsumeByName("twigs", 1) inst.plants = "sapling" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("cutgrass", 1) then inst.components.container:ConsumeByName("cutgrass", 1) inst.plants = "grass" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("petals", 1) then inst.components.container:ConsumeByName("petals", 1) inst.plants = "flower" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("petals_evil", 1) then inst.components.container:ConsumeByName("petals_evil", 1) inst.plants = "flower_evil" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("cutreeds", 1) then inst.components.container:ConsumeByName("cutreeds", 1) inst.plants = "reeds" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("red_cap", 1) then inst.components.container:ConsumeByName("red_cap", 1) inst.plants = "red_mushroom" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("green_cap", 1) then inst.components.container:ConsumeByName("green_cap", 1) inst.plants = "green_mushroom" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("blue_cap", 1) then inst.components.container:ConsumeByName("blue_cap", 1) inst.plants = "blue_mushroom" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("carrot", 1) then inst.components.container:ConsumeByName("carrot", 1) inst.plants = "carrot_planted" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("berries", 1) then inst.components.container:ConsumeByName("berries", 1) inst.plants = "berrybush2" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("mandrake", 1) then inst.components.container:ConsumeByName("mandrake", 1) inst.plants = "mandrake" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("foliage", 1) then inst.components.container:ConsumeByName("foliage", 1) inst.plants = "cave_fern" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("cave_banana", 1) then inst.components.container:ConsumeByName("cave_banana", 1) inst.plants = "cave_banana_tree" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("cutlichen", 1) then inst.components.container:ConsumeByName("cutlichen", 1) inst.plants = "lichen" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("lightbulb", 1) then inst.components.container:ConsumeByName("lightbulb", 1) inst.plants = "flower_cave_triple" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("pinecone", 1) then inst.components.container:ConsumeByName("pinecone", 1) inst.plants = "evergreen_tall" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("charcoal", 1) then inst.components.container:ConsumeByName("charcoal", 1) inst.plants = "mushtree_tall" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("acorn", 1) then inst.components.container:ConsumeByName("acorn", 1) inst.plants = "deciduoustree_tall" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end if inst.components.container:Has("cactus_meat", 1) then inst.components.container:ConsumeByName("cactus_meat", 1) inst.plants = "cactus" GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) end local pt = Vector3(inst.Transform:GetWorldPosition()) inst:StartThread(function() for k = 1, 25 do local result_offset = FindValidPositionByFan(1 * 2 * PI, 4, 25, function(offset) local x,y,z = (pt + offset):Get() local ents = TheSim:FindEntities(x,y,z , 1) return not next(ents) end) if result_offset then local plant = SpawnPrefab(inst.plants) plant.Transform:SetPosition((pt + result_offset):Get()) GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) local fx = SpawnPrefab("splash_ocean") local pos = pt + result_offset fx.Transform:SetPosition(pos.x, pos.y, pos.z) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") end Sleep(.33) end for k = 1, 37 do local result_offset = FindValidPositionByFan(1 * 2 * PI, 6, 37, function(offset) local x,y,z = (pt + offset):Get() local ents = TheSim:FindEntities(x,y,z , 1) return not next(ents) end) if result_offset then local plant = SpawnPrefab(inst.plants) plant.Transform:SetPosition((pt + result_offset):Get()) GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) local fx = SpawnPrefab("splash_ocean") local pos = pt + result_offset fx.Transform:SetPosition(pos.x, pos.y, pos.z) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") end Sleep(.23) end for k = 1, 50 do local result_offset = FindValidPositionByFan(1 * 2 * PI, 8, 50, function(offset) local x,y,z = (pt + offset):Get() local ents = TheSim:FindEntities(x,y,z , 1) return not next(ents) end) if result_offset then local plant = SpawnPrefab(inst.plants) plant.Transform:SetPosition((pt + result_offset):Get()) GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) local fx = SpawnPrefab("splash_ocean") local pos = pt + result_offset fx.Transform:SetPosition(pos.x, pos.y, pos.z) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") end Sleep(.13) end end) end end } inst:AddComponent("container") inst.components.container:SetNumSlots(#slotpos) inst.components.container.widgetslotpos = slotpos inst.components.container.widgetpos = Vector3(0,180,0) inst.components.container.side_align_tip = 160 inst.components.container.itemtestfn = itemtest inst.components.container.acceptsstacks = false inst.components.container.widgetbuttoninfo = widgetbuttoninfo 即可在空旷的地上建一个避雷针,鼠标左键点避雷针可打开格子,在格子中放入植物后点Do按钮,可自动种下100多株该植物,将花费50个黄金,身上黄金数不足时不会种植。可种植的17种植物有:给树枝种树苗、给草种草、给花瓣种花、给噩梦花瓣种噩梦花、给芦苇种芦苇、给红蘑菇种红蘑菇、给绿蘑菇种绿蘑菇、给蓝蘑菇种蓝蘑菇、给胡萝卜种胡萝卜、给浆果种果树丛、给曼德拉草种曼德拉草、给叶子种蕨类植物、给香蕉种香蕉树、给苔藓种苔藓、给荧光果种三朵洞穴花、给松果种树、给木炭种蘑菇树、给仙人掌肉种仙人掌、给橡果种橡树(橡树种下时不显示,存档退出再读档就可正常显示)。注意,其中果树丛、香蕉树、树、蘑菇树等种好后人无法通行,可以用“瑞士手杖”瞬移(或“神奇跳跃”跳出来),并用“收割者”大面积收获

2025/04/23 · Bny

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