Merge pull request #231 from argonui/trashcan

Trash: adding context menu function to empty
This commit is contained in:
BootleggerFinn 2023-03-12 14:51:59 -05:00 committed by GitHub
commit 0865c2b92f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 5 deletions

View File

@ -34,7 +34,7 @@
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScript": "",
"LuaScript": "require(\"util/Trashcan\")",
"LuaScriptState": "",
"MaterialIndex": -1,
"MeasureMovement": false,

View File

@ -34,7 +34,7 @@
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScript": "",
"LuaScript": "require(\"util/Trashcan\")",
"LuaScriptState": "",
"MaterialIndex": -1,
"MeasureMovement": false,

View File

@ -34,7 +34,7 @@
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScript": "",
"LuaScript": "require(\"util/Trashcan\")",
"LuaScriptState": "",
"MaterialIndex": -1,
"MeasureMovement": false,

View File

@ -34,7 +34,7 @@
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScript": "",
"LuaScript": "require(\"util/Trashcan\")",
"LuaScriptState": "",
"MaterialIndex": -1,
"MeasureMovement": false,

View File

@ -34,7 +34,7 @@
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScript": "",
"LuaScript": "require(\"util/Trashcan\")",
"LuaScriptState": "",
"MaterialIndex": -1,
"MeasureMovement": false,

11
src/util/Trashcan.ttslua Normal file
View File

@ -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