代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
1
2二七七.电动铺路铲(拿黄金铲自动将脚下的空地皮铺成路)
3
4 用MT管理器打开游戏目录/assets/scripts/prefabs/shovel.lua文件,
5
6 1.将下列内容:
7
8local function onequipgold(inst, owner)
9 owner.AnimState:OverrideSymbol("swap_object", "swap_goldenshovel", "swap_goldenshovel")
10 owner.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
11 owner.AnimState:Show("ARM_carry")
12 owner.AnimState:Hide("ARM_normal")
13end
14
15 替换为:
16
17local function pickup(inst, owner)
18 inst.name = GROUND.ROAD
19 local pt = owner:GetPosition()
20 local ground = GetWorld()
21 local tile = ground.Map:GetTileAtPoint(pt.x, pt.y, pt.z)
22 if ground and tile == GROUND.DIRT then
23 local original_tile_type = ground.Map:GetTileAtPoint(pt.x, pt.y, pt.z)
24 local x, y = ground.Map:GetTileCoordsAtPoint(pt.x, pt.y, pt.z)
25 if x and y then
26 ground.Map:SetTile(x,y, inst.name)
27 ground.Map:RebuildLayer( original_tile_type, x, y )
28 ground.Map:RebuildLayer( inst.name, x, y )
29 end
30 local minimap = TheSim:FindFirstEntityWithTag("minimap")
31 if minimap then
32 minimap.MiniMap:RebuildLayer( original_tile_type, x, y )
33 minimap.MiniMap:RebuildLayer( inst.name, x, y )
34 end
35 end
36 inst.SoundEmitter:PlaySound("dontstarve/wilson/dig")
37end
38local function onequipgold(inst, owner)
39 if owner.components.inventory:Has("lightbulb", 1) then
40 inst.task = inst:DoPeriodicTask(.033, function() pickup(inst, owner) end)
41 owner.components.inventory:ConsumeByName("lightbulb", 1)
42 end
43 owner.AnimState:OverrideSymbol("swap_object", "swap_goldenshovel", "swap_goldenshovel")
44 owner.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
45 owner.AnimState:Show("ARM_carry")
46 owner.AnimState:Hide("ARM_normal")
47end
48local function onunequipgold(inst, owner)
49 owner.AnimState:Hide("ARM_carry")
50 owner.AnimState:Show("ARM_normal")
51 if inst.task then inst.task:Cancel() inst.task = nil end
52end
53
54
55 2.在inst.components.equippable:SetOnEquip( onequipgold )的下一行插入inst.components.equippable:SetOnUnequip( onunequipgold )
56
57 即可拿黄金铲自动将脚下的空地皮铺成路,效率极高,铺路的速度只取决于你走多快。电动铺路铲需要能源,每次装备时自动开启,会消耗1个荧光果,如果身上没有荧光果,则不会开启电动功能。将其中GROUND.ROAD(卵石路)替换为其他地皮名称,如GROUND.ROCKY(岩石地皮)、GROUND.DIRT(污垢地皮)、GROUND.SAVANNA(热带草原地皮)、GROUND.GRASS(长草地皮)、GROUND.FOREST(森林地皮)、GROUND.MARSH(沼泽地皮)、GROUND.WOODFLOOR(木质地板)、GROUND.CARPET(地毯地板)、GROUND.CHECKER(棋盘地板)、GROUND.CAVE(鸟粪地皮)、GROUND.FUNGUS(菌类地皮)、GROUND.FUNGUSRED(红菌类地皮)、GROUND.FUNGUSGREEN(绿菌类地皮)、GROUND.SINKHOLE(粘滑地皮)、GROUND.UNDERROCK(洞穴石地地皮)、GROUND.MUD(泥泞地皮),就可以自动铺其他地皮