[分享]饥荒联机版,支持局域网联机。

YN252-鲜果龙树(用蝙蝠棒种龙树,每天掉落水果,可上树)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二五二.鲜果龙树(用蝙蝠棒种龙树,每天掉落水果,可上树) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/batbat.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local colours= 7{ 8 {198/255,43/255,43/255}, 9 {0/255,255/255,0/255}, 10 {0/255,0/255,255/255}, 11 {255/255,255/255,0/255}, 12 {109/255,50/255,163/255}, 13 {255/255,0/255,0/255}, 14 {255/255,255/255,255/255}, 15} 16local function createtree(inst) 17 local pt = inst:GetPosition() 18 local phantom = SpawnPrefab("batbat") 19 phantom.Transform:SetPosition(pt.x, pt.y, pt.z) 20 phantom.AnimState:SetBank("firepit") 21 phantom.AnimState:SetBuild("firepit") 22 phantom.AnimState:PlayAnimation("idle",false) 23 phantom.Transform:SetScale(0.8, 0.8, 0.8) 24 phantom:RemoveComponent("weapon") 25 phantom:RemoveComponent("finiteuses") 26 phantom:RemoveComponent("inventoryitem") 27 phantom:RemoveComponent("equippable") 28 phantom:RemoveComponent("deployable") 29 phantom:RemoveTag("dull") 30 phantom:AddTag("NOCLICK") 31 local light = phantom.entity:AddLight() 32 phantom.Light:SetFalloff(0.6) 33 phantom.Light:SetIntensity(.8) 34 phantom.Light:SetRadius(5) 35 phantom.colour_idx = math.random(#colours) 36 phantom.Light:SetColour(colours[phantom.colour_idx][1],colours[phantom.colour_idx][2],colours[phantom.colour_idx][3]) 37 phantom.Light:Enable(true) 38 phantom:DoPeriodicTask(15, function() 39 phantom.colour_idx = math.random(#colours) 40 phantom.Light:SetColour(colours[phantom.colour_idx][1],colours[phantom.colour_idx][2],colours[phantom.colour_idx][3]) 41 end ) 42 phantom:ListenForEvent( "daytime", function() 43 local pos = Vector3(phantom.Transform:GetWorldPosition()) 44 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 5) 45 for k,v in pairs(ents) do 46 if v.components.inventoryitem and not v.components.inventoryitem:IsHeld() then 47 if v.prefab == "durian" or v.prefab == "pomegranate" or v.prefab == "dragonfruit" then 48 v:Remove() 49 end 50 end 51 end 52 phantom:DoTaskInTime(0.3, function(phantom) 53 phantom:StartThread(function() 54 for k = 1,math.random(3,7) do 55 local pt1 = phantom:GetPosition() 56 local names = {"durian","pomegranate","dragonfruit"} 57 local name = names[math.random(#names)] 58 local fruit = SpawnPrefab(name) 59 fruit.Transform:SetPosition(pt1.x+(math.random(5)-math.random(5)), 5, pt1.z+(math.random(5)-math.random(5))) 60 Sleep(0.3) 61 end 62 end ) 63 end ) 64 end , GetWorld() ) 65 phantom:AddTag("phantom") 66 phantom.long = SpawnPrefab("batbat") 67 phantom.long.AnimState:SetBank("worm") 68 phantom.long.AnimState:SetBuild("worm") 69 phantom.long.AnimState:SetPercent("atk", 0.40) 70 phantom.long.Transform:SetScale(1.5, 1.5, 1.5) 71 phantom.long.Physics:SetActive(false) 72 phantom.long:RemoveComponent("weapon") 73 phantom.long:RemoveComponent("finiteuses") 74 phantom.long:RemoveComponent("inventoryitem") 75 phantom.long:RemoveComponent("equippable") 76 phantom.long:RemoveComponent("deployable") 77 phantom.long:RemoveTag("dull") 78 local follower = phantom.long.entity:AddFollower() 79 follower:FollowSymbol( phantom.GUID, "swap_object", 10, -90, 0 ) 80 phantom.long.components.inspectable.getstatus = function() 81 if not GetPlayer():HasTag("climbtree") then 82 GetPlayer():AddTag("climbtree") 83 GetPlayer().components.playercontroller:Enable(false) 84 local pt0 = phantom:GetPosition() 85 GetPlayer().Transform:SetPosition(pt0.x, 10.2, pt0.z) 86 GetPlayer():DoTaskInTime(5, function() 87 GetPlayer().Transform:SetPosition(pt0.x, 0, pt0.z) 88 GetPlayer():RemoveTag("climbtree") 89 GetPlayer().components.playercontroller:Enable(true) 90 end ) 91 end 92 end 93 phantom.long:AddTag("lightningrod") 94 phantom.long:ListenForEvent("lightningstrike", function() 95 phantom.long.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" ) 96 phantom.long:DoTaskInTime(60, function() 97 phantom.long.AnimState:SetBloomEffectHandle("") 98 end ) 99 end ) 100 phantom.long:AddComponent("sanityaura") 101 phantom.long.components.sanityaura.aura = TUNING.SANITYAURA_MED 102 phantom.long:AddTag("goodbye") 103 phantom.guo1 = SpawnPrefab("batbat") 104 phantom.guo1.AnimState:SetBank("durian") 105 phantom.guo1.AnimState:SetBuild("durian") 106 phantom.guo1.AnimState:PlayAnimation("idle") 107 phantom.guo1.Transform:SetScale(1.5, 1.5, 1.5) 108 phantom.guo1.Physics:SetActive(false) 109 phantom.guo1:RemoveComponent("weapon") 110 phantom.guo1:RemoveComponent("finiteuses") 111 phantom.guo1:RemoveComponent("inventoryitem") 112 phantom.guo1:RemoveComponent("equippable") 113 phantom.guo1:RemoveComponent("deployable") 114 phantom.guo1:RemoveTag("dull") 115 local follower = phantom.guo1.entity:AddFollower() 116 follower:FollowSymbol( phantom.GUID, "swap_object", -550, -580, 0 ) 117 phantom.guo1:AddTag("NOCLICK") 118 phantom.guo1:AddTag("goodbye") 119 phantom.guo2 = SpawnPrefab("batbat") 120 phantom.guo2.AnimState:SetBank("pomegranate") 121 phantom.guo2.AnimState:SetBuild("pomegranate") 122 phantom.guo2.AnimState:PlayAnimation("idle") 123 phantom.guo2.Transform:SetScale(1.5, 1.5, 1.5) 124 phantom.guo2.Physics:SetActive(false) 125 phantom.guo2:RemoveComponent("weapon") 126 phantom.guo2:RemoveComponent("finiteuses") 127 phantom.guo2:RemoveComponent("inventoryitem") 128 phantom.guo2:RemoveComponent("equippable") 129 phantom.guo2:RemoveComponent("deployable") 130 phantom.guo2:RemoveTag("dull") 131 local follower = phantom.guo2.entity:AddFollower() 132 follower:FollowSymbol( phantom.GUID, "swap_object", 610, -690, 0 ) 133 phantom.guo2:AddTag("NOCLICK") 134 phantom.guo2:AddTag("goodbye") 135 phantom.guo3 = SpawnPrefab("batbat") 136 phantom.guo3.AnimState:SetBank("dragonfruit") 137 phantom.guo3.AnimState:SetBuild("dragonfruit") 138 phantom.guo3.AnimState:PlayAnimation("idle") 139 phantom.guo3.Transform:SetScale(1.5, 1.5, 1.5) 140 phantom.guo3.Physics:SetActive(false) 141 phantom.guo3:RemoveComponent("weapon") 142 phantom.guo3:RemoveComponent("finiteuses") 143 phantom.guo3:RemoveComponent("inventoryitem") 144 phantom.guo3:RemoveComponent("equippable") 145 phantom.guo3:RemoveComponent("deployable") 146 phantom.guo3:RemoveTag("dull") 147 local follower = phantom.guo3.entity:AddFollower() 148 follower:FollowSymbol( phantom.GUID, "swap_object", -290, -1385, 0 ) 149 phantom.guo3:AddTag("NOCLICK") 150 phantom.guo3:AddTag("goodbye") 151end 152local function OnDeploy (inst, pt) 153 createtree(inst) 154 inst:Remove() 155end 156 inst:AddComponent("deployable") 157 inst.components.deployable.ondeploy = OnDeploy 158local function onsave(inst, data) 159 if inst:HasTag("goodbye") then 160 data.goodbye = true 161 end 162 if inst:HasTag("phantom") then 163 data.phantom = true 164 end 165end 166local function onload(inst, data) 167 if data and data.goodbye then 168 inst:Remove() 169 end 170 if data and data.phantom then 171 createtree(inst) 172 inst:Remove() 173 end 174end 175 inst.OnSave = onsave 176 inst.OnLoad = onload 177MakeLargeBurnable(inst) 178MakeLargePropagator(inst) 179 180 即可用蝙蝠棒种龙树,靠近可补脑,每天会掉落各种水果。龙树可吸收闪电,起到避雷针的作用。鼠标左键点龙树,会爬上树顶眺望风景,5秒后滑下。龙树会不断变化七彩光,夜晚可照明。不想要龙树时,烧掉即可。蝙蝠棒在魔法选项(画着红骷髅)下,用5个蝙蝠翅膀、2个活木头、1个紫宝石制造

2025/04/23 · Bny

YN253-小病小灾(主角会感冒、食物中毒,吃曼德拉草可痊愈)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二五三.小病小灾(主角会感冒、食物中毒,吃曼德拉草可痊愈) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("eater")的下一行插入以下内容: 5 6local function OnEat(inst, food) 7 if food and food.prefab ~= "mandrake" then 8 if math.random()<0.1 then 9 if not inst:HasTag("poisoning") and not inst:HasTag("fever") then 10 inst:AddTag("poisoning") 11 inst.AnimState:SetMultColour(0/255,255/255,0/255,1) 12 inst.components.health:DoDelta(-inst.components.health.maxhealth*.2) 13 inst.components.sanity:DoDelta(-inst.components.sanity.max*.5) 14 inst.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED*.3 15 inst.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED*.3 16 inst.components.combat:SetAttackPeriod(TUNING.WILSON_ATTACK_PERIOD*5) 17 inst.poison = inst:DoPeriodicTask(10, function() 18 inst.components.hunger:DoDelta(-20) 19 inst.components.locomotor:Stop() 20 inst.AnimState:PlayAnimation("pickup") 21 SpawnPrefab("poop").Transform:SetPosition(inst.Transform:GetWorldPosition()) 22 end ) 23 end 24 end 25 end 26 if food.prefab == "mandrake" then 27 if inst:HasTag("poisoning") then inst:RemoveTag("poisoning") end 28 if inst:HasTag("fever") then inst:RemoveTag("fever") end 29 if inst.poison then inst.poison:Cancel() inst.poison = nil end 30 if inst.fever then inst.fever:Cancel() inst.fever = nil end 31 inst.AnimState:SetMultColour(255/255,255/255,255/255,1) 32 inst.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED 33 inst.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED 34 inst.components.combat:SetAttackPeriod(TUNING.WILSON_ATTACK_PERIOD) 35 end 36end 37 inst.components.eater:SetOnEatFn(OnEat) 38local function OnDay(inst) 39 if inst:HasTag("poisoning") then 40 inst:RemoveTag("poisoning") 41 inst.AnimState:SetMultColour(255/255,255/255,255/255,1) 42 inst.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED 43 inst.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED 44 inst.components.combat:SetAttackPeriod(TUNING.WILSON_ATTACK_PERIOD) 45 if inst.poison then inst.poison:Cancel() inst.poison = nil end 46 end 47 if not inst:HasTag("fever") then 48 if math.random()<0.1 then 49 inst:AddTag("fever") 50 inst.AnimState:SetMultColour(255/255,0/255,0/255,1) 51 inst.components.sanity:DoDelta(-inst.components.sanity.max*.5) 52 inst.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED*.3 53 inst.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED*.3 54 inst.components.combat:SetAttackPeriod(TUNING.WILSON_ATTACK_PERIOD*5) 55 inst.fever = inst:DoPeriodicTask(15, function() 56 inst.components.health:DoDelta(-inst.components.health.maxhealth*.05) 57 inst.components.locomotor:Stop() 58 inst.AnimState:PlayAnimation("idle_shiver_pre") 59 inst.AnimState:PushAnimation("idle_shiver_loop") 60 inst.AnimState:PushAnimation("idle_shiver_pst", false) 61 end ) 62 end 63 else 64 inst:RemoveTag("fever") 65 inst.AnimState:SetMultColour(255/255,255/255,255/255,1) 66 inst.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED 67 inst.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED 68 inst.components.combat:SetAttackPeriod(TUNING.WILSON_ATTACK_PERIOD) 69 if inst.fever then inst.fever:Cancel() inst.fever = nil end 70 end 71end 72 inst:ListenForEvent( "daytime", function() OnDay(inst) end, GetWorld()) 73 74 即可让游戏有更加真实的体验,主角会感冒,浑身因发烧而呈红色,行动迟缓,生命值不断下降,如不注意补血,则有生命危险。另外,在吃食物时,也有一定概率发生食物中毒,浑身呈绿色,行动迟缓,且不断出现腹泻,饥饿值下降速度加快。无论感冒还是食物中毒,只要你抗过一天,基本都能痊愈,如果服用曼德拉草,则可立即痊愈。如果修改了“小诊所”,也可以给护士5个黄金治疗疾病。不要与“伍迪吃疯肉立即变海狸且随身物品不掉落”一同修改

2025/04/23 · Bny

YN254-噩梦草(用鸟粪种噩梦草,可采噩梦燃料,有一定概率出现地下巨人)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二五四.噩梦草(用鸟粪种噩梦草,可采噩梦燃料,有一定概率出现地下巨人) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/guano.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local items = { SWORD = "swap_ham_bat" } 7local function EquipItem(inst, item) 8 if item then 9 inst.AnimState:OverrideSymbol("swap_object", item, item) 10 inst.AnimState:Show("ARM_carry") 11 inst.AnimState:Hide("ARM_normal") 12 end 13end 14 inst.items = items 15 inst.equipfn = EquipItem 16 EquipItem(inst) 17local function OnDeploy (inst, pt) 18 local darkgrass = SpawnPrefab("guano") 19 darkgrass.Transform:SetPosition(pt.x, pt.y, pt.z) 20 darkgrass.AnimState:SetBank("marsh_plant") 21 darkgrass.AnimState:SetBuild("marsh_plant") 22 darkgrass.AnimState:PlayAnimation("idle") 23 darkgrass.Transform:SetScale(1.8, 1.8, 1.8) 24 darkgrass.AnimState:SetMultColour(255/255,255/255,0/255,1) 25 darkgrass:RemoveComponent("stackable") 26 darkgrass:RemoveComponent("inventoryitem") 27 darkgrass:RemoveComponent("fertilizer") 28 darkgrass:RemoveComponent("smotherer") 29 darkgrass:RemoveComponent("fuel") 30 darkgrass:RemoveComponent("burnable") 31 darkgrass:RemoveComponent("propagator") 32 darkgrass:RemoveComponent("deployable") 33 MakeMediumBurnable(darkgrass) 34 MakeSmallPropagator(darkgrass) 35 if darkgrass.flies then darkgrass.flies:Remove() darkgrass.flies = nil end 36 darkgrass:AddComponent("workable") 37 darkgrass.components.workable:SetWorkAction(ACTIONS.DIG) 38 darkgrass.components.workable:SetWorkLeft(1) 39 darkgrass.components.workable:SetOnFinishCallback(function(darkgrass) 40 SpawnPrefab("nightmarefuel").Transform:SetPosition(darkgrass.Transform:GetWorldPosition()) 41 darkgrass:Remove() 42 end ) 43 darkgrass:AddComponent("pickable") 44 darkgrass.components.pickable:SetUp("nightmarefuel", 480) 45 darkgrass.components.pickable:SetOnRegenFn(function(darkgrass) darkgrass.AnimState:SetMultColour(255/255,255/255,0/255,1) end ) 46 darkgrass.components.pickable:SetOnPickedFn(function(darkgrass) 47 darkgrass.AnimState:SetMultColour(255/255,255/255,255/255,1) 48 if math.random()<0.05 then 49 GetPlayer().components.playercontroller:ShakeCamera(darkgrass, "FULL", 1.5, 0.03, 2, 30) 50 GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 51 SpawnPrefab("collapse_big").Transform:SetPosition(darkgrass.Transform:GetWorldPosition()) 52 local giant = SpawnPrefab("guano") 53 giant.Transform:SetPosition(darkgrass.Transform:GetWorldPosition()) 54 giant.entity:AddSoundEmitter() 55 giant.AnimState:SetBank("wilson") 56 giant.AnimState:SetBuild("wolfgang") 57 giant.AnimState:PlayAnimation("idle") 58 giant.AnimState:OverrideSymbol("swap_object", "swap_ham_bat", "swap_ham_bat") 59 giant.AnimState:OverrideSymbol("swap_body", "armor_slurper", "swap_body") 60 giant.AnimState:Show("ARM_carry") 61 giant.AnimState:Hide("ARM_normal") 62 giant.Transform:SetFourFaced() 63 giant.Transform:SetScale(3.5,3.5,3.5) 64 local sound = giant.entity:AddSoundEmitter() 65 local shadow = giant.entity:AddDynamicShadow() 66 shadow:SetSize( 6, 3.5 ) 67 MakeCharacterPhysics(giant, 200, 1) 68 local minimap = giant.entity:AddMiniMapEntity() 69 minimap:SetIcon("wolfgang.png") 70 local brain = require "brains/leifbrain" 71 giant:SetBrain(brain) 72 giant:AddComponent("locomotor") 73 giant.components.locomotor.walkspeed = 1 74 giant.components.locomotor.runspeed = 2 75 giant:SetStateGraph("SGshadowwaxwell") 76 giant:RemoveComponent("stackable") 77 giant:RemoveComponent("inventoryitem") 78 giant:RemoveComponent("fertilizer") 79 giant:RemoveComponent("smotherer") 80 giant:RemoveComponent("fuel") 81 giant:RemoveComponent("burnable") 82 giant:RemoveComponent("propagator") 83 giant:RemoveComponent("deployable") 84 if giant.flies then giant.flies:Remove() giant.flies = nil end 85 giant:AddComponent("follower") 86 giant:AddComponent("inventory") 87 giant:AddComponent("combat") 88 giant.components.combat.hiteffectsymbol = "torso" 89 giant.components.combat:SetDefaultDamage(70) 90 giant.components.combat:SetAttackPeriod(3) 91 giant.components.combat.onhitotherfn = function() 92 giant.SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 93 GetPlayer().components.playercontroller:ShakeCamera(giant, "FULL", 0.5, 0.05, 2, 40) 94 end 95 giant.components.combat:SetAreaDamage(5, 0.8) 96 giant.components.combat:SetRetargetFunction(3, function(giant) 97 if not giant.components.health:IsDead() then 98 return FindEntity(giant, 20, function(guy) 99 return giant.components.combat:CanTarget(guy) and not guy:HasTag("giant") 100 end ) 101 end 102 end ) 103 giant:ListenForEvent("attacked", function(giant, data) 104 giant.components.combat:SetTarget(data.attacker) 105 end ) 106 giant.Physics:SetCollisionCallback(function(giant, other) 107 if other and other.components.workable and other.components.workable.workleft > 0 then 108 other.components.workable:Destroy(giant) 109 end 110 end ) 111 giant:AddComponent("health") 112 giant.components.health:SetMaxHealth(8000) 113 giant.components.health.nofadeout = true 114 giant:AddComponent("sanityaura") 115 giant.components.sanityaura.aura = -TUNING.SANITYAURA_LARGE 116 giant:ListenForEvent("death", function() 117 local pt1 = giant:GetPosition() 118 for k = 1,math.random(20,35) do 119 local gold = SpawnPrefab("goldnugget") 120 gold.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) 121 end 122 local rewards = {"walrus_tusk","trunk_summer","trunk_winter","deerclops_eyeball","minotaurhorn"} 123 local reward = rewards[math.random(#rewards)] 124 SpawnPrefab(reward).Transform:SetPosition(pt1.x, 0, pt1.z) 125 end ) 126 giant:DoTaskInTime(480, function(giant) 127 giant:Remove() 128 end ) 129 giant:AddTag("monster") 130 giant:AddTag("giant") 131 end 132 end ) 133 darkgrass:AddTag("darkgrass") 134 inst.components.stackable:Get():Remove() 135end 136 inst:AddComponent("deployable") 137 inst.components.deployable.ondeploy = OnDeploy 138local function onsave(inst, data) 139 if inst:HasTag("darkgrass") then 140 data.darkgrass = true 141 end 142 if inst:HasTag("giant") then 143 data.giant = true 144 end 145end 146local function onload(inst, data) 147 if data and data.darkgrass then 148 inst.AnimState:SetBank("marsh_plant") 149 inst.AnimState:SetBuild("marsh_plant") 150 inst.AnimState:PlayAnimation("idle") 151 inst.Transform:SetScale(1.8, 1.8, 1.8) 152 inst.AnimState:SetMultColour(255/255,255/255,0/255,1) 153 inst:RemoveComponent("stackable") 154 inst:RemoveComponent("inventoryitem") 155 inst:RemoveComponent("fertilizer") 156 inst:RemoveComponent("smotherer") 157 inst:RemoveComponent("fuel") 158 inst:RemoveComponent("burnable") 159 inst:RemoveComponent("propagator") 160 inst:RemoveComponent("deployable") 161 MakeMediumBurnable(inst) 162 MakeSmallPropagator(inst) 163 if inst.flies then inst.flies:Remove() inst.flies = nil end 164 inst:AddComponent("workable") 165 inst.components.workable:SetWorkAction(ACTIONS.DIG) 166 inst.components.workable:SetWorkLeft(1) 167 inst.components.workable:SetOnFinishCallback(function(inst) 168 SpawnPrefab("nightmarefuel").Transform:SetPosition(inst.Transform:GetWorldPosition()) 169 inst:Remove() 170 end ) 171 inst:AddComponent("pickable") 172 inst.components.pickable:SetUp("nightmarefuel", 480) 173 inst.components.pickable:SetOnRegenFn(function(inst) inst.AnimState:SetMultColour(255/255,255/255,0/255,1) end ) 174 inst.components.pickable:SetOnPickedFn(function(inst) 175 inst.AnimState:SetMultColour(255/255,255/255,255/255,1) 176 if math.random()<0.05 then 177 GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 1.5, 0.03, 2, 30) 178 GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 179 SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) 180 local giant = SpawnPrefab("guano") 181 giant.Transform:SetPosition(inst.Transform:GetWorldPosition()) 182 giant.entity:AddSoundEmitter() 183 giant.AnimState:SetBank("wilson") 184 giant.AnimState:SetBuild("wolfgang") 185 giant.AnimState:PlayAnimation("idle") 186 giant.AnimState:OverrideSymbol("swap_object", "swap_ham_bat", "swap_ham_bat") 187 giant.AnimState:OverrideSymbol("swap_body", "armor_slurper", "swap_body") 188 giant.AnimState:Show("ARM_carry") 189 giant.AnimState:Hide("ARM_normal") 190 giant.Transform:SetFourFaced() 191 giant.Transform:SetScale(3.5,3.5,3.5) 192 local sound = giant.entity:AddSoundEmitter() 193 local shadow = giant.entity:AddDynamicShadow() 194 shadow:SetSize( 6, 3.5 ) 195 MakeCharacterPhysics(giant, 200, 1) 196 local minimap = giant.entity:AddMiniMapEntity() 197 minimap:SetIcon("wolfgang.png") 198 local brain = require "brains/leifbrain" 199 giant:SetBrain(brain) 200 giant:AddComponent("locomotor") 201 giant.components.locomotor.walkspeed = 1 202 giant.components.locomotor.runspeed = 2 203 giant:SetStateGraph("SGshadowwaxwell") 204 giant:RemoveComponent("stackable") 205 giant:RemoveComponent("inventoryitem") 206 giant:RemoveComponent("fertilizer") 207 giant:RemoveComponent("smotherer") 208 giant:RemoveComponent("fuel") 209 giant:RemoveComponent("burnable") 210 giant:RemoveComponent("propagator") 211 giant:RemoveComponent("deployable") 212 if giant.flies then giant.flies:Remove() giant.flies = nil end 213 giant:AddComponent("follower") 214 giant:AddComponent("inventory") 215 giant:AddComponent("combat") 216 giant.components.combat.hiteffectsymbol = "torso" 217 giant.components.combat:SetDefaultDamage(70) 218 giant.components.combat:SetAttackPeriod(3) 219 giant.components.combat.onhitotherfn = function() 220 giant.SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 221 GetPlayer().components.playercontroller:ShakeCamera(giant, "FULL", 0.5, 0.05, 2, 40) 222 end 223 giant.components.combat:SetAreaDamage(5, 0.8) 224 giant.components.combat:SetRetargetFunction(3, function(giant) 225 if not giant.components.health:IsDead() then 226 return FindEntity(giant, 20, function(guy) 227 return giant.components.combat:CanTarget(guy) and not guy:HasTag("giant") 228 end ) 229 end 230 end ) 231 giant:ListenForEvent("attacked", function(giant, data) 232 giant.components.combat:SetTarget(data.attacker) 233 end ) 234 giant.Physics:SetCollisionCallback(function(giant, other) 235 if other and other.components.workable and other.components.workable.workleft > 0 then 236 other.components.workable:Destroy(giant) 237 end 238 end ) 239 giant:AddComponent("health") 240 giant.components.health:SetMaxHealth(8000) 241 giant.components.health.nofadeout = true 242 giant:AddComponent("sanityaura") 243 giant.components.sanityaura.aura = -TUNING.SANITYAURA_LARGE 244 giant:ListenForEvent("death", function() 245 local pt1 = giant:GetPosition() 246 for k = 1,math.random(20,35) do 247 local gold = SpawnPrefab("goldnugget") 248 gold.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) 249 end 250 local rewards = {"walrus_tusk","trunk_summer","trunk_winter","deerclops_eyeball","minotaurhorn"} 251 local reward = rewards[math.random(#rewards)] 252 SpawnPrefab(reward).Transform:SetPosition(pt1.x, 0, pt1.z) 253 end ) 254 giant:DoTaskInTime(480, function(giant) 255 giant:Remove() 256 end ) 257 giant:AddTag("monster") 258 giant:AddTag("giant") 259 end 260 end ) 261 inst:AddTag("darkgrass") 262 end 263 if data and data.giant then 264 inst.entity:AddSoundEmitter() 265 inst.AnimState:SetBank("wilson") 266 inst.AnimState:SetBuild("wolfgang") 267 inst.AnimState:PlayAnimation("idle") 268 inst.AnimState:OverrideSymbol("swap_object", "swap_ham_bat", "swap_ham_bat") 269 inst.AnimState:OverrideSymbol("swap_body", "armor_slurper", "swap_body") 270 inst.AnimState:Show("ARM_carry") 271 inst.AnimState:Hide("ARM_normal") 272 inst.Transform:SetFourFaced() 273 inst.Transform:SetScale(3.5,3.5,3.5) 274 local sound = inst.entity:AddSoundEmitter() 275 local shadow = inst.entity:AddDynamicShadow() 276 shadow:SetSize( 6, 3.5 ) 277 MakeCharacterPhysics(inst, 200, 1) 278 local minimap = inst.entity:AddMiniMapEntity() 279 minimap:SetIcon("wolfgang.png") 280 local brain = require "brains/leifbrain" 281 inst:SetBrain(brain) 282 inst:AddComponent("locomotor") 283 inst.components.locomotor.walkspeed = 1 284 inst.components.locomotor.runspeed = 2 285 inst:SetStateGraph("SGshadowwaxwell") 286 inst:RemoveComponent("stackable") 287 inst:RemoveComponent("inventoryitem") 288 inst:RemoveComponent("fertilizer") 289 inst:RemoveComponent("smotherer") 290 inst:RemoveComponent("fuel") 291 inst:RemoveComponent("burnable") 292 inst:RemoveComponent("propagator") 293 inst:RemoveComponent("deployable") 294 if inst.flies then inst.flies:Remove() inst.flies = nil end 295 inst:AddComponent("follower") 296 inst:AddComponent("inventory") 297 inst:AddComponent("combat") 298 inst.components.combat.hiteffectsymbol = "torso" 299 inst.components.combat:SetDefaultDamage(70) 300 inst.components.combat:SetAttackPeriod(3) 301 inst.components.combat.onhitotherfn = function() 302 inst.SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 303 GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.5, 0.05, 2, 40) 304 end 305 inst.components.combat:SetAreaDamage(5, 0.8) 306 inst.components.combat:SetRetargetFunction(3, function(inst) 307 if not inst.components.health:IsDead() then 308 return FindEntity(inst, 20, function(guy) 309 return inst.components.combat:CanTarget(guy) and not guy:HasTag("giant") 310 end ) 311 end 312 end ) 313 inst:ListenForEvent("attacked", function(inst, data) 314 inst.components.combat:SetTarget(data.attacker) 315 end ) 316 inst.Physics:SetCollisionCallback(function(inst, other) 317 if other and other.components.workable and other.components.workable.workleft > 0 then 318 other.components.workable:Destroy(inst) 319 end 320 end ) 321 inst:AddComponent("health") 322 inst.components.health:SetMaxHealth(8000) 323 inst.components.health.nofadeout = true 324 inst:AddComponent("sanityaura") 325 inst.components.sanityaura.aura = -TUNING.SANITYAURA_LARGE 326 inst:ListenForEvent("death", function() 327 local pt1 = inst:GetPosition() 328 for k = 1,math.random(20,35) do 329 local gold = SpawnPrefab("goldnugget") 330 gold.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) 331 end 332 local rewards = {"walrus_tusk","trunk_summer","trunk_winter","deerclops_eyeball","minotaurhorn"} 333 local reward = rewards[math.random(#rewards)] 334 SpawnPrefab(reward).Transform:SetPosition(pt1.x, 0, pt1.z) 335 end ) 336 inst:DoTaskInTime(480, function(inst) 337 inst:Remove() 338 end ) 339 inst:AddTag("monster") 340 inst:AddTag("giant") 341 end 342end 343 inst.OnSave = onsave 344 inst.OnLoad = onload 345 346 即可用鸟粪(白色便便)种噩梦草(请远离基地种植),可采摘噩梦燃料,每天都能采一次。采摘时有一定概率出现地下巨人,将攻击你,消灭巨人可获得黄金、巨鹿眼球、远古守护者角、海象牙等宝物。巨人的血量及攻击力都很强,如果打不过,就先逃跑避避风头,一天后巨人将回到地下。巨人在小地图上显示为大力士的图标,绕着点走吧

2025/04/23 · Bny

YN255-天然温泉(用触手皮种温泉,可恢复生命和脑,可抓鱼)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二五五.天然温泉(用触手皮种温泉,可恢复生命和脑,可抓鱼) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/tentaclespots.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function spa(inst) 7 local pt = inst:GetPosition() 8 local spa = SpawnPrefab("tentaclespots") 9 spa.Transform:SetPosition(pt.x, pt.y, pt.z) 10 spa.AnimState:SetBank("marsh_tile") 11 spa.AnimState:SetBuild("marsh_tile") 12 spa.AnimState:PlayAnimation("idle_cave",true) 13 spa.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround ) 14 spa.AnimState:SetLayer( LAYER_BACKGROUND ) 15 spa.AnimState:SetSortOrder( 3 ) 16 spa.Transform:SetScale(1.5, 1.5, 1.5) 17 spa:RemoveComponent("inventoryitem") 18 spa:RemoveComponent("stackable") 19 spa:RemoveComponent("fuel") 20 spa:RemoveComponent("burnable") 21 spa:RemoveComponent("propagator") 22 spa:RemoveComponent("deployable") 23 if spa.components.edible then spa:RemoveComponent("edible") end 24 spa:AddTag("NOCLICK") 25 spa:AddTag("spa") 26 spa:DoPeriodicTask(math.random(10,20), function(spa) 27 local pt1 = spa:GetPosition() 28 local names = {"fish","eel"} 29 local name = names[math.random(#names)] 30 local fish = SpawnPrefab(name) 31 fish.Transform:SetPosition(pt1.x+(math.random(4)-math.random(4)), 0, pt1.z+(math.random(4)-math.random(4))) 32 SpawnPrefab("splash").Transform:SetPosition(fish.Transform:GetWorldPosition()) 33 spa:DoTaskInTime(0.5, function(spa) 34 local pos = Vector3(spa.Transform:GetWorldPosition()) 35 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 5) 36 for k,v in pairs(ents) do 37 if v.components.inventoryitem and not v.components.inventoryitem:IsHeld() then 38 if v.prefab == "fish" or v.prefab == "eel" then 39 SpawnPrefab("splash").Transform:SetPosition(v.Transform:GetWorldPosition()) 40 v:Remove() 41 end 42 end 43 end 44 end ) 45 end ) 46 spa:DoPeriodicTask(3, function(spa) 47 local pos2 = Vector3(spa.Transform:GetWorldPosition()) 48 local ents = TheSim:FindEntities(pos2.x,pos2.y,pos2.z, 4.8) 49 for k,v in pairs(ents) do 50 if v:HasTag("player") then 51 v.components.health:DoDelta(v.components.health.maxhealth*.02) 52 v.components.sanity:DoDelta(v.components.sanity.max*.02) 53 end 54 end 55 end ) 56 local rock1 = SpawnPrefab("tentaclespots") 57 rock1.Transform:SetPosition(pt.x-3.3-0.5, 0, pt.z-3.3+0.5) 58 rock1.AnimState:SetBank("rock") 59 rock1.AnimState:SetBuild("rock") 60 rock1.AnimState:PlayAnimation("full") 61 rock1.Transform:SetScale(2, 2, 2) 62 rock1:AddTag("sparock") 63 rock1:RemoveComponent("inventoryitem") 64 rock1:RemoveComponent("stackable") 65 rock1:RemoveComponent("fuel") 66 rock1:RemoveComponent("burnable") 67 rock1:RemoveComponent("propagator") 68 rock1:RemoveComponent("deployable") 69 if rock1.components.edible then rock1:RemoveComponent("edible") end 70 rock1:AddComponent("workable") 71 rock1.components.workable:SetWorkAction(ACTIONS.HAMMER) 72 rock1.components.workable:SetWorkLeft(3) 73 rock1.components.workable:SetOnFinishCallback(function(rock1) 74 SpawnPrefab("collapse_big").Transform:SetPosition(rock1.Transform:GetWorldPosition()) 75 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/rock_break") 76 local pos3 = Vector3(rock1.Transform:GetWorldPosition()) 77 local ents = TheSim:FindEntities(pos3.x,pos3.y,pos3.z, 10) 78 for k,v in pairs(ents) do 79 if v:HasTag("spa") then 80 v:Remove() 81 end 82 if v:HasTag("sparock") then 83 v:Remove() 84 end 85 end 86 rock1:Remove() 87 end ) 88 local rock2 = SpawnPrefab("tentaclespots") 89 rock2.Transform:SetPosition(pt.x-2.1-2.8, 0, pt.z-2.1+2.8) 90 rock2.AnimState:SetBank("firepit") 91 rock2.AnimState:SetBuild("firepit") 92 rock2.AnimState:PlayAnimation("idle",false) 93 rock2.Transform:SetScale(0.6, 1, 0.6) 94 rock2:AddTag("sparock") 95 rock2:RemoveComponent("inventoryitem") 96 rock2:RemoveComponent("stackable") 97 rock2:RemoveComponent("fuel") 98 rock2:RemoveComponent("burnable") 99 rock2:RemoveComponent("propagator") 100 rock2:RemoveComponent("deployable") 101 if rock2.components.edible then rock2:RemoveComponent("edible") end 102 rock2:AddComponent("burnable") 103 rock2.components.burnable:SetFXLevel(5) 104 rock2.components.burnable:AddBurnFX("campfirefire", Vector3(0,0.6,0) ) 105 rock2.components.burnable:Ignite(true) 106 rock2:AddComponent("cooker") 107 local rock3 = SpawnPrefab("tentaclespots") 108 rock3.Transform:SetPosition(pt.x+2.1+2.1, 0, pt.z-2.1+2.1) 109 rock3.AnimState:SetBank("flowers") 110 rock3.AnimState:SetBuild("flowers") 111 rock3.AnimState:PlayAnimation("f10") 112 rock3.Transform:SetScale(1.8, 1.8, 1.8) 113 rock3:AddTag("sparock") 114 rock3:RemoveComponent("inventoryitem") 115 rock3:RemoveComponent("stackable") 116 rock3:RemoveComponent("fuel") 117 rock3:RemoveComponent("burnable") 118 rock3:RemoveComponent("propagator") 119 rock3:RemoveComponent("deployable") 120 if rock3.components.edible then rock3:RemoveComponent("edible") end 121end 122local function OnDeploy (inst, pt) 123 spa(inst) 124 inst.components.stackable:Get():Remove() 125end 126 inst:AddComponent("deployable") 127 inst.components.deployable.ondeploy = OnDeploy 128local function onsave(inst, data) 129 if inst:HasTag("spa") then 130 data.spa = true 131 end 132 if inst:HasTag("sparock") then 133 data.sparock = true 134 end 135end 136local function onload(inst, data) 137 if data and data.spa then 138 spa(inst) 139 inst:Remove() 140 end 141 if data and data.sparock then 142 inst:Remove() 143 end 144end 145 inst.OnSave = onsave 146 inst.OnLoad = onload 147 148 即可用触手皮种温泉(拿着1个触手皮对地面点鼠标右键,如果拿着多个触手皮,则不会种出来),站在水里可以取暖,并补充生命值和脑值。温泉里会有鱼跳出水面,按住键盘空格键不放,有机会抓住鱼,在温泉旁的火盆里烤鱼吃吧。不想要温泉时,用锤子砸掉大石头即可

2025/04/23 · Bny

YN256-小冰山(用铥矿碎片种小冰山,靠近可解暑,无限开采冰和永冻冰,吃了能降温)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二五六.小冰山(用铥矿碎片种小冰山,靠近可解暑,无限开采冰和永冻冰,吃了能降温) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/thulecite_pieces.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function makeiceberg(inst) 7 local pt = inst:GetPosition() 8 local iceberg = SpawnPrefab("thulecite_pieces") 9 iceberg.Transform:SetPosition(pt.x, pt.y, pt.z) 10 iceberg.AnimState:SetBank("ice_boulder") 11 iceberg.AnimState:SetBuild("ice_boulder") 12 iceberg.AnimState:PlayAnimation("full") 13 iceberg.Transform:SetScale(2, 2, 2) 14 iceberg:AddComponent("named") 15 iceberg.components.named:SetName("Ice") 16 local minimap = iceberg.entity:AddMiniMapEntity() 17 minimap:SetIcon( "iceboulder.png" ) 18 MakeObstaclePhysics(iceberg, 1) 19 MakeLargeBurnable(iceberg) 20 iceberg.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 21 iceberg.entity:AddLight() 22 iceberg.Light:SetFalloff(1) 23 iceberg.Light:SetIntensity(.8) 24 iceberg.Light:SetRadius(7) 25 iceberg.Light:SetColour(255/255,255/255,255/255) 26 iceberg.Light:Enable(true) 27 iceberg:RemoveComponent("edible") 28 iceberg:RemoveComponent("tradable") 29 iceberg:RemoveComponent("inventoryitem") 30 iceberg:RemoveComponent("stackable") 31 iceberg:RemoveComponent("bait") 32 iceberg:RemoveComponent("repairer") 33 iceberg:RemoveComponent("deployable") 34 iceberg:RemoveTag("molebait") 35 iceberg:AddComponent("heater") 36 iceberg.components.heater.iscooler = true 37 iceberg.components.heater.heatfn = function(iceberg) return -40 end 38 iceberg:AddComponent("workable") 39 iceberg.components.workable:SetWorkAction(ACTIONS.MINE) 40 iceberg.components.workable:SetWorkLeft(30) 41 iceberg.components.workable:SetOnWorkCallback(function(iceberg) 42 iceberg.components.workable:SetWorkLeft(30) 43 local pt1 = iceberg:GetPosition() 44 if math.random()<.2 then 45 local icecream = SpawnPrefab("thulecite_pieces") 46 icecream.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 3, pt1.z+(math.random(3)-math.random(3))) 47 icecream.AnimState:SetBank("ice") 48 icecream.AnimState:SetBuild("ice") 49 icecream.AnimState:PlayAnimation("f1") 50 icecream:RemoveComponent("edible") 51 icecream:RemoveComponent("tradable") 52 icecream:RemoveComponent("stackable") 53 icecream:RemoveComponent("bait") 54 icecream:RemoveComponent("repairer") 55 icecream:RemoveComponent("deployable") 56 icecream:RemoveTag("molebait") 57 icecream:AddComponent("named") 58 icecream.components.named:SetName("Ice") 59 icecream.components.inventoryitem.imagename = "ice" 60 icecream:AddComponent("edible") 61 icecream.components.edible.foodtype = "SEEDS" 62 icecream.components.edible.healthvalue = TUNING.HEALING_TINY/2 63 icecream.components.edible.hungervalue = TUNING.CALORIES_TINY/4 64 icecream.components.edible:SetOnEatenFn(function(icecream, eater) 65 if eater and eater.components.temperature then 66 local temp = eater.components.temperature:GetCurrent() 67 eater.components.temperature:SetTemperature(temp - 70) 68 end 69 end ) 70 icecream.components.edible.degrades_with_spoilage = false 71 icecream:AddTag("icecream") 72 elseif math.random()<.4 then 73 local ice = SpawnPrefab("ice") 74 ice.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 3, pt1.z+(math.random(3)-math.random(3))) 75 end 76 end ) 77 iceberg.components.workable:SetOnFinishCallback(function(iceberg) 78 SpawnPrefab("ground_chunks_breaking").Transform:SetPosition(iceberg.Transform:GetWorldPosition()) 79 iceberg:Remove() 80 end ) 81 iceberg:AddTag("iceberg") 82end 83local function OnDeploy (inst, pt) 84 makeiceberg(inst) 85 inst.components.stackable:Get():Remove() 86end 87 inst:AddComponent("deployable") 88 inst.components.deployable.ondeploy = OnDeploy 89local function onsave(inst, data) 90 if inst:HasTag("iceberg") then 91 data.iceberg = true 92 end 93 if inst:HasTag("icecream") then 94 data.icecream = true 95 end 96end 97local function onload(inst, data) 98 if data and data.iceberg then 99 makeiceberg(inst) 100 inst:Remove() 101 end 102 if data and data.icecream then 103 inst.AnimState:SetBank("ice") 104 inst.AnimState:SetBuild("ice") 105 inst.AnimState:PlayAnimation("f1") 106 inst:RemoveComponent("edible") 107 inst:RemoveComponent("tradable") 108 inst:RemoveComponent("stackable") 109 inst:RemoveComponent("bait") 110 inst:RemoveComponent("repairer") 111 inst:RemoveComponent("deployable") 112 inst:RemoveTag("molebait") 113 inst:AddComponent("named") 114 inst.components.named:SetName("Ice") 115 inst.components.inventoryitem.imagename = "ice" 116 inst:AddComponent("edible") 117 inst.components.edible.foodtype = "SEEDS" 118 inst.components.edible.healthvalue = TUNING.HEALING_TINY/2 119 inst.components.edible.hungervalue = TUNING.CALORIES_TINY/4 120 inst.components.edible:SetOnEatenFn(function(inst, eater) 121 if eater and eater.components.temperature then 122 local temp = eater.components.temperature:GetCurrent() 123 eater.components.temperature:SetTemperature(temp - 70) 124 end 125 end ) 126 inst.components.edible.degrades_with_spoilage = false 127 inst:AddTag("icecream") 128 end 129end 130 inst.OnSave = onsave 131 inst.OnLoad = onload 132 133 即可用铥矿碎片种小冰山(拿着1个铥矿碎片对地面点鼠标右键,如果拿着多个,则不会种出来),靠近可解暑。用锄头凿冰山,有一定概率获得冰和永冻冰(不会腐烂且不可堆叠的是永冻冰),永冻冰可食用,吃了能降温,如果没有中暑就不要吃,否则会冻伤。不想要小冰山了,烧掉即可。不要与“用铥矿碎片种猴子桶”一同修改

2025/04/23 · Bny

YN257-生物克隆机(用夜魔盔甲种克隆机,随身携带,大量克隆各种生物)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二五七.生物克隆机(用夜魔盔甲种克隆机,随身携带,大量克隆各种生物) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/armor_sanity.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function itemtest(inst, item, slot) 7 if item.prefab == "silk" or item.prefab == "houndstooth" or item.prefab == "beefalowool" or item.prefab == "tentaclespots" or item.prefab == "froglegs" or item.prefab == "stinger" or item.prefab == "mosquitosack" or item.prefab == "tallbirdegg" or item.prefab == "walrus_tusk" or item.prefab == "livinglog" or item.prefab == "bird_egg" or item.prefab == "trunk_summer" or item.prefab == "trunk_winter" or item.prefab == "deerclops_eyeball" or item.prefab == "fish" or item.prefab == "plantmeat" or item.prefab == "rocks" or item.prefab == "cave_banana" or item.prefab == "slurper_pelt" or item.prefab == "minotaurhorn" or item.prefab == "wormlight" or item.prefab == "slurtle_shellpieces" or item.prefab == "slurtleslime" or item.prefab == "batwing" or item.prefab == "manrabbit_tail" or item.prefab == "pigskin" or item.prefab == "lightninggoathorn" or item.prefab == "dragon_scales" or item.prefab == "goose_feather" or item.prefab == "bearger_fur" then 8 return true 9 end 10 return false 11end 12local slotpos = { Vector3(0,-75,0)} 13local widgetbuttoninfo = { 14 text = "GO", 15 position = Vector3(0, -135, 0), 16 fn = function(inst) 17 if inst:HasTag("machines") then 18 if not inst.components.container:IsEmpty() then 19 for k,v in pairs(inst.components.container.slots) do 20 if v and v.prefab == "silk" then inst.weirdo = "spiderqueen" end 21 if v and v.prefab == "houndstooth" then inst.weirdo = "firehound" end 22 if v and v.prefab == "beefalowool" then inst.weirdo = "beefalo" end 23 if v and v.prefab == "tentaclespots" then inst.weirdo = "tentacle" end 24 if v and v.prefab == "froglegs" then inst.weirdo = "frog" end 25 if v and v.prefab == "stinger" then inst.weirdo = "killerbee" end 26 if v and v.prefab == "mosquitosack" then inst.weirdo = "mosquito" end 27 if v and v.prefab == "tallbirdegg" then inst.weirdo = "tallbird" end 28 if v and v.prefab == "walrus_tusk" then inst.weirdo = "walrus" end 29 if v and v.prefab == "livinglog" then inst.weirdo = "leif_sparse" end 30 if v and v.prefab == "bird_egg" then inst.weirdo = "perd" end 31 if v and v.prefab == "trunk_summer" then inst.weirdo = "koalefant_summer" end 32 if v and v.prefab == "trunk_winter" then inst.weirdo = "koalefant_winter" end 33 if v and v.prefab == "deerclops_eyeball" then inst.weirdo = "deerclops" end 34 if v and v.prefab == "fish" then inst.weirdo = "merm" end 35 if v and v.prefab == "plantmeat" then inst.weirdo = "lureplant" end 36 if v and v.prefab == "rocks" then inst.weirdo = "rocky" end 37 if v and v.prefab == "cave_banana" then inst.weirdo = "monkey" end 38 if v and v.prefab == "slurper_pelt" then inst.weirdo = "slurper" end 39 if v and v.prefab == "minotaurhorn" then inst.weirdo = "minotaur" end 40 if v and v.prefab == "wormlight" then inst.weirdo = "worm" end 41 if v and v.prefab == "slurtle_shellpieces" then inst.weirdo = "slurtle" end 42 if v and v.prefab == "slurtleslime" then inst.weirdo = "snurtle" end 43 if v and v.prefab == "batwing" then inst.weirdo = "bat" end 44 if v and v.prefab == "manrabbit_tail" then inst.weirdo = "bunnyman" end 45 if v and v.prefab == "pigskin" then inst.weirdo = "pigman" end 46 if v and v.prefab == "lightninggoathorn" then inst.weirdo = "lightninggoat" end 47 if v and v.prefab == "dragon_scales" then inst.weirdo = "dragonfly" end 48 if v and v.prefab == "goose_feather" then inst.weirdo = "moose" end 49 if v and v.prefab == "bearger_fur" then inst.weirdo = "bearger" end 50 v:Remove() 51 end 52 local pt0 = Vector3(GetPlayer().Transform:GetWorldPosition()) 53 for k = 1, 20 do 54 local result_offset = FindValidPositionByFan(1 * 2 * PI, 10, 20, function(offset) 55 local x,y,z = (pt0 + offset):Get() 56 local ents = TheSim:FindEntities(x,y,z , 1) 57 return not next(ents) 58 end) 59 if result_offset then 60 local newweirdo = SpawnPrefab(inst.weirdo) 61 newweirdo.Transform:SetPosition((pt0 + result_offset):Get()) 62 GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) 63 local fx = SpawnPrefab("collapse_small") 64 local pos = pt0 + result_offset 65 fx.Transform:SetPosition(pos.x, pos.y, pos.z) 66 end 67 end 68 end 69 end 70 end } 71local function OnDeploy (inst, pt) 72 local machine = SpawnPrefab("armor_sanity") 73 machine.Transform:SetPosition(pt.x, pt.y, pt.z) 74 machine.AnimState:SetBank("rain_meter") 75 machine.AnimState:SetBuild("rain_meter") 76 machine.AnimState:PlayAnimation("meter", 0) 77 machine.Transform:SetScale(0.5, 0.5, 0.5) 78 machine:RemoveTag("sanity") 79 machine:RemoveComponent("inventoryitem") 80 machine:RemoveComponent("armor") 81 machine:RemoveComponent("equippable") 82 machine:RemoveComponent("deployable") 83 machine.components.container.canbeopened = true 84 machine:AddComponent("inventoryitem") 85 machine.components.inventoryitem:ChangeImageName("rainometer") 86 machine:AddComponent("equippable") 87 machine.components.equippable.equipslot = EQUIPSLOTS.BODY 88 machine.components.equippable.walkspeedmult = TUNING.CANE_SPEED_MULT*2 89 machine.components.equippable:SetOnEquip( function(machine) 90 GetPlayer().components.inventory:SetOverflow(machine) 91 machine.components.container:Open(GetPlayer()) 92 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/backpack_open", "open") 93 GetPlayer():Hide() 94 local shadow = GetPlayer().entity:AddDynamicShadow() 95 shadow:SetSize( 0, 0 ) 96 end ) 97 machine.components.equippable:SetOnUnequip( function(machine) 98 machine.components.container:Close(GetPlayer()) 99 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/backpack_close", "open") 100 GetPlayer():Show() 101 local shadow = GetPlayer().entity:AddDynamicShadow() 102 shadow:SetSize( 1.3, .6 ) 103 end ) 104 machine:AddTag("machines") 105 inst:Remove() 106end 107 inst:AddComponent("deployable") 108 inst.components.deployable.ondeploy = OnDeploy 109local function onsave(inst, data) 110 if inst:HasTag("machines") then 111 data.machines = true 112 end 113end 114local function onload(inst, data) 115 if data and data.machines then 116 inst.AnimState:SetBank("rain_meter") 117 inst.AnimState:SetBuild("rain_meter") 118 inst.AnimState:PlayAnimation("meter", 0) 119 inst.Transform:SetScale(0.5, 0.5, 0.5) 120 inst:RemoveTag("sanity") 121 inst:RemoveComponent("inventoryitem") 122 inst:RemoveComponent("armor") 123 inst:RemoveComponent("equippable") 124 inst:RemoveComponent("deployable") 125 inst.components.container.canbeopened = true 126 inst:AddComponent("inventoryitem") 127 inst.components.inventoryitem:ChangeImageName("rainometer") 128 inst:AddComponent("equippable") 129 inst.components.equippable.equipslot = EQUIPSLOTS.BODY 130 inst.components.equippable.walkspeedmult = TUNING.CANE_SPEED_MULT*2 131 inst.components.equippable:SetOnEquip( function(inst) 132 GetPlayer().components.inventory:SetOverflow(inst) 133 inst.components.container:Open(GetPlayer()) 134 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/backpack_open", "open") 135 GetPlayer():Hide() 136 local shadow = GetPlayer().entity:AddDynamicShadow() 137 shadow:SetSize( 0, 0 ) 138 end ) 139 inst.components.equippable:SetOnUnequip( function(inst) 140 inst.components.container:Close(GetPlayer()) 141 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/backpack_close", "open") 142 GetPlayer():Show() 143 local shadow = GetPlayer().entity:AddDynamicShadow() 144 shadow:SetSize( 1.3, .6 ) 145 end ) 146 inst:AddTag("machines") 147 end 148end 149 inst.OnSave = onsave 150 inst.OnLoad = onload 151 inst:AddComponent("container") 152 inst.components.container:SetNumSlots(#slotpos) 153 inst.components.container.widgetslotpos = slotpos 154 inst.components.container.widgetpos = Vector3(-80,150,0) 155 inst.components.container.side_widget = true 156 inst.components.container.itemtestfn = itemtest 157 inst.components.container.widgetbuttoninfo = widgetbuttoninfo 158 inst.components.container.acceptsstacks = false 159 inst.components.container.canbeopened = false 160 161 即可用夜魔盔甲种克隆机,装备克隆机后主角隐身(以免遭怪物围攻),屏幕右侧会出现格子和按钮,在格子中放入1个生物掉落的物品,按GO按钮,就可以克隆20个该生物,具体为:蜘蛛丝克隆蜘蛛女王、犬牙克隆火狗、牛毛克隆牛、触手皮克隆触手、蛙腿克隆青蛙、蜂刺克隆杀人蜂、蚊子血囊克隆蚊子、高鸟蛋克隆大高鸟、海象牙克隆海象、活木头克隆树精、鸡蛋克隆火鸡、夏象鼻克隆夏象、冬象鼻克隆冬象、巨鹿眼球克隆巨鹿、鱼克隆鱼人、食人花肉克隆食人花、岩石克隆龙虾、香蕉克隆猴子、缀食者皮克隆缀食者、远古守护者角克隆远古守护者、虫子果克隆虫子、蜗牛龟壳片克隆蜗牛龟、蜗牛龟粘液克隆黏糊虫、蝙蝠翅膀克隆蝙蝠、兔人尾巴克隆兔人、猪皮克隆猪人、闪电羊角克隆闪电羊、蜻蜓鳞片克隆蜻蜓、熊皮克隆熊、鹿鸭羽毛克隆鹿鸭。卸载克隆机后主角现身。拥有克隆机,让你有无限的怪物可刷,也可用于以怪制怪,比如在牛群里制造触手,在蜘蛛群里释放杀人蜂等,创造一个生机勃勃的世界吧。夜魔盔甲在魔法选项(画着红骷髅)下用5个噩梦燃料、3张纸制造

2025/04/23 · Bny

YN258-强迫症标尺(按键盘Insert键在地上画坐标,方便建造、种植,再按Insert键消失)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二五八.强迫症标尺(按键盘Insert键在地上画坐标,方便建造、种植,再按Insert键消失) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("playeractionpicker")的下一行插入以下内容: 5 6TheInput:AddKeyUpHandler(KEY_INSERT, function() 7 if not inst:HasTag("ruler") then 8 inst:AddTag("ruler") 9 local pt = inst:GetPosition() 10 for y = 10, 0, -1 do 11 for x = 0, 10 do 12 local coordinate = SpawnPrefab("gridplacer") 13 coordinate.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround ) 14 coordinate.AnimState:SetLayer( LAYER_BACKGROUND ) 15 coordinate.AnimState:SetSortOrder( 1 ) 16 coordinate.Transform:SetRotation( 45 ) 17 coordinate.Transform:SetPosition(pt.x-14.1+x*2.82, 0, pt.z-14.1+y*2.82) 18 local light = coordinate.entity:AddLight() 19 light:SetIntensity(.6) 20 light:SetRadius(.5) 21 light:SetFalloff(.6) 22 light:Enable(true) 23 light:SetColour(180/255, 195/255, 225/255) 24 coordinate:AddTag("NOCLICK") 25 coordinate:AddTag("coordinate") 26 end 27 end 28 else 29 inst:RemoveTag("ruler") 30 local pos = Vector3(inst.Transform:GetWorldPosition()) 31 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) 32 for k,v in pairs(ents) do 33 if v:HasTag("coordinate") then 34 v:Remove() 35 end 36 end 37 end 38end ) 39 40 即可按键盘Insert键,以主角为中心在地上画出白色坐标,可作为建造或种植的参照线,也可测量你现有的建筑、植物是不是歪了,强迫症必备,还有夜光效果哦,再按一次Insert键坐标消失

2025/04/23 · Bny

YN259-制冰机(用草伞种制冰机,下雨时自动制冰,可加工成大冰块永久保存,大冰块可砸碎成冰)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二五九.制冰机(用草伞种制冰机,下雨时自动制冰,可加工成大冰块永久保存,大冰块可砸碎成冰) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/umbrella.lua文件,在inst:AddTag("show_spoilage")的下一行插入以下内容: 5 6local function itemtest(inst, item, slot) 7 if item.prefab == "ice" then 8 return true 9 end 10 return false 11end 12local slotpos = { Vector3(0,-75,0)} 13local widgetbuttoninfo = { 14 text = "Make", 15 position = Vector3(0, -135, 0), 16 fn = function(inst) 17 if inst:HasTag("icemaker") then 18 if inst.components.container:Has("ice", 10) then 19 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/rock_break") 20 inst.components.container:ConsumeByName("ice", 10) 21 local pt = inst:GetPosition() 22 local bigice = SpawnPrefab("grass_umbrella") 23 bigice.Transform:SetPosition(pt.x+(math.random(3)-math.random(3)), 0, pt.z+(math.random(3)-math.random(3))) 24 bigice.AnimState:SetBank("icehat") 25 bigice.AnimState:SetBuild("hat_ice") 26 bigice.AnimState:PlayAnimation("anim") 27 bigice.Transform:SetScale(1.5, 1.5, 1.5) 28 bigice:RemoveComponent("waterproofer") 29 bigice:RemoveComponent("equippable") 30 bigice:RemoveComponent("insulator") 31 bigice:RemoveComponent("perishable") 32 bigice:RemoveComponent("fuel") 33 bigice:RemoveComponent("burnable") 34 bigice:RemoveComponent("propagator") 35 bigice:RemoveComponent("deployable") 36 bigice:RemoveComponent("container") 37 bigice:RemoveTag("nopunch") 38 bigice:RemoveTag("show_spoilage") 39 bigice:RemoveAllEventCallbacks() 40 bigice:AddComponent("named") 41 bigice.components.named:SetName("Big ice") 42 bigice.components.inventoryitem:ChangeImageName("icehat") 43 bigice:AddComponent("heater") 44 bigice.components.heater.iscooler = true 45 bigice.components.heater.heatfn = function(bigice) return -40 end 46 bigice:AddComponent("workable") 47 bigice.components.workable:SetWorkAction(ACTIONS.HAMMER) 48 bigice.components.workable:SetWorkLeft(1) 49 bigice.components.workable:SetOnFinishCallback(function(bigice) 50 SpawnPrefab("ground_chunks_breaking").Transform:SetPosition(bigice.Transform:GetWorldPosition()) 51 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 52 for k = 1, 10 do 53 local pt1 = bigice:GetPosition() 54 local ice = SpawnPrefab("ice") 55 ice.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) 56 end 57 bigice:Remove() 58 end ) 59 bigice:AddTag("bigice") 60 end 61 end 62 end } 63local function OnDeploy (inst, pt) 64 local icemaker = SpawnPrefab("grass_umbrella") 65 icemaker.Transform:SetPosition(pt.x, pt.y, pt.z) 66 icemaker.AnimState:SetBank("eyeball_turret_base") 67 icemaker.AnimState:SetBuild("eyeball_turret_base") 68 icemaker.AnimState:PlayAnimation("idle_loop") 69 icemaker.Transform:SetScale(0.8, 0.8, 0.8) 70 icemaker.AnimState:SetMultColour(0/255,255/255,0/255,1) 71 icemaker:RemoveComponent("waterproofer") 72 icemaker:RemoveComponent("inventoryitem") 73 icemaker:RemoveComponent("equippable") 74 icemaker:RemoveComponent("insulator") 75 icemaker:RemoveComponent("perishable") 76 icemaker:RemoveComponent("fuel") 77 icemaker:RemoveComponent("burnable") 78 icemaker:RemoveComponent("propagator") 79 icemaker:RemoveComponent("deployable") 80 icemaker:RemoveTag("nopunch") 81 icemaker:RemoveTag("show_spoilage") 82 icemaker:RemoveAllEventCallbacks() 83 icemaker:AddComponent("named") 84 icemaker.components.named:SetName("Ice maker") 85 icemaker.components.container.canbeopened = true 86 icemaker:AddComponent("workable") 87 icemaker.components.workable:SetWorkAction(ACTIONS.HAMMER) 88 icemaker.components.workable:SetWorkLeft(3) 89 icemaker.components.workable:SetOnFinishCallback(function(icemaker) 90 SpawnPrefab("collapse_big").Transform:SetPosition(icemaker.Transform:GetWorldPosition()) 91 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 92 icemaker:Remove() 93 end ) 94 icemaker:ListenForEvent("rainstart", function() 95 icemaker.task = icemaker:DoPeriodicTask(10, function() 96 local ice = SpawnPrefab("ice") 97 icemaker.components.container:GiveItem(ice) 98 end ) 99 end, GetWorld()) 100 icemaker:ListenForEvent("rainstop", function() 101 if icemaker.task then icemaker.task:Cancel() icemaker.task = nil end 102 end, GetWorld()) 103 icemaker:AddTag("icemaker") 104 inst:Remove() 105end 106 inst:AddComponent("deployable") 107 inst.components.deployable.ondeploy = OnDeploy 108 inst:AddComponent("container") 109 inst.components.container:SetNumSlots(#slotpos) 110 inst.components.container.widgetslotpos = slotpos 111 inst.components.container.widgetpos = Vector3(0,150,0) 112 inst.components.container.side_align_tip = 160 113 inst.components.container.itemtestfn = itemtest 114 inst.components.container.widgetbuttoninfo = widgetbuttoninfo 115 inst.components.container.canbeopened = false 116 inst.components.container.onopenfn = function(inst) GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") end 117 inst.components.container.onclosefn = function(inst) GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") end 118 inst:AddTag("fridge") 119local function onsave(inst, data) 120 if inst:HasTag("icemaker") then 121 data.icemaker = true 122 end 123 if inst:HasTag("bigice") then 124 data.bigice = true 125 end 126end 127local function onload(inst, data) 128 if data and data.icemaker then 129 inst.AnimState:SetBank("eyeball_turret_base") 130 inst.AnimState:SetBuild("eyeball_turret_base") 131 inst.AnimState:PlayAnimation("idle_loop") 132 inst.Transform:SetScale(0.8, 0.8, 0.8) 133 inst.AnimState:SetMultColour(0/255,255/255,0/255,1) 134 inst:RemoveComponent("waterproofer") 135 inst:RemoveComponent("inventoryitem") 136 inst:RemoveComponent("equippable") 137 inst:RemoveComponent("insulator") 138 inst:RemoveComponent("perishable") 139 inst:RemoveComponent("fuel") 140 inst:RemoveComponent("burnable") 141 inst:RemoveComponent("propagator") 142 inst:RemoveComponent("deployable") 143 inst:RemoveTag("nopunch") 144 inst:RemoveTag("show_spoilage") 145 inst:RemoveAllEventCallbacks() 146 inst:AddComponent("named") 147 inst.components.named:SetName("Ice maker") 148 inst.components.container.canbeopened = true 149 inst:AddComponent("workable") 150 inst.components.workable:SetWorkAction(ACTIONS.HAMMER) 151 inst.components.workable:SetWorkLeft(3) 152 inst.components.workable:SetOnFinishCallback(function(inst) 153 SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) 154 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 155 inst:Remove() 156 end ) 157 inst:ListenForEvent("rainstart", function() 158 inst.task = inst:DoPeriodicTask(10, function() 159 local ice = SpawnPrefab("ice") 160 inst.components.container:GiveItem(ice) 161 end ) 162 end, GetWorld()) 163 inst:ListenForEvent("rainstop", function() 164 if inst.task then inst.task:Cancel() inst.task = nil end 165 end, GetWorld()) 166 inst:AddTag("icemaker") 167 end 168 if data and data.bigice then 169 inst.AnimState:SetBank("icehat") 170 inst.AnimState:SetBuild("hat_ice") 171 inst.AnimState:PlayAnimation("anim") 172 inst.Transform:SetScale(1.5, 1.5, 1.5) 173 inst:RemoveComponent("waterproofer") 174 inst:RemoveComponent("equippable") 175 inst:RemoveComponent("insulator") 176 inst:RemoveComponent("perishable") 177 inst:RemoveComponent("fuel") 178 inst:RemoveComponent("burnable") 179 inst:RemoveComponent("propagator") 180 inst:RemoveComponent("deployable") 181 inst:RemoveComponent("container") 182 inst:RemoveTag("nopunch") 183 inst:RemoveTag("show_spoilage") 184 inst:RemoveAllEventCallbacks() 185 inst:AddComponent("named") 186 inst.components.named:SetName("Big ice") 187 inst.components.inventoryitem:ChangeImageName("icehat") 188 inst:AddComponent("heater") 189 inst.components.heater.iscooler = true 190 inst.components.heater.heatfn = function(inst) return -40 end 191 inst:AddComponent("workable") 192 inst.components.workable:SetWorkAction(ACTIONS.HAMMER) 193 inst.components.workable:SetWorkLeft(1) 194 inst.components.workable:SetOnFinishCallback(function(inst) 195 SpawnPrefab("ground_chunks_breaking").Transform:SetPosition(inst.Transform:GetWorldPosition()) 196 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 197 for k = 1, 10 do 198 local pt1 = inst:GetPosition() 199 local ice = SpawnPrefab("ice") 200 ice.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) 201 end 202 inst:Remove() 203 end ) 204 inst:AddTag("bigice") 205 end 206end 207 inst.OnSave = onsave 208 inst.OnLoad = onload 209 210 即可用草伞种制冰机,下雨时每10秒制成一块冰,鼠标左键点制冰机,可打开格子,在格子中拿取。当格子中至少有10块冰时,点格子下面的“Make”按钮,可将冰加工成大冰块,用以永久保存。靠近大冰块可降温,用锤子砸大冰块,可还原成小冰。不想要制冰机了,用锤子炸毁即可。草伞在生存选项(画着绳套)下,用4个树枝、3个草、6个花瓣制造

2025/04/23 · Bny

YN260-奶报箱(用苔藓种奶报箱,放入黄金,每天清晨送来报纸和5瓶牛奶,读报纸可补脑)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二六0.奶报箱(用苔藓种奶报箱,放入黄金,每天清晨送来报纸和5瓶牛奶,读报纸可补脑) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/cutlichen.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function itemtest(inst, item, slot) 7 if item.prefab == "goldnugget" or item.prefab == "goatmilk" or item.prefab == "cutlichen" then 8 return true 9 end 10 return false 11end 12local slotpos = { Vector3(0,32+4,0), Vector3(0,-(32+4),0), Vector3(0,-(64+32+8+4),0)} 13local widgetbuttoninfo = { 14 text = "Buy", 15 position = Vector3(0, 95, 0), 16 fn = function(inst) 17 if inst:HasTag("milkcartons") and inst.components.container:Has("goldnugget", 1) then 18 inst.components.container:ConsumeByName("goldnugget", 1) 19 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available") 20 local newspaper = SpawnPrefab("cutlichen") 21 newspaper.AnimState:SetBank("blueprint") 22 newspaper.AnimState:SetBuild("blueprint") 23 newspaper.AnimState:PlayAnimation("idle") 24 newspaper.components.inventoryitem:ChangeImageName("blueprint") 25 newspaper.Transform:SetScale(1.2, 1.2, 1.2) 26 newspaper:AddComponent("named") 27 newspaper.components.named:SetName("Newspaper") 28 newspaper:RemoveComponent("stackable") 29 newspaper:RemoveComponent("edible") 30 newspaper:RemoveComponent("perishable") 31 newspaper:RemoveComponent("container") 32 newspaper:RemoveComponent("deployable") 33 newspaper.components.inspectable.getstatus = function(newspaper) 34 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_clothing") 35 GetPlayer().components.sanity:DoDelta(GetPlayer().components.sanity.max) 36 newspaper:Remove() 37 end 38 newspaper:AddTag("newspapers") 39 GetPlayer().components.inventory:GiveItem(newspaper) 40 end 41 end } 42local function OnDeploy (inst, pt) 43 local milkcarton = SpawnPrefab("cutlichen") 44 milkcarton.Transform:SetPosition(pt.x, pt.y, pt.z) 45 milkcarton.AnimState:SetBank("icebox") 46 milkcarton.AnimState:SetBuild("ice_box") 47 milkcarton.AnimState:PlayAnimation("closed") 48 milkcarton.Transform:SetScale(0.6, 0.6, 0.6) 49 milkcarton.AnimState:SetMultColour(0/255,185/255,255/255,1) 50 milkcarton:AddComponent("named") 51 milkcarton.components.named:SetName("Milk carton") 52 milkcarton:RemoveComponent("stackable") 53 milkcarton:RemoveComponent("inventoryitem") 54 milkcarton:RemoveComponent("edible") 55 milkcarton:RemoveComponent("perishable") 56 milkcarton:RemoveComponent("deployable") 57 milkcarton.components.container.canbeopened = true 58 milkcarton:AddComponent("workable") 59 milkcarton.components.workable:SetWorkAction(ACTIONS.HAMMER) 60 milkcarton.components.workable:SetWorkLeft(3) 61 milkcarton.components.workable:SetOnFinishCallback(function(milkcarton) 62 SpawnPrefab("collapse_big").Transform:SetPosition(milkcarton.Transform:GetWorldPosition()) 63 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 64 milkcarton:Remove() 65 end ) 66 milkcarton:ListenForEvent( "daytime", function() 67 if milkcarton.components.container:Has("goldnugget", 5) then 68 milkcarton.components.container:ConsumeByName("goldnugget", 5) 69 for k = 1, 5 do 70 local goatmilk = SpawnPrefab("goatmilk") 71 milkcarton.components.container:GiveItem(goatmilk) 72 end 73 local newspaper = SpawnPrefab("cutlichen") 74 newspaper.AnimState:SetBank("blueprint") 75 newspaper.AnimState:SetBuild("blueprint") 76 newspaper.AnimState:PlayAnimation("idle") 77 newspaper.components.inventoryitem:ChangeImageName("blueprint") 78 newspaper.Transform:SetScale(1.2, 1.2, 1.2) 79 newspaper:AddComponent("named") 80 newspaper.components.named:SetName("Newspaper") 81 newspaper:RemoveComponent("stackable") 82 newspaper:RemoveComponent("edible") 83 newspaper:RemoveComponent("perishable") 84 newspaper:RemoveComponent("container") 85 newspaper:RemoveComponent("deployable") 86 newspaper.components.inspectable.getstatus = function(newspaper) 87 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_clothing") 88 GetPlayer().components.sanity:DoDelta(GetPlayer().components.sanity.max) 89 newspaper:Remove() 90 end 91 newspaper:AddTag("newspapers") 92 milkcarton.components.container:GiveItem(newspaper) 93 end 94 end, GetWorld()) 95 milkcarton:AddTag("milkcartons") 96 inst.components.stackable:Get():Remove() 97end 98 inst:AddComponent("deployable") 99 inst.components.deployable.ondeploy = OnDeploy 100 inst.components.deployable.min_spacing = 1 101 inst:AddComponent("container") 102 inst.components.container.widgetbuttoninfo = widgetbuttoninfo 103 inst.components.container:SetNumSlots(#slotpos) 104 inst.components.container.widgetslotpos = slotpos 105 inst.components.container.widgetpos = Vector3(0,150,0) 106 inst.components.container.side_align_tip = 160 107 inst.components.container.canbeopened = false 108 inst.components.container.onopenfn = function(inst) inst.AnimState:PlayAnimation("open") GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") end 109 inst.components.container.onclosefn = function(inst) inst.AnimState:PlayAnimation("close") GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") end 110 inst.components.container.itemtestfn = itemtest 111 inst:AddTag("fridge") 112local function onsave(inst, data) 113 if inst:HasTag("milkcartons") then 114 data.milkcartons = true 115 end 116 if inst:HasTag("newspapers") then 117 data.newspapers = true 118 end 119end 120local function onload(inst, data) 121 if data and data.milkcartons then 122 inst.AnimState:SetBank("icebox") 123 inst.AnimState:SetBuild("ice_box") 124 inst.AnimState:PlayAnimation("closed") 125 inst.Transform:SetScale(0.6, 0.6, 0.6) 126 inst.AnimState:SetMultColour(0/255,185/255,255/255,1) 127 inst:AddComponent("named") 128 inst.components.named:SetName("Milk carton") 129 inst:RemoveComponent("stackable") 130 inst:RemoveComponent("inventoryitem") 131 inst:RemoveComponent("edible") 132 inst:RemoveComponent("perishable") 133 inst:RemoveComponent("deployable") 134 inst.components.container.canbeopened = true 135 inst:AddComponent("workable") 136 inst.components.workable:SetWorkAction(ACTIONS.HAMMER) 137 inst.components.workable:SetWorkLeft(3) 138 inst.components.workable:SetOnFinishCallback(function(inst) 139 SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) 140 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 141 inst:Remove() 142 end ) 143 inst:ListenForEvent( "daytime", function() 144 if inst.components.container:Has("goldnugget", 5) then 145 inst.components.container:ConsumeByName("goldnugget", 5) 146 for k = 1, 5 do 147 local goatmilk = SpawnPrefab("goatmilk") 148 inst.components.container:GiveItem(goatmilk) 149 end 150 local newspaper = SpawnPrefab("cutlichen") 151 newspaper.AnimState:SetBank("blueprint") 152 newspaper.AnimState:SetBuild("blueprint") 153 newspaper.AnimState:PlayAnimation("idle") 154 newspaper.components.inventoryitem:ChangeImageName("blueprint") 155 newspaper.Transform:SetScale(1.2, 1.2, 1.2) 156 newspaper:AddComponent("named") 157 newspaper.components.named:SetName("Newspaper") 158 newspaper:RemoveComponent("stackable") 159 newspaper:RemoveComponent("edible") 160 newspaper:RemoveComponent("perishable") 161 newspaper:RemoveComponent("container") 162 newspaper:RemoveComponent("deployable") 163 newspaper.components.inspectable.getstatus = function(newspaper) 164 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_clothing") 165 GetPlayer().components.sanity:DoDelta(GetPlayer().components.sanity.max) 166 newspaper:Remove() 167 end 168 newspaper:AddTag("newspapers") 169 inst.components.container:GiveItem(newspaper) 170 end 171 end, GetWorld()) 172 inst:AddTag("milkcartons") 173 end 174 if data and data.newspapers then 175 inst.AnimState:SetBank("blueprint") 176 inst.AnimState:SetBuild("blueprint") 177 inst.AnimState:PlayAnimation("idle") 178 inst.components.inventoryitem:ChangeImageName("blueprint") 179 inst.Transform:SetScale(1.2, 1.2, 1.2) 180 inst:AddComponent("named") 181 inst.components.named:SetName("Newspaper") 182 inst:RemoveComponent("stackable") 183 inst:RemoveComponent("edible") 184 inst:RemoveComponent("perishable") 185 inst:RemoveComponent("container") 186 inst:RemoveComponent("deployable") 187 inst.components.inspectable.getstatus = function(inst) 188 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_clothing") 189 GetPlayer().components.sanity:DoDelta(GetPlayer().components.sanity.max) 190 inst:Remove() 191 end 192 inst:AddTag("newspapers") 193 end 194end 195 inst.OnSave = onsave 196 inst.OnLoad = onload 197 198 即可用苔藓种奶报箱,鼠标左键点奶报箱可打开格子,在格子中放入黄金(订奶预付款,最少5个黄金),第二天清晨将送来5瓶牛奶,并免费赠送一份报纸,同时扣除5个黄金。将报纸放入物品栏,对其点鼠标右键可读报,将补满脑值。如果格子中有黄金,点格子上方的“Buy”按钮,可以额外购买报纸,每份1个黄金。如果每天想多订牛奶和报纸,就多种几个奶报箱吧。不想要奶报箱了,用锤子砸毁即可。苔藓可在洞穴中采到。不要与“用苔藓种苔藓(苔藓可移植)”一同修改

2025/04/23 · Bny

YN261-智能路灯(用蓝色护身符种智能路灯,夜晚自动点亮,白天熄灭,可手动开关、防雷击)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二六一.智能路灯(用蓝色护身符种智能路灯,夜晚自动点亮,白天熄灭,可手动开关、防雷击) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/amulet.lua文件,在inst.AnimState:PlayAnimation("blueamulet")的下一行插入以下内容: 5 6local function makestreetlight(inst) 7 local pt = inst:GetPosition() 8 local streetlight = SpawnPrefab("blueamulet") 9 streetlight.Transform:SetPosition(pt.x, pt.y, pt.z) 10 streetlight.AnimState:SetBank("nightstick") 11 streetlight.AnimState:SetBuild("nightstick") 12 streetlight.AnimState:PlayAnimation("idle") 13 streetlight.Transform:SetScale(1.5, 1.5, 1.5) 14 streetlight.AnimState:SetMultColour(255/255,255/255,0/255,1) 15 MakeObstaclePhysics(streetlight, .5 ) 16 streetlight:RemoveComponent("equippable") 17 streetlight:RemoveComponent("inventoryitem") 18 streetlight:RemoveComponent("heater") 19 streetlight:RemoveComponent("fueled") 20 streetlight:RemoveComponent("deployable") 21 streetlight:AddComponent("named") 22 streetlight.components.named:SetName("Street Light") 23 streetlight:AddComponent("workable") 24 streetlight.components.workable:SetWorkAction(ACTIONS.HAMMER) 25 streetlight.components.workable:SetWorkLeft(3) 26 streetlight.components.workable:SetOnFinishCallback(function(streetlight, worker) 27 SpawnPrefab("collapse_big").Transform:SetPosition(streetlight.Transform:GetWorldPosition()) 28 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 29 local pos = Vector3(streetlight.Transform:GetWorldPosition()) 30 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 2) 31 for k,v in pairs(ents) do 32 if v:HasTag("bulbs") then 33 v:Remove() 34 end 35 end 36 streetlight:Remove() 37 end ) 38 streetlight:AddTag("streetlights") 39 local bulb = SpawnPrefab("blueamulet") 40 bulb.AnimState:SetBank("bulb") 41 bulb.AnimState:SetBuild("bulb") 42 bulb.AnimState:PlayAnimation("idle") 43 bulb.Transform:SetScale(1.6, 1.6, 1.6) 44 bulb.Physics:SetActive(false) 45 bulb:RemoveComponent("equippable") 46 bulb:RemoveComponent("inventoryitem") 47 bulb:RemoveComponent("heater") 48 bulb:RemoveComponent("fueled") 49 bulb:RemoveComponent("deployable") 50 bulb.persists = false 51 bulb:AddComponent("named") 52 bulb.components.named:SetName("Street Light") 53 bulb.entity:AddSoundEmitter() 54 local light = bulb.entity:AddLight() 55 light:SetFalloff(1) 56 light:SetIntensity(.8) 57 light:SetRadius(10) 58 light:SetColour(255/255,255/255,255/255) 59 light:Enable(false) 60 local follower = bulb.entity:AddFollower() 61 follower:FollowSymbol( streetlight.GUID, "swap_object", 15, -160, 0.1 ) 62 bulb:AddComponent("machine") 63 bulb.components.machine.turnonfn = function() 64 bulb.SoundEmitter:PlaySound("dontstarve/wilson/lantern_on") 65 bulb.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 66 bulb.Light:Enable(true) 67 end 68 bulb.components.machine.turnofffn = function() 69 bulb.SoundEmitter:PlaySound("dontstarve/wilson/lantern_off") 70 bulb.AnimState:SetBloomEffectHandle( "" ) 71 bulb.Light:Enable(false) 72 end 73 bulb:ListenForEvent( "daytime", function() bulb.components.machine:TurnOff() end , GetWorld() ) 74 bulb:ListenForEvent( "dusktime", function() bulb.components.machine:TurnOn() end , GetWorld() ) 75 bulb:AddTag("lightningrod") 76 bulb:AddTag("bulbs") 77 if not GetClock():IsDay() then 78 bulb.components.machine:TurnOn() 79 else 80 bulb.components.machine:TurnOff() 81 end 82end 83local function OnDeploy (inst, pt) 84 makestreetlight(inst) 85 inst:Remove() 86end 87 inst:AddComponent("deployable") 88 inst.components.deployable.ondeploy = OnDeploy 89local function onsave(inst, data) 90 if inst:HasTag("streetlights") then 91 data.streetlights = true 92 end 93end 94local function onload(inst, data) 95 if data and data.streetlights then 96 makestreetlight(inst) 97 inst:Remove() 98 end 99end 100 inst.OnSave = onsave 101 inst.OnLoad = onload 102 103 即可用蓝色护身符种智能路灯,夜晚自动点亮,白天自动熄灭。鼠标右键点灯泡,可手动开关。智能路灯靠太阳能和闪电做能源,无须手动充能,靠近可防雷击。不想要智能路灯了,用锤子砸掉即可。蓝色护身符在魔法选项(画着红骷髅)下,用3个黄金、1个蓝宝石制造

2025/04/23 · Bny