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