diff options
author | Vanessa Dannenberg <vanessa.e.dannenberg@gmail.com> | 2019-05-03 02:22:32 -0400 |
---|---|---|
committer | Vanessa Dannenberg <vanessa.e.dannenberg@gmail.com> | 2019-05-03 02:22:32 -0400 |
commit | 5f793789ad38179aff7aaddcc262eec64cc9f087 (patch) | |
tree | d36720f72c348715ff88b861de621b040de9a9df /simple_streetlights | |
parent | cee90ea59a3c6e8a3175d850f1d057a328f345b8 (diff) | |
download | dreambuilder_modpack-5f793789ad38179aff7aaddcc262eec64cc9f087.tar dreambuilder_modpack-5f793789ad38179aff7aaddcc262eec64cc9f087.tar.gz dreambuilder_modpack-5f793789ad38179aff7aaddcc262eec64cc9f087.tar.bz2 dreambuilder_modpack-5f793789ad38179aff7aaddcc262eec64cc9f087.tar.xz dreambuilder_modpack-5f793789ad38179aff7aaddcc262eec64cc9f087.zip |
update homedecor and simple_streetlights
Diffstat (limited to 'simple_streetlights')
17 files changed, 90 insertions, 56 deletions
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 Binary files differnew file mode 100644 index 0000000..386b6d2 --- /dev/null +++ b/simple_streetlights/textures/simple_streetlights_inv_light_source_glowlight_cube.png diff --git a/simple_streetlights/textures/simple_streetlights_inv_light_source_ilight.png b/simple_streetlights/textures/simple_streetlights_inv_light_source_ilight.png Binary files differnew file mode 100644 index 0000000..cb7cfdb --- /dev/null +++ b/simple_streetlights/textures/simple_streetlights_inv_light_source_ilight.png diff --git a/simple_streetlights/textures/simple_streetlights_inv_light_source_meselamp.png b/simple_streetlights/textures/simple_streetlights_inv_light_source_meselamp.png Binary files differnew file mode 100644 index 0000000..d30515f --- /dev/null +++ b/simple_streetlights/textures/simple_streetlights_inv_light_source_meselamp.png diff --git a/simple_streetlights/textures/simple_streetlights_inv_pole_brass.png b/simple_streetlights/textures/simple_streetlights_inv_pole_brass.png Binary files differnew file mode 100644 index 0000000..e97853e --- /dev/null +++ b/simple_streetlights/textures/simple_streetlights_inv_pole_brass.png diff --git a/simple_streetlights/textures/simple_streetlights_inv_pole_junglewood.png b/simple_streetlights/textures/simple_streetlights_inv_pole_junglewood.png Binary files differnew file mode 100644 index 0000000..ccced10 --- /dev/null +++ b/simple_streetlights/textures/simple_streetlights_inv_pole_junglewood.png diff --git a/simple_streetlights/textures/simple_streetlights_inv_pole_steel.png b/simple_streetlights/textures/simple_streetlights_inv_pole_steel.png Binary files differnew file mode 100644 index 0000000..c3d1261 --- /dev/null +++ b/simple_streetlights/textures/simple_streetlights_inv_pole_steel.png diff --git a/simple_streetlights/textures/simple_streetlights_inv_pole_wood.png b/simple_streetlights/textures/simple_streetlights_inv_pole_wood.png Binary files differnew file mode 100644 index 0000000..227e0f5 --- /dev/null +++ b/simple_streetlights/textures/simple_streetlights_inv_pole_wood.png diff --git a/simple_streetlights/textures/simple_streetlights_inv_pole_wrought_iron.png b/simple_streetlights/textures/simple_streetlights_inv_pole_wrought_iron.png Binary files differnew file mode 100644 index 0000000..a0fa09f --- /dev/null +++ b/simple_streetlights/textures/simple_streetlights_inv_pole_wrought_iron.png diff --git a/simple_streetlights/textures/simple_streetlights_spawner_brass_white.png b/simple_streetlights/textures/simple_streetlights_spawner_brass_white.png Binary files differdeleted file mode 100644 index 10bbf38..0000000 --- a/simple_streetlights/textures/simple_streetlights_spawner_brass_white.png +++ /dev/null diff --git a/simple_streetlights/textures/simple_streetlights_spawner_steel_white.png b/simple_streetlights/textures/simple_streetlights_spawner_steel_white.png Binary files differdeleted file mode 100644 index df9c34f..0000000 --- a/simple_streetlights/textures/simple_streetlights_spawner_steel_white.png +++ /dev/null diff --git a/simple_streetlights/textures/simple_streetlights_spawner_wood_meselamp.png b/simple_streetlights/textures/simple_streetlights_spawner_wood_meselamp.png Binary files differdeleted file mode 100644 index 1bf5910..0000000 --- a/simple_streetlights/textures/simple_streetlights_spawner_wood_meselamp.png +++ /dev/null diff --git a/simple_streetlights/textures/simple_streetlights_spawner_wood_white.png b/simple_streetlights/textures/simple_streetlights_spawner_wood_white.png Binary files differdeleted file mode 100644 index 4ba28f1..0000000 --- a/simple_streetlights/textures/simple_streetlights_spawner_wood_white.png +++ /dev/null diff --git a/simple_streetlights/textures/simple_streetlights_spawner_wrought_iron_white.png b/simple_streetlights/textures/simple_streetlights_spawner_wrought_iron_white.png Binary files differdeleted file mode 100644 index 2025424..0000000 --- a/simple_streetlights/textures/simple_streetlights_spawner_wrought_iron_white.png +++ /dev/null |