YN240-完好如初(红色魔杖可修复物品、回复新鲜度、补充燃料及治愈同伴)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二四0.完好如初(红色魔杖可修复物品、回复新鲜度、补充燃料及治愈同伴) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/staff.lua文件,在local inst = commonfn("red")的下一行插入以下内容: local function canbeback(staff, caster, target, pos) if caster.components.inventory:Has("goldnugget", 1) then return true end return false end local function beback(staff, target, pos) local player = GetPlayer() SpawnPrefab("book_fx").Transform:SetPosition(target.Transform:GetWorldPosition()) if target.components.fueled then target.components.fueled.currentfuel = target.components.fueled.maxfuel player.components.inventory:ConsumeByName("goldnugget", 1) end if target.components.finiteuses then target.components.finiteuses.current = target.components.finiteuses.total player.components.inventory:ConsumeByName("goldnugget", 1) end if target.components.armor then target.components.armor.condition = target.components.armor.maxcondition player.components.inventory:ConsumeByName("goldnugget", 1) end if target.components.perishable then target.components.perishable.perishremainingtime = target.components.perishable.perishtime player.components.inventory:ConsumeByName("goldnugget", 1) end if target.components.health then target.components.health.currenthealth = target.components.health.maxhealth player.components.inventory:ConsumeByName("goldnugget", 1) end end inst:AddComponent("spellcaster") inst.components.spellcaster:SetSpellFn(beback) inst.components.spellcaster:SetSpellTestFn(canbeback) inst.components.spellcaster.canuseontargets = true inst.components.spellcaster.canusefrominventory = false 即可将想要修复的物品放在地上,装备红色魔杖右键点地上的物品,可修复武器装备使用百分比,回复食物新鲜度,为照明物品补充燃料,也可用于治疗同伴。每次使用须支付1个黄金,身上没有黄金时无法使用。可堆叠的物品尽量堆在一起修复,这样只要花费1个黄金即可

2025/04/23 · Bny

YN241-我的小屋(用巨鹿眼球种小屋,左键点击可睡觉,右键点击打开库房,点按钮可修理装备、恢复食物新鲜、烘干物品)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二四一.我的小屋(用巨鹿眼球种小屋,左键点击可睡觉,右键点击打开库房,点按钮可修理装备、恢复食物新鲜、烘干物品) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/deerclops_eyeball.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local slotpos = {} for y = 2, 0, -1 do for x = 0, 11 do table.insert(slotpos, Vector3(75*x-75*2+75, 75*y-75*2+75,0)) table.insert(slotpos, Vector3(75*x-75*2+75, 75*y-75*2-175,0)) table.insert(slotpos, Vector3(75*x-75*2+75, 75*y-75*2-425,0)) end end local widgetbuttoninfo = { text = "Repair", position = Vector3(741, 135, 0), fn = function(inst) GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available") inst.components.container:Close(GetPlayer()) for k,v in pairs(inst.components.container.slots) do if v.components.fueled then v.components.fueled.currentfuel = v.components.fueled.maxfuel end if v.components.finiteuses then v.components.finiteuses.current = v.components.finiteuses.total end if v.components.armor then v.components.armor.condition = v.components.armor.maxcondition end if v.components.perishable then v.components.perishable.perishremainingtime = v.components.perishable.perishtime end if v.components.moisturelistener then v.components.moisturelistener.wet = false end end inst:DoTaskInTime(0.1, function() inst.components.container:Open(GetPlayer()) end ) end } local function OnDeploy (inst, pt) local house = SpawnPrefab("deerclops_eyeball") house.Transform:SetPosition(pt.x, pt.y, pt.z) house.AnimState:SetBank("walrus_house") house.AnimState:SetBuild("walrus_house") house.AnimState:PlayAnimation("lit", true) house.Transform:SetScale(1.5, 1.5, 1.5) MakeObstaclePhysics(house, 1) local minimap = house.entity:AddMiniMapEntity() minimap:SetIcon( "igloo.png" ) house:RemoveComponent("inventoryitem") house:RemoveComponent("edible") house:RemoveComponent("stackable") house:RemoveComponent("deployable") local light = house.entity:AddLight() light:SetFalloff(1) light:SetIntensity(.8) light:SetRadius(10) light:Enable(true) light:SetColour(180/255, 195/255, 50/255) house:AddComponent("named") house.components.named:SetName("My House") house:AddComponent("workable") house.components.workable:SetWorkAction(ACTIONS.HAMMER) house.components.workable:SetWorkLeft(3) house.components.workable:SetOnFinishCallback(function(house) house.Light:Enable(false) SpawnPrefab("collapse_big").Transform:SetPosition(house.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") house.components.container:DropEverything() house:Remove() end ) house:AddComponent("machine") house.components.machine.turnonfn = function() house.components.container:Open(GetPlayer()) end house.components.machine.turnofffn = function() house.components.container:Open(GetPlayer()) end house:AddComponent("sleepingbag") house.components.sleepingbag.onsleep = function(house, sleeper) sleeper.components.health:SetInvincible(true) sleeper.components.playercontroller:Enable(false) GetPlayer().HUD:Hide() TheFrontEnd:Fade(false,1) house:DoTaskInTime(1.2, function() GetPlayer().HUD:Show() TheFrontEnd:Fade(true,1) GetClock():MakeNextDay() sleeper.components.health:SetInvincible(false) sleeper.components.playercontroller:Enable(true) sleeper.components.sanity:DoDelta(sleeper.components.sanity.max) sleeper.components.hunger:DoDelta(sleeper.components.hunger.max) sleeper.components.health:DoDelta(sleeper.components.health.maxhealth) sleeper.components.temperature:SetTemperature(20) if sleeper.components.moisture then sleeper.components.moisture:SetMoistureLevel(0) end end) end house:AddTag("houses") inst.components.stackable:Get():Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("houses") then data.houses = true end end local function onload(inst, data) if data and data.houses then inst.AnimState:SetBank("walrus_house") inst.AnimState:SetBuild("walrus_house") inst.AnimState:PlayAnimation("lit", true) inst.Transform:SetScale(1.5, 1.5, 1.5) MakeObstaclePhysics(inst, 1) local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon( "igloo.png" ) inst:RemoveComponent("inventoryitem") inst:RemoveComponent("edible") inst:RemoveComponent("stackable") inst:RemoveComponent("deployable") local light = inst.entity:AddLight() light:SetFalloff(1) light:SetIntensity(.8) light:SetRadius(10) light:Enable(true) light:SetColour(180/255, 195/255, 50/255) inst:AddComponent("named") inst.components.named:SetName("My House") inst:AddComponent("workable") inst.components.workable:SetWorkAction(ACTIONS.HAMMER) inst.components.workable:SetWorkLeft(3) inst.components.workable:SetOnFinishCallback(function(inst) inst.Light:Enable(false) SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") inst.components.container:DropEverything() inst:Remove() end ) inst:AddComponent("machine") inst.components.machine.turnonfn = function() inst.components.container:Open(GetPlayer()) end inst.components.machine.turnofffn = function() inst.components.container:Open(GetPlayer()) end inst:AddComponent("sleepingbag") inst.components.sleepingbag.onsleep = function(inst, sleeper) sleeper.components.health:SetInvincible(true) sleeper.components.playercontroller:Enable(false) GetPlayer().HUD:Hide() TheFrontEnd:Fade(false,1) inst:DoTaskInTime(1.2, function() GetPlayer().HUD:Show() TheFrontEnd:Fade(true,1) GetClock():MakeNextDay() sleeper.components.health:SetInvincible(false) sleeper.components.playercontroller:Enable(true) sleeper.components.sanity:DoDelta(sleeper.components.sanity.max) sleeper.components.hunger:DoDelta(sleeper.components.hunger.max) sleeper.components.health:DoDelta(sleeper.components.health.maxhealth) sleeper.components.temperature:SetTemperature(20) if sleeper.components.moisture then sleeper.components.moisture:SetMoistureLevel(0) end end) end inst:AddTag("houses") 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(-150,300,0) inst.components.container.side_align_tip = 160 inst.components.container.widgetbuttoninfo = widgetbuttoninfo inst.components.container.canbeopened = false inst:AddTag("fridge") 即可用巨鹿眼球种小屋,鼠标左键点小屋可睡觉(白天也可以睡),睡醒后会将脑、饥饿、生命全部补满,去除湿度,并解除中暑、冻伤状态。鼠标右键点击小屋,会打开库房(远离小屋自动关闭),共108格存储空间,具有冷藏功能。点格子右上角的“Repair”按钮,可修理小屋中的装备、恢复食物新鲜度、烘干物品。小屋日夜灯火通明,会照亮周边。不想要小屋时,用锤子砸掉即可,如果库房没有清空,里面的物品会掉在地上

2025/04/23 · Bny

YN242-自动门(用木盔甲种自动门,进出自动开关)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二四二.自动门(用木盔甲种自动门,进出自动开关) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/armor_wood.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function OnDeploy (inst, pt) local door1 = SpawnPrefab("armorwood") door1.Transform:SetPosition(pt.x+0.55, pt.y, pt.z-0.55) door1.AnimState:SetBank("winter_meter") door1.AnimState:SetBuild("winter_meter") door1.AnimState:SetPercent("meter", 1) door1.Transform:SetScale(1, 0.7, 1) MakeObstaclePhysics(door1, 0.48) door1:RemoveComponent("inventoryitem") door1:RemoveComponent("fuel") door1:RemoveComponent("armor") door1:RemoveComponent("equippable") door1:RemoveComponent("burnable") door1:RemoveComponent("propagator") door1:RemoveComponent("deployable") door1:RemoveTag("wood") door1:AddComponent("workable") door1.components.workable:SetWorkAction(ACTIONS.HAMMER) door1.components.workable:SetWorkLeft(2) door1.components.workable:SetOnFinishCallback(function(door1) SpawnPrefab("collapse_big").Transform:SetPosition(door1.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") door1:Remove() end ) door1:AddComponent( "playerprox" ) door1.components.playerprox:SetDist(2,3) door1.components.playerprox:SetOnPlayerNear(function(door1) door1.Transform:SetScale(0.1, 0.7, 1) door1.Physics:SetActive(false) GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") end ) door1.components.playerprox:SetOnPlayerFar(function(door1) door1.Transform:SetScale(1, 0.7, 1) door1.Physics:SetActive(true) GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") end ) door1.components.inspectable.getstatus = function(door1) door1.Transform:SetScale(0.1, 0.7, 1) door1.Physics:SetActive(false) door1:DoTaskInTime(3, function(door1) door1.Transform:SetScale(1, 0.7, 1) door1.Physics:SetActive(true) end ) end door1:AddTag("doors") local door2 = SpawnPrefab("armorwood") door2.Transform:SetPosition(pt.x-0.55, pt.y, pt.z+0.55) door2.AnimState:SetBank("winter_meter") door2.AnimState:SetBuild("winter_meter") door2.AnimState:SetPercent("meter", 1) door2.Transform:SetScale(1, 0.7, 1) MakeObstaclePhysics(door2, 0.48) door2:RemoveComponent("inventoryitem") door2:RemoveComponent("fuel") door2:RemoveComponent("armor") door2:RemoveComponent("equippable") door2:RemoveComponent("burnable") door2:RemoveComponent("propagator") door2:RemoveComponent("deployable") door2:RemoveTag("wood") door2:AddComponent("workable") door2.components.workable:SetWorkAction(ACTIONS.HAMMER) door2.components.workable:SetWorkLeft(2) door2.components.workable:SetOnFinishCallback(function(door2) SpawnPrefab("collapse_big").Transform:SetPosition(door2.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") door2:Remove() end ) door2:AddComponent( "playerprox" ) door2.components.playerprox:SetDist(2,3) door2.components.playerprox:SetOnPlayerNear(function(door2) door2.Transform:SetScale(0.1, 0.7, 1) door2.Physics:SetActive(false) GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") end ) door2.components.playerprox:SetOnPlayerFar(function(door2) door2.Transform:SetScale(1, 0.7, 1) door2.Physics:SetActive(true) GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") end ) door2.components.inspectable.getstatus = function(door2) door2.Transform:SetScale(0.1, 0.7, 1) door2.Physics:SetActive(false) door2:DoTaskInTime(3, function(door2) door2.Transform:SetScale(1, 0.7, 1) door2.Physics:SetActive(true) end ) end door2:AddTag("doors") inst:Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("doors") then data.doors = true end end local function onload(inst, data) if data and data.doors then inst.AnimState:SetBank("winter_meter") inst.AnimState:SetBuild("winter_meter") inst.AnimState:SetPercent("meter", 1) inst.Transform:SetScale(1, 0.7, 1) MakeObstaclePhysics(inst, 0.48) inst:RemoveComponent("inventoryitem") inst:RemoveComponent("fuel") inst:RemoveComponent("armor") inst:RemoveComponent("equippable") inst:RemoveComponent("burnable") inst:RemoveComponent("propagator") inst:RemoveComponent("deployable") inst:RemoveTag("wood") inst:AddComponent("workable") inst.components.workable:SetWorkAction(ACTIONS.HAMMER) inst.components.workable:SetWorkLeft(2) 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( "playerprox" ) inst.components.playerprox:SetDist(2,3) inst.components.playerprox:SetOnPlayerNear(function(inst) inst.Transform:SetScale(0.1, 0.7, 1) inst.Physics:SetActive(false) GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") end ) inst.components.playerprox:SetOnPlayerFar(function(inst) inst.Transform:SetScale(1, 0.7, 1) inst.Physics:SetActive(true) GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") end ) inst.components.inspectable.getstatus = function(inst) inst.Transform:SetScale(0.1, 0.7, 1) inst.Physics:SetActive(false) inst:DoTaskInTime(3, function(inst) inst.Transform:SetScale(1, 0.7, 1) inst.Physics:SetActive(true) end ) end inst:AddTag("doors") end end inst.OnSave = onsave inst.OnLoad = onload 即可用木盔甲种自动门,进出时自动开关,为方便宠物进出,也可以手动开关,鼠标左键点击可开门,3秒后自动关门。种门时,可先建好一排墙,然后砸掉其中2堵,在留下的空地正中间种下自动门,即可与墙完美契合。自动门有方向的限制,只可种在正面的墙之间(进入游戏默认的方向),不能种在侧面的墙之间。不需要自动门时,用锤子砸毁即可。木盔甲在战斗选项(画着两把剑)下,用8个木头、2个绳子制造

2025/04/23 · Bny

YN243-新移民(白天石头营火附近出现新移民,自动打怪,可与他们做买卖)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二四三.新移民(白天石头营火附近出现新移民,自动打怪,可与他们做买卖) 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/firepit.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function createnpc(inst) for k = 1,math.random(10,25) do local pt = inst:GetPosition() local npc = SpawnPrefab("frog") npc.Transform:SetPosition(pt.x+(math.random(50)-math.random(50)), 0, pt.z+(math.random(50)-math.random(50))) npc.AnimState:SetBank("wilson") local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} local buildname = names[math.random(#names)] npc.AnimState:SetBuild(buildname) local hats = {"hat_bee","hat_beefalo","hat_bush","hat_earmuffs","hat_feather","hat_flower","hat_football","hat_miner","hat_ruins","hat_slurper","hat_slurtle","hat_spider","hat_straw","hat_top","hat_walrus","hat_winter","hat_rain","hat_watermelon","hat_ice","hat_catcoon","hat_wathgrithr"} local hat = hats[math.random(#hats)] npc.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") local armors = {"armor_grass","armor_marble","armor_onemanband","armor_ruins","armor_sanity","armor_slurper","armor_slurtleshell","armor_sweatervest","armor_trunkvest_summer","armor_trunkvest_winter","armor_wood","torso_rain"} local armor = armors[math.random(#armors)] npc.AnimState:OverrideSymbol("swap_body", armor, "swap_body") npc.AnimState:Show("HAT") npc.AnimState:Show("HAT_HAIR") npc.AnimState:Hide("HAIR_NOHAT") npc.AnimState:Hide("HAIR") npc.AnimState:Hide("ARM_carry") npc.AnimState:Show("ARM_normal") npc.AnimState:PlayAnimation("idle") MakeCharacterPhysics(npc, 75, .5) local minimap = npc.entity:AddMiniMapEntity() minimap:SetIcon( "lighter.png" ) npc:RemoveComponent("sleeper") npc:RemoveComponent("thief") npc:RemoveComponent("lootdropper") npc:RemoveTag("animal") npc:RemoveTag("prey") npc:RemoveTag("smallcreature") npc:RemoveTag("frog") npc:RemoveTag("canbetrapped") npc:RemoveAllEventCallbacks() npc:SetStateGraph("SGshadowwaxwell") npc.components.health:SetMaxHealth(1000) npc:RemoveComponent("combat") npc:AddComponent("combat") npc.components.combat:SetDefaultDamage(10) npc.components.combat:SetAttackPeriod(1) npc.components.combat:SetRetargetFunction(3, function(npc) if not npc.components.health:IsDead() then return FindEntity(npc, 20, function(guy) if guy.components.combat and guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == npc or npc.components.combat.target == guy or guy:HasTag("monster") end end ) end end ) npc.components.combat:SetKeepTargetFunction(function(npc, target) return target and target:IsValid() end ) npc:ListenForEvent("attacked", function(npc, data) npc.components.combat:SetTarget(data.attacker) npc.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("npcs") and not dude.components.health:IsDead() end, 5) end ) npc:AddComponent("trader") npc.components.trader:SetAcceptTest(function(npc, 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 == "meat" or item.prefab == "smallmeat" or item.prefab == "fish" or item.prefab == "eel" or item.prefab == "drumstick" or item.prefab == "bird_egg" or item.prefab == "froglegs" or item.prefab == "monstermeat" or item.prefab == "butter" or item.prefab == "butterflywings" or item.prefab == "cutlichen" or item.prefab == "foliage" or item.prefab == "honey" or item.prefab == "lightbulb" or item.prefab == "red_cap" or item.prefab == "green_cap" or item.prefab == "blue_cap" or item.prefab == "petals" or item.prefab == "petals_evil" or item.prefab == "redgem" or item.prefab == "bluegem" or item.prefab == "purplegem" or item.prefab == "greengem" or item.prefab == "orangegem" or item.prefab == "yellowgem" then return true end return false end ) npc.components.trader.onaccept = function(npc, giver, item) for k = 1, 2 do local goldnugget = SpawnPrefab("goldnugget") GetPlayer().components.inventory:GiveItem(goldnugget) end end npc:ListenForEvent( "nighttime", function() npc:Remove() end , GetWorld()) npc:AddComponent("talker") npc:DoPeriodicTask(math.random(30,60), function() local words = {"Good day","I'm happy","I like here","Thank you","Where's the enemy","I'm hungry","Too hot","Too cold","Hello","Bye","Sorry","Good morning","Good afternoon","Good evening","I'll go home","I want to go hunting","I'm going to mining","I want to go to the farm","I want to pick","I want to go fishing","I'm going to catch","I want to fight","I want to have a rest","I was a good man","I want to be rich","I was lucky","I want to make friends"} local word = words[math.random(#words)] npc.components.talker:Say(word, 4, false) end) npc:AddTag("npcs") end end inst:ListenForEvent( "daytime", function() createnpc(inst) end , GetWorld()) 2.用MT管理器打开游戏目录/assets/scripts/prefabs/frog.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local names = {"swap_axe","swap_batbat","swap_cane","swap_diviningrod","swap_ruins_bat","swap_fishingrod","swap_goldenaxe","swap_goldenpickaxe","swap_goldenshovel","swap_ham_bat","swap_hammer","swap_lucy_axe","swap_nightmaresword","swap_pickaxe","swap_pitchfork","swap_ruins_bat","swap_shovel","swap_spear","swap_spike","swap_umbrella","swap_spear_wathgrithr","swap_parasol"} local weapon = names[math.random(#names)] local items = { SWORD = weapon } local function EquipItem(inst, item) if item then inst.AnimState:OverrideSymbol("swap_object", item, item) inst.AnimState:Show("ARM_carry") inst.AnimState:Hide("ARM_normal") end end inst.items = items inst.equipfn = EquipItem EquipItem(inst) local function onsave(inst, data) if inst:HasTag("npcs") then data.npcs = true end end local function onload(inst, data) if data and data.npcs then inst.AnimState:SetBank("wilson") local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} local buildname = names[math.random(#names)] inst.AnimState:SetBuild(buildname) local hats = {"hat_bee","hat_beefalo","hat_bush","hat_earmuffs","hat_feather","hat_flower","hat_football","hat_miner","hat_ruins","hat_slurper","hat_slurtle","hat_spider","hat_straw","hat_top","hat_walrus","hat_winter","hat_rain","hat_watermelon","hat_ice","hat_catcoon","hat_wathgrithr"} local hat = hats[math.random(#hats)] inst.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") local armors = {"armor_grass","armor_marble","armor_onemanband","armor_ruins","armor_sanity","armor_slurper","armor_slurtleshell","armor_sweatervest","armor_trunkvest_summer","armor_trunkvest_winter","armor_wood","torso_rain"} local armor = armors[math.random(#armors)] inst.AnimState:OverrideSymbol("swap_body", armor, "swap_body") inst.AnimState:Show("HAT") inst.AnimState:Show("HAT_HAIR") inst.AnimState:Hide("HAIR_NOHAT") inst.AnimState:Hide("HAIR") inst.AnimState:Hide("ARM_carry") inst.AnimState:Show("ARM_normal") inst.AnimState:PlayAnimation("idle") MakeCharacterPhysics(inst, 75, .5) local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon( "lighter.png" ) inst:RemoveComponent("sleeper") inst:RemoveComponent("thief") inst:RemoveComponent("lootdropper") inst:RemoveTag("animal") inst:RemoveTag("prey") inst:RemoveTag("smallcreature") inst:RemoveTag("frog") inst:RemoveTag("canbetrapped") inst:RemoveAllEventCallbacks() inst:SetStateGraph("SGshadowwaxwell") inst.components.health:SetMaxHealth(1000) inst:RemoveComponent("combat") inst:AddComponent("combat") inst.components.combat:SetDefaultDamage(10) inst.components.combat:SetAttackPeriod(1) inst.components.combat:SetRetargetFunction(3, function(inst) if not inst.components.health:IsDead() then return FindEntity(inst, 20, function(guy) if guy.components.combat and guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == inst or inst.components.combat.target == guy or guy:HasTag("monster") end end ) end end ) inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) inst:ListenForEvent("attacked", function(inst, data) inst.components.combat:SetTarget(data.attacker) inst.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("npcs") and not dude.components.health:IsDead() end, 5) end ) inst:AddComponent("trader") inst.components.trader:SetAcceptTest(function(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 == "meat" or item.prefab == "smallmeat" or item.prefab == "fish" or item.prefab == "eel" or item.prefab == "drumstick" or item.prefab == "bird_egg" or item.prefab == "froglegs" or item.prefab == "monstermeat" or item.prefab == "butter" or item.prefab == "butterflywings" or item.prefab == "cutlichen" or item.prefab == "foliage" or item.prefab == "honey" or item.prefab == "lightbulb" or item.prefab == "red_cap" or item.prefab == "green_cap" or item.prefab == "blue_cap" or item.prefab == "petals" or item.prefab == "petals_evil" or item.prefab == "redgem" or item.prefab == "bluegem" or item.prefab == "purplegem" or item.prefab == "greengem" or item.prefab == "orangegem" or item.prefab == "yellowgem" then return true end return false end ) inst.components.trader.onaccept = function(inst, giver, item) for k = 1, 2 do local goldnugget = SpawnPrefab("goldnugget") GetPlayer().components.inventory:GiveItem(goldnugget) end end inst:ListenForEvent( "nighttime", function() inst:Remove() end , GetWorld()) inst:AddComponent("talker") inst:DoPeriodicTask(math.random(30,60), function() local words = {"Good day","I'm happy","I like here","Thank you","Where's the enemy","I'm hungry","Too hot","Too cold","Hello","Bye","Sorry","Good morning","Good afternoon","Good evening","I'll go home","I want to go hunting","I'm going to mining","I want to go to the farm","I want to pick","I want to go fishing","I'm going to catch","I want to fight","I want to have a rest","I was a good man","I want to be rich","I was lucky","I want to make friends"} local word = words[math.random(#words)] inst.components.talker:Say(word, 4, false) end) inst:AddTag("npcs") end end inst.OnSave = onsave inst.OnLoad = onload 即可在白天时,石头营火附近有新移民走动,黑夜离去,会主动攻击怪物,有他们的地方是安全的。他们愿意购买你的肉类、蔬菜和宝石(拿着物品对新移民点鼠标左键),每个物品可以卖2个黄金。如果你攻击新移民,附近的其他人将围殴你。新移民会自言自语,听听他们都说了些什么吧。在地图各处建造石头营火及其他建筑,就会形成许多小镇,饥荒世界从此不再冷清。新移民在小地图上显示为打火机图标(代表着希望),通过查看小地图,可以了解各个小镇的人口情况

2025/04/23 · Bny

YN244-神奇跳跃(按键盘R键主角可向前跳跃)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二四四.神奇跳跃(按键盘R键主角可向前跳跃) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("resurrectable")的下一行插入以下内容: TheInput:AddKeyUpHandler(KEY_R, function() inst.Physics:SetCollides(false) inst:DoTaskInTime(0, function() inst.AnimState:PlayAnimation("give") inst.components.playercontroller:Enable(false) inst.components.locomotor:Stop() inst.Physics:SetMotorVelOverride(50,45,0) end ) inst:DoTaskInTime(0.2, function() inst.Physics:ClearMotorVelOverride() inst.Physics:SetMotorVelOverride(50,0,0) end ) inst:DoTaskInTime(0.3, function() inst.Physics:ClearMotorVelOverride() inst.Physics:SetMotorVelOverride(50,-25,0) end ) inst:DoTaskInTime(0.5, function() inst.Physics:ClearMotorVelOverride() inst.components.locomotor:Stop() local pt = inst:GetPosition() inst.Transform:SetPosition(pt.x, 0, pt.z) inst.components.playercontroller:Enable(true) inst.Physics:SetCollides(true) inst.AnimState:PlayAnimation("idle") inst.SoundEmitter:PlaySound("dontstarve/movement/bodyfall_dirt", "bodyfall") end ) end ) 即可按键盘R键,让主角向前跳跃,用以方便地越过沟壑、墙等障碍,也可以跳到海面上,渡海而行。当身边有障碍物时,会影响跳跃高度。将其中KEY_R替换为其他键,比如KEY_C,就可以按键盘C键跳跃

2025/04/23 · Bny

YN245-如来神掌(按键盘J键,主角飞起并砸向地面,引发威力巨大的地震)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二四五.如来神掌(按键盘J键,主角飞起并砸向地面,引发威力巨大的地震) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("playeractionpicker")的下一行插入以下内容: TheInput:AddKeyUpHandler(KEY_J, function() if not inst:HasTag("jump") then inst.components.hunger:DoDelta(-50) inst.components.playercontroller:Enable(false) inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") shadow:SetSize( 0, 0 ) inst:AddTag("jump") inst.jump = inst:DoPeriodicTask(.01, function() inst.Physics:SetMotorVelOverride(0,15,0) end) inst:DoTaskInTime(5, function() if inst.jump then inst.jump:Cancel() inst.jump = nil end local pos = inst:GetPosition() GetSeasonManager():DoLightningStrike(pos) inst.sg:GoToState("hit") inst.jump2 = inst:DoPeriodicTask(.01, function() inst.Physics:SetMotorVelOverride(0,-55,0) end) end ) inst:DoTaskInTime(6.35, function() if inst.jump2 then inst.jump2:Cancel() inst.jump2 = nil end inst.sg:GoToState("hit") inst.AnimState:SetBloomEffectHandle("") shadow:SetSize( 1.3, .6 ) SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") for k = 1,math.random(5) do local pt = Vector3(inst.Transform:GetWorldPosition()) SpawnPrefab("rocks").Transform:SetPosition(pt.x+(math.random(3)-math.random(3)), 0, pt.z+(math.random(3)-math.random(3))) end inst.components.playercontroller:ShakeCamera(inst, "FULL", 2.5, 0.03, 2, 30) end ) inst:DoTaskInTime(6.5, function() local pos = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 30) for k,v in pairs(ents) do if v.components.workable and v.components.workable.workleft > 0 and not v.components.inventoryitem then v.components.workable:Destroy(inst) end if v:HasTag("monster") or v.prefab == "beefalo" or v.prefab == "babybeefalo" or v.prefab == "bunnyman" or v.prefab == "pigman" or v.prefab == "pigguard" or v.prefab == "merm" or v.prefab == "monkey" or v.prefab == "tallbird" or v.prefab == "walrus" or v.prefab == "little_walrus" or v.prefab == "wasphive" or v.prefab == "beehive" or v.prefab == "koalefant_summer" or v.prefab == "koalefant_winter" or v.prefab == "lureplant" or v.prefab == "penguin" or v.prefab == "perd" or v.prefab == "rocky" or v.prefab == "slurper" or v.prefab == "snurtle" or v.prefab == "slurtle" or v.prefab == "slurtlehole" or v.prefab == "spiderden" or v.prefab == "spiderden_2" or v.prefab == "spiderden_3" then v.components.health:DoDelta(-3000) end end inst:RemoveTag("jump") inst.components.playercontroller:Enable(true) end ) end end ) 即可按下键盘J键使出如来神掌,你将腾空而起并砸向地面(不会伤血),引发剧烈的地震,震毁周围一切建筑、石头、树木,并震死绝大多数动物(不伤宠物等同伴)。如来神掌是迄今为止威力最大的武林绝学,追求和谐游戏的玩家请慎用。每次发功消耗50点饥饿值

2025/04/23 · Bny

YN246-警戒模式(按键盘F8键主角自动巡逻并战斗,再按F8键恢复手动控制)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二四六.警戒模式(按键盘F8键主角自动巡逻并战斗,再按F8键恢复手动控制) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("playercontroller")的下一行插入以下内容: local items = { SWORD = "swap_spear" } local function EquipItem(inst, item) if item then inst.AnimState:OverrideSymbol("swap_object", item, item) inst.AnimState:Show("ARM_carry") inst.AnimState:Hide("ARM_normal") end end inst.items = items inst.equipfn = EquipItem EquipItem(inst) TheInput:AddKeyUpHandler(KEY_F8, function() if not inst:HasTag("patrol") then inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.talker:ShutUp() inst.components.playercontroller:Enable(false) inst:DoTaskInTime(0.3, function() inst:AddTag("patrol") inst.SoundEmitter:PlaySound("dontstarve/HUD/research_available") inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") inst:AddComponent("knownlocations") local brain = require "brains/frogbrain" inst:SetBrain(brain) inst:RestartBrain() local head = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD) inst.components.inventory:DropItem(head) local hands = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) inst.components.inventory:DropItem(hands) local body = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.BODY) inst.components.inventory:DropItem(body) inst.AnimState:OverrideSymbol("swap_object", "swap_spear", "swap_spear") inst.AnimState:Show("ARM_carry") inst.AnimState:Hide("ARM_normal") inst.HUD.controls.crafttabs:Hide() inst.HUD.controls.inv:Hide() local light = inst.entity:AddLight() light:SetIntensity(.8) light:SetRadius(20) light:SetFalloff(.6) light:Enable(true) light:SetColour(255/255,255/255,0/255) inst.components.locomotor.walkspeed = 10 inst.components.locomotor.runspeed = 15 inst:SetStateGraph("SGshadowwaxwell") inst.components.health:SetInvincible(true) inst.components.hunger:Pause() inst.components.sanity.ignore = true inst.components.temperature:SetTemp(20) inst.components.combat:SetDefaultDamage(200) inst.components.combat:SetAttackPeriod(0.25) inst.components.combat:SetRange(3) inst.components.combat:SetRetargetFunction(1, function(inst) if not inst.components.health:IsDead() then return FindEntity(inst, 50, function(guy) if guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == inst or inst.components.combat.target == guy or guy:HasTag("monster") end end ) end end ) inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) end ) else inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.talker:ShutUp() inst:DoTaskInTime(0.3, function() inst:RemoveTag("patrol") inst.SoundEmitter:PlaySound("dontstarve/HUD/research_available") inst.AnimState:SetBloomEffectHandle("") local brain = require "brains/wilsonbrain" inst:SetBrain(brain) inst:RestartBrain() inst:RemoveComponent("knownlocations") inst.AnimState:Hide("ARM_carry") inst.AnimState:Show("ARM_normal") inst.HUD.controls.crafttabs:Show() inst.HUD.controls.inv:Show() inst.Light:Enable(false) inst.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED inst.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED inst:SetStateGraph("SGwilson") inst.components.health:SetInvincible(false) inst.components.hunger:Resume() inst.components.sanity.ignore = false inst.components.temperature:SetTemp(nil) inst.components.hunger:DoDelta(-inst.components.hunger.max*.5) inst.components.combat:SetDefaultDamage(TUNING.UNARMED_DAMAGE) inst.components.combat:SetAttackPeriod(TUNING.WILSON_ATTACK_PERIOD) inst.components.combat:SetRange(2) inst.components.combat:SetTarget(nil) inst.components.combat:SetRetargetFunction(nil, nil ) inst.components.combat:SetKeepTargetFunction(nil) inst.components.playercontroller:Enable(true) end ) end end ) 即可按键盘F8键,开启主角警戒模式,CPU将接管你对主角的控制权,让主角自动巡逻并保护所在地区(夜晚站岗),一旦发现敌人,会自行战斗,由于主角的生命、脑、饥饿值已全部锁死,并且无惧寒冷和黑暗,所以你无须担心主角的安全。再次按键盘F8键即可恢复手动操作,并扣减一半饥饿值,注意及时补充食物。开启警戒模式前,请将身上的装备全部卸下,否则将掉落在地上

2025/04/23 · Bny

YN247-观赏秃鹫(用蛛丝种笼中的秃鹫,喂腐烂食物产种子,喂肉生高鸟蛋)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二四七.观赏秃鹫(用蛛丝种笼中的秃鹫,喂腐烂食物产种子,喂肉生高鸟蛋) 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/spoiledfood.lua文件,在inst:AddComponent("inspectable")的下一行插入inst:AddComponent("tradable") 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/silk.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function makecage(inst) local pt = inst:GetPosition() local cage = SpawnPrefab("silk") cage.Transform:SetPosition(pt.x, pt.y, pt.z) cage.AnimState:SetBank("birdcage") cage.AnimState:SetBuild("bird_cage") cage.AnimState:PlayAnimation("idle") cage.AnimState:SetMultColour(0/255,255/255,0/255,1) MakeObstaclePhysics(cage, .5 ) cage:RemoveComponent("tradable") cage:RemoveComponent("stackable") cage:RemoveComponent("inventoryitem") cage:RemoveComponent("upgrader") cage:RemoveComponent("deployable") cage:RemoveTag("cattoy") cage:AddComponent("named") cage.components.named:SetName("Buzzard") cage:AddComponent("lootdropper") cage:AddComponent("workable") cage.components.workable:SetWorkAction(ACTIONS.HAMMER) cage.components.workable:SetWorkLeft(3) cage.components.workable:SetOnFinishCallback(function(cage, worker) SpawnPrefab("collapse_big").Transform:SetPosition(cage.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") local pos = Vector3(cage.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 2) for k,v in pairs(ents) do if v:HasTag("cageanimal") then v:Remove() end end cage:Remove() end ) cage:AddComponent("trader") cage.components.trader:SetAcceptTest(function(cage, item) if item.prefab == "spoiled_food" or item.prefab == "meat" or item.prefab == "smallmeat" then return true end return false end ) cage.components.trader.onaccept = function(cage, giver, item) GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/buzzard/taunt") if item.prefab == "spoiled_food" then for k = 1, math.random(5) do local names = {"carrot_seeds","corn_seeds","pumpkin_seeds","eggplant_seeds","durian_seeds","pomegranate_seeds","dragonfruit_seeds","watermelon_seeds","seeds"} local name = names[math.random(#names)] cage.components.lootdropper:SpawnLootPrefab(name) end end if item.prefab == "meat" or item.prefab == "smallmeat" then cage.components.lootdropper:SpawnLootPrefab("tallbirdegg") end end cage:AddTag("cages") local animal = SpawnPrefab("silk") animal.AnimState:SetBank("buzzard") animal.AnimState:SetBuild("buzzard_build") animal.AnimState:PlayAnimation("idle", true) animal.Transform:SetFourFaced() animal.Physics:SetActive(false) animal.entity:AddSoundEmitter() animal:AddTag("NOCLICK") animal:RemoveComponent("tradable") animal:RemoveComponent("stackable") animal:RemoveComponent("inventoryitem") animal:RemoveComponent("upgrader") animal:RemoveComponent("deployable") animal:RemoveTag("cattoy") local follower = animal.entity:AddFollower() follower:FollowSymbol( cage.GUID, "swap_object", -10, -220, -0.1 ) animal:DoPeriodicTask(10, function(animal) animal.AnimState:PlayAnimation("caw") animal.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/buzzard/taunt") animal:DoTaskInTime(1.5, function() animal.AnimState:PlayAnimation("idle", true) end ) end ) animal:AddTag("cageanimal") end local function OnDeploy (inst, pt) makecage(inst) inst.components.stackable:Get():Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("cages") then data.cages = true end if inst:HasTag("cageanimal") then data.cageanimal = true end end local function onload(inst, data) if data and data.cages then makecage(inst) inst:Remove() end if data and data.cageanimal then inst:Remove() end end inst.OnSave = onsave inst.OnLoad = onload 即可用蛛丝种关在笼中的秃鹫(拿着1个蛛丝对地面点鼠标右键,如果拿着多个,则不会种出来),喂它腐烂食物,会掉落随机品种的植物种子,喂大肉、小肉会生高鸟蛋。不想要观赏秃鹫了,用锤子砸掉即可

2025/04/23 · Bny

YN248-迷你花坛(用燧石种花坛,给种子长出花朵,每晚招来萤火虫)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二四八.迷你花坛(用燧石种花坛,给种子长出花朵,每晚招来萤火虫) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/flint.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local names = {"f1","f2","f3","f4","f5","f6","f7","f8","f9","f10"} local function OnDeploy (inst, pt) local flowerpot = SpawnPrefab("flint") flowerpot.Transform:SetPosition(pt.x, pt.y, pt.z) flowerpot.AnimState:SetBank("firepit") flowerpot.AnimState:SetBuild("firepit") flowerpot.AnimState:PlayAnimation("idle",false) flowerpot.Transform:SetScale(0.5, 0.8, 0.5) flowerpot:RemoveComponent("edible") flowerpot:RemoveComponent("tradable") flowerpot:RemoveComponent("stackable") flowerpot:RemoveComponent("inventoryitem") flowerpot:RemoveComponent("bait") flowerpot:RemoveTag("molebait") flowerpot:AddTag("flowerpot") flowerpot:AddComponent("workable") flowerpot.components.workable:SetWorkAction(ACTIONS.HAMMER) flowerpot.components.workable:SetWorkLeft(3) flowerpot.components.workable:SetOnFinishCallback(function(flowerpot) SpawnPrefab("collapse_big").Transform:SetPosition(flowerpot.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/rock_break") local pos1 = Vector3(flowerpot.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos1.x,pos1.y,pos1.z, 0.5) for k,v in pairs(ents) do if v:HasTag("newflower") then v:Remove() end end flowerpot:Remove() end ) flowerpot:ListenForEvent( "dusktime", function() if flowerpot:HasTag("flowering") then for k = 1,math.random(2,5) do local pt1 = flowerpot:GetPosition() local fireflies = SpawnPrefab("fireflies") fireflies.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) end end end , GetWorld() ) flowerpot:ListenForEvent( "daytime", function() local pos = Vector3(flowerpot.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 5) for k,v in pairs(ents) do if v.prefab == "fireflies" and not v.components.inventoryitem:IsHeld() then v:Remove() end end end , GetWorld() ) flowerpot:AddComponent("trader") flowerpot.components.trader:SetAcceptTest(function(flowerpot, item) if not flowerpot:HasTag("flowering") then if item.prefab == "seeds" then return true end end return false end ) flowerpot.components.trader.onaccept = function(flowerpot, giver, item) local flower = SpawnPrefab("flint") flower.AnimState:SetBank("flowers") flower.AnimState:SetBuild("flowers") flower.animname = names[math.random(#names)] flower.AnimState:PlayAnimation(flower.animname) flower.AnimState:SetRayTestOnBB(true) flower.Transform:SetScale(1.5, 1.5, 1.5) flower.Physics:SetActive(false) local follower = flower.entity:AddFollower() follower:FollowSymbol( flowerpot.GUID, "swap_object", 0, -50, 0 ) flower:RemoveComponent("edible") flower:RemoveComponent("tradable") flower:RemoveComponent("stackable") flower:RemoveComponent("inventoryitem") flower:RemoveComponent("bait") flower:RemoveTag("molebait") flower:AddComponent("sanityaura") flower.components.sanityaura.aura = TUNING.SANITYAURA_SMALL flower:AddComponent("pickable") flower.components.pickable.picksound = "dontstarve/wilson/pickup_plants" flower.components.pickable:SetUp("petals", 0.1) flower.components.pickable.onpickedfn = function(flower) flower:Remove() flower = nil flowerpot:RemoveTag("flowering") end flower:AddTag("newflower") flower:AddTag("goodbye") flowerpot:AddTag("flowering") end inst.components.stackable:Get():Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("goodbye") then data.goodbye = true end if inst:HasTag("flowerpot") then data.flowerpot = true end if inst:HasTag("flowering") then data.flowering = true end end local function onload(inst, data) if data and data.goodbye then inst:Remove() end if data and data.flowerpot then inst.AnimState:SetBank("firepit") inst.AnimState:SetBuild("firepit") inst.AnimState:PlayAnimation("idle",false) inst.Transform:SetScale(0.5, 0.8, 0.5) inst:RemoveComponent("edible") inst:RemoveComponent("tradable") inst:RemoveComponent("stackable") inst:RemoveComponent("inventoryitem") inst:RemoveComponent("bait") inst:RemoveTag("molebait") inst:AddTag("flowerpot") 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/wilson/rock_break") local pos1 = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos1.x,pos1.y,pos1.z, 0.5) for k,v in pairs(ents) do if v:HasTag("newflower") then v:Remove() end end inst:Remove() end ) inst:ListenForEvent( "dusktime", function() if inst:HasTag("flowering") then for k = 1,math.random(2,5) do local pt1 = inst:GetPosition() local fireflies = SpawnPrefab("fireflies") fireflies.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) end end end , GetWorld() ) inst:ListenForEvent( "daytime", function() local pos = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 5) for k,v in pairs(ents) do if v.prefab == "fireflies" and not v.components.inventoryitem:IsHeld() then v:Remove() end end end , GetWorld() ) inst:AddComponent("trader") inst.components.trader:SetAcceptTest(function(inst, item) if not inst:HasTag("flowering") then if item.prefab == "seeds" then return true end end return false end ) inst.components.trader.onaccept = function(inst, giver, item) local flower = SpawnPrefab("flint") flower.AnimState:SetBank("flowers") flower.AnimState:SetBuild("flowers") flower.animname = names[math.random(#names)] flower.AnimState:PlayAnimation(flower.animname) flower.AnimState:SetRayTestOnBB(true) flower.Transform:SetScale(1.5, 1.5, 1.5) flower.Physics:SetActive(false) local follower = flower.entity:AddFollower() follower:FollowSymbol( inst.GUID, "swap_object", 0, -50, 0 ) flower:RemoveComponent("edible") flower:RemoveComponent("tradable") flower:RemoveComponent("stackable") flower:RemoveComponent("inventoryitem") flower:RemoveComponent("bait") flower:RemoveTag("molebait") flower:AddComponent("sanityaura") flower.components.sanityaura.aura = TUNING.SANITYAURA_SMALL flower:AddComponent("pickable") flower.components.pickable.picksound = "dontstarve/wilson/pickup_plants" flower.components.pickable:SetUp("petals", 0.1) flower.components.pickable.onpickedfn = function(flower) flower:Remove() flower = nil inst:RemoveTag("flowering") end flower:AddTag("newflower") flower:AddTag("goodbye") inst:AddTag("flowering") end end if data and data.flowering then local flower = SpawnPrefab("flint") flower.AnimState:SetBank("flowers") flower.AnimState:SetBuild("flowers") flower.animname = names[math.random(#names)] flower.AnimState:PlayAnimation(flower.animname) flower.AnimState:SetRayTestOnBB(true) flower.Transform:SetScale(1.5, 1.5, 1.5) flower.Physics:SetActive(false) local follower = flower.entity:AddFollower() follower:FollowSymbol( inst.GUID, "swap_object", 0, -50, 0 ) flower:RemoveComponent("edible") flower:RemoveComponent("tradable") flower:RemoveComponent("stackable") flower:RemoveComponent("inventoryitem") flower:RemoveComponent("bait") flower:RemoveTag("molebait") flower:AddComponent("sanityaura") flower.components.sanityaura.aura = TUNING.SANITYAURA_SMALL flower:AddComponent("pickable") flower.components.pickable.picksound = "dontstarve/wilson/pickup_plants" flower.components.pickable:SetUp("petals", 0.1) flower.components.pickable.onpickedfn = function(flower) flower:Remove() flower = nil inst:RemoveTag("flowering") end flower:AddTag("newflower") flower:AddTag("goodbye") inst:AddTag("flowering") end end inst.OnSave = onsave inst.OnLoad = onload 即可用燧石种迷你花坛,在花坛中放入1个种子(拿着种子对花坛点鼠标左键),可开一朵花,品种随机。鼠标左键点花朵,可摘花(获得花瓣)。当花坛中有花时,靠近可以补脑,并且每晚都会招来萤火虫(天亮时消失),尽情捕捉吧。如果同时修改了“网上宠宠店”,就可以将抓到的萤火虫在线卖掉换黄金。不想要迷你花坛时,用锤子砸掉即可

2025/04/23 · Bny

YN249-橡树盆栽(用化肥种橡树盆栽,每天掉落橡果,靠近可补脑,鼠标左键点击树叶可变色)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二四九.橡树盆栽(用化肥种橡树盆栽,每天掉落橡果,靠近可补脑,鼠标左键点击树叶可变色) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/fertilizer.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function createoak(inst) local pt = inst:GetPosition() local oak = SpawnPrefab("fertilizer") oak.Transform:SetPosition(pt.x, pt.y, pt.z) oak.AnimState:SetBank("fertilizer") oak.AnimState:SetBuild("fertilizer") oak.AnimState:PlayAnimation("idle") oak.Transform:SetScale(1.2, 1.2, 1.2) oak:RemoveComponent("inventoryitem") oak:RemoveComponent("finiteuses") oak:RemoveComponent("fertilizer") oak:RemoveComponent("smotherer") oak:RemoveComponent("deployable") oak:AddTag("NOCLICK") oak:ListenForEvent( "daytime", function() local pos = Vector3(oak.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 2) for k,v in pairs(ents) do if v.components.inventoryitem and not v.components.inventoryitem:IsHeld() then if v.prefab == "acorn" then v:Remove() end end end oak:DoTaskInTime(0.3, function(oak) oak:StartThread(function() for k = 1,math.random(3,6) do local pt1 = oak:GetPosition() local acorn = SpawnPrefab("acorn") acorn.Transform:SetPosition(pt1.x+(math.random(2)-math.random(2)), 5, pt1.z+(math.random(2)-math.random(2))) Sleep(0.3) end end ) end ) end , GetWorld() ) oak:AddTag("oak") oak.tree = SpawnPrefab("fertilizer") oak.tree.AnimState:SetBank("tree_leaf") oak.tree.AnimState:SetBuild("tree_leaf_trunk_build") local names = {"tree_leaf_green_build","tree_leaf_red_build","tree_leaf_orange_build","tree_leaf_yellow_build"} local name = names[math.random(#names)] oak.tree.AnimState:OverrideSymbol("swap_leaves", name, "swap_leaves") oak.tree.AnimState:PlayAnimation("idle_tall") oak.tree.Transform:SetScale(0.8, 0.8, 0.8) oak.tree.Physics:SetActive(false) oak.tree:RemoveComponent("inventoryitem") oak.tree:RemoveComponent("finiteuses") oak.tree:RemoveComponent("fertilizer") oak.tree:RemoveComponent("smotherer") oak.tree:RemoveComponent("deployable") local follower = oak.tree.entity:AddFollower() follower:FollowSymbol( oak.GUID, "swap_object", -1, -115, 0 ) oak.tree:AddComponent("sanityaura") oak.tree.components.sanityaura.aura = TUNING.SANITYAURA_MED oak.tree:AddComponent("workable") oak.tree.components.workable:SetWorkAction(ACTIONS.CHOP) oak.tree.components.workable:SetWorkLeft(1) oak.tree.components.workable:SetOnFinishCallback(function() SpawnPrefab("collapse_big").Transform:SetPosition(oak.tree.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") local pos = Vector3(oak.tree.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 1) for k,v in pairs(ents) do if v:HasTag("oak") then v:Remove() end end oak.tree:Remove() end ) oak.tree.components.inspectable.getstatus = function() local names = {"tree_leaf_green_build","tree_leaf_red_build","tree_leaf_orange_build","tree_leaf_yellow_build"} local name = names[math.random(#names)] oak.tree.AnimState:OverrideSymbol("swap_leaves", name, "swap_leaves") end oak.tree:AddTag("goodbye") end local function OnDeploy (inst, pt) createoak(inst) inst:Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("goodbye") then data.goodbye = true end if inst:HasTag("oak") then data.oak = true end end local function onload(inst, data) if data and data.goodbye then inst:Remove() end if data and data.oak then createoak(inst) inst:Remove() end end inst.OnSave = onsave inst.OnLoad = onload 即可用化肥种橡树盆栽,四季常青,每天清晨掉落橡果,靠近可补脑。鼠标左键点橡树,可改变树叶的颜色。不想要橡树盆栽了,用斧子砍掉即可。化肥在种植选项(画着胡萝卜)下,用3个便便、2个硬骨头、4个木头制造

2025/04/23 · Bny