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

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



二三二.移动垃圾桶(狗箱增加删除物品按钮作垃圾桶)

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

local widgetbuttoninfo = {
	text = "Delete",
	position = Vector3(0, -195, 0),
	fn = function(inst)
		inst.components.container:DestroyContents()
		inst.SoundEmitter:PlaySound("dontstarve/common/destroy_stone")
	end }
	inst.components.container.widgetbuttoninfo = widgetbuttoninfo

	即可在切斯特狗箱的格子下方增加一个Delete按钮,将不想要的物品放入狗箱,按下Delete按钮即可清除掉,让游戏不会因垃圾太多而越来越卡。不按钮的话,照常可以储存物品。千万不要把骨眼放入狗箱清除掉哦