summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author4Evergreen4 <everett@mcjohnso.com>2016-01-12 20:58:14 -0500
committer4Evergreen4 <everett@mcjohnso.com>2016-01-12 20:58:14 -0500
commite2e670435bed9243764e7bc21b966ee276642d18 (patch)
treedbed55f0129e27f33b335cadf1abc5bec2d18f84
parente3b300c3cc950ac9d4ae663c243f929a5be31d81 (diff)
Use set_list instead of loop to clear trash
-rw-r--r--README.txt2
-rw-r--r--init.lua8
2 files changed, 3 insertions, 7 deletions
diff --git a/README.txt b/README.txt
index ccfa95a..da4ffb6 100644
--- a/README.txt
+++ b/README.txt
@@ -8,7 +8,7 @@
This mod adds a wooden trash can, and a dumpster to the game. Right click it, put in your trash, and click the empty trash button.
You can also throw things in the wooden trash can by pressing "q" or throwing them out of your inventory.
-Version: 0.2.1
+Version: 0.2.2
License: MIT (see LICENSE.txt)
Dependencies:
diff --git a/init.lua b/init.lua
index 03e7709..6ae0f50 100644
--- a/init.lua
+++ b/init.lua
@@ -119,9 +119,7 @@ minetest.register_node("trash_can:trash_can_wooden",{
if fields.empty then
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
- for i = 1, inv:get_size("trashlist") do
- inv:set_stack("trashlist", i, nil)
- end
+ inv:set_list("trashlist", {})
minetest.sound_play("trash", {to_player=sender:get_player_name(), gain = 1.0})
minetest.log("action", sender:get_player_name() ..
" empties trash can at " .. minetest.pos_to_string(pos))
@@ -198,9 +196,7 @@ minetest.register_node("trash_can:dumpster", {
if fields.empty then
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
- for i = 1, inv:get_size("main") do
- inv:set_stack("main", i, nil)
- end
+ inv:set_list("main", {})
minetest.sound_play("trash", {to_player=sender:get_player_name(), gain = 2.0})
end
end