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

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


 1
 2二三七.节日礼花(点燃荧光果放礼花)
 3
 4	MT管理器打开游戏目录/assets/scripts/prefabs/lightbulb.lua文件,在inst:AddComponent("inventoryitem")的下一行插入以下内容:
 5
 6local function OnIgniteFn(inst)
 7	GetPlayer().SoundEmitter:PlaySound("dontstarve/common/blackpowder_explo")
 8	inst:DoTaskInTime(1.5, function() inst.Physics:SetMotorVelOverride(0,42,0) end)
 9end
10local function OnExplodeFn(inst)
11	GetPlayer().components.sanity:DoDelta(5)
12	inst:StartThread(function()
13	   for k = 1,3 do
14		   GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo")
15		   TheCamera:Shake("FULL", 0.3, 0.02, .5, 40)
16		   Sleep(.1)
17	   end
18	end)
19end
20	inst:AddComponent("explosive")
21	inst.components.explosive:SetOnExplodeFn(OnExplodeFn)
22	inst.components.explosive:SetOnIgniteFn(OnIgniteFn)
23
24	即可用火炬点燃放在地上的荧光果,荧光果会飞上天空爆炸,每放一颗补5点脑,为你的节日增加一点气氛吧。在地洞里放礼花可以引起地震。如果想连续燃放,就将荧光果摆成一排(距离要近一些),点燃一个,其他就会陆续被点燃