diff --git a/objects/Trash.147e80.json b/objects/Trash.147e80.json index 6cfcc6af..493eeef7 100644 --- a/objects/Trash.147e80.json +++ b/objects/Trash.147e80.json @@ -34,7 +34,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "", + "LuaScript": "require(\"util/Trashcan\")", "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, diff --git a/objects/Trash.4b8594.json b/objects/Trash.4b8594.json index f93d73c2..b3d8e954 100644 --- a/objects/Trash.4b8594.json +++ b/objects/Trash.4b8594.json @@ -34,7 +34,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "", + "LuaScript": "require(\"util/Trashcan\")", "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, diff --git a/objects/Trash.5f896a.json b/objects/Trash.5f896a.json index 9de436ed..c0aed51b 100644 --- a/objects/Trash.5f896a.json +++ b/objects/Trash.5f896a.json @@ -34,7 +34,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "", + "LuaScript": "require(\"util/Trashcan\")", "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, diff --git a/objects/Trash.70b9f6.json b/objects/Trash.70b9f6.json index 8efdd284..9157562a 100644 --- a/objects/Trash.70b9f6.json +++ b/objects/Trash.70b9f6.json @@ -34,7 +34,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "", + "LuaScript": "require(\"util/Trashcan\")", "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, diff --git a/objects/Trash.f7b6c8.json b/objects/Trash.f7b6c8.json index 9825562c..a5fc05c6 100644 --- a/objects/Trash.f7b6c8.json +++ b/objects/Trash.f7b6c8.json @@ -34,7 +34,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, - "LuaScript": "", + "LuaScript": "require(\"util/Trashcan\")", "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, diff --git a/src/util/Trashcan.ttslua b/src/util/Trashcan.ttslua new file mode 100644 index 00000000..6a5a6625 --- /dev/null +++ b/src/util/Trashcan.ttslua @@ -0,0 +1,11 @@ +-- adds a context menu entry to trigger the emptying +function onLoad() + self.addContextMenuItem("Empty Trash", emptyTrash) +end + +-- removes all objects by taking them out and then destructing them +function emptyTrash() + for _, trash in ipairs(self.getObjects()) do + self.takeObject().destruct() + end +end