代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。

原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html



二七六.电动草叉(拿草叉自动铲起脚下的地皮)

	用MT管理器打开游戏目录/assets/scripts/prefabs/pitchfork.lua文件,将下列内容:

local function onequip(inst, owner) 
	owner.AnimState:OverrideSymbol("swap_object", "swap_pitchfork", "swap_pitchfork")
	owner.AnimState:Show("ARM_carry") 
	owner.AnimState:Hide("ARM_normal") 
end

local function onunequip(inst, owner) 
	owner.AnimState:Hide("ARM_carry") 
	owner.AnimState:Show("ARM_normal") 
end

	替换为:

local function pickup(inst, owner)
	local pt = owner:GetPosition()
	inst.components.terraformer:Terraform(pt)
	inst.SoundEmitter:PlaySound("dontstarve/wilson/dig")
end
local function onequip(inst, owner) 
	if owner.components.inventory:Has("lightbulb", 1) then
	   inst.task = inst:DoPeriodicTask(.033, function() pickup(inst, owner) end)
	   owner.components.inventory:ConsumeByName("lightbulb", 1)
	end
	owner.AnimState:OverrideSymbol("swap_object", "swap_pitchfork", "swap_pitchfork")
	owner.AnimState:Show("ARM_carry") 
	owner.AnimState:Hide("ARM_normal") 
end
local function onunequip(inst, owner) 
	owner.AnimState:Hide("ARM_carry") 
	owner.AnimState:Show("ARM_normal") 
	if inst.task then inst.task:Cancel() inst.task = nil end
end

	即可拿草叉自动铲起脚下的地皮,效率极高,铲地的速度只取决于你走多快。电动草叉需要能源,每次装备时自动开启,会消耗1个荧光果,如果身上没有荧光果,则不会开启电动功能,只能手动铲地了