From 03fe55a1e907a3ca6243f23de1ae061643c450b2 Mon Sep 17 00:00:00 2001 From: Luke aka SwissalpS <161979+SwissalpS@users.noreply.github.com> Date: Tue, 31 Dec 2024 19:17:14 +0100 Subject: [PATCH] Add [smartshop] support (#34) Co-authored-by: Buckaroo Banzai <39065740+BuckarooBanzay@users.noreply.github.com> --- .luacheckrc | 1 + init.lua | 1 + mod.conf | 1 + nodes/smartshop.lua | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 nodes/smartshop.lua diff --git a/.luacheckrc b/.luacheckrc index ca3151d..57fde29 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -17,6 +17,7 @@ read_globals = { "mesecon", "pipeworks", "signs_lib", + "smartshop", "spacecannon", "xdecor", "bones", diff --git a/init.lua b/init.lua index b01aaa0..db069d4 100644 --- a/init.lua +++ b/init.lua @@ -50,6 +50,7 @@ local mods = { "powerbanks", "protector", "signs_lib", + "smartshop", "spacecannon", "soundblock", "technic", diff --git a/mod.conf b/mod.conf index 57617cd..fb0c306 100644 --- a/mod.conf +++ b/mod.conf @@ -29,6 +29,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, +}) +