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

YN262-传送石(右键点装备的保温石,将主角传送到另一块保温石处)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二六二.传送石(右键点装备的保温石,将主角传送到另一块保温石处) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/heatrock.lua文件,在inst:AddComponent("inspectable")下一行插入以下内容: 5 6local function canteleport(inst, caster) 7 return true 8end 9local function teleport(inst) 10 local caster = inst.components.inventoryitem.owner 11 local range = 3000 12 local pos = Vector3(caster.Transform:GetWorldPosition()) 13 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, range) 14 for k,v in pairs(ents) do 15 if v.prefab == "heatrock" and not v.components.inventoryitem:IsHeld() then 16 caster.Transform:SetPosition(v.Transform:GetWorldPosition()) 17 end 18 end 19 return true 20end 21 inst:AddComponent("spellcaster") 22 inst.components.spellcaster:SetSpellFn(teleport) 23 inst.components.spellcaster:SetSpellTestFn(canteleport) 24 inst.components.spellcaster.canusefrominventory = false 25 inst.components.spellcaster.canuseonpoint = true 26 inst:AddComponent("equippable") 27 inst.components.equippable.equipslot = EQUIPSLOTS.HANDS 28 29 即可制造2块保温石,1块扔在要传到的地点(比如家、洞穴出口处等),另1块带在身上,无论走到地图何处,只要装备保温石对空地按鼠标右键,马上传送回扔在地上的保温石处。如果制造3块保温石,将2块扔在不同地点,这2点间将形成虫洞效果,装备保温石对空地按鼠标右键,会在这2点间来回传送

2025/04/23 · Bny

YN263-御风飞翔(装备羽毛飞翔10秒)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二六三.御风飞翔(装备羽毛飞翔10秒) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/feathers.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function onequip(inst, owner) 7 inst.fire = SpawnPrefab( "feather_"..name ) 8 inst.fire.Physics:SetActive(false) 9 local follower = inst.fire.entity:AddFollower() 10 follower:FollowSymbol( inst.GUID, "swap_object", 0, 60, 0 ) 11 local pt = owner:GetPosition() 12 owner.Transform:SetPosition(pt.x, pt.y+30, pt.z) 13 inst:DoTaskInTime(10, function() 14 local pt = owner:GetPosition() 15 owner.Transform:SetPosition(pt.x, pt.y-30, pt.z) 16 inst:Remove() 17 end) 18end 19local function onunequip(inst, owner) 20 local pt = owner:GetPosition() 21 owner.Transform:SetPosition(pt.x, pt.y-30, pt.z) 22 inst.fire:Remove() 23 inst.fire = nil 24end 25 inst:AddComponent("equippable") 26 inst.components.equippable:SetOnEquip( onequip ) 27 inst.components.equippable:SetOnUnequip( onunequip ) 28 inst.components.equippable.equipslot = EQUIPSLOTS.HEAD 29 inst.components.equippable.walkspeedmult = TUNING.CANE_SPEED_MULT*5 30 31 即可装备羽毛飞翔10秒,体会饥荒世界从未有过的美妙感觉,洞穴也可飞行。10秒后羽毛被耗尽,想飞就要多捕鸟哦。注意飞行时不要佩戴橙色护身符和带宠物

2025/04/23 · Bny

YN264-风力滑板车(饥荒世界陆上交通工具)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二六四.风力滑板车(饥荒世界陆上交通工具) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/umbrella.lua文件, 5 6 1.将下列内容: 7 8local function onequip(inst, owner) 9 owner.AnimState:OverrideSymbol("swap_object", "swap_umbrella", "swap_umbrella") 10 owner.AnimState:Show("ARM_carry") 11 owner.AnimState:Hide("ARM_normal") 12 UpdateSound(inst) 13 14 owner.DynamicShadow:SetSize(2.2, 1.4) 15 16 inst.components.fueled:StartConsuming() 17end 18 19local function onunequip(inst, owner) 20 owner.AnimState:Hide("ARM_carry") 21 owner.AnimState:Show("ARM_normal") 22 UpdateSound(inst) 23 24 owner.DynamicShadow:SetSize(1.3, 0.6) 25 26 inst.components.fueled:StopConsuming() 27end 28 29 替换为: 30 31local function onequip(inst, owner) 32 owner.AnimState:OverrideSymbol("swap_object", "swap_umbrella", "swap_umbrella") 33 owner.AnimState:Show("ARM_carry") 34 owner.AnimState:Hide("ARM_normal") 35 UpdateSound(inst) 36 inst.task = inst:DoPeriodicTask(.01, function() owner.Physics:SetMotorVelOverride(20,0,0) end) 37 inst.fire = SpawnPrefab( "telebase" ) 38 inst.fire.Physics:SetActive(false) 39 local follower = inst.fire.entity:AddFollower() 40 follower:FollowSymbol( owner.GUID, "swap_object", -90, 130, 0 ) 41end 42local function onunequip(inst, owner) 43 owner.AnimState:Hide("ARM_carry") 44 owner.AnimState:Show("ARM_normal") 45 UpdateSound(inst) 46 if inst.task then inst.task:Cancel() inst.task = nil end 47 inst.fire:Remove() 48 inst.fire = nil 49end 50 51 52 2.在inst.components.fueled:SetDepletedFn(onperish)的下一行插入inst:AddComponent("blinkstaff") 53 54 即可在装备雨伞时,脚下踩着滑板自动行驶,伞就是你的风帆,卸载雨伞后停下。鼠标左键点地可以控制方向(也可以用键盘W、S、A、D键控制方向),鼠标右键点地可以瞬移(用以跳过障碍),有空儿去兜兜风吧。雨伞在生存选项(画着绳套)下,用6个树枝、1个猪皮、2个蛛丝制造

2025/04/23 · Bny

YN265-动力飞行帽(戴羽毛帽在天空自由飞翔)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二六五.动力飞行帽(戴羽毛帽在天空自由飞翔) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/hats.lua文件,将下列内容: 5 6 local function feather_equip(inst, owner) 7 onequip(inst, owner) 8 local ground = GetWorld() 9 if ground and ground.components.birdspawner then 10 ground.components.birdspawner:SetSpawnTimes(TUNING.BIRD_SPAWN_DELAY_FEATHERHAT) 11 ground.components.birdspawner:SetMaxBirds(TUNING.BIRD_SPAWN_MAX_FEATHERHAT) 12 end 13 end 14 local function feather_unequip(inst, owner) 15 onunequip(inst, owner) 16 local ground = GetWorld() 17 if ground and ground.components.birdspawner then 18 ground.components.birdspawner:SetSpawnTimes(TUNING.BIRD_SPAWN_DELAY) 19 ground.components.birdspawner:SetMaxBirds(TUNING.BIRD_SPAWN_MAX) 20 end 21 end 22 local function feather() 23 local inst = simple() 24 25 inst.components.equippable.dapperness = TUNING.DAPPERNESS_SMALL 26 27 inst.components.equippable:SetOnEquip( feather_equip ) 28 inst.components.equippable:SetOnUnequip( feather_unequip ) 29 30 inst:AddComponent("fueled") 31 inst.components.fueled.fueltype = "USAGE" 32 inst.components.fueled:InitializeFuelLevel(TUNING.FEATHERHAT_PERISHTIME) 33 inst.components.fueled:SetDepletedFn(generic_perish) 34 35 替换为: 36 37local function feather_equip(inst, owner) 38 onequip(inst, owner) 39 local shadow = GetPlayer().entity:AddDynamicShadow() 40 shadow:SetSize( 0, 0 ) 41 inst.task = inst:DoPeriodicTask(.01, function() owner.Physics:SetMotorVelOverride(20,10,0) end ) 42 inst:DoTaskInTime(3, function() 43 if inst.task then inst.task:Cancel() inst.task = nil end 44 inst.task = inst:DoPeriodicTask(.01, function() owner.Physics:SetMotorVelOverride(20,1,0) end) 45 end ) 46end 47local function feather_unequip(inst, owner) 48 if inst.task then inst.task:Cancel() inst.task = nil end 49 inst.task = inst:DoPeriodicTask(.01, function() owner.Physics:SetMotorVelOverride(20,-10,0) end) 50 inst:DoTaskInTime(3, function() 51 if inst.task then inst.task:Cancel() inst.task = nil end 52 onunequip(inst, owner) 53 local shadow = GetPlayer().entity:AddDynamicShadow() 54 shadow:SetSize( 1.3, .6 ) 55 end) 56end 57local function feather() 58 local inst = simple() 59 inst.components.equippable.dapperness = TUNING.DAPPERNESS_SMALL 60 inst.components.equippable:SetOnEquip( feather_equip ) 61 inst.components.equippable:SetOnUnequip( feather_unequip ) 62 63 即可在戴羽毛帽时开始起飞,爬升3秒后平飞,用键盘W、S、A、D键控制方向。想降落时卸载羽毛帽即可开始着陆,落地后会滑行一段(按W、S、A、D键可以减少滑行距离)。注意不要在爬升阶段卸载羽毛帽(平飞时再卸载即可),否则在惯性作用下将滑出很长一段距离

2025/04/23 · Bny

YN266-虫洞地铁(虫洞可以搬到任意地点,搭建地铁网络)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二六六.虫洞地铁(虫洞可以搬到任意地点,搭建地铁网络) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/wormhole.lua文件, 5 6 1.将doer.components.sanity:DoDelta(-TUNING.SANITY_MED)替换为doer.components.sanity:DoDelta(TUNING.SANITY_MED) 7 8 9 2.在inst:AddComponent("inspectable")的下一行插入以下内容: 10 11local function turnon(inst) 12 inst.components.machine.ison = true 13 inst.components.inventoryitem.canbepickedup = true 14end 15local function turnoff(inst) 16 inst.components.machine.ison = false 17 inst.components.inventoryitem.canbepickedup = false 18end 19 inst:AddComponent("equippable") 20 inst:AddComponent("inventoryitem") 21 inst.components.inventoryitem:ChangeImageName("abigail_flower") 22 inst.components.inventoryitem.canbepickedup = false 23 inst:AddComponent("machine") 24 inst.components.machine.turnonfn = turnon 25 inst.components.machine.turnofffn = turnoff 26 27 即可对虫洞按鼠标右键解除锁在地上,再点左键就可以将它捡起(在物品栏里显示为一朵花的图片),到要放置的地点后,将虫洞拿出放在地上,对其点鼠标右键即可再次锁在地上。在家门口摆一排虫洞,将对应的虫洞放在想去的地方,组成自己的虫洞地铁网络吧。另外跳虫洞不但不会降脑,反而会补脑,让你出行的心情更加愉快

2025/04/23 · Bny

YN267-蜘蛛座骑(按键盘PageUP键召唤蜘蛛座骑,按PageDown键取消)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二六七.蜘蛛座骑(按键盘PageUP键召唤蜘蛛座骑,按PageDown键取消) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("inventory")的下一行插入以下内容: 5 6TheInput:AddKeyUpHandler(KEY_PAGEUP, function() 7 if inst.task then inst.task:Cancel() inst.task = nil end 8 if inst.task2 then inst.task2:Cancel() inst.task2 = nil end 9 if inst.doll then inst.doll:Remove() inst.doll = nil end 10 inst.components.locomotor:Stop() 11 inst.components.playercontroller:Enable(false) 12 SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) 13 inst.SoundEmitter:PlaySound("dontstarve/creatures/spiderqueen/scream_short") 14 inst:DoTaskInTime(0.1, function() 15 inst.AnimState:SetBank("spider_queen") 16 inst.AnimState:SetBuild("spider_queen_build") 17 inst.AnimState:PlayAnimation("idle", true) 18 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 19 inst:SetStateGraph("SGspiderqueen") 20 shadow:SetSize( 7, 3 ) 21 inst.components.locomotor.walkspeed = 15 22 inst.components.locomotor.runspeed = 20 23 inst.components.health:SetInvincible(true) 24 inst.components.hunger:Pause() 25 inst.components.combat:SetDefaultDamage(300) 26 inst.components.temperature:SetTemp(20) 27 inst.components.playercontroller:Enable(true) 28 local pt = GetPlayer():GetPosition() 29 inst.doll = SpawnPrefab( "beardhair" ) 30 inst.doll.Transform:SetPosition(pt.x, 3.5, pt.z) 31 inst.doll.Physics:SetActive(false) 32 inst.doll.AnimState:SetBank("wilson") 33 inst.doll.AnimState:SetBuild(name) 34 inst.doll.AnimState:OverrideSymbol("swap_object", "swap_spear", "swap_spear") 35 inst.doll.AnimState:Hide("ARM_normal") 36 inst.doll.AnimState:Show("ARM_carry") 37 inst.doll.Transform:SetFourFaced() 38 inst.doll.AnimState:PlayAnimation("idle") 39 inst.doll:RemoveComponent("burnable") 40 inst.doll:RemoveComponent("propagator") 41 inst.doll:RemoveComponent("inspectable") 42 inst.doll:RemoveComponent("inventoryitem") 43 inst.doll:RemoveComponent("stackable") 44 inst.doll:RemoveComponent("fuel") 45 inst.task = inst:DoPeriodicTask(.05, function() 46 local pt1 = GetPlayer():GetPosition() 47 inst.doll.Transform:SetPosition(pt1.x, 3.5, pt1.z) 48 inst.doll.Transform:SetRotation(GetPlayer().Transform:GetRotation()) 49 end ) 50 inst.task2 = inst:DoPeriodicTask(10, function() 51 inst.doll.AnimState:PlayAnimation("give",true) 52 inst:DoTaskInTime(2.2, function() inst.doll.AnimState:PlayAnimation("idle") end ) 53 end ) 54 end ) 55end ) 56TheInput:AddKeyUpHandler(KEY_PAGEDOWN, function() 57 inst.components.locomotor:Stop() 58 inst.components.playercontroller:Enable(false) 59 SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) 60 inst.SoundEmitter:PlaySound("dontstarve/creatures/spiderqueen/scream_short") 61 inst:DoTaskInTime(0.1, function() 62 inst.AnimState:SetBank("wilson") 63 inst.AnimState:SetBuild(name) 64 inst.AnimState:PlayAnimation("idle") 65 inst.AnimState:SetBloomEffectHandle("") 66 inst:SetStateGraph("SGwilson") 67 shadow:SetSize( 1.3, .6 ) 68 inst.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED 69 inst.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED 70 inst.components.health:SetInvincible(false) 71 inst.components.hunger:Resume() 72 inst.components.combat:SetDefaultDamage(TUNING.UNARMED_DAMAGE) 73 inst.components.temperature:SetTemp(nil) 74 inst.components.playercontroller:Enable(true) 75 if inst.task then inst.task:Cancel() inst.task = nil end 76 if inst.task2 then inst.task2:Cancel() inst.task2 = nil end 77 if inst.doll then inst.doll:Remove() inst.doll = nil end 78 end ) 79end ) 80 81 即可按键盘PageUP键召唤蜘蛛座骑(自动骑在蜘蛛身上),按PageDown键取消座骑。攻击时对敌人按Ctrl + 鼠标左键(也可以按住F键连续还击)。骑在蜘蛛身上时,敌人无法打到主角,所以主角不会掉血

2025/04/23 · Bny

YN268-喷气虫座骑(用夏日背心种喷气虫座骑,左键点虫可骑乘,右键点主角可下来,给草让它原地等待)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二六八.喷气虫座骑(用夏日背心种喷气虫座骑,左键点虫可骑乘,右键点主角可下来,给草让它原地等待) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/trunkvest.lua文件,在inst.AnimState:SetBuild("armor_trunkvest_summer")的下一行插入以下内容: 5 6local function OnDeploy (inst, pt) 7 local jet = SpawnPrefab("trunkvest_summer") 8 jet.Transform:SetPosition(pt.x, pt.y, pt.z) 9 jet.AnimState:SetBank("glommer") 10 jet.AnimState:SetBuild("glommer") 11 jet.AnimState:PlayAnimation("idle_loop") 12 jet.Transform:SetFourFaced() 13 jet.entity:AddSoundEmitter() 14 local shadow = jet.entity:AddDynamicShadow() 15 shadow:SetSize( 2, .75 ) 16 local minimap = jet.entity:AddMiniMapEntity() 17 minimap:SetIcon("glommer.png") 18 jet:AddComponent("named") 19 jet.components.named:SetName("Glommer") 20 jet:RemoveComponent("inventoryitem") 21 jet:RemoveComponent("equippable") 22 jet:RemoveComponent("insulator") 23 jet:RemoveComponent("fueled") 24 jet:RemoveComponent("waterproofer") 25 jet:RemoveComponent("deployable") 26 jet:AddComponent("knownlocations") 27 jet:AddComponent("follower") 28 jet.components.follower:SetLeader(GetPlayer()) 29 jet:AddComponent("lootdropper") 30 jet:AddComponent("health") 31 jet.components.health:SetMaxHealth(2000) 32 jet:AddComponent("combat") 33 jet:AddComponent("locomotor") 34 jet.components.locomotor.walkspeed = 15 35 jet:SetStateGraph("SGglommer") 36 local brain = require "brains/chesterbrain" 37 jet:SetBrain(brain) 38 jet:AddComponent("trader") 39 jet.components.trader:SetAcceptTest(function(jet, item) 40 if not jet:HasTag("driving") then 41 if item.prefab == "cutgrass" then 42 return true 43 end 44 end 45 return false 46 end ) 47 jet.components.trader.onaccept = function(jet, giver, item) 48 jet.components.health:DoDelta(2000) 49 if not jet:HasTag("stophere") then 50 jet:AddTag("stophere") 51 jet.components.locomotor:Stop() 52 jet:SetBrain(nil) 53 jet.components.follower:SetLeader(nil) 54 else 55 jet:RemoveTag("stophere") 56 local brain = require "brains/chesterbrain" 57 jet:SetBrain(brain) 58 jet:RestartBrain() 59 jet.components.follower:SetLeader(GetPlayer()) 60 end 61 end 62 jet.components.inspectable.getstatus = function() 63 if not jet:HasTag("driving") then 64 jet:AddTag("driving") 65 jet:RemoveTag("stophere") 66 jet.components.locomotor:Stop() 67 local shadow = jet.entity:AddDynamicShadow() 68 shadow:SetSize( 0, 0 ) 69 jet.Physics:SetActive(false) 70 jet:SetStateGraph("SGshadowwaxwell") 71 jet:SetBrain(nil) 72 jet.components.follower:SetLeader(nil) 73 jet.AnimState:SetBank("wilson") 74 if GetPlayer().prefab == "wilson" then jet.AnimState:SetBuild("wilson") end 75 if GetPlayer().prefab == "wendy" then jet.AnimState:SetBuild("wendy") end 76 if GetPlayer().prefab == "wes" then jet.AnimState:SetBuild("wes") end 77 if GetPlayer().prefab == "wickerbottom" then jet.AnimState:SetBuild("wickerbottom") end 78 if GetPlayer().prefab == "willow" then jet.AnimState:SetBuild("willow") end 79 if GetPlayer().prefab == "wolfgang" then jet.AnimState:SetBuild("wolfgang") end 80 if GetPlayer().prefab == "wx78" then jet.AnimState:SetBuild("wx78") end 81 if GetPlayer().prefab == "woodie" then jet.AnimState:SetBuild("woodie") end 82 if GetPlayer().prefab == "waxwell" then jet.AnimState:SetBuild("waxwell") end 83 if GetPlayer().prefab == "wathgrithr" then jet.AnimState:SetBuild("wathgrithr") end 84 if GetPlayer().prefab == "webber" then jet.AnimState:SetBuild("webber") end 85 jet.AnimState:PlayAnimation("idle") 86 jet.AnimState:Hide("ARM_carry") 87 jet.AnimState:Show("ARM_normal") 88 jet.Transform:SetRotation( 0 ) 89 jet.task = jet:DoPeriodicTask(0.05, function(jet) 90 local pt1 = GetPlayer():GetPosition() 91 jet.Transform:SetPosition(pt1.x, 3.5, pt1.z) 92 jet.Transform:SetRotation(GetPlayer().Transform:GetRotation()) 93 end ) 94 GetPlayer().AnimState:SetBank("glommer") 95 GetPlayer().AnimState:SetBuild("glommer") 96 GetPlayer().AnimState:PlayAnimation("idle_loop") 97 GetPlayer():SetStateGraph("SGglommer") 98 local shadow = GetPlayer().entity:AddDynamicShadow() 99 shadow:SetSize( 2, .75 ) 100 GetPlayer().components.locomotor.walkspeed = 25 101 GetPlayer().components.locomotor.runspeed = 25 102 GetPlayer().components.health:SetInvincible(true) 103 GetPlayer().components.hunger:Pause() 104 GetPlayer().components.temperature:SetTemp(20) 105 GetPlayer().components.playeractionpicker.leftclickoverride = function(target_ent, pos) 106 if GetPlayer().components.combat:CanTarget(target_ent) then 107 return GetPlayer().components.playeractionpicker:SortActionList({ACTIONS.LOOKAT}, target_ent, nil) 108 end 109 end 110 else 111 jet:RemoveTag("driving") 112 local shadow = jet.entity:AddDynamicShadow() 113 shadow:SetSize( 2, .75 ) 114 jet.Physics:SetActive(true) 115 jet.AnimState:SetBank("glommer") 116 jet.AnimState:SetBuild("glommer") 117 jet.AnimState:PlayAnimation("idle_loop") 118 jet:SetStateGraph("SGglommer") 119 local brain = require "brains/chesterbrain" 120 jet:SetBrain(brain) 121 jet:RestartBrain() 122 jet.components.follower:SetLeader(GetPlayer()) 123 if jet.task then jet.task:Cancel() jet.task = nil end 124 local pt1 = GetPlayer():GetPosition() 125 jet.Transform:SetPosition(pt1.x, 0, pt1.z) 126 GetPlayer().AnimState:SetBank("wilson") 127 if GetPlayer().prefab == "wilson" then GetPlayer().AnimState:SetBuild("wilson") end 128 if GetPlayer().prefab == "wendy" then GetPlayer().AnimState:SetBuild("wendy") end 129 if GetPlayer().prefab == "wes" then GetPlayer().AnimState:SetBuild("wes") end 130 if GetPlayer().prefab == "wickerbottom" then GetPlayer().AnimState:SetBuild("wickerbottom") end 131 if GetPlayer().prefab == "willow" then GetPlayer().AnimState:SetBuild("willow") end 132 if GetPlayer().prefab == "wolfgang" then GetPlayer().AnimState:SetBuild("wolfgang") end 133 if GetPlayer().prefab == "wx78" then GetPlayer().AnimState:SetBuild("wx78") end 134 if GetPlayer().prefab == "woodie" then GetPlayer().AnimState:SetBuild("woodie") end 135 if GetPlayer().prefab == "waxwell" then GetPlayer().AnimState:SetBuild("waxwell") end 136 if GetPlayer().prefab == "wathgrithr" then GetPlayer().AnimState:SetBuild("wathgrithr") end 137 if GetPlayer().prefab == "webber" then GetPlayer().AnimState:SetBuild("webber") end 138 GetPlayer().AnimState:PlayAnimation("idle") 139 GetPlayer():SetStateGraph("SGwilson") 140 local shadow = GetPlayer().entity:AddDynamicShadow() 141 shadow:SetSize( 1.3, .6 ) 142 GetPlayer().components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED 143 GetPlayer().components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED 144 GetPlayer().components.health:SetInvincible(false) 145 GetPlayer().components.hunger:Resume() 146 GetPlayer().components.temperature:SetTemp(nil) 147 GetPlayer().components.playeractionpicker.leftclickoverride = nil 148 end 149 end 150 jet:AddTag("jets") 151 inst:Remove() 152end 153 inst:AddComponent("deployable") 154 inst.components.deployable.ondeploy = OnDeploy 155local function onsave(inst, data) 156 if inst:HasTag("jets") then 157 data.jets = true 158 end 159 if inst:HasTag("stophere") then 160 data.stophere = true 161 end 162end 163local function onload(inst, data) 164 if data and data.jets then 165 inst.AnimState:SetBank("glommer") 166 inst.AnimState:SetBuild("glommer") 167 inst.AnimState:PlayAnimation("idle_loop") 168 inst.Transform:SetFourFaced() 169 inst.entity:AddSoundEmitter() 170 local shadow = inst.entity:AddDynamicShadow() 171 shadow:SetSize( 2, .75 ) 172 local minimap = inst.entity:AddMiniMapEntity() 173 minimap:SetIcon("glommer.png") 174 inst:AddComponent("named") 175 inst.components.named:SetName("Glommer") 176 inst:RemoveComponent("inventoryitem") 177 inst:RemoveComponent("equippable") 178 inst:RemoveComponent("insulator") 179 inst:RemoveComponent("fueled") 180 inst:RemoveComponent("waterproofer") 181 inst:RemoveComponent("deployable") 182 inst:AddComponent("knownlocations") 183 inst:AddComponent("follower") 184 inst.components.follower:SetLeader(GetPlayer()) 185 inst:AddComponent("lootdropper") 186 inst:AddComponent("health") 187 inst.components.health:SetMaxHealth(2000) 188 inst:AddComponent("combat") 189 inst:AddComponent("locomotor") 190 inst.components.locomotor.walkspeed = 15 191 inst:SetStateGraph("SGglommer") 192 local brain = require "brains/chesterbrain" 193 inst:SetBrain(brain) 194 inst:AddComponent("trader") 195 inst.components.trader:SetAcceptTest(function(inst, item) 196 if not inst:HasTag("driving") then 197 if item.prefab == "cutgrass" then 198 return true 199 end 200 end 201 return false 202 end ) 203 inst.components.trader.onaccept = function(inst, giver, item) 204 inst.components.health:DoDelta(2000) 205 if not inst:HasTag("stophere") then 206 inst:AddTag("stophere") 207 inst.components.locomotor:Stop() 208 inst:SetBrain(nil) 209 inst.components.follower:SetLeader(nil) 210 else 211 inst:RemoveTag("stophere") 212 local brain = require "brains/chesterbrain" 213 inst:SetBrain(brain) 214 inst:RestartBrain() 215 inst.components.follower:SetLeader(GetPlayer()) 216 end 217 end 218 inst.components.inspectable.getstatus = function() 219 if not inst:HasTag("driving") then 220 inst:AddTag("driving") 221 inst:RemoveTag("stophere") 222 inst.components.locomotor:Stop() 223 local shadow = inst.entity:AddDynamicShadow() 224 shadow:SetSize( 0, 0 ) 225 inst.Physics:SetActive(false) 226 inst:SetStateGraph("SGshadowwaxwell") 227 inst:SetBrain(nil) 228 inst.components.follower:SetLeader(nil) 229 inst.AnimState:SetBank("wilson") 230 if GetPlayer().prefab == "wilson" then inst.AnimState:SetBuild("wilson") end 231 if GetPlayer().prefab == "wendy" then inst.AnimState:SetBuild("wendy") end 232 if GetPlayer().prefab == "wes" then inst.AnimState:SetBuild("wes") end 233 if GetPlayer().prefab == "wickerbottom" then inst.AnimState:SetBuild("wickerbottom") end 234 if GetPlayer().prefab == "willow" then inst.AnimState:SetBuild("willow") end 235 if GetPlayer().prefab == "wolfgang" then inst.AnimState:SetBuild("wolfgang") end 236 if GetPlayer().prefab == "wx78" then inst.AnimState:SetBuild("wx78") end 237 if GetPlayer().prefab == "woodie" then inst.AnimState:SetBuild("woodie") end 238 if GetPlayer().prefab == "waxwell" then inst.AnimState:SetBuild("waxwell") end 239 if GetPlayer().prefab == "wathgrithr" then inst.AnimState:SetBuild("wathgrithr") end 240 if GetPlayer().prefab == "webber" then inst.AnimState:SetBuild("webber") end 241 inst.AnimState:PlayAnimation("idle") 242 inst.AnimState:Hide("ARM_carry") 243 inst.AnimState:Show("ARM_normal") 244 inst.Transform:SetRotation( 0 ) 245 inst.task = inst:DoPeriodicTask(0.05, function(inst) 246 local pt1 = GetPlayer():GetPosition() 247 inst.Transform:SetPosition(pt1.x, 3.5, pt1.z) 248 inst.Transform:SetRotation(GetPlayer().Transform:GetRotation()) 249 end ) 250 GetPlayer().AnimState:SetBank("glommer") 251 GetPlayer().AnimState:SetBuild("glommer") 252 GetPlayer().AnimState:PlayAnimation("idle_loop") 253 GetPlayer():SetStateGraph("SGglommer") 254 local shadow = GetPlayer().entity:AddDynamicShadow() 255 shadow:SetSize( 2, .75 ) 256 GetPlayer().components.locomotor.walkspeed = 25 257 GetPlayer().components.locomotor.runspeed = 25 258 GetPlayer().components.health:SetInvincible(true) 259 GetPlayer().components.hunger:Pause() 260 GetPlayer().components.temperature:SetTemp(20) 261 GetPlayer().components.playeractionpicker.leftclickoverride = function(target_ent, pos) 262 if GetPlayer().components.combat:CanTarget(target_ent) then 263 return GetPlayer().components.playeractionpicker:SortActionList({ACTIONS.LOOKAT}, target_ent, nil) 264 end 265 end 266 else 267 inst:RemoveTag("driving") 268 local shadow = inst.entity:AddDynamicShadow() 269 shadow:SetSize( 2, .75 ) 270 inst.Physics:SetActive(true) 271 inst.AnimState:SetBank("glommer") 272 inst.AnimState:SetBuild("glommer") 273 inst.AnimState:PlayAnimation("idle_loop") 274 inst:SetStateGraph("SGglommer") 275 local brain = require "brains/chesterbrain" 276 inst:SetBrain(brain) 277 inst:RestartBrain() 278 inst.components.follower:SetLeader(GetPlayer()) 279 if inst.task then inst.task:Cancel() inst.task = nil end 280 local pt1 = GetPlayer():GetPosition() 281 inst.Transform:SetPosition(pt1.x, 0, pt1.z) 282 GetPlayer().AnimState:SetBank("wilson") 283 if GetPlayer().prefab == "wilson" then GetPlayer().AnimState:SetBuild("wilson") end 284 if GetPlayer().prefab == "wendy" then GetPlayer().AnimState:SetBuild("wendy") end 285 if GetPlayer().prefab == "wes" then GetPlayer().AnimState:SetBuild("wes") end 286 if GetPlayer().prefab == "wickerbottom" then GetPlayer().AnimState:SetBuild("wickerbottom") end 287 if GetPlayer().prefab == "willow" then GetPlayer().AnimState:SetBuild("willow") end 288 if GetPlayer().prefab == "wolfgang" then GetPlayer().AnimState:SetBuild("wolfgang") end 289 if GetPlayer().prefab == "wx78" then GetPlayer().AnimState:SetBuild("wx78") end 290 if GetPlayer().prefab == "woodie" then GetPlayer().AnimState:SetBuild("woodie") end 291 if GetPlayer().prefab == "waxwell" then GetPlayer().AnimState:SetBuild("waxwell") end 292 if GetPlayer().prefab == "wathgrithr" then GetPlayer().AnimState:SetBuild("wathgrithr") end 293 if GetPlayer().prefab == "webber" then GetPlayer().AnimState:SetBuild("webber") end 294 GetPlayer().AnimState:PlayAnimation("idle") 295 GetPlayer():SetStateGraph("SGwilson") 296 local shadow = GetPlayer().entity:AddDynamicShadow() 297 shadow:SetSize( 1.3, .6 ) 298 GetPlayer().components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED 299 GetPlayer().components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED 300 GetPlayer().components.health:SetInvincible(false) 301 GetPlayer().components.hunger:Resume() 302 GetPlayer().components.temperature:SetTemp(nil) 303 GetPlayer().components.playeractionpicker.leftclickoverride = nil 304 end 305 end 306 inst:AddTag("jets") 307 end 308 if data and data.stophere then 309 inst.components.locomotor:Stop() 310 inst:SetBrain(nil) 311 inst.components.follower:SetLeader(nil) 312 inst:AddTag("stophere") 313 end 314end 315 inst.OnSave = onsave 316 inst.OnLoad = onload 317 318 即可用夏日背心种喷气虫座骑,对喷气虫点鼠标左键(手里不要拿武器)可骑乘,对主角按鼠标右键可下来。骑着喷气虫时无法战斗,但遭到攻击时不会受伤(敌人够不到你)。喷气虫会跟随你,喂它一根草(拿着草对它点鼠标左键)可让其停在原地,并同时补血,再给一根草可继续跟随。喷气虫座骑在小地图上显示为格罗门图标,不想要喷气虫座骑了,杀掉即可(按Ctrl + 鼠标左键攻击)。夏日背心在穿戴选项(画着帽子)下,用1个红色象鼻、8个蛛丝制造

2025/04/23 · Bny

YN269-公车站(用草席卷种公车站,买票坐到下一站)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二六九.公车站(用草席卷种公车站,买票坐到下一站) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/bedroll_straw.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6 inst.kind = "" 7 inst.soundpath = "dontstarve/creatures/rook/" 8 inst.effortsound = "dontstarve/creatures/rook/steam" 9local function OnDeploy (inst, pt) 10 local busstation = SpawnPrefab("bedroll_straw") 11 busstation.Transform:SetPosition(pt.x, pt.y, pt.z) 12 busstation.AnimState:SetBank("sign_home") 13 busstation.AnimState:SetBuild("sign_home") 14 busstation.AnimState:PlayAnimation("idle") 15 busstation.Transform:SetScale(1.5, 1.5, 1.5) 16 busstation.AnimState:SetMultColour(255/255,105/255,0/255,0.8) 17 local minimap = busstation.entity:AddMiniMapEntity() 18 minimap:SetIcon( "sign.png" ) 19 busstation:RemoveComponent("inventoryitem") 20 busstation:RemoveComponent("stackable") 21 busstation:RemoveComponent("fuel") 22 busstation:RemoveComponent("sleepingbag") 23 busstation:RemoveComponent("burnable") 24 busstation:RemoveComponent("propagator") 25 busstation:RemoveComponent("deployable") 26 busstation:AddTag("busstation") 27 busstation:AddComponent("workable") 28 busstation.components.workable:SetWorkAction(ACTIONS.HAMMER) 29 busstation.components.workable:SetWorkLeft(3) 30 busstation.components.workable:SetOnFinishCallback(function(busstation) 31 SpawnPrefab("collapse_big").Transform:SetPosition(busstation.Transform:GetWorldPosition()) 32 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 33 busstation:Remove() 34 end ) 35 busstation:AddComponent("trader") 36 busstation.components.trader:SetAcceptTest(function(busstation, item) 37 if item.prefab == "goldnugget" then 38 return true 39 end 40 return false 41 end ) 42 busstation.components.trader.onaccept = function(busstation, giver, item) 43 busstation:AddTag("startingpoint") 44 local target = FindEntity(busstation, 3000, function(guy) 45 return guy:HasTag("busstation") and not guy:HasTag("startingpoint") 46 end ) 47 if target then 48 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") 49 GetPlayer().components.playercontroller:Enable(false) 50 local pt1 = busstation:GetPosition() 51 local bus = SpawnPrefab("bedroll_straw") 52 bus.Transform:SetPosition(pt1.x+15+2, 0, pt1.z-15+2) 53 bus.AnimState:SetBank("rook") 54 bus.AnimState:SetBuild("rook_build") 55 bus.AnimState:PlayAnimation("idle", true) 56 bus.Transform:SetFourFaced() 57 bus.Transform:SetScale(1.2, 1.2, 1.2) 58 bus.AnimState:SetMultColour(255/255,105/255,0/255,1) 59 local sound = bus.entity:AddSoundEmitter() 60 bus:RemoveComponent("inventoryitem") 61 bus:RemoveComponent("stackable") 62 bus:RemoveComponent("fuel") 63 bus:RemoveComponent("sleepingbag") 64 bus:RemoveComponent("burnable") 65 bus:RemoveComponent("propagator") 66 bus:RemoveComponent("deployable") 67 bus:AddTag("goodbye") 68 bus:AddComponent("locomotor") 69 bus.components.locomotor.walkspeed = 5 70 bus.components.locomotor.runspeed = 10 71 bus:SetStateGraph("SGrook") 72 bus:AddComponent("health") 73 bus.components.health:SetMaxHealth(1000) 74 bus.components.health:SetInvincible(true) 75 bus:AddComponent("combat") 76 bus:AddComponent("follower") 77 bus:AddComponent("knownlocations") 78 bus:DoTaskInTime(1, function() 79 bus.components.locomotor:GoToPoint(Point(pt1.x+2, 0, pt1.z+2)) 80 end ) 81 bus:DoTaskInTime(9, function() 82 GetPlayer():Hide() 83 GetPlayer().components.health:SetInvincible(true) 84 local shadow = GetPlayer().entity:AddDynamicShadow() 85 shadow:SetSize( 0, 0 ) 86 bus.components.locomotor:GoToPoint(Point(pt1.x-15+2, 0, pt1.z+15+2)) 87 end ) 88 GetPlayer():DoTaskInTime(15, function() 89 TheFrontEnd:Fade(false,1) 90 bus:Remove() 91 GetPlayer().Transform:SetPosition(target.Transform:GetWorldPosition()) 92 GetPlayer():DoTaskInTime(2, function() 93 TheFrontEnd:Fade(true,1) 94 busstation:RemoveTag("startingpoint") 95 GetPlayer():Show() 96 GetPlayer().components.health:SetInvincible(false) 97 GetPlayer().components.playercontroller:Enable(true) 98 local shadow = GetPlayer().entity:AddDynamicShadow() 99 shadow:SetSize( 1.3, .6 ) 100 end ) 101 end ) 102 else 103 SpawnPrefab("goldnugget").Transform:SetPosition(GetPlayer().Transform:GetWorldPosition()) 104 busstation:RemoveTag("startingpoint") 105 end 106 end 107 inst.components.stackable:Get():Remove() 108end 109 inst:AddComponent("deployable") 110 inst.components.deployable.ondeploy = OnDeploy 111local function onsave(inst, data) 112 if inst:HasTag("goodbye") then 113 data.goodbye = true 114 end 115 if inst:HasTag("busstation") then 116 data.busstation = true 117 end 118end 119local function onload(inst, data) 120 if data and data.goodbye then 121 inst:Remove() 122 end 123 if data and data.busstation then 124 inst.AnimState:SetBank("sign_home") 125 inst.AnimState:SetBuild("sign_home") 126 inst.AnimState:PlayAnimation("idle") 127 inst.Transform:SetScale(1.5, 1.5, 1.5) 128 inst.AnimState:SetMultColour(255/255,105/255,0/255,0.8) 129 local minimap = inst.entity:AddMiniMapEntity() 130 minimap:SetIcon( "sign.png" ) 131 inst:RemoveComponent("inventoryitem") 132 inst:RemoveComponent("stackable") 133 inst:RemoveComponent("fuel") 134 inst:RemoveComponent("sleepingbag") 135 inst:RemoveComponent("burnable") 136 inst:RemoveComponent("propagator") 137 inst:RemoveComponent("deployable") 138 inst:AddTag("busstation") 139 inst:AddComponent("workable") 140 inst.components.workable:SetWorkAction(ACTIONS.HAMMER) 141 inst.components.workable:SetWorkLeft(3) 142 inst.components.workable:SetOnFinishCallback(function(inst) 143 SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) 144 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 145 inst:Remove() 146 end ) 147 inst:AddComponent("trader") 148 inst.components.trader:SetAcceptTest(function(inst, item) 149 if item.prefab == "goldnugget" then 150 return true 151 end 152 return false 153 end ) 154 inst.components.trader.onaccept = function(inst, giver, item) 155 inst:AddTag("startingpoint") 156 local target = FindEntity(inst, 3000, function(guy) 157 return guy:HasTag("busstation") and not guy:HasTag("startingpoint") 158 end ) 159 if target then 160 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") 161 GetPlayer().components.playercontroller:Enable(false) 162 local pt1 = inst:GetPosition() 163 local bus = SpawnPrefab("bedroll_straw") 164 bus.Transform:SetPosition(pt1.x+15+2, 0, pt1.z-15+2) 165 bus.AnimState:SetBank("rook") 166 bus.AnimState:SetBuild("rook_build") 167 bus.AnimState:PlayAnimation("idle", true) 168 bus.Transform:SetFourFaced() 169 bus.Transform:SetScale(1.2, 1.2, 1.2) 170 bus.AnimState:SetMultColour(255/255,105/255,0/255,1) 171 local sound = bus.entity:AddSoundEmitter() 172 bus:RemoveComponent("inventoryitem") 173 bus:RemoveComponent("stackable") 174 bus:RemoveComponent("fuel") 175 bus:RemoveComponent("sleepingbag") 176 bus:RemoveComponent("burnable") 177 bus:RemoveComponent("propagator") 178 bus:RemoveComponent("deployable") 179 bus:AddTag("goodbye") 180 bus:AddComponent("locomotor") 181 bus.components.locomotor.walkspeed = 5 182 bus.components.locomotor.runspeed = 10 183 bus:SetStateGraph("SGrook") 184 bus:AddComponent("health") 185 bus.components.health:SetMaxHealth(1000) 186 bus.components.health:SetInvincible(true) 187 bus:AddComponent("combat") 188 bus:AddComponent("follower") 189 bus:AddComponent("knownlocations") 190 bus:DoTaskInTime(1, function() 191 bus.components.locomotor:GoToPoint(Point(pt1.x+2, 0, pt1.z+2)) 192 end ) 193 bus:DoTaskInTime(9, function() 194 GetPlayer():Hide() 195 GetPlayer().components.health:SetInvincible(true) 196 local shadow = GetPlayer().entity:AddDynamicShadow() 197 shadow:SetSize( 0, 0 ) 198 bus.components.locomotor:GoToPoint(Point(pt1.x-15+2, 0, pt1.z+15+2)) 199 end ) 200 GetPlayer():DoTaskInTime(15, function() 201 TheFrontEnd:Fade(false,1) 202 bus:Remove() 203 GetPlayer().Transform:SetPosition(target.Transform:GetWorldPosition()) 204 GetPlayer():DoTaskInTime(2, function() 205 TheFrontEnd:Fade(true,1) 206 inst:RemoveTag("startingpoint") 207 GetPlayer():Show() 208 GetPlayer().components.health:SetInvincible(false) 209 GetPlayer().components.playercontroller:Enable(true) 210 local shadow = GetPlayer().entity:AddDynamicShadow() 211 shadow:SetSize( 1.3, .6 ) 212 end ) 213 end ) 214 else 215 SpawnPrefab("goldnugget").Transform:SetPosition(GetPlayer().Transform:GetWorldPosition()) 216 inst:RemoveTag("startingpoint") 217 end 218 end 219 end 220end 221 inst.OnSave = onsave 222 inst.OnLoad = onload 223 224 即可在地图的任意两个地点,用草席卷种公车站,给站牌1个黄金(拿着黄金对站牌点鼠标左键),会来公共汽车送你到另一个站牌,方便在两点间快速移动。公车站须种在空旷的地方,以便公共汽车行驶。如果只种了一个公车站,则站牌不会接受你的黄金。公车站在小地图上显示为路牌的图标。不想要公车站时,用锤子砸掉即可。草席卷在生存选项下(画着绳套)下,用6个草、1个绳子制造

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二七0.筋斗云(按键盘Z键召唤筋斗云在天上飞行,再按Z键落地) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("resurrectable")的下一行插入以下内容: 5 6TheInput:AddKeyUpHandler(KEY_Z, function() 7 if not inst:HasTag("flycloud") then 8 inst:AddTag("flycloud") 9 inst.components.locomotor:Stop() 10 inst.components.talker:ShutUp() 11 SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) 12 inst.AnimState:PlayAnimation("give") 13 inst:DoTaskInTime(0.3, function() 14 inst.cloud = SpawnPrefab("corn_cooked") 15 inst.cloud.Physics:SetActive(false) 16 inst.cloud.Transform:SetScale(1.8, 1.8, 1.8) 17 inst.cloud.AnimState:SetMultColour(255/255,255/255,255/255,0.6) 18 inst.cloud.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 19 inst.cloud:RemoveComponent("perishable") 20 inst.cloud:RemoveComponent("edible") 21 inst.cloud:RemoveComponent("stackable") 22 inst.cloud:RemoveComponent("inventoryitem") 23 inst.cloud:RemoveComponent("bait") 24 inst.cloud:RemoveComponent("tradable") 25 inst.cloud:RemoveComponent("burnable") 26 inst.cloud:RemoveComponent("propagator") 27 inst.cloud.persists = false 28 inst.cloud:AddTag("NOCLICK") 29 local follower = inst.cloud.entity:AddFollower() 30 follower:FollowSymbol( inst.GUID, "swap_body", 0, 60, 0 ) 31 local pt = inst:GetPosition() 32 inst.Transform:SetPosition(pt.x, 10, pt.z) 33 local shadow = inst.entity:AddDynamicShadow() 34 shadow:SetSize( 0, 0 ) 35 inst.gogogo = inst:DoPeriodicTask(.01, function() inst.Physics:SetMotorVelOverride(25,1.5,0) end) 36 end ) 37 else 38 inst:RemoveTag("flycloud") 39 inst.components.locomotor:Stop() 40 inst.components.talker:ShutUp() 41 SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) 42 inst.AnimState:PlayAnimation("give") 43 inst:DoTaskInTime(0.3, function() 44 if inst.cloud then inst.cloud:Remove() inst.cloud = nil end 45 if inst.gogogo then inst.gogogo:Cancel() inst.gogogo = nil end 46 local pt = inst:GetPosition() 47 inst.Transform:SetPosition(pt.x, 0, pt.z) 48 local shadow = inst.entity:AddDynamicShadow() 49 shadow:SetSize( 1.3, .6 ) 50 inst.Physics:ClearMotorVelOverride() 51 inst.Physics:ClearMotorVelOverride() 52 end ) 53 end 54end ) 55 56 即可口中默念咒语——“走你”,并按下键盘Z键,召唤筋斗云在天上飞行,用键盘W、S、A、D键控制方向,再次按Z键可落地

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二七一.全自动播种机(给避雷针植物,自动种下一百多个) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/lightningrod.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local slotpos = { Vector3(0,-75,0)} 7local function itemtest(inst, item, slot) 8 if item.prefab == "twigs" or item.prefab == "cutgrass" or item.prefab == "petals" or item.prefab == "petals_evil" or item.prefab == "cutreeds" or item.prefab == "red_cap" or item.prefab == "green_cap" or item.prefab == "blue_cap" or item.prefab == "carrot" or item.prefab == "berries" or item.prefab == "mandrake" or item.prefab == "foliage" or item.prefab == "cave_banana" or item.prefab == "cutlichen" or item.prefab == "lightbulb" or item.prefab == "pinecone" or item.prefab == "charcoal" or item.prefab == "acorn" or item.prefab == "cactus_meat" then 9 return true 10 end 11 return false 12end 13local widgetbuttoninfo = { 14 text = "Do", 15 position = Vector3(0, -145, 0), 16 fn = function(inst) 17 if GetPlayer().components.inventory:Has("goldnugget", 50) then 18 if inst.components.container:Has("twigs", 1) then 19 inst.components.container:ConsumeByName("twigs", 1) 20 inst.plants = "sapling" 21 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 22 end 23 if inst.components.container:Has("cutgrass", 1) then 24 inst.components.container:ConsumeByName("cutgrass", 1) 25 inst.plants = "grass" 26 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 27 end 28 if inst.components.container:Has("petals", 1) then 29 inst.components.container:ConsumeByName("petals", 1) 30 inst.plants = "flower" 31 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 32 end 33 if inst.components.container:Has("petals_evil", 1) then 34 inst.components.container:ConsumeByName("petals_evil", 1) 35 inst.plants = "flower_evil" 36 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 37 end 38 if inst.components.container:Has("cutreeds", 1) then 39 inst.components.container:ConsumeByName("cutreeds", 1) 40 inst.plants = "reeds" 41 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 42 end 43 if inst.components.container:Has("red_cap", 1) then 44 inst.components.container:ConsumeByName("red_cap", 1) 45 inst.plants = "red_mushroom" 46 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 47 end 48 if inst.components.container:Has("green_cap", 1) then 49 inst.components.container:ConsumeByName("green_cap", 1) 50 inst.plants = "green_mushroom" 51 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 52 end 53 if inst.components.container:Has("blue_cap", 1) then 54 inst.components.container:ConsumeByName("blue_cap", 1) 55 inst.plants = "blue_mushroom" 56 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 57 end 58 if inst.components.container:Has("carrot", 1) then 59 inst.components.container:ConsumeByName("carrot", 1) 60 inst.plants = "carrot_planted" 61 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 62 end 63 if inst.components.container:Has("berries", 1) then 64 inst.components.container:ConsumeByName("berries", 1) 65 inst.plants = "berrybush2" 66 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 67 end 68 if inst.components.container:Has("mandrake", 1) then 69 inst.components.container:ConsumeByName("mandrake", 1) 70 inst.plants = "mandrake" 71 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 72 end 73 if inst.components.container:Has("foliage", 1) then 74 inst.components.container:ConsumeByName("foliage", 1) 75 inst.plants = "cave_fern" 76 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 77 end 78 if inst.components.container:Has("cave_banana", 1) then 79 inst.components.container:ConsumeByName("cave_banana", 1) 80 inst.plants = "cave_banana_tree" 81 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 82 end 83 if inst.components.container:Has("cutlichen", 1) then 84 inst.components.container:ConsumeByName("cutlichen", 1) 85 inst.plants = "lichen" 86 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 87 end 88 if inst.components.container:Has("lightbulb", 1) then 89 inst.components.container:ConsumeByName("lightbulb", 1) 90 inst.plants = "flower_cave_triple" 91 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 92 end 93 if inst.components.container:Has("pinecone", 1) then 94 inst.components.container:ConsumeByName("pinecone", 1) 95 inst.plants = "evergreen_tall" 96 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 97 end 98 if inst.components.container:Has("charcoal", 1) then 99 inst.components.container:ConsumeByName("charcoal", 1) 100 inst.plants = "mushtree_tall" 101 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 102 end 103 if inst.components.container:Has("acorn", 1) then 104 inst.components.container:ConsumeByName("acorn", 1) 105 inst.plants = "deciduoustree_tall" 106 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 107 end 108 if inst.components.container:Has("cactus_meat", 1) then 109 inst.components.container:ConsumeByName("cactus_meat", 1) 110 inst.plants = "cactus" 111 GetPlayer().components.inventory:ConsumeByName("goldnugget", 50) 112 end 113 local pt = Vector3(inst.Transform:GetWorldPosition()) 114 inst:StartThread(function() 115 for k = 1, 25 do 116 local result_offset = FindValidPositionByFan(1 * 2 * PI, 4, 25, function(offset) 117 local x,y,z = (pt + offset):Get() 118 local ents = TheSim:FindEntities(x,y,z , 1) 119 return not next(ents) 120 end) 121 if result_offset then 122 local plant = SpawnPrefab(inst.plants) 123 plant.Transform:SetPosition((pt + result_offset):Get()) 124 GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) 125 local fx = SpawnPrefab("splash_ocean") 126 local pos = pt + result_offset 127 fx.Transform:SetPosition(pos.x, pos.y, pos.z) 128 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 129 end 130 Sleep(.33) 131 end 132 for k = 1, 37 do 133 local result_offset = FindValidPositionByFan(1 * 2 * PI, 6, 37, function(offset) 134 local x,y,z = (pt + offset):Get() 135 local ents = TheSim:FindEntities(x,y,z , 1) 136 return not next(ents) 137 end) 138 if result_offset then 139 local plant = SpawnPrefab(inst.plants) 140 plant.Transform:SetPosition((pt + result_offset):Get()) 141 GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) 142 local fx = SpawnPrefab("splash_ocean") 143 local pos = pt + result_offset 144 fx.Transform:SetPosition(pos.x, pos.y, pos.z) 145 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 146 end 147 Sleep(.23) 148 end 149 for k = 1, 50 do 150 local result_offset = FindValidPositionByFan(1 * 2 * PI, 8, 50, function(offset) 151 local x,y,z = (pt + offset):Get() 152 local ents = TheSim:FindEntities(x,y,z , 1) 153 return not next(ents) 154 end) 155 if result_offset then 156 local plant = SpawnPrefab(inst.plants) 157 plant.Transform:SetPosition((pt + result_offset):Get()) 158 GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) 159 local fx = SpawnPrefab("splash_ocean") 160 local pos = pt + result_offset 161 fx.Transform:SetPosition(pos.x, pos.y, pos.z) 162 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 163 end 164 Sleep(.13) 165 end 166 end) 167 end 168end } 169 inst:AddComponent("container") 170 inst.components.container:SetNumSlots(#slotpos) 171 inst.components.container.widgetslotpos = slotpos 172 inst.components.container.widgetpos = Vector3(0,180,0) 173 inst.components.container.side_align_tip = 160 174 inst.components.container.itemtestfn = itemtest 175 inst.components.container.acceptsstacks = false 176 inst.components.container.widgetbuttoninfo = widgetbuttoninfo 177 178 即可在空旷的地上建一个避雷针,鼠标左键点避雷针可打开格子,在格子中放入植物后点Do按钮,可自动种下100多株该植物,将花费50个黄金,身上黄金数不足时不会种植。可种植的17种植物有:给树枝种树苗、给草种草、给花瓣种花、给噩梦花瓣种噩梦花、给芦苇种芦苇、给红蘑菇种红蘑菇、给绿蘑菇种绿蘑菇、给蓝蘑菇种蓝蘑菇、给胡萝卜种胡萝卜、给浆果种果树丛、给曼德拉草种曼德拉草、给叶子种蕨类植物、给香蕉种香蕉树、给苔藓种苔藓、给荧光果种三朵洞穴花、给松果种树、给木炭种蘑菇树、给仙人掌肉种仙人掌、给橡果种橡树(橡树种下时不显示,存档退出再读档就可正常显示)。注意,其中果树丛、香蕉树、树、蘑菇树等种好后人无法通行,可以用“瑞士手杖”瞬移(或“神奇跳跃”跳出来),并用“收割者”大面积收获

2025/04/23 · Bny