From 6c4bfd62054a1bbd7d27daec265560c099171f3a Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Sun, 27 Jun 2021 18:38:34 -0400 Subject: [PATCH] pass streetlight "model" parameters via table --- functions.lua | 9 ++++++++- simple.lua | 21 ++++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/functions.lua b/functions.lua index 85ef924..d5412ae 100644 --- a/functions.lua +++ b/functions.lua @@ -31,7 +31,14 @@ function streetlights.rightclick_pointed_thing(pos, placer, itemstack, pointed_t return def.on_rightclick(pos, node, placer, itemstack, pointed_thing) or itemstack end -function streetlights.check_and_place(itemstack, placer, pointed_thing, pole, light, param2, needs_digiline_wire, distributor_node) +function streetlights.check_and_place(itemstack, placer, pointed_thing, def) + + local pole = def.pole + local light = def.light + local param2 = def.param2 + local needs_digiline_wire = def.needs_digiline_wire + local distributor_node = def.distributor_node + local controls = placer:get_player_control() if not placer then return end local playername = placer:get_player_name() diff --git a/simple.lua b/simple.lua index ad73993..1cf2361 100644 --- a/simple.lua +++ b/simple.lua @@ -114,7 +114,11 @@ for _, pole in ipairs(poles_tab) do use_texture_alpha = true, tool_capabilities = { full_punch_interval=0.1 }, on_place = function(itemstack, placer, pointed_thing) - streetlights.check_and_place(itemstack, placer, pointed_thing, matnode, lightnode, lightparam2) + streetlights.check_and_place(itemstack, placer, pointed_thing, { + pole=matnode, + light=lightnode, + param2=lightparam2 + }) end }) @@ -142,7 +146,12 @@ for _, pole in ipairs(poles_tab) do use_texture_alpha = true, tool_capabilities = { full_punch_interval=0.1 }, on_place = function(itemstack, placer, pointed_thing) - streetlights.check_and_place(itemstack, placer, pointed_thing, matnode, lightnode, lightparam2, true) + streetlights.check_and_place(itemstack, placer, pointed_thing, { + pole=matnode, + light=lightnode, + param2=lightparam2, + needs_digiline_wire=true + }) end, on_use = ilights.digiline_on_use }) @@ -192,7 +201,13 @@ for _, pole in ipairs(poles_tab) do use_texture_alpha = true, tool_capabilities = { full_punch_interval=0.1 }, on_place = function(itemstack, placer, pointed_thing) - streetlights.check_and_place(itemstack, placer, pointed_thing, matnode, lightnode, lightparam2, true, distributor) + streetlights.check_and_place(itemstack, placer, pointed_thing, { + pole=matnode, + light=lightnode, + param2=lightparam2, + needs_digiline_wire=true, + distributor_node=distributor + }) end, on_use = ilights.digiline_on_use })