diff options
author | 4Evergreen4 <everett@mcjohnso.com> | 2016-01-12 20:58:14 -0500 |
---|---|---|
committer | 4Evergreen4 <everett@mcjohnso.com> | 2016-01-12 20:58:14 -0500 |
commit | e2e670435bed9243764e7bc21b966ee276642d18 (patch) | |
tree | dbed55f0129e27f33b335cadf1abc5bec2d18f84 | |
parent | e3b300c3cc950ac9d4ae663c243f929a5be31d81 (diff) |
Use set_list instead of loop to clear trash
-rw-r--r-- | README.txt | 2 | ||||
-rw-r--r-- | init.lua | 8 |
2 files changed, 3 insertions, 7 deletions
@@ -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: @@ -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 |