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

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



二三七.节日礼花(点燃荧光果放礼花)

	用MT管理器打开游戏目录/assets/scripts/prefabs/lightbulb.lua文件,在inst:AddComponent("inventoryitem")的下一行插入以下内容:

local function OnIgniteFn(inst)
	GetPlayer().SoundEmitter:PlaySound("dontstarve/common/blackpowder_explo")
	inst:DoTaskInTime(1.5, function() inst.Physics:SetMotorVelOverride(0,42,0) end)
end
local function OnExplodeFn(inst)
	GetPlayer().components.sanity:DoDelta(5)
	inst:StartThread(function()
	   for k = 1,3 do
		   GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo")
		   TheCamera:Shake("FULL", 0.3, 0.02, .5, 40)
		   Sleep(.1)
	   end
	end)
end
	inst:AddComponent("explosive")
	inst.components.explosive:SetOnExplodeFn(OnExplodeFn)
	inst.components.explosive:SetOnIgniteFn(OnIgniteFn)

	即可用火炬点燃放在地上的荧光果,荧光果会飞上天空爆炸,每放一颗补5点脑,为你的节日增加一点气氛吧。在地洞里放礼花可以引起地震。如果想连续燃放,就将荧光果摆成一排(距离要近一些),点燃一个,其他就会陆续被点燃