From 5f793789ad38179aff7aaddcc262eec64cc9f087 Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Fri, 3 May 2019 02:22:32 -0400 Subject: update homedecor and simple_streetlights --- simple_streetlights/depends.txt | 4 +- simple_streetlights/init.lua | 6 +- simple_streetlights/minedot.lua | 15 ++- simple_streetlights/simple.lua | 121 ++++++++++++--------- ...treetlights_inv_light_source_glowlight_cube.png | Bin 0 -> 192 bytes ...simple_streetlights_inv_light_source_ilight.png | Bin 0 -> 203 bytes ...mple_streetlights_inv_light_source_meselamp.png | Bin 0 -> 513 bytes .../simple_streetlights_inv_pole_brass.png | Bin 0 -> 787 bytes .../simple_streetlights_inv_pole_junglewood.png | Bin 0 -> 700 bytes .../simple_streetlights_inv_pole_steel.png | Bin 0 -> 757 bytes .../textures/simple_streetlights_inv_pole_wood.png | Bin 0 -> 644 bytes .../simple_streetlights_inv_pole_wrought_iron.png | Bin 0 -> 716 bytes .../simple_streetlights_spawner_brass_white.png | Bin 1850 -> 0 bytes .../simple_streetlights_spawner_steel_white.png | Bin 1599 -> 0 bytes .../simple_streetlights_spawner_wood_meselamp.png | Bin 1700 -> 0 bytes .../simple_streetlights_spawner_wood_white.png | Bin 1691 -> 0 bytes ...ple_streetlights_spawner_wrought_iron_white.png | Bin 1630 -> 0 bytes 17 files changed, 90 insertions(+), 56 deletions(-) create mode 100644 simple_streetlights/textures/simple_streetlights_inv_light_source_glowlight_cube.png create mode 100644 simple_streetlights/textures/simple_streetlights_inv_light_source_ilight.png create mode 100644 simple_streetlights/textures/simple_streetlights_inv_light_source_meselamp.png create mode 100644 simple_streetlights/textures/simple_streetlights_inv_pole_brass.png create mode 100644 simple_streetlights/textures/simple_streetlights_inv_pole_junglewood.png create mode 100644 simple_streetlights/textures/simple_streetlights_inv_pole_steel.png create mode 100644 simple_streetlights/textures/simple_streetlights_inv_pole_wood.png create mode 100644 simple_streetlights/textures/simple_streetlights_inv_pole_wrought_iron.png delete mode 100644 simple_streetlights/textures/simple_streetlights_spawner_brass_white.png delete mode 100644 simple_streetlights/textures/simple_streetlights_spawner_steel_white.png delete mode 100644 simple_streetlights/textures/simple_streetlights_spawner_wood_meselamp.png delete mode 100644 simple_streetlights/textures/simple_streetlights_spawner_wood_white.png delete mode 100644 simple_streetlights/textures/simple_streetlights_spawner_wrought_iron_white.png (limited to 'simple_streetlights') diff --git a/simple_streetlights/depends.txt b/simple_streetlights/depends.txt index 191f064..26a770c 100644 --- a/simple_streetlights/depends.txt +++ b/simple_streetlights/depends.txt @@ -1,6 +1,8 @@ default +basic_materials? creative? ilights? gloopblocks? -homedecor? +homedecor_fences? +homedecor_lighting? streetspoles? diff --git a/simple_streetlights/init.lua b/simple_streetlights/init.lua index 50310b6..e18ba8a 100644 --- a/simple_streetlights/init.lua +++ b/simple_streetlights/init.lua @@ -2,7 +2,11 @@ local modpath = minetest.get_modpath("simple_streetlights") +streetlights = {} +streetlights.basic_materials = minetest.get_modpath("basic_materials") +streetlights.concrete = "basic_materials:concrete_block" + dofile(modpath.."/simple.lua") -if minetest.get_modpath("homedecor") and minetest.get_modpath("streetspoles") then +if minetest.get_modpath("homedecor_lighting") and minetest.get_modpath("streetspoles") then dofile(modpath.."/minedot.lua") end diff --git a/simple_streetlights/minedot.lua b/simple_streetlights/minedot.lua index 7521deb..e8f8141 100644 --- a/simple_streetlights/minedot.lua +++ b/simple_streetlights/minedot.lua @@ -31,7 +31,7 @@ local offsets = { }, } -local function takeMaterials(player,materials) +local function takeMaterials(player, sneak, materials) local name = player:get_player_name() if creative and creative.is_enabled_for(name) then return true end local inv = minetest.get_inventory({type = "player",name = name}) @@ -39,8 +39,14 @@ local function takeMaterials(player,materials) for _,i in ipairs(materials) do if not inv:contains_item("main",i) then hasMaterials = false end end + if sneak and streetlights.basic_materials and not inv:contains_item("main", streetlights.concrete) then + hasMaterials = false + end if hasMaterials then for _,i in ipairs(materials) do inv:remove_item("main",i) end + if sneak then + inv:remove_item("main", streetlights.concrete) + end return true else minetest.chat_send_player(name,"You don't have the necessary materials to do that!") @@ -50,6 +56,7 @@ end local function place(itemstack,player,pointed) if not player then return end + local sneak = player:get_player_control().sneak local name = player:get_player_name() if not minetest.check_player_privs(name,{streetlight = true}) then minetest.chat_send_player(name,"*** You don't have permission to use a streetlight spawner.") @@ -58,9 +65,10 @@ local function place(itemstack,player,pointed) local pos = pointed.above if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass = true}) then minetest.record_protection_violation(pos,name) + return end local isDouble = string.sub(itemstack:get_name(),-6,-1) == "double" - if not takeMaterials(player,isDouble and doubleMaterials or singleMaterials) then return end + if not takeMaterials(player, sneak, isDouble and doubleMaterials or singleMaterials) then return end local facedir = minetest.facedir_to_dir(minetest.dir_to_facedir(player:get_look_dir())) local schemDir = 0 if facedir.x == 1 then schemDir = 180 @@ -69,6 +77,9 @@ local function place(itemstack,player,pointed) local offset = offsets[isDouble and "double" or "single"][schemDir] local pos = vector.add(pos,offset) minetest.place_schematic(pos,isDouble and schems.double or schems.single,schemDir,nil,false) + if sneak and streetlights.basic_materials then + minetest.set_node({x=pos.x, y=pos.y-1, z=pos.z}, {name = streetlights.concrete}) + end end minetest.register_tool(":minedot_streetlights:spawner_single",{ diff --git a/simple_streetlights/simple.lua b/simple_streetlights/simple.lua index 5d2518e..aaf5575 100644 --- a/simple_streetlights/simple.lua +++ b/simple_streetlights/simple.lua @@ -11,7 +11,8 @@ minetest.register_privilege("streetlight", { give_to_singleplayer = true }) -local function check_and_place(itemstack, placer, pointed_thing, pole, light) +local function check_and_place(itemstack, placer, pointed_thing, pole, light, param2) + local sneak = placer:get_player_control().sneak if not placer then return end if not minetest.check_player_privs(placer, "streetlight") then minetest.chat_send_player(placer:get_player_name(), "*** You don't have permission to use a streetlight spawner.") @@ -57,9 +58,17 @@ local function check_and_place(itemstack, placer, pointed_thing, pole, light) def4 = minetest.registered_items[node4.name] if minetest.is_protected(pos4, player_name) or not (def3 and def4.buildable_to) then return end + if sneak and minetest.is_protected(pos1, player_name) then return end + if not creative or not creative.is_enabled_for(player_name) then local inv = placer:get_inventory() if not inv:contains_item("main", pole.." 5") or not inv:contains_item("main", light) then return end + if sneak and inv:contains_item("main", streetlights.concrete) then + inv:remove_item("main", streetlights.concrete) + else + return + end + inv:remove_item("main", pole.." 5") inv:remove_item("main", light) end @@ -69,61 +78,69 @@ local function check_and_place(itemstack, placer, pointed_thing, pole, light) minetest.set_node(pos2, {name = pole }) end minetest.set_node(pos3, { name = pole }) - minetest.set_node(pos4, { name = light, param2 = 0 }) + minetest.set_node(pos4, { name = light, param2 = param2 }) + if sneak then + minetest.set_node(pos1, { name = streetlights.concrete }) + end end -minetest.register_tool("simple_streetlights:spawner_wood_meselamp", { - description = "Streetlight spawner (wooden pole, Mese lamp cube)", - inventory_image = "simple_streetlights_spawner_wood_meselamp.png", - use_texture_alpha = true, - tool_capabilities = { full_punch_interval=0.1 }, - on_place = function(itemstack, placer, pointed_thing) - check_and_place(itemstack, placer, pointed_thing, "default:fence_wood", "default:meselamp") - end -}) +local poles_tab = { +-- material name, mod name, node name + { "wood", "default", "default:fence_wood" }, + { "junglewood", "default", "default:fence_junglewood" }, + { "brass", "homedecor_fences", "homedecor:fence_brass" }, + { "wrought_iron", "homedecor_fences", "homedecor:fence_wrought_iron" }, + { "steel", "gloopblocks", "gloopblocks:fence_steel" } +} -if minetest.get_modpath("ilights") then - minetest.register_tool("simple_streetlights:spawner_wood_white", { - description = "Streetlight spawner (wooden pole, white light)", - inventory_image = "simple_streetlights_spawner_wood_white.png", - use_texture_alpha = true, - tool_capabilities = { full_punch_interval=0.1 }, - on_place = function(itemstack, placer, pointed_thing) - check_and_place(itemstack, placer, pointed_thing, "default:fence_wood", "ilights:light") - end - }) - - if minetest.get_modpath("gloopblocks") then - minetest.register_tool("simple_streetlights:spawner_steel_white", { - description = "Streetlight spawner (steel pole, white light)", - inventory_image = "simple_streetlights_spawner_steel_white.png", - use_texture_alpha = true, - tool_capabilities = { full_punch_interval=0.1 }, - on_place = function(itemstack, placer, pointed_thing) - check_and_place(itemstack, placer, pointed_thing, "gloopblocks:fence_steel", "ilights:light") - end - }) - end +local lights_tab = { +-- light name, mod name, node name, optional param2 + { "meselamp", "default", "default:meselamp" }, + { "ilight", "ilights", "ilights:light" }, + { "glowlight_cube", "homedecor_lighting", "homedecor:glowlight_small_cube" } +} + +for _, pole in ipairs(poles_tab) do + local matname = pole[1] + local matmod = pole[2] + local matnode = pole[3] + + if minetest.get_modpath(matmod) then + + for _, light in ipairs(lights_tab) do + local lightname = light[1] + local lightmod = light[2] + local lightnode = light[3] + local lightparam2 = light[4] or 0 + + if minetest.get_modpath(lightmod) then + + minetest.register_tool("simple_streetlights:spawner_"..matname.."_"..lightname, { + description = "Streetlight spawner ("..matname.." pole, "..lightname..")", + inventory_image = "simple_streetlights_inv_pole_"..matname..".png".. + "^simple_streetlights_inv_light_source_"..lightname..".png", + use_texture_alpha = true, + tool_capabilities = { full_punch_interval=0.1 }, + on_place = function(itemstack, placer, pointed_thing) + check_and_place(itemstack, placer, pointed_thing, matnode, lightnode, lightparam2) + end + }) + + minetest.register_craft({ + output = "simple_streetlights:spawner_"..matname.."_"..lightname, + type = "shapeless", + recipe = { + matnode, + matnode, + matnode, + matnode, + matnode, + matnode, + lightnode + } + }) - if minetest.get_modpath("homedecor") then - minetest.register_tool("simple_streetlights:spawner_wrought_iron_white", { - description = "Streetlight spawner (wrought iron pole, white light)", - inventory_image = "simple_streetlights_spawner_wrought_iron_white.png", - use_texture_alpha = true, - tool_capabilities = { full_punch_interval=0.1 }, - on_place = function(itemstack, placer, pointed_thing) - check_and_place(itemstack, placer, pointed_thing, "homedecor:fence_wrought_iron", "ilights:light") - end - }) - - minetest.register_tool("simple_streetlights:spawner_brass_white", { - description = "Streetlight spawner (brass pole, white light)", - inventory_image = "simple_streetlights_spawner_brass_white.png", - use_texture_alpha = true, - tool_capabilities = { full_punch_interval=0.1 }, - on_place = function(itemstack, placer, pointed_thing) - check_and_place(itemstack, placer, pointed_thing, "homedecor:fence_brass", "ilights:light") end - }) + end end end diff --git a/simple_streetlights/textures/simple_streetlights_inv_light_source_glowlight_cube.png b/simple_streetlights/textures/simple_streetlights_inv_light_source_glowlight_cube.png new file mode 100644 index 0000000..386b6d2 Binary files /dev/null and b/simple_streetlights/textures/simple_streetlights_inv_light_source_glowlight_cube.png differ diff --git a/simple_streetlights/textures/simple_streetlights_inv_light_source_ilight.png b/simple_streetlights/textures/simple_streetlights_inv_light_source_ilight.png new file mode 100644 index 0000000..cb7cfdb Binary files /dev/null and b/simple_streetlights/textures/simple_streetlights_inv_light_source_ilight.png differ diff --git a/simple_streetlights/textures/simple_streetlights_inv_light_source_meselamp.png b/simple_streetlights/textures/simple_streetlights_inv_light_source_meselamp.png new file mode 100644 index 0000000..d30515f Binary files /dev/null and b/simple_streetlights/textures/simple_streetlights_inv_light_source_meselamp.png differ diff --git a/simple_streetlights/textures/simple_streetlights_inv_pole_brass.png b/simple_streetlights/textures/simple_streetlights_inv_pole_brass.png new file mode 100644 index 0000000..e97853e Binary files /dev/null and b/simple_streetlights/textures/simple_streetlights_inv_pole_brass.png differ diff --git a/simple_streetlights/textures/simple_streetlights_inv_pole_junglewood.png b/simple_streetlights/textures/simple_streetlights_inv_pole_junglewood.png new file mode 100644 index 0000000..ccced10 Binary files /dev/null and b/simple_streetlights/textures/simple_streetlights_inv_pole_junglewood.png differ diff --git a/simple_streetlights/textures/simple_streetlights_inv_pole_steel.png b/simple_streetlights/textures/simple_streetlights_inv_pole_steel.png new file mode 100644 index 0000000..c3d1261 Binary files /dev/null and b/simple_streetlights/textures/simple_streetlights_inv_pole_steel.png differ diff --git a/simple_streetlights/textures/simple_streetlights_inv_pole_wood.png b/simple_streetlights/textures/simple_streetlights_inv_pole_wood.png new file mode 100644 index 0000000..227e0f5 Binary files /dev/null and b/simple_streetlights/textures/simple_streetlights_inv_pole_wood.png differ diff --git a/simple_streetlights/textures/simple_streetlights_inv_pole_wrought_iron.png b/simple_streetlights/textures/simple_streetlights_inv_pole_wrought_iron.png new file mode 100644 index 0000000..a0fa09f Binary files /dev/null and b/simple_streetlights/textures/simple_streetlights_inv_pole_wrought_iron.png differ diff --git a/simple_streetlights/textures/simple_streetlights_spawner_brass_white.png b/simple_streetlights/textures/simple_streetlights_spawner_brass_white.png deleted file mode 100644 index 10bbf38..0000000 Binary files a/simple_streetlights/textures/simple_streetlights_spawner_brass_white.png and /dev/null differ diff --git a/simple_streetlights/textures/simple_streetlights_spawner_steel_white.png b/simple_streetlights/textures/simple_streetlights_spawner_steel_white.png deleted file mode 100644 index df9c34f..0000000 Binary files a/simple_streetlights/textures/simple_streetlights_spawner_steel_white.png and /dev/null differ diff --git a/simple_streetlights/textures/simple_streetlights_spawner_wood_meselamp.png b/simple_streetlights/textures/simple_streetlights_spawner_wood_meselamp.png deleted file mode 100644 index 1bf5910..0000000 Binary files a/simple_streetlights/textures/simple_streetlights_spawner_wood_meselamp.png and /dev/null differ diff --git a/simple_streetlights/textures/simple_streetlights_spawner_wood_white.png b/simple_streetlights/textures/simple_streetlights_spawner_wood_white.png deleted file mode 100644 index 4ba28f1..0000000 Binary files a/simple_streetlights/textures/simple_streetlights_spawner_wood_white.png and /dev/null differ diff --git a/simple_streetlights/textures/simple_streetlights_spawner_wrought_iron_white.png b/simple_streetlights/textures/simple_streetlights_spawner_wrought_iron_white.png deleted file mode 100644 index 2025424..0000000 Binary files a/simple_streetlights/textures/simple_streetlights_spawner_wrought_iron_white.png and /dev/null differ -- cgit v1.2.3