From 05685e7a720959e946a22d7473b025e2849431b5 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Tue, 9 Jun 2015 21:26:21 +0200 Subject: [PATCH] Merged doors and dyes - Removed comments in dyes --- minetestforfun_game/mods/doors/depends.txt | 1 + minetestforfun_game/mods/doors/init.lua | 80 ++++++++++++++++++++-- minetestforfun_game/mods/dye/init.lua | 53 -------------- 3 files changed, 75 insertions(+), 59 deletions(-) diff --git a/minetestforfun_game/mods/doors/depends.txt b/minetestforfun_game/mods/doors/depends.txt index 4ad96d51..5e28beeb 100755 --- a/minetestforfun_game/mods/doors/depends.txt +++ b/minetestforfun_game/mods/doors/depends.txt @@ -1 +1,2 @@ default +screwdriver? diff --git a/minetestforfun_game/mods/doors/init.lua b/minetestforfun_game/mods/doors/init.lua index 216d2607..87cbf4a6 100755 --- a/minetestforfun_game/mods/doors/init.lua +++ b/minetestforfun_game/mods/doors/init.lua @@ -42,7 +42,7 @@ function doors.register_door(name, def) end local pt = pointed_thing.above - local pt2 = {x = pt.x, y = pt.y, z = pt.z} + local pt2 = {x=pt.x, y=pt.y, z=pt.z} pt2.y = pt2.y+1 if not minetest.registered_nodes[minetest.get_node(pt).name].buildable_to or @@ -60,7 +60,7 @@ function doors.register_door(name, def) end local p2 = minetest.dir_to_facedir(placer:get_look_dir()) - local pt3 = {x = pt.x, y = pt.y, z = pt.z} + local pt3 = {x=pt.x, y=pt.y, z=pt.z} if p2 == 0 then pt3.x = pt3.x-1 elseif p2 == 1 then @@ -107,6 +107,25 @@ function doors.register_door(name, def) end end + local function check_and_blast(pos, name) + local node = minetest.get_node(pos) + if node.name == name then + minetest.remove_node(pos) + end + end + + local function make_on_blast(base_name, dir, door_type, other_door_type) + if def.only_placer_can_open then + return function() end + else + return function(pos, intensity) + check_and_blast(pos, base_name .. door_type) + pos.y = pos.y + dir + check_and_blast(pos, base_name .. other_door_type) + end + end + end + local function on_rightclick(pos, dir, check_name, replace, replace_dir, params) pos.y = pos.y+dir if not minetest.get_node(pos).name == check_name then @@ -143,6 +162,33 @@ function doors.register_door(name, def) return meta:get_string("doors_owner") == pn end + local function on_rotate(pos, node, dir, user, check_name, mode, new_param2) + if not check_player_priv(pos, user) then + return false + end + if mode ~= screwdriver.ROTATE_FACE then + return false + end + + pos.y = pos.y + dir + if not minetest.get_node(pos).name == check_name then + return false + end + if minetest.is_protected(pos, user:get_player_name()) then + minetest.record_protection_violation(pos, user:get_player_name()) + return false + end + + local node2 = minetest.get_node(pos) + node2.param2 = (node2.param2 + 1) % 4 + minetest.swap_node(pos, node2) + + pos.y = pos.y - dir + node.param2 = (node.param2 + 1) % 4 + minetest.swap_node(pos, node) + return true + end + minetest.register_node(name.."_b_1", { tiles = {tb[2], tb[2], tb[2], tb[2], tb[1], tb[1].."^[transformfx"}, paramtype = "light", @@ -170,9 +216,14 @@ function doors.register_door(name, def) end end, + on_rotate = function(pos, node, user, mode, new_param2) + return on_rotate(pos, node, 1, user, name.."_t_1", mode) + end, + can_dig = check_player_priv, sounds = def.sounds, - sunlight_propagates = def.sunlight + sunlight_propagates = def.sunlight, + on_blast = make_on_blast(name, 1, "_b_1", "_t_1") }) minetest.register_node(name.."_t_1", { @@ -202,9 +253,14 @@ function doors.register_door(name, def) end end, + on_rotate = function(pos, node, user, mode, new_param2) + return on_rotate(pos, node, -1, user, name.."_b_1", mode) + end, + can_dig = check_player_priv, sounds = def.sounds, - sunlight_propagates = def.sunlight, + sunlight_propagates = def.sunlight, + on_blast = make_on_blast(name, -1, "_t_1", "_b_1") }) minetest.register_node(name.."_b_2", { @@ -234,9 +290,14 @@ function doors.register_door(name, def) end end, + on_rotate = function(pos, node, user, mode, new_param2) + return on_rotate(pos, node, 1, user, name.."_t_2", mode) + end, + can_dig = check_player_priv, sounds = def.sounds, - sunlight_propagates = def.sunlight + sunlight_propagates = def.sunlight, + on_blast = make_on_blast(name, 1, "_b_2", "_t_2") }) minetest.register_node(name.."_t_2", { @@ -266,9 +327,14 @@ function doors.register_door(name, def) end end, + on_rotate = function(pos, node, user, mode, new_param2) + return on_rotate(pos, node, -1, user, name.."_b_2", mode) + end, + can_dig = check_player_priv, sounds = def.sounds, - sunlight_propagates = def.sunlight + sunlight_propagates = def.sunlight, + on_blast = make_on_blast(name, -1, "_t_2", "_b_2") }) end @@ -388,6 +454,8 @@ function doors.register_trapdoor(name, def) minetest.set_node(pos, {name = newname, param1 = node.param1, param2 = node.param2}) end + def.on_rotate = minetest.get_modpath("screwdriver") and screwdriver.rotate_simple + -- Common trapdoor configuration def.drawtype = "nodebox" def.paramtype = "light" diff --git a/minetestforfun_game/mods/dye/init.lua b/minetestforfun_game/mods/dye/init.lua index 3e827446..d7d18f7a 100755 --- a/minetestforfun_game/mods/dye/init.lua +++ b/minetestforfun_game/mods/dye/init.lua @@ -1,63 +1,10 @@ -- minetest/dye/init.lua --- To make recipes that will work with any dye ever made by anybody, define --- them based on groups. --- You can select any group of groups, based on your need for amount of colors. --- basecolor: 9, excolor: 17, unicolor: 89 --- --- Example of one shapeless recipe using a color group: --- Note: As this uses basecolor_*, you'd need 9 of these. --- minetest.register_craft({ --- type = "shapeless", --- output = ':item_yellow', --- recipe = {':item_no_color', 'group:basecolor_yellow'}, --- }) - -- Other mods can use these for looping through available colors dye = {} dye.basecolors = {"white", "grey", "black", "red", "yellow", "green", "cyan", "blue", "magenta"} dye.excolors = {"white", "lightgrey", "grey", "darkgrey", "black", "red", "orange", "yellow", "lime", "green", "aqua", "cyan", "sky_blue", "blue", "violet", "magenta", "red_violet"} --- Base color groups: --- - basecolor_white --- - basecolor_grey --- - basecolor_black --- - basecolor_red --- - basecolor_yellow --- - basecolor_green --- - basecolor_cyan --- - basecolor_blue --- - basecolor_magenta - --- Extended color groups (* = equal to a base color): --- * excolor_white --- - excolor_lightgrey --- * excolor_grey --- - excolor_darkgrey --- * excolor_black --- * excolor_red --- - excolor_orange --- * excolor_yellow --- - excolor_lime --- * excolor_green --- - excolor_aqua --- * excolor_cyan --- - excolor_sky_blue --- * excolor_blue --- - excolor_violet --- * excolor_magenta --- - excolor_red_violet - --- The whole unifieddyes palette as groups: --- - unicolor_ --- For the following, no white/grey/black is allowed: --- - unicolor_medium_ --- - unicolor_dark_ --- - unicolor_light_ --- - unicolor__s50 --- - unicolor_medium__s50 --- - unicolor_dark__s50 - -- Local stuff local dyelocal = {}