diff --git a/.luacheckrc b/.luacheckrc index 86d4d4c..3552356 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -18,6 +18,7 @@ read_globals = { "mesecon", "pipeworks", "signs_lib", + "smartshop", "spacecannon", "xdecor", "bones", diff --git a/init.lua b/init.lua index 81e2df8..bbaac33 100644 --- a/init.lua +++ b/init.lua @@ -51,6 +51,7 @@ local mods = { "powerbanks", "protector", "signs_lib", + "smartshop", "spacecannon", "soundblock", "technic", diff --git a/mod.conf b/mod.conf index c35f7b8..14a938d 100644 --- a/mod.conf +++ b/mod.conf @@ -30,6 +30,7 @@ optional_depends = """ powerbanks, protector, signs_lib, + smartshop, spacecannon, soundblock, technic, diff --git a/nodes/smartshop.lua b/nodes/smartshop.lua new file mode 100644 index 0000000..88277ff --- /dev/null +++ b/nodes/smartshop.lua @@ -0,0 +1,42 @@ + +-- Register wrench support for the smartshop mod + +wrench.register_node("smartshop:shop", { + lists = { + "give1", "give2", "give3", "give4", + "main", + "pay1", "pay2", "pay3", "pay4", + }, + metas = { + alerted = wrench.META_TYPE_INT, + creative = wrench.META_TYPE_INT, + ghost = wrench.META_TYPE_INT, + infotext = wrench.META_TYPE_IGNORE, + owner = wrench.META_TYPE_STRING, + state = wrench.META_TYPE_IGNORE, + type = wrench.META_TYPE_INT, + }, + after_pickup = function(pos) + -- Remove entities + if smartshop.update_entities then + smartshop.update_entities(pos, "clear") + else + -- Older version + smartshop.update(pos, "clear") + end + -- Give smartshop a chance to keep track of statistics + smartshop.update_info(pos) + end, + after_place = function(pos) + -- Update infotext + smartshop.update_info(pos) + -- Create entities + if smartshop.update_entities then + smartshop.update_entities(pos, "update") + else + -- Older version + smartshop.update(pos, "update") + end + end, +}) +