diff --git a/mods/ENTITIES/mobs_mc/villager.lua b/mods/ENTITIES/mobs_mc/villager.lua index a7b7d9852..9c10c703d 100644 --- a/mods/ENTITIES/mobs_mc/villager.lua +++ b/mods/ENTITIES/mobs_mc/villager.lua @@ -30,6 +30,8 @@ local DEFAULT_WALK_CHANCE = 33 -- chance to walk in percent, if no player nearby local PLAYER_SCAN_INTERVAL = 5 -- every X seconds, villager looks for players nearby local PLAYER_SCAN_RADIUS = 4 -- scan radius for looking for nearby players +local RESETTLE_DISTANCE = 100 -- If a mob is transported this far from home, it gives up bed and job and resettles + local PATHFINDING = "gowp" --[=======[ TRADING ]=======] @@ -885,11 +887,18 @@ local function has_golem(pos) end end +local function monsters_near(self) + for _,o in pairs(minetest.get_objects_inside_radius(self.object:get_pos(),10)) do + local l = o:get_luaentity() + if l and l.type =="monster" then return true end + end +end + local function has_summon_participants(self) local r = 0 for _,o in pairs(minetest.get_objects_inside_radius(self.object:get_pos(),10)) do local l = o:get_luaentity() - --TODO check for panicking or gossiping + --TODO check for gossiping if l and l.name == "mobs_mc:villager" then r = r + 1 end end return r > 2 @@ -913,7 +922,8 @@ local function check_summon(self,dtime) if self._summon_timer and self._summon_timer > 30 then local pos = self.object:get_pos() self._summon_timer = 0 - if has_golem(pos) then return false end + if has_golem(pos) then return end + if not monsters_near(self) then return end if not has_summon_participants(self) then return end summon_golem(self) elseif self._summon_timer == nil then @@ -1089,25 +1099,38 @@ local function retrieve_my_jobsite (self) return end +local function remove_job (self) + self._jobsite = nil + if not has_traded(self) then + mcl_log("Cannot retrieve my jobsite. I am now unemployed.") + self._profession = "unemployed" + self._trades = nil + set_textures(self) + else + mcl_log("Cannot retrieve my jobsite but I've traded so only remove jobsite.") + end +end + local function validate_jobsite(self) if self._profession == "unemployed" then return false end - if not retrieve_my_jobsite (self) then - self._jobsite = nil + local job_block = retrieve_my_jobsite (self) + if not job_block then if self.order == WORK then self.order = nil end - if not has_traded(self) then - mcl_log("Cannot retrieve my jobsite. I am now unemployed.") - self._profession = "unemployed" - self._trades = nil - set_textures(self) - else - mcl_log("Cannot retrieve my jobsite but I've traded so only remove jobsite.") - end + remove_job (self) return false else + local resettle = vector.distance(self.object:get_pos(),self._jobsite) > RESETTLE_DISTANCE + mcl_log("Jobsite far, so resettle: " .. tostring(resettle)) + if resettle then + local m = minetest.get_meta(self._jobsite) + m:set_string("villager", nil) + remove_job (self) + return false + end return true end end @@ -1222,6 +1245,17 @@ local function validate_bed(self) local bed_valid = true local m = minetest.get_meta(self._bed) + + local resettle = vector.distance(self.object:get_pos(),self._bed) > RESETTLE_DISTANCE + mcl_log("Bed far, so resettle: " .. tostring(resettle)) + if resettle then + mcl_log("Resettled. Ditch bed.") + m:set_string("villager", nil) + self._bed = nil + bed_valid = false + return false + end + local owned_by_player = m:get_string("player") mcl_log("Player owner: " .. owned_by_player) if owned_by_player ~= "" then @@ -1229,7 +1263,7 @@ local function validate_bed(self) m:set_string("villager", nil) self._bed = nil bed_valid = false - return + return false end if m:get_string("villager") ~= self._id then @@ -1245,6 +1279,10 @@ end local function do_activity (self) -- Maybe just check we're pathfinding first? + if self.following then + mcl_log("Following, so do not do activity.") + return + end if not validate_bed(self) and self.state ~= PATHFINDING then if self.order == SLEEP then self.order = nil end diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor.lua b/mods/ENVIRONMENT/mcl_weather/skycolor.lua index a4108598f..6fb8ab56c 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor.lua @@ -1,7 +1,11 @@ local mods_loaded = false local NIGHT_VISION_RATIO = 0.45 +local water_color = "#0b4880" + function mcl_weather.set_sky_box_clear(player) + local pos = player:get_pos() + if minetest.get_item_group(minetest.get_node(vector.new(pos.x,pos.y+1.5,pos.z)).name, "water") ~= 0 then return end player:set_sky({ type = "regular", sky_color = { @@ -16,6 +20,16 @@ function mcl_weather.set_sky_box_clear(player) }) end +function mcl_weather.set_sky_color(player, def) + local pos = player:get_pos() + if minetest.get_item_group(minetest.get_node(vector.new(pos.x,pos.y+1.5,pos.z)).name, "water") ~= 0 then return end + player:set_sky({ + type = def.type, + sky_color = def.sky_color, + clouds = def.clouds, + }) +end + mcl_weather.skycolor = { -- Should be activated before do any effect. active = true, @@ -96,6 +110,19 @@ mcl_weather.skycolor = { local pos = player:get_pos() local dim = mcl_worlds.pos_to_dimension(pos) local has_weather = (mcl_worlds.has_weather(pos) and (mcl_weather.state == "snow" or mcl_weather.state =="rain" or mcl_weather.state == "thunder") and mcl_weather.has_snow(pos)) or ((mcl_weather.state =="rain" or mcl_weather.state == "thunder") and mcl_weather.has_rain(pos)) + if minetest.get_item_group(minetest.get_node(vector.new(pos.x,pos.y+1.5,pos.z)).name, "water") ~= 0 then + player:set_sky({ type = "regular", + sky_color = { + day_sky = water_color, + day_horizon = water_color, + dawn_sky = water_color, + dawn_horizon = water_color, + night_sky = water_color, + night_horizon = water_color, + }, + clouds = true, + }) + end if dim == "overworld" then if (mcl_weather.state == "none") then -- Clear weather @@ -108,7 +135,8 @@ mcl_weather.skycolor = { local day_color = mcl_weather.skycolor.get_sky_layer_color(0.15) local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.27) local night_color = mcl_weather.skycolor.get_sky_layer_color(0.1) - player:set_sky({ type = "regular", + mcl_weather.set_sky_color(player, { + type = "regular", sky_color = { day_sky = day_color, day_horizon = day_color, @@ -127,7 +155,8 @@ mcl_weather.skycolor = { local day_color = mcl_weather.skycolor.get_sky_layer_color(0.5) local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.75) local night_color = mcl_weather.skycolor.get_sky_layer_color(0) - player:set_sky({ type = "regular", + mcl_weather.set_sky_color(player, { + type = "regular", sky_color = { day_sky = day_color, day_horizon = day_color, @@ -178,7 +207,7 @@ mcl_weather.skycolor = { } local biometint = nether_sky[minetest.get_biome_name(minetest.get_biome_data(player:get_pos()).biome)] - player:set_sky({ + mcl_weather.set_sky_color(player, { type = "regular", sky_color = { day_sky = "#300808", diff --git a/mods/HUD/mcl_achievements/init.lua b/mods/HUD/mcl_achievements/init.lua index f76662fce..952fc1789 100644 --- a/mods/HUD/mcl_achievements/init.lua +++ b/mods/HUD/mcl_achievements/init.lua @@ -389,6 +389,40 @@ awards.register_achievement("mcl:theEndAgain", { group = "End", }) +-- Triggered in mcl_beehives +awards.register_achievement("mcl:bee_our_guest", { + title = S("Bee Our Guest"), + description = S("Use a campfire to collect a bottle of honey from a beehive without aggrivating the bees inside."), + icon = "mcl_honey_honey_bottle.png", + type = "Advancement", + group = "Husbandry", +}) + +awards.register_achievement("mcl:total_beelocation", { + title = S("Total Beelocation"), + description = S("Move a bee nest, with 3 bees inside, using a silk touch enchanted tool."), + icon = "mcl_beehives_bee_nest_front_honey.png", + type = "Advancement", + group = "Husbandry", +}) + +-- Triggered in mcl_copper +awards.register_achievement("mcl:wax_on", { + title = S("Wax On"), + description = S("Apply honeycomb to a copper block to protect it from the elements."), + icon = "mcl_honey_honeycomb.png", + type = "Advancement", + group = "Husbandry", +}) + +awards.register_achievement("mcl:wax_off", { + title = S("Wax Off"), + description = S("Scrape wax off of a copper block."), + icon = "default_tool_stoneaxe.png", + type = "Advancement", + group = "Husbandry", +}) + -- NON-PC ACHIEVEMENTS (XBox, Pocket Edition, etc.) if non_pc_achievements then diff --git a/mods/HUD/mcl_achievements/locale/template.txt b/mods/HUD/mcl_achievements/locale/template.txt index cd3726b05..3420a39dc 100644 --- a/mods/HUD/mcl_achievements/locale/template.txt +++ b/mods/HUD/mcl_achievements/locale/template.txt @@ -87,3 +87,11 @@ Sky's The Limit= Find the elytra and prepare to fly above and beyond!= Free the End= Kill the ender dragon. Good Luck!= +Bee Our Guest= +Use a campfire to collect a bottle of honey from a beehive without aggrivating the bees inside.= +Total Beelocation= +Move a bee nest, with 3 bees inside, using a silk touch enchanted tool.= +Wax On= +Apply honeycomb to a copper block to protect it from the elements.= +Wax Off= +Scrape wax off of a copper block.= diff --git a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua index a27904e48..b2ff0916e 100644 --- a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua @@ -364,7 +364,7 @@ function mesecon.mvps_move_objects(pos, dir, nodestack) for _, r in ipairs(mesecon.rules.alldirs) do local adjpos = vector.add(np, r) local adjnode = minetest.get_node(adjpos) - if minetest.registered_nodes[adjnode.name] and minetest.registered_nodes[adjnode.name].mvps_sticky then + if minetest.registered_nodes[adjnode.name] and minetest.registered_nodes[adjnode.name].mvps_sticky and adjnode.name == "mcl_core:slimeblock" then local np = vector.add(obj:get_pos(), dir) -- Reset acceleration of all objects before launching. diff --git a/mods/ITEMS/mcl_beehives/init.lua b/mods/ITEMS/mcl_beehives/init.lua new file mode 100644 index 000000000..a7a1a7623 --- /dev/null +++ b/mods/ITEMS/mcl_beehives/init.lua @@ -0,0 +1,230 @@ +------------------ +---- Beehives ---- +------------------ + +-- Variables +local S = minetest.get_translator(minetest.get_current_modname()) + +-- Function to allow harvesting honey and honeycomb from the beehive and bee nest. +local honey_harvest = function(pos, node, player, itemstack, pointed_thing) + local inv = player:get_inventory() + local shears = player:get_wielded_item():get_name() == "mcl_tools:shears" + local bottle = player:get_wielded_item():get_name() == "mcl_potions:glass_bottle" + local beehive = "mcl_beehives:beehive" + local is_creative = minetest.is_creative_enabled(player:get_player_name()) + + if node.name == "mcl_beehives:beehive_5" then + beehive = "mcl_beehives:beehive" + elseif node.name == "mcl_beehives:bee_nest_5" then + beehive = "mcl_beehives:bee_nest" + end + + local campfire_area = vector.offset(pos, 0, -5, 0) + local campfire = minetest.find_nodes_in_area(pos, campfire_area, "group:lit_campfire") + + if bottle then + local honey = "mcl_honey:honey_bottle" + if inv:room_for_item("main", honey) then + node.name = beehive + minetest.set_node(pos, node) + inv:add_item("main", "mcl_honey:honey_bottle") + if not is_creative then + itemstack:take_item() + end + if not campfire[1] then mcl_util.deal_damage(player, 10) else awards.unlock(player:get_player_name(), "mcl:bee_our_guest") end + end + elseif shears then + minetest.add_item(pos, "mcl_honey:honeycomb 3") + node.name = beehive + minetest.set_node(pos, node) + if not campfire[1] then mcl_util.deal_damage(player, 10) end + end +end + +-- Dig Function for Beehives +local dig_hive = function(pos, node, oldmetadata, digger) + local wield_item = digger:get_wielded_item() + local beehive = string.find(node.name, "mcl_beehives:beehive") + local beenest = string.find(node.name, "mcl_beehives:bee_nest") + local silk_touch = mcl_enchanting.has_enchantment(wield_item, "silk_touch") + local is_creative = minetest.is_creative_enabled(digger:get_player_name()) + + if beehive then + minetest.add_item(pos, "mcl_beehives:beehive") + if not silk_touch and not is_creative then mcl_util.deal_damage(digger, 10) end + elseif beenest then + if silk_touch or is_creative then + minetest.add_item(pos, "mcl_beehives:bee_nest") + awards.unlock(digger:get_player_name(), "mcl:total_beelocation") + else + mcl_util.deal_damage(digger, 10) + end + end +end + +-- Beehive +minetest.register_node("mcl_beehives:beehive", { + description = S("Beehive"), + _doc_items_longdesc = S("Artificial bee nest."), + tiles = { + "mcl_beehives_beehive_end.png", "mcl_beehives_beehive_end.png", + "mcl_beehives_beehive_side.png", "mcl_beehives_beehive_side.png", + "mcl_beehives_beehive_side.png", "mcl_beehives_beehive_front.png", + }, + paramtype2 = "facedir", + groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 5, material_wood = 1, beehive = 1 }, + _mcl_blast_resistance = 0.6, + _mcl_hardness = 0.6, + drop = "", + after_dig_node = dig_hive, +}) + +for l = 1, 4 do + minetest.register_node("mcl_beehives:beehive_" .. l, { + description = S("Beehive"), + _doc_items_longdesc = S("Artificial bee nest."), + tiles = { + "mcl_beehives_beehive_end.png", "mcl_beehives_beehive_end.png", + "mcl_beehives_beehive_side.png", "mcl_beehives_beehive_side.png", + "mcl_beehives_beehive_side.png", "mcl_beehives_beehive_front.png", + }, + paramtype2 = "facedir", + groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 5, material_wood = 1, not_in_creative_inventory = 1, beehive = 1 }, + _mcl_blast_resistance = 0.6, + _mcl_hardness = 0.6, + drop = "", + after_dig_node = dig_hive, + }) +end + +minetest.register_node("mcl_beehives:beehive_5", { + description = S("Beehive"), + _doc_items_longdesc = S("Artificial bee nest."), + tiles = { + "mcl_beehives_beehive_end.png", "mcl_beehives_beehive_end.png", + "mcl_beehives_beehive_side.png", "mcl_beehives_beehive_side.png", + "mcl_beehives_beehive_side.png", "mcl_beehives_beehive_front_honey.png", + }, + paramtype2 = "facedir", + groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 5, material_wood = 1, not_in_creative_inventory = 1, beehive = 1 }, + _mcl_blast_resistance = 0.6, + _mcl_hardness = 0.6, + on_rightclick = honey_harvest, + drop = "", + after_dig_node = dig_hive, +}) + +-- Bee Nest +minetest.register_node("mcl_beehives:bee_nest", { + description = S("Bee Nest"), + _doc_items_longdesc = S("A naturally generating block that houses bees and a tasty treat...if you can get it."), + tiles = { + "mcl_beehives_bee_nest_top.png", "mcl_beehives_bee_nest_bottom.png", + "mcl_beehives_bee_nest_side.png", "mcl_beehives_bee_nest_side.png", + "mcl_beehives_bee_nest_side.png", "mcl_beehives_bee_nest_front.png", + }, + paramtype2 = "facedir", + groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 30, bee_nest = 1 }, + _mcl_blast_resistance = 0.3, + _mcl_hardness = 0.3, + drop = "", + after_dig_node = dig_hive, +}) + +for i = 1, 4 do + minetest.register_node("mcl_beehives:bee_nest_"..i, { + description = S("Bee Nest"), + _doc_items_longdesc = S("A naturally generating block that houses bees and a tasty treat...if you can get it."), + tiles = { + "mcl_beehives_bee_nest_top.png", "mcl_beehives_bee_nest_bottom.png", + "mcl_beehives_bee_nest_side.png", "mcl_beehives_bee_nest_side.png", + "mcl_beehives_bee_nest_side.png", "mcl_beehives_bee_nest_front.png", + }, + paramtype2 = "facedir", + groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 30, not_in_creative_inventory = 1, bee_nest = 1 }, + _mcl_blast_resistance = 0.3, + _mcl_hardness = 0.3, + drop = "", + after_dig_node = dig_hive, + }) +end + +minetest.register_node("mcl_beehives:bee_nest_5", { + description = S("Bee Nest"), + _doc_items_longdesc = S("A naturally generating block that houses bees and a tasty treat...if you can get it."), + tiles = { + "mcl_beehives_bee_nest_top.png", "mcl_beehives_bee_nest_bottom.png", + "mcl_beehives_bee_nest_side.png", "mcl_beehives_bee_nest_side.png", + "mcl_beehives_bee_nest_side.png", "mcl_beehives_bee_nest_front_honey.png", + }, + paramtype2 = "facedir", + groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 30, not_in_creative_inventory = 1, bee_nest = 1 }, + _mcl_blast_resistance = 0.3, + _mcl_hardness = 0.3, + on_rightclick = honey_harvest, + drop = "", + after_dig_node = dig_hive, +}) + +-- Crafting +minetest.register_craft({ + output = "mcl_beehives:beehive", + recipe = { + { "group:wood", "group:wood", "group:wood" }, + { "mcl_honey:honeycomb", "mcl_honey:honeycomb", "mcl_honey:honeycomb" }, + { "group:wood", "group:wood", "group:wood" }, + }, +}) + +-- Temporary ABM to update honey levels +minetest.register_abm({ + label = "Update Beehive Honey Levels", + nodenames = "group:beehive", + interval = 500, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local beehive = "mcl_beehives:beehive" + if node.name == beehive then + node.name = beehive.."_1" + minetest.set_node(pos, node) + elseif node.name == beehive.."_1" then + node.name = beehive.."_2" + minetest.set_node(pos, node) + elseif node.name == beehive.."_2" then + node.name = beehive.."_3" + minetest.set_node(pos, node) + elseif node.name == beehive.."_3" then + node.name = beehive.."_4" + minetest.set_node(pos, node) + elseif node.name == beehive.."_4" then + node.name = beehive.."_5" + minetest.set_node(pos, node) + end + end, +}) + +minetest.register_abm({ + label = "Update Bee Nest Honey Levels", + nodenames = "group:bee_nest", + interval = 500, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local beehive = "mcl_beehives:bee_nest" + if node.name == beehive then + node.name = beehive.."_1" + minetest.set_node(pos, node) + elseif node.name == beehive.."_1" then + node.name = beehive.."_2" + minetest.set_node(pos, node) + elseif node.name == beehive.."_2" then + node.name = beehive.."_3" + minetest.set_node(pos, node) + elseif node.name == beehive.."_3" then + node.name = beehive.."_4" + minetest.set_node(pos, node) + elseif node.name == beehive.."_4" then + node.name = beehive.."_5" + minetest.set_node(pos, node) + end + end, +}) diff --git a/mods/ITEMS/mcl_beehives/locale/template.txt b/mods/ITEMS/mcl_beehives/locale/template.txt new file mode 100644 index 000000000..135786c7c --- /dev/null +++ b/mods/ITEMS/mcl_beehives/locale/template.txt @@ -0,0 +1,4 @@ +Beehive= +Artificial bee nest.= +Bee Nest= +A naturally generating block that houses bees and a tasty treat...if you can get it.= \ No newline at end of file diff --git a/mods/ITEMS/mcl_beehives/mod.conf b/mods/ITEMS/mcl_beehives/mod.conf new file mode 100644 index 000000000..0a7855bec --- /dev/null +++ b/mods/ITEMS/mcl_beehives/mod.conf @@ -0,0 +1,4 @@ +name = mcl_beehives +author = PrairieWind +description = Adds beehives and bee nests to MineClone 2. +depends = mcl_util, mcl_enchanting diff --git a/mods/ITEMS/mcl_beehives/textures/mcl_beehives_bee_nest_bottom.png b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_bee_nest_bottom.png new file mode 100644 index 000000000..f3ad4a418 Binary files /dev/null and b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_bee_nest_bottom.png differ diff --git a/mods/ITEMS/mcl_beehives/textures/mcl_beehives_bee_nest_front.png b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_bee_nest_front.png new file mode 100644 index 000000000..023e79d92 Binary files /dev/null and b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_bee_nest_front.png differ diff --git a/mods/ITEMS/mcl_beehives/textures/mcl_beehives_bee_nest_front_honey.png b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_bee_nest_front_honey.png new file mode 100644 index 000000000..d88dd6555 Binary files /dev/null and b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_bee_nest_front_honey.png differ diff --git a/mods/ITEMS/mcl_beehives/textures/mcl_beehives_bee_nest_side.png b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_bee_nest_side.png new file mode 100644 index 000000000..9c0de93d7 Binary files /dev/null and b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_bee_nest_side.png differ diff --git a/mods/ITEMS/mcl_beehives/textures/mcl_beehives_bee_nest_top.png b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_bee_nest_top.png new file mode 100644 index 000000000..5f80eb98e Binary files /dev/null and b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_bee_nest_top.png differ diff --git a/mods/ITEMS/mcl_beehives/textures/mcl_beehives_beehive_end.png b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_beehive_end.png new file mode 100644 index 000000000..3ee339135 Binary files /dev/null and b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_beehive_end.png differ diff --git a/mods/ITEMS/mcl_beehives/textures/mcl_beehives_beehive_front.png b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_beehive_front.png new file mode 100644 index 000000000..94e14d9f9 Binary files /dev/null and b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_beehive_front.png differ diff --git a/mods/ITEMS/mcl_beehives/textures/mcl_beehives_beehive_front_honey.png b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_beehive_front_honey.png new file mode 100644 index 000000000..e47a7c776 Binary files /dev/null and b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_beehive_front_honey.png differ diff --git a/mods/ITEMS/mcl_beehives/textures/mcl_beehives_beehive_side.png b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_beehive_side.png new file mode 100644 index 000000000..820acb491 Binary files /dev/null and b/mods/ITEMS/mcl_beehives/textures/mcl_beehives_beehive_side.png differ diff --git a/mods/ITEMS/mcl_copper/crafting.lua b/mods/ITEMS/mcl_copper/crafting.lua index 7b1e183c7..ce280fcdf 100644 --- a/mods/ITEMS/mcl_copper/crafting.lua +++ b/mods/ITEMS/mcl_copper/crafting.lua @@ -47,6 +47,17 @@ minetest.register_craft({ }, }) +local waxable_blocks = { "block", "block_cut", "block_exposed", "block_exposed_cut", "block_weathered", "block_weathered_cut", "block_oxidized", "block_oxidized_cut" } + +for _, w in ipairs(waxable_blocks) do + minetest.register_craft({ + output = "mcl_copper:waxed_"..w, + recipe = { + { "mcl_copper:"..w, "mcl_honey:honeycomb" }, + }, + }) +end + minetest.register_craft({ output = "mcl_copper:copper_ingot 4", recipe = { @@ -73,4 +84,11 @@ minetest.register_craft({ output = "mcl_copper:copper_ingot", recipe = "mcl_copper:stone_with_copper", cooktime = 10, -}) \ No newline at end of file +}) + +minetest.register_craft({ + type = "cooking", + output = "mcl_copper:block", + recipe = "mcl_copper:block_raw", + cooktime = 90, +}) diff --git a/mods/ITEMS/mcl_copper/functions.lua b/mods/ITEMS/mcl_copper/functions.lua index b6e0cb7e2..81dfdb69d 100644 --- a/mods/ITEMS/mcl_copper/functions.lua +++ b/mods/ITEMS/mcl_copper/functions.lua @@ -12,6 +12,34 @@ local function register_oxidation_abm(abm_name, node_name, oxidized_variant) }) end +function waxing_copper_block(pos, node, player, itemstack, convert_to) + if itemstack:get_name() == "mcl_honey:honeycomb" then + node.name = convert_to + minetest.set_node(pos, node) + awards.unlock(player:get_player_name(), "mcl:wax_on") + if not minetest.is_creative_enabled(player:get_player_name()) then + itemstack:take_item() + end + else + return true + end +end + +function scraping_copper_block(pos, node, player, itemstack, convert_to) + if itemstack:get_name():find("axe") then + node.name = convert_to + minetest.set_node(pos, node) + awards.unlock(player:get_player_name(), "mcl:wax_off") + if not minetest.is_creative_enabled(player:get_player_name()) then + local tool = itemstack:get_name() + local wear = mcl_autogroup.get_wear(tool, "axey") + itemstack:add_wear(wear) + end + else + return true + end +end + --[[ local stairs = { {"stair", "exposed", "_inner", "cut_inner"}, diff --git a/mods/ITEMS/mcl_copper/init.lua b/mods/ITEMS/mcl_copper/init.lua index ea15e5827..a99d03f2c 100644 --- a/mods/ITEMS/mcl_copper/init.lua +++ b/mods/ITEMS/mcl_copper/init.lua @@ -1,6 +1,6 @@ local path = minetest.get_modpath("mcl_copper") +dofile(path .. "/functions.lua") dofile(path .. "/nodes.lua") dofile(path .. "/items.lua") dofile(path .. "/crafting.lua") -dofile(path .. "/functions.lua") \ No newline at end of file diff --git a/mods/ITEMS/mcl_copper/items.lua b/mods/ITEMS/mcl_copper/items.lua index 450ec8cb3..694e693dc 100644 --- a/mods/ITEMS/mcl_copper/items.lua +++ b/mods/ITEMS/mcl_copper/items.lua @@ -11,5 +11,5 @@ minetest.register_craftitem("mcl_copper:raw_copper", { description = S("Raw Copper"), _doc_items_longdesc = S("Raw Copper. Mine a Copper Ore to get it."), inventory_image = "mcl_copper_raw.png", - groups = { craftitem = 1 }, + groups = { craftitem = 1, blast_furnace_smeltable = 1 }, }) \ No newline at end of file diff --git a/mods/ITEMS/mcl_copper/locale/template.txt b/mods/ITEMS/mcl_copper/locale/template.txt index 050c099ee..7022780ff 100644 --- a/mods/ITEMS/mcl_copper/locale/template.txt +++ b/mods/ITEMS/mcl_copper/locale/template.txt @@ -2,36 +2,56 @@ A block of copper is mostly a decorative block.= A block used for compact raw copper storage.= Block of Copper= +Waxed Block of Copper= Block of Raw Copper= Copper Ingot= Copper Ore= Cut copper is a decorative block.= Cut Copper= +Waxed Cut Copper= Double Slab of Cut Copper= Double Slab of Exposed Cut Copper= Double Slab of Oxidized Cut Copper= Double Slab of Weathered Cut Copper= +Waxed Double Slab of Cut Copper= +Waxed Double Slab of Exposed Cut Copper= +Waxed Double Slab of Oxidized Cut Copper= +Waxed Double Slab of Weathered Cut Copper= Exposed copper is a decorative block.= Exposed Copper= +Waxed Exposed Copper= Exposed cut copper is a decorative block.= Exposed Cut Copper= +Waxed Exposed Cut Copper= Molten Raw Copper. It is used to craft blocks.= Oxidized copper is a decorative block.= Oxidized Copper= +Waxed Oxidized Copper= Oxidized cut copper is a decorative block.= Oxidized Cut Copper= +Waxed Oxidized Cut Copper= Raw Copper. Mine a Copper Ore to get it.= Raw Copper= Slab of Cut Copper= Slab of Exposed Cut Copper= Slab of Oxidized Cut Copper= Slab of Weathered Cut Copper= +Waxed Slab of Cut Copper= +Waxed Slab of Exposed Cut Copper= +Waxed Slab of Oxidized Cut Copper= +Waxed Slab of Weathered Cut Copper= Some copper contained in stone, it is pretty common and can be found below sea level.= Stairs of Cut Copper= Stairs of Exposed Cut Copper= Stairs of Oxidized Cut Copper= Stairs of Weathered Cut Copper= +Waxed Stairs of Cut Copper= +Waxed Stairs of Exposed Cut Copper= +Waxed Stairs of Oxidized Cut Copper= +Waxed Stairs of Weathered Cut Copper= Weathered copper is a decorative block.= Weathered Copper= +Waxed Weathered Copper= Weathered cut copper is a decorative block.= Weathered Cut Copper= +Waxed Weathered Cut Copper= diff --git a/mods/ITEMS/mcl_copper/nodes.lua b/mods/ITEMS/mcl_copper/nodes.lua index 22c1bf807..c83dd9e10 100644 --- a/mods/ITEMS/mcl_copper/nodes.lua +++ b/mods/ITEMS/mcl_copper/nodes.lua @@ -20,7 +20,7 @@ minetest.register_node("mcl_copper:block_raw", { _doc_items_longdesc = S("A block used for compact raw copper storage."), tiles = {"mcl_copper_block_raw.png"}, is_ground_content = false, - groups = {pickaxey = 2, building_block = 1}, + groups = {pickaxey = 2, building_block = 1, blast_furnace_smeltable = 1 }, sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, @@ -35,6 +35,19 @@ minetest.register_node("mcl_copper:block", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 3, + on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block") end, +}) + +minetest.register_node("mcl_copper:waxed_block", { + description = S("Waxed Block of Copper"), + _doc_items_longdesc = S("A block of copper is mostly a decorative block."), + tiles = {"mcl_copper_block.png"}, + is_ground_content = false, + groups = {pickaxey = 2, building_block = 1}, + sounds = mcl_sounds.node_sound_metal_defaults(), + _mcl_blast_resistance = 6, + _mcl_hardness = 3, + on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block") end, }) minetest.register_node("mcl_copper:block_exposed", { @@ -47,18 +60,19 @@ minetest.register_node("mcl_copper:block_exposed", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_anti_oxidation_varient = "mcl_copper:block", + on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_exposed") end, }) -minetest.register_node("mcl_copper:block_oxidized", { - description = S("Oxidized Copper"), - _doc_items_longdesc = S("Oxidized copper is a decorative block."), - tiles = {"mcl_copper_oxidized.png"}, +minetest.register_node("mcl_copper:waxed_block_exposed", { + description = S("Waxed Exposed Copper"), + _doc_items_longdesc = S("Exposed copper is a decorative block."), + tiles = {"mcl_copper_exposed.png"}, is_ground_content = false, groups = {pickaxey = 2, building_block = 1}, sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_anti_oxidation_varient = "mcl_copper:block_weathered", + on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block") end, }) minetest.register_node("mcl_copper:block_weathered", { @@ -71,6 +85,44 @@ minetest.register_node("mcl_copper:block_weathered", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_anti_oxidation_varient = "mcl_copper:block_exposed", + on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_weathered") end, +}) + +minetest.register_node("mcl_copper:waxed_block_weathered", { + description = S("Waxed Weathered Copper"), + _doc_items_longdesc = S("Weathered copper is a decorative block."), + tiles = {"mcl_copper_weathered.png"}, + is_ground_content = false, + groups = {pickaxey = 2, building_block = 1}, + sounds = mcl_sounds.node_sound_metal_defaults(), + _mcl_blast_resistance = 6, + _mcl_hardness = 5, + on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_exposed") end, +}) + +minetest.register_node("mcl_copper:block_oxidized", { + description = S("Oxidized Copper"), + _doc_items_longdesc = S("Oxidized copper is a decorative block."), + tiles = {"mcl_copper_oxidized.png"}, + is_ground_content = false, + groups = {pickaxey = 2, building_block = 1}, + sounds = mcl_sounds.node_sound_metal_defaults(), + _mcl_blast_resistance = 6, + _mcl_hardness = 5, + _mcl_anti_oxidation_varient = "mcl_copper:block_weathered", + on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_oxidized") end, +}) + +minetest.register_node("mcl_copper:waxed_block_oxidized", { + description = S("Waxed Oxidized Copper"), + _doc_items_longdesc = S("Oxidized copper is a decorative block."), + tiles = {"mcl_copper_oxidized.png"}, + is_ground_content = false, + groups = {pickaxey = 2, building_block = 1}, + sounds = mcl_sounds.node_sound_metal_defaults(), + _mcl_blast_resistance = 6, + _mcl_hardness = 5, + on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_weather") end, }) minetest.register_node("mcl_copper:block_cut", { @@ -82,6 +134,19 @@ minetest.register_node("mcl_copper:block_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, + on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_cut") end, +}) + +minetest.register_node("mcl_copper:waxed_block_cut", { + description = S("Waxed Cut Copper"), + _doc_items_longdesc = S("Cut copper is a decorative block."), + tiles = {"mcl_copper_block_cut.png"}, + is_ground_content = false, + groups = {pickaxey = 2, building_block = 1}, + sounds = mcl_sounds.node_sound_metal_defaults(), + _mcl_blast_resistance = 6, + _mcl_hardness = 5, + on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_cut") end, }) minetest.register_node("mcl_copper:block_exposed_cut", { @@ -94,18 +159,19 @@ minetest.register_node("mcl_copper:block_exposed_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_anti_oxidation_varient = "mcl_copper:block_cut", + on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_exposed_cut") end, }) -minetest.register_node("mcl_copper:block_oxidized_cut", { - description = S("Oxidized Cut Copper"), - _doc_items_longdesc = S("Oxidized cut copper is a decorative block."), - tiles = {"mcl_copper_oxidized_cut.png"}, +minetest.register_node("mcl_copper:waxed_block_exposed_cut", { + description = S("Waxed Exposed Cut Copper"), + _doc_items_longdesc = S("Exposed cut copper is a decorative block."), + tiles = {"mcl_copper_exposed_cut.png"}, is_ground_content = false, groups = {pickaxey = 2, building_block = 1}, sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_anti_oxidation_varient = "mcl_copper:block_weathered_cut", + on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_cut") end, }) minetest.register_node("mcl_copper:block_weathered_cut", { @@ -118,6 +184,44 @@ minetest.register_node("mcl_copper:block_weathered_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_anti_oxidation_varient = "mcl_copper:block_exposed_cut", + on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_weathered_cut") end, +}) + +minetest.register_node("mcl_copper:waxed_block_weathered_cut", { + description = S("Waxed Weathered Cut Copper"), + _doc_items_longdesc = S("Weathered cut copper is a decorative block."), + tiles = {"mcl_copper_weathered_cut.png"}, + is_ground_content = false, + groups = {pickaxey = 2, building_block = 1}, + sounds = mcl_sounds.node_sound_metal_defaults(), + _mcl_blast_resistance = 6, + _mcl_hardness = 5, + on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_exposed_cut") end, +}) + +minetest.register_node("mcl_copper:block_oxidized_cut", { + description = S("Oxidized Cut Copper"), + _doc_items_longdesc = S("Oxidized cut copper is a decorative block."), + tiles = {"mcl_copper_oxidized_cut.png"}, + is_ground_content = false, + groups = {pickaxey = 2, building_block = 1}, + sounds = mcl_sounds.node_sound_metal_defaults(), + _mcl_blast_resistance = 6, + _mcl_hardness = 5, + _mcl_anti_oxidation_varient = "mcl_copper:block_weathered_cut", + on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_oxidized_cut") end, +}) + +minetest.register_node("mcl_copper:waxed_block_oxidized_cut", { + description = S("Waxed Oxidized Cut Copper"), + _doc_items_longdesc = S("Oxidized cut copper is a decorative block."), + tiles = {"mcl_copper_oxidized_cut.png"}, + is_ground_content = false, + groups = {pickaxey = 2, building_block = 1}, + sounds = mcl_sounds.node_sound_metal_defaults(), + _mcl_blast_resistance = 6, + _mcl_hardness = 5, + on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_weathered_cut") end, }) mcl_stairs.register_slab("copper_cut", "mcl_copper:block_cut", @@ -127,6 +231,13 @@ mcl_stairs.register_slab("copper_cut", "mcl_copper:block_cut", nil, nil, nil, S("Double Slab of Cut Copper")) +mcl_stairs.register_slab("waxed_copper_cut", "mcl_copper:waxed_block_cut", + {pickaxey = 2}, + {"mcl_copper_block_cut.png", "mcl_copper_block_cut.png", "mcl_copper_block_cut.png"}, + S("Waxed Slab of Cut Copper"), + nil, nil, nil, + S("Waxed Double Slab of Cut Copper")) + mcl_stairs.register_slab("copper_exposed_cut", "mcl_copper:block_exposed_cut", {pickaxey = 2}, {"mcl_copper_exposed_cut.png", "mcl_copper_exposed_cut.png", "mcl_copper_exposed_cut.png"}, @@ -134,12 +245,12 @@ mcl_stairs.register_slab("copper_exposed_cut", "mcl_copper:block_exposed_cut", nil, nil, nil, S("Double Slab of Exposed Cut Copper")) -mcl_stairs.register_slab("copper_oxidized_cut", "mcl_copper:block_oxidized_cut", +mcl_stairs.register_slab("waxed_copper_exposed_cut", "mcl_copper:waxed_block_exposed_cut", {pickaxey = 2}, - {"mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png"}, - S("Slab of Oxidized Cut Copper"), + {"mcl_copper_exposed_cut.png", "mcl_copper_exposed_cut.png", "mcl_copper_exposed_cut.png"}, + S("Waxed Slab of Exposed Cut Copper"), nil, nil, nil, - S("Double Slab of Oxidized Cut Copper")) + S("Waxed Double Slab of Exposed Cut Copper")) mcl_stairs.register_slab("copper_weathered_cut", "mcl_copper:block_weathered_cut", {pickaxey = 2}, @@ -148,6 +259,27 @@ mcl_stairs.register_slab("copper_weathered_cut", "mcl_copper:block_weathered_cut nil, nil, nil, S("Double Slab of Weathered Cut Copper")) +mcl_stairs.register_slab("waxed_copper_weathered_cut", "mcl_copper:waxed_block_weathered_cut", + {pickaxey = 2}, + {"mcl_copper_weathered_cut.png", "mcl_copper_weathered_cut.png", "mcl_copper_weathered_cut.png"}, + S("Waxed Slab of Weathered Cut Copper"), + nil, nil, nil, + S("Waxed Double Slab of Weathered Cut Copper")) + +mcl_stairs.register_slab("copper_oxidized_cut", "mcl_copper:block_oxidized_cut", + {pickaxey = 2}, + {"mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png"}, + S("Slab of Oxidized Cut Copper"), + nil, nil, nil, + S("Double Slab of Oxidized Cut Copper")) + +mcl_stairs.register_slab("waxed_copper_oxidized_cut", "mcl_copper:waxed_block_oxidized_cut", + {pickaxey = 2}, + {"mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png"}, + S("Waxed Slab of Oxidized Cut Copper"), + nil, nil, nil, + S("Waxed Double Slab of Oxidized Cut Copper")) + mcl_stairs.register_stair("copper_cut", "mcl_copper:block_cut", {pickaxey = 2}, {"mcl_copper_block_cut.png", "mcl_copper_block_cut.png", "mcl_copper_block_cut.png", "mcl_copper_block_cut.png", "mcl_copper_block_cut.png", "mcl_copper_block_cut.png"}, @@ -155,6 +287,13 @@ mcl_stairs.register_stair("copper_cut", "mcl_copper:block_cut", nil, 6, nil, "woodlike") +mcl_stairs.register_stair("waxed_copper_cut", "mcl_copper:waxed_block_cut", + {pickaxey = 2}, + {"mcl_copper_block_cut.png", "mcl_copper_block_cut.png", "mcl_copper_block_cut.png", "mcl_copper_block_cut.png", "mcl_copper_block_cut.png", "mcl_copper_block_cut.png"}, + S("Waxed Stairs of Cut Copper"), + nil, 6, nil, + "woodlike") + mcl_stairs.register_stair("copper_exposed_cut", "mcl_copper:block_exposed_cut", {pickaxey = 2}, {"mcl_copper_exposed_cut.png", "mcl_copper_exposed_cut.png", "mcl_copper_exposed_cut.png", "mcl_copper_exposed_cut.png", "mcl_copper_exposed_cut.png", "mcl_copper_exposed_cut.png"}, @@ -162,10 +301,10 @@ mcl_stairs.register_stair("copper_exposed_cut", "mcl_copper:block_exposed_cut", nil, 6, nil, "woodlike") -mcl_stairs.register_stair("copper_oxidized_cut", "mcl_copper:block_oxidized_cut", +mcl_stairs.register_stair("waxed_copper_exposed_cut", "mcl_copper:waxed_block_exposed_cut", {pickaxey = 2}, - {"mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png"}, - S("Stairs of Oxidized Cut Copper"), + {"mcl_copper_exposed_cut.png", "mcl_copper_exposed_cut.png", "mcl_copper_exposed_cut.png", "mcl_copper_exposed_cut.png", "mcl_copper_exposed_cut.png", "mcl_copper_exposed_cut.png"}, + S("Waxed Stairs of Exposed Cut Copper"), nil, 6, nil, "woodlike") @@ -174,4 +313,25 @@ mcl_stairs.register_stair("copper_weathered_cut", "mcl_copper:block_weathered_cu {"mcl_copper_weathered_cut.png", "mcl_copper_weathered_cut.png", "mcl_copper_weathered_cut.png", "mcl_copper_weathered_cut.png", "mcl_copper_weathered_cut.png", "mcl_copper_weathered_cut.png"}, S("Stairs of Weathered Cut Copper"), nil, 6, nil, - "woodlike") \ No newline at end of file + "woodlike") + +mcl_stairs.register_stair("waxed_copper_weathered_cut", "mcl_copper:waxed_block_weathered_cut", + {pickaxey = 2}, + {"mcl_copper_weathered_cut.png", "mcl_copper_weathered_cut.png", "mcl_copper_weathered_cut.png", "mcl_copper_weathered_cut.png", "mcl_copper_weathered_cut.png", "mcl_copper_weathered_cut.png"}, + S("Waxed Stairs of Weathered Cut Copper"), + nil, 6, nil, + "woodlike") + +mcl_stairs.register_stair("copper_oxidized_cut", "mcl_copper:block_oxidized_cut", + {pickaxey = 2}, + {"mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png"}, + S("Stairs of Oxidized Cut Copper"), + nil, 6, nil, + "woodlike") + +mcl_stairs.register_stair("waxed_copper_oxidized_cut", "mcl_copper:waxed_block_oxidized_cut", + {pickaxey = 2}, + {"mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png", "mcl_copper_oxidized_cut.png"}, + S("Waxed Stairs of Oxidized Cut Copper"), + nil, 6, nil, + "woodlike") diff --git a/mods/ITEMS/mcl_core/nodes_liquid.lua b/mods/ITEMS/mcl_core/nodes_liquid.lua index 68ae4a829..081f1978a 100644 --- a/mods/ITEMS/mcl_core/nodes_liquid.lua +++ b/mods/ITEMS/mcl_core/nodes_liquid.lua @@ -50,7 +50,7 @@ minetest.register_node("mcl_core:water_flowing", { liquid_viscosity = WATER_VISC, liquid_range = 7, waving = 3, - post_effect_color = {a=209, r=0x03, g=0x3C, b=0x5C}, + post_effect_color = {a=20, r=0x03, g=0x3C, b=0x5C}, groups = { water=3, liquid=3, puts_out_fire=1, not_in_creative_inventory=1, freezes=1, melt_around=1, dig_by_piston=1}, _mcl_blast_resistance = 100, -- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode @@ -95,7 +95,7 @@ S("• When water is directly below lava, the water turns into stone."), liquid_alternative_source = "mcl_core:water_source", liquid_viscosity = WATER_VISC, liquid_range = 7, - post_effect_color = {a=209, r=0x03, g=0x3C, b=0x5C}, + post_effect_color = {a=60, r=0x03, g=0x3C, b=0x5C}, stack_max = 64, groups = { water=3, liquid=3, puts_out_fire=1, freezes=1, not_in_creative_inventory=1, dig_by_piston=1}, _mcl_blast_resistance = 100, diff --git a/mods/ITEMS/mcl_core/schematics/mcl_core_birch_bee_nest.mts b/mods/ITEMS/mcl_core/schematics/mcl_core_birch_bee_nest.mts new file mode 100644 index 000000000..fff8fddc4 Binary files /dev/null and b/mods/ITEMS/mcl_core/schematics/mcl_core_birch_bee_nest.mts differ diff --git a/mods/ITEMS/mcl_core/schematics/mcl_core_oak_classic_bee_nest.mts b/mods/ITEMS/mcl_core/schematics/mcl_core_oak_classic_bee_nest.mts new file mode 100644 index 000000000..1f793f47c Binary files /dev/null and b/mods/ITEMS/mcl_core/schematics/mcl_core_oak_classic_bee_nest.mts differ diff --git a/mods/ITEMS/mcl_dye/init.lua b/mods/ITEMS/mcl_dye/init.lua index 73884856a..8296519ca 100644 --- a/mods/ITEMS/mcl_dye/init.lua +++ b/mods/ITEMS/mcl_dye/init.lua @@ -379,6 +379,8 @@ local function apply_bone_meal(pointed_thing,user) return false end +mcl_dye.apply_bone_meal = apply_bone_meal + minetest.register_craftitem("mcl_dye:white", { inventory_image = "mcl_dye_white.png", description = S("Bone Meal"), diff --git a/mods/ITEMS/mcl_farming/README.txt b/mods/ITEMS/mcl_farming/README.txt index 5779d7035..02cdaf93a 100644 --- a/mods/ITEMS/mcl_farming/README.txt +++ b/mods/ITEMS/mcl_farming/README.txt @@ -1,16 +1,12 @@ ===FARMING MOD for MINETEST-C55=== by PilzAdam +Modified heavily by MineClone 2 Dev Team. + Introduction: This mod adds farming to Minetest. -How to install: -Unzip the archive an place it in minetest-base-directory/mods/minetest/ -if you have a windows client or a linux run-in-place client. If you have -a linux system-wide instalation place it in ~/.minetest/mods/minetest/. -If you want to install this mod only in one world create the folder -worldmods/ in your worlddirectory. -For further information or help see: +How to install see: http://wiki.minetest.com/wiki/Installing_Mods How to use the mod: @@ -25,22 +21,8 @@ For further information or help see: http://minetest.net/forum/viewtopic.php?id=2787 License: -Sourcecode: WTFPL (see below) -Graphics: WTFPL (see below) +Sourcecode: CC-BY-SA 4 (see below) +Graphics: CC-BY-SA 4 (see below) See also: http://minetest.net/ - - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - Version 2, December 2004 - - Copyright (C) 2004 Sam Hocevar - - Everyone is permitted to copy and distribute verbatim or modified - copies of this license document, and changing it is allowed as long - as the name is changed. - - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/mods/ITEMS/mcl_farming/shared_functions.lua b/mods/ITEMS/mcl_farming/shared_functions.lua index 7b9784503..e2e42dd25 100644 --- a/mods/ITEMS/mcl_farming/shared_functions.lua +++ b/mods/ITEMS/mcl_farming/shared_functions.lua @@ -69,7 +69,7 @@ function mcl_farming:add_plant(identifier, full_grown, names, interval, chance) interval = interval, chance = chance, action = function(pos, node) - local low_speed = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name ~= "mcl_farming:soil_wet" + local low_speed = minetest.get_node({ x = pos.x, y = pos.y - 1, z = pos.z }).name ~= "mcl_farming:soil_wet" mcl_farming:grow_plant(identifier, pos, node, false, false, low_speed) end, }) @@ -130,7 +130,7 @@ function mcl_farming:grow_plant(identifier, pos, node, stages, ignore_light, low stages = 1 end stages = stages + math.ceil(intervals_counter) - local new_node = {name = plant_info.names[step+stages]} + local new_node = { name = plant_info.names[step + stages] } if new_node.name == nil then new_node.name = plant_info.full_grown end @@ -157,14 +157,14 @@ function mcl_farming:place_seed(itemstack, placer, pointed_thing, plantname) end end - local pos = {x=pt.above.x, y=pt.above.y-1, z=pt.above.z} + local pos = { x = pt.above.x, y = pt.above.y - 1, z = pt.above.z } local farmland = minetest.get_node(pos) - pos= {x=pt.above.x, y=pt.above.y, z=pt.above.z} + pos = { x = pt.above.x, y = pt.above.y, z = pt.above.z } local place_s = minetest.get_node(pos) - if string.find(farmland.name, "mcl_farming:soil") and string.find(place_s.name, "air") then - minetest.sound_play(minetest.registered_nodes[plantname].sounds.place, {pos = pos}, true) - minetest.add_node(pos, {name=plantname, param2 = minetest.registered_nodes[plantname].place_param2}) + if string.find(farmland.name, "mcl_farming:soil") and string.find(place_s.name, "air") then + minetest.sound_play(minetest.registered_nodes[plantname].sounds.place, { pos = pos }, true) + minetest.add_node(pos, { name = plantname, param2 = minetest.registered_nodes[plantname].place_param2 }) --local intervals_counter = get_intervals_counter(pos, 1, 1) else return @@ -179,7 +179,7 @@ end --[[ Helper function to create a gourd (e.g. melon, pumpkin), the connected stem nodes as -- full_unconnected_stem: itemstring of the full-grown but unconnceted stem node. This node must already be done +- full_unconnected_stem: itemstring of the full-grown but unconnected stem node. This node must already be done - connected_stem_basename: prefix of the itemstrings used for the 4 connected stem nodes to create - stem_itemstring: Desired itemstring of the fully-grown unconnected stem node - stem_def: Partial node definition of the fully-grown unconnected stem node. Many fields are already defined. You need to add `tiles` and `description` at minimum. Don't define on_construct without good reason @@ -202,10 +202,10 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s } local neighbors = { - { x=-1, y=0, z=0 }, - { x=1, y=0, z=0 }, - { x=0, y=0, z=-1 }, - { x=0, y=0, z=1 }, + { x = -1, y = 0, z = 0 }, + { x = 1, y = 0, z = 0 }, + { x = 0, y = 0, z = -1 }, + { x = 0, y = 0, z = 1 }, } -- Connect the stem at stempos to the first neighboring gourd block. @@ -215,19 +215,19 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s if stem.name ~= full_unconnected_stem then return false end - for n=1, #neighbors do + for n = 1, #neighbors do local offset = neighbors[n] local blockpos = vector.add(stempos, offset) local block = minetest.get_node(blockpos) if block.name == gourd_itemstring then if offset.x == 1 then - minetest.set_node(stempos, {name=connected_stem_names[1]}) + minetest.set_node(stempos, { name = connected_stem_names[1] }) elseif offset.x == -1 then - minetest.set_node(stempos, {name=connected_stem_names[2]}) + minetest.set_node(stempos, { name = connected_stem_names[2] }) elseif offset.z == 1 then - minetest.set_node(stempos, {name=connected_stem_names[3]}) + minetest.set_node(stempos, { name = connected_stem_names[3] }) elseif offset.z == -1 then - minetest.set_node(stempos, {name=connected_stem_names[4]}) + minetest.set_node(stempos, { name = connected_stem_names[4] }) end return true end @@ -238,13 +238,13 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s if not gourd_def.after_destruct then gourd_def.after_destruct = function(blockpos, oldnode) -- Disconnect any connected stems, turning them back to normal stems - for n=1, #neighbors do + for n = 1, #neighbors do local offset = neighbors[n] local expected_stem = connected_stem_names[n] local stempos = vector.add(blockpos, offset) local stem = minetest.get_node(stempos) if stem.name == expected_stem then - minetest.add_node(stempos, {name=full_unconnected_stem}) + minetest.add_node(stempos, { name = full_unconnected_stem }) try_connect_stem(stempos) end end @@ -253,7 +253,7 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s if not gourd_def.on_construct then function gourd_def.on_construct(blockpos) -- Connect all unconnected stems at full size - for n=1, #neighbors do + for n = 1, #neighbors do local stempos = vector.add(blockpos, neighbors[n]) try_connect_stem(stempos) end @@ -272,7 +272,7 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s stem_def.selection_box = { type = "fixed", fixed = { - {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15} + { -0.15, -0.5, -0.15, 0.15, 0.5, 0.15 } }, } end @@ -292,7 +292,7 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s stem_def.drop = stem_drop end if stem_def.groups == nil then - stem_def.groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1,attached_node=1, dig_by_water=1,destroy_by_lava_flow=1,} + stem_def.groups = { dig_immediate = 3, not_in_creative_inventory = 1, plant = 1, attached_node = 1, dig_by_water = 1, destroy_by_lava_flow = 1, } end if stem_def.sounds == nil then stem_def.sounds = mcl_sounds.node_sound_leaves_defaults() @@ -310,48 +310,48 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s local connected_stem_tiles = { { "blank.png", --top - "blank.png", -- bottom - "blank.png", -- right - "blank.png", -- left - connected_stem_texture, -- back - connected_stem_texture.."^[transformFX90" --front + "blank.png", -- bottom + "blank.png", -- right + "blank.png", -- left + connected_stem_texture, -- back + connected_stem_texture .. "^[transformFX90" --front }, { "blank.png", --top - "blank.png", -- bottom - "blank.png", -- right - "blank.png", -- left - connected_stem_texture.."^[transformFX90", --back - connected_stem_texture, -- front + "blank.png", -- bottom + "blank.png", -- right + "blank.png", -- left + connected_stem_texture .. "^[transformFX90", --back + connected_stem_texture, -- front }, { "blank.png", --top - "blank.png", -- bottom - connected_stem_texture.."^[transformFX90", -- right - connected_stem_texture, -- left - "blank.png", --back - "blank.png", -- front + "blank.png", -- bottom + connected_stem_texture .. "^[transformFX90", -- right + connected_stem_texture, -- left + "blank.png", --back + "blank.png", -- front }, { "blank.png", --top - "blank.png", -- bottom - connected_stem_texture, -- right - connected_stem_texture.."^[transformFX90", -- left - "blank.png", --back - "blank.png", -- front + "blank.png", -- bottom + connected_stem_texture, -- right + connected_stem_texture .. "^[transformFX90", -- left + "blank.png", --back + "blank.png", -- front } } local connected_stem_nodebox = { - {-0.5, -0.5, 0, 0.5, 0.5, 0}, - {-0.5, -0.5, 0, 0.5, 0.5, 0}, - {0, -0.5, -0.5, 0, 0.5, 0.5}, - {0, -0.5, -0.5, 0, 0.5, 0.5}, + { -0.5, -0.5, 0, 0.5, 0.5, 0 }, + { -0.5, -0.5, 0, 0.5, 0.5, 0 }, + { 0, -0.5, -0.5, 0, 0.5, 0.5 }, + { 0, -0.5, -0.5, 0, 0.5, 0.5 }, } local connected_stem_selectionbox = { - {-0.1, -0.5, -0.1, 0.5, 0.2, 0.1}, - {-0.5, -0.5, -0.1, 0.1, 0.2, 0.1}, - {-0.1, -0.5, -0.1, 0.1, 0.2, 0.5}, - {-0.1, -0.5, -0.5, 0.1, 0.2, 0.1}, + { -0.1, -0.5, -0.1, 0.5, 0.2, 0.1 }, + { -0.5, -0.5, -0.1, 0.1, 0.2, 0.1 }, + { -0.1, -0.5, -0.1, 0.1, 0.2, 0.5 }, + { -0.1, -0.5, -0.5, 0.1, 0.2, 0.1 }, } - for i=1, 4 do + for i = 1, 4 do minetest.register_node(connected_stem_names[i], { _doc_items_create_entry = false, paramtype = "light", @@ -369,7 +369,7 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s }, tiles = connected_stem_tiles[i], use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true, - groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1,attached_node=1, dig_by_water=1,destroy_by_lava_flow=1,}, + groups = { dig_immediate = 3, not_in_creative_inventory = 1, plant = 1, attached_node = 1, dig_by_water = 1, destroy_by_lava_flow = 1, }, sounds = mcl_sounds.node_sound_leaves_defaults(), _mcl_blast_resistance = 0, }) @@ -380,9 +380,9 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s end minetest.register_abm({ - label = "Grow gourd stem to gourd ("..full_unconnected_stem.." → "..gourd_itemstring..")", - nodenames = {full_unconnected_stem}, - neighbors = {"air"}, + label = "Grow gourd stem to gourd (" .. full_unconnected_stem .. " → " .. gourd_itemstring .. ")", + nodenames = { full_unconnected_stem }, + neighbors = { "air" }, interval = grow_interval, chance = grow_chance, action = function(stempos) @@ -390,20 +390,20 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s if light and light > 10 then -- Check the four neighbors and filter out neighbors where gourds can't grow local neighbors = { - { x=-1, y=0, z=0 }, - { x=1, y=0, z=0 }, - { x=0, y=0, z=-1 }, - { x=0, y=0, z=1 }, + { x = -1, y = 0, z = 0 }, + { x = 1, y = 0, z = 0 }, + { x = 0, y = 0, z = -1 }, + { x = 0, y = 0, z = 1 }, } local floorpos, floor - for n=#neighbors, 1, -1 do + for n = #neighbors, 1, -1 do local offset = neighbors[n] local blockpos = vector.add(stempos, offset) - floorpos = { x=blockpos.x, y=blockpos.y-1, z=blockpos.z } + floorpos = vector.offset (blockpos, 0, -1,0) -- replaces { x = blockpos.x, y = blockpos.y - 1, z = blockpos.z } floor = minetest.get_node(floorpos) local block = minetest.get_node(blockpos) local soilgroup = minetest.get_item_group(floor.name, "soil") - if not ((minetest.get_item_group(floor.name, "grass_block") == 1 or floor.name=="mcl_core:dirt" or soilgroup == 2 or soilgroup == 3) and block.name == "air") then + if not ((minetest.get_item_group(floor.name, "grass_block") == 1 or floor.name == "mcl_core:dirt" or soilgroup == 2 or soilgroup == 3) and block.name == "air") then table.remove(neighbors, n) end end @@ -416,27 +416,35 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s local blockpos = vector.add(stempos, offset) local p2 if offset.x == 1 then - minetest.set_node(stempos, {name=connected_stem_names[1]}) + minetest.set_node(stempos, { name = connected_stem_names[1] }) p2 = 3 elseif offset.x == -1 then - minetest.set_node(stempos, {name=connected_stem_names[2]}) + minetest.set_node(stempos, { name = connected_stem_names[2] }) p2 = 1 elseif offset.z == 1 then - minetest.set_node(stempos, {name=connected_stem_names[3]}) + minetest.set_node(stempos, { name = connected_stem_names[3] }) p2 = 2 elseif offset.z == -1 then - minetest.set_node(stempos, {name=connected_stem_names[4]}) + minetest.set_node(stempos, { name = connected_stem_names[4] }) p2 = 0 end -- Place the gourd if gourd_def.paramtype2 == "facedir" then - minetest.add_node(blockpos, {name=gourd_itemstring, param2=p2}) + minetest.add_node(blockpos, { name = gourd_itemstring, param2 = p2 }) else - minetest.add_node(blockpos, {name=gourd_itemstring}) + minetest.add_node(blockpos, { name = gourd_itemstring }) end + -- Reset farmland, etc. to dirt when the gourd grows on top + + -- FIXED: The following 2 lines were missing, and wasn't being set (outside of the above loop that + -- finds the neighbors.) + -- FYI - don't factor this out thinking that the loop above is setting the positions correctly. + floorpos = vector.offset (blockpos, 0, -1,0) -- replaces { x = blockpos.x, y = blockpos.y - 1, z = blockpos.z } + floor = minetest.get_node(floorpos) + -- END OF FIX ------------------------------------- if minetest.get_item_group(floor.name, "dirtifies_below_solid") == 1 then - minetest.set_node(floorpos, {name = "mcl_core:dirt"}) + minetest.set_node(floorpos, { name = "mcl_core:dirt" }) end end end @@ -452,7 +460,7 @@ end function mcl_farming:stem_color(startcolor, endcolor, step, step_count) local color = {} local function get_component(startt, endd, step, step_count) - return math.floor(math.max(0, math.min(255, (startt + (((step-1)/step_count) * endd))))) + return math.floor(math.max(0, math.min(255, (startt + (((step - 1) / step_count) * endd))))) end color.r = get_component(startcolor.r, endcolor.r, step, step_count) color.g = get_component(startcolor.g, endcolor.g, step, step_count) @@ -464,14 +472,14 @@ end minetest.register_lbm({ label = "Add growth for unloaded farming plants", name = "mcl_farming:growth", - nodenames = {"group:plant"}, + nodenames = { "group:plant" }, run_at_every_load = true, action = function(pos, node) local identifier = plant_nodename_to_id_list[node.name] if not identifier then return end - local low_speed = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name ~= "mcl_farming:soil_wet" + local low_speed = minetest.get_node({ x = pos.x, y = pos.y - 1, z = pos.z }).name ~= "mcl_farming:soil_wet" mcl_farming:grow_plant(identifier, pos, node, false, false, low_speed) end, }) diff --git a/mods/ITEMS/mcl_farming/sweet_berry.lua b/mods/ITEMS/mcl_farming/sweet_berry.lua index f87220d90..69ac552e5 100644 --- a/mods/ITEMS/mcl_farming/sweet_berry.lua +++ b/mods/ITEMS/mcl_farming/sweet_berry.lua @@ -35,6 +35,24 @@ for i=0, 3 do sounds = mcl_sounds.node_sound_leaves_defaults(), _mcl_blast_resistance = 0, _mcl_hardness = 0, + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + if mcl_dye and clicker:get_wielded_item():get_name() == "mcl_dye:white" then + mcl_dye.apply_bone_meal({under=pos},clicker) + return + end + local stage + if node.name:find("_2") then + stage = 2 + elseif node.name:find("_3") then + stage = 3 + end + if stage then + for i=1,math.random(stage) do + minetest.add_item(pos,"mcl_farming:sweet_berry") + end + minetest.swap_node(pos,{name = "mcl_farming:sweet_berry_bush_" .. stage - 1 }) + end + end, }) minetest.register_alias("mcl_sweet_berry:sweet_berry_bush_" .. i, node_name) end diff --git a/mods/ITEMS/mcl_honey/init.lua b/mods/ITEMS/mcl_honey/init.lua new file mode 100644 index 000000000..e736320aa --- /dev/null +++ b/mods/ITEMS/mcl_honey/init.lua @@ -0,0 +1,136 @@ +--------------- +---- Honey ---- +--------------- + +-- Variables +local S = minetest.get_translator(minetest.get_current_modname()) +local alldirs = {{x=0,y=0,z=1}, {x=1,y=0,z=0}, {x=0,y=0,z=-1}, {x=-1,y=0,z=0}, {x=0,y=-1,z=0}, {x=0,y=1,z=0}} + +-- Honeycomb +minetest.register_craftitem("mcl_honey:honeycomb", { + description = S("Honeycomb"), + _doc_items_longdesc = S("Used to craft beehives and protect copper blocks from further oxidation."), + _doc_items_usagehelp = S("Use on copper blocks to prevent further oxidation."), + inventory_image = "mcl_honey_honeycomb.png", + groups = { craftitem = 1 }, +}) + +minetest.register_node("mcl_honey:honeycomb_block", { + description = S("Honeycomb Block"), + _doc_items_longdesc = S("Honeycomb Block. Used as a decoration."), + tiles = { + "mcl_honey_honeycomb_block.png" + }, + groups = { handy = 1, deco_block = 1 }, + _mcl_blast_resistance = 0.6, + _mcl_hardness = 0.6, +}) + +-- Honey +minetest.register_craftitem("mcl_honey:honey_bottle", { + description = S("Honey Bottle"), + _doc_items_longdesc = S("Honey Bottle is used to craft honey blocks and to restore hunger points."), + _doc_items_usagehelp = S("Drinking will restore 6 hunger points. Can also be used to craft honey blocks."), + inventory_image = "mcl_honey_honey_bottle.png", + groups = { craftitem = 1, food = 3, eatable = 6, can_eat_when_full=1 }, + on_place = minetest.item_eat(6, "mcl_potions:glass_bottle"), + on_secondary_use = minetest.item_eat(6, "mcl_potions:glass_bottle"), + _mcl_saturation = 1.2, + stack_max = 16, +}) + +minetest.register_node("mcl_honey:honey_block", { + description = S("Honey Block"), + _doc_items_longdesc = S("Honey Block. Used as a decoration and in redstone. Is sticky on some sides."), + tiles = {"mcl_honey_block_side.png"}, + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "blend" or true, + groups = { handy = 1, deco_block = 1, fall_damage_add_percent = -80 }, + paramtype = "light", + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.4, -0.4, -0.4, 0.4, 0.4, 0.4}, + {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, + } + }, + selection_box = { + type = "regular", + }, + _mcl_blast_resistance = 0, + _mcl_hardness = 0, + mvps_sticky = function(pos, node, piston_pos) + local connected = {} + for n, v in ipairs(alldirs) do + local neighbor_pos = vector.add(pos, v) + local neighbor_node = minetest.get_node(neighbor_pos) + if neighbor_node then + if neighbor_node.name == "ignore" then + minetest.get_voxel_manip():read_from_map(neighbor_pos, neighbor_pos) + neighbor_node = minetest.get_node(neighbor_pos) + end + local name = neighbor_node.name + if name ~= "air" and name ~= "ignore" and not mesecon.mvps_unsticky[name] then + local piston, piston_side, piston_up, piston_down = false, false, false, false + if name == "mesecons_pistons:piston_sticky_off" or name == "mesecons_pistons:piston_normal_off" then + piston, piston_side = true, true + elseif name == "mesecons_pistons:piston_up_sticky_off" or name == "mesecons_pistons:piston_up_normal_off" then + piston, piston_up = true, true + elseif name == "mesecons_pistons:piston_down_sticky_off" or name == "mesecons_pistons:piston_down_normal_off" then + piston, piston_down = true, true + end + if not( (piston_side and (n-1==neighbor_node.param2)) or (piston_up and (n==5)) or (piston_down and (n==6)) ) then + if piston and piston_pos then + if piston_pos.x == neighbor_pos.x and piston_pos.y == neighbor_pos.y and piston_pos.z == neighbor_pos.z then + -- Loopback to the same piston! Preventing unwanted behavior: + return {}, true + end + end + table.insert(connected, neighbor_pos) + end + end + end + end + return connected, false + end, +}) + +-- Crafting +minetest.register_craft({ + output = "mcl_honey:honeycomb_block", + recipe = { + { "mcl_honey:honeycomb", "mcl_honey:honeycomb" }, + { "mcl_honey:honeycomb", "mcl_honey:honeycomb" }, + }, +}) + +minetest.register_craft({ + output = "mcl_honey:honey_block", + recipe = { + { "mcl_honey:honey_bottle", "mcl_honey:honey_bottle" }, + { "mcl_honey:honey_bottle", "mcl_honey:honey_bottle" }, + }, + replacements = { + { "mcl_honey:honey_bottle", "mcl_potions:glass_bottle" }, + { "mcl_honey:honey_bottle", "mcl_potions:glass_bottle" }, + { "mcl_honey:honey_bottle", "mcl_potions:glass_bottle" }, + { "mcl_honey:honey_bottle", "mcl_potions:glass_bottle" }, + }, +}) + +minetest.register_craft({ + output = "mcl_honey:honey_bottle 4", + recipe = { + { "mcl_potions:glass_bottle", "mcl_potions:glass_bottle", "mcl_honey:honey_block" }, + { "mcl_potions:glass_bottle", "mcl_potions:glass_bottle", "" }, + }, +}) + +minetest.register_craft({ + type = "shapeless", + output = "mcl_core:sugar 3", + recipe = { "mcl_honey:honey_bottle" }, + replacements = { + { "mcl_honey:honey_bottle", "mcl_potions:glass_bottle" }, + }, +}) diff --git a/mods/ITEMS/mcl_honey/locale/template.txt b/mods/ITEMS/mcl_honey/locale/template.txt new file mode 100644 index 000000000..a9814d617 --- /dev/null +++ b/mods/ITEMS/mcl_honey/locale/template.txt @@ -0,0 +1,10 @@ +Honeycomb= +Used to craft beehives and protect copper blocks from further oxidation.= +Use on copper blocks to prevent further oxidation.= +Honeycomb Block= +Honeycomb Block. Used as a decoration.= +Honey Bottle= +Honey Bottle is used to craft honey blocks and to restore hunger points.= +Drinking will restore 6 hunger points. Can also be used to craft honey blocks.= +Honey Block= +Honey Block. Used as a decoration and in redstone. Is sticky on some sides.= \ No newline at end of file diff --git a/mods/ITEMS/mcl_honey/mod.conf b/mods/ITEMS/mcl_honey/mod.conf new file mode 100644 index 000000000..436811291 --- /dev/null +++ b/mods/ITEMS/mcl_honey/mod.conf @@ -0,0 +1,4 @@ +name = mcl_honey +author = PrairieWind +description = MineClone 2 mod that adds honey and honeycomb and the respective block versions. +depends = mesecons_mvps diff --git a/mods/ITEMS/mcl_honey/textures/mcl_honey_block_bottom.png b/mods/ITEMS/mcl_honey/textures/mcl_honey_block_bottom.png new file mode 100644 index 000000000..9de965284 Binary files /dev/null and b/mods/ITEMS/mcl_honey/textures/mcl_honey_block_bottom.png differ diff --git a/mods/ITEMS/mcl_honey/textures/mcl_honey_block_side.png b/mods/ITEMS/mcl_honey/textures/mcl_honey_block_side.png new file mode 100644 index 000000000..4cdecfb03 Binary files /dev/null and b/mods/ITEMS/mcl_honey/textures/mcl_honey_block_side.png differ diff --git a/mods/ITEMS/mcl_honey/textures/mcl_honey_block_top.png b/mods/ITEMS/mcl_honey/textures/mcl_honey_block_top.png new file mode 100644 index 000000000..c2f330440 Binary files /dev/null and b/mods/ITEMS/mcl_honey/textures/mcl_honey_block_top.png differ diff --git a/mods/ITEMS/mcl_honey/textures/mcl_honey_honey_bottle.png b/mods/ITEMS/mcl_honey/textures/mcl_honey_honey_bottle.png new file mode 100644 index 000000000..16956f56e Binary files /dev/null and b/mods/ITEMS/mcl_honey/textures/mcl_honey_honey_bottle.png differ diff --git a/mods/ITEMS/mcl_honey/textures/mcl_honey_honeycomb.png b/mods/ITEMS/mcl_honey/textures/mcl_honey_honeycomb.png new file mode 100644 index 000000000..a590d517a Binary files /dev/null and b/mods/ITEMS/mcl_honey/textures/mcl_honey_honeycomb.png differ diff --git a/mods/ITEMS/mcl_honey/textures/mcl_honey_honeycomb_block.png b/mods/ITEMS/mcl_honey/textures/mcl_honey_honeycomb_block.png new file mode 100644 index 000000000..42c4ce85e Binary files /dev/null and b/mods/ITEMS/mcl_honey/textures/mcl_honey_honeycomb_block.png differ diff --git a/mods/ITEMS/mcl_hoppers/init.lua b/mods/ITEMS/mcl_hoppers/init.lua index 10f37afb4..c204071a9 100644 --- a/mods/ITEMS/mcl_hoppers/init.lua +++ b/mods/ITEMS/mcl_hoppers/init.lua @@ -338,8 +338,8 @@ minetest.register_node("mcl_hoppers:hopper_side_disabled", def_hopper_side_disab --[[ END OF NODE DEFINITIONS ]] -local function hopper_pull_from_mc (mc_ent, dest_pos) - local inv = mcl_entity_invs.load_inv(mc_ent,5) +local function hopper_pull_from_mc (mc_ent, dest_pos, inv_size) + local inv = mcl_entity_invs.load_inv(mc_ent, inv_size) if not inv then mcl_log("No inv") return false @@ -382,7 +382,7 @@ end --[[ BEGIN OF ABM DEFINITONS ]] minetest.register_abm({ - label = "Hoppers pull from minecart hoppers", + label = "Hoppers pull from minecart", nodenames = {"mcl_hoppers:hopper","mcl_hoppers:hopper_side"}, interval = 0.5, chance = 1, @@ -396,9 +396,9 @@ minetest.register_abm({ if entity and entity.name then --mcl_log("Name of object near: " .. tostring(entity.name)) - if entity.name == "mcl_minecarts:hopper_minecart" then + if entity.name == "mcl_minecarts:hopper_minecart" or entity.name == "mcl_minecarts:chest_minecart"then local hm_pos = entity.object:get_pos() - mcl_log("We have a hopper minecart close: ".. minetest.pos_to_string(hm_pos)) + mcl_log("We have a minecart with inventory close: ".. minetest.pos_to_string(hm_pos)) --if hm_pos.y == pos.y + 1 then mcl_log("y is correct") end --if (hm_pos.x >= pos.x - DIST_FROM_MC and hm_pos.x <= pos.x + DIST_FROM_MC) then mcl_log("x is within range") end @@ -409,7 +409,11 @@ minetest.register_abm({ and (hm_pos.x >= pos.x - DIST_FROM_MC and hm_pos.x <= pos.x + DIST_FROM_MC) and (hm_pos.z >= pos.z - DIST_FROM_MC and hm_pos.z <= pos.z + DIST_FROM_MC) then mcl_log("Minecart close enough") - hopper_pull_from_mc (entity, pos) + if entity.name == "mcl_minecarts:hopper_minecart" then + hopper_pull_from_mc(entity, pos, 5) + elseif entity.name == "mcl_minecarts:chest_minecart" then + hopper_pull_from_mc(entity, pos, 27) + end end end else @@ -620,10 +624,10 @@ minetest.register_abm({ end end end - end + end if compchance > 0 then itemcomp[hslot]:take_item() - inv:set_list("main", itemcomp) + inv:set_list("main", itemcomp) local rand = math.random(0,100) if compchance >= rand then local level = 0 diff --git a/mods/ITEMS/mcl_itemframes/item_frames_API.lua b/mods/ITEMS/mcl_itemframes/item_frames_API.lua index 741e6ce71..231482800 100644 --- a/mods/ITEMS/mcl_itemframes/item_frames_API.lua +++ b/mods/ITEMS/mcl_itemframes/item_frames_API.lua @@ -34,6 +34,8 @@ local glow_amount = 6 -- LIGHT_MAX is 15, but the items aren't supposed to be a local frame_item_base = {} local map_item_base = {} +local TIMER_INTERVAL = 40.0 + -- Time to Fleckenstein! (it just sounds cool lol) --- self: the object to roll. @@ -247,6 +249,7 @@ mcl_itemframes.update_item_entity = function(pos, node, param2) local map_id_entity = {} local map_id_lua = {} + local timer = minetest.get_node_timer(pos) if map_id == "" then -- handle regular items placed into custom frame. if mcl_itemframes.DEBUG then @@ -268,13 +271,32 @@ mcl_itemframes.update_item_entity = function(pos, node, param2) if itemname == "" or itemname == nil then map_id_lua._texture = "blank.png" map_id_lua._scale = 1 + + -- set up glow, as this is the default/initial clause on placement. if has_glow then map_id_lua.glow = glow_amount end + + -- if there's nothing to display, then kill the timer. + if timer:is_started() == true then + timer:stop() + end else map_id_lua._texture = itemname local def = minetest.registered_items[itemname] map_id_lua._scale = def and def.wield_scale and def.wield_scale.x or 1 + + -- fix for /ClearObjects + if minetest.get_item_group(itemname, "clock") == 0 then + -- Do timer related stuff - but only if there is something to display... and it's not a clock. + if timer:is_started() == false then + timer:start(TIMER_INTERVAL) + else + timer:stop() + timer:start(TIMER_INTERVAL) + end + end + end if mcl_itemframes.DEBUG then minetest.log("action", "[mcl_itemframes] Update_Generic_Item: item's name: " .. itemname) @@ -297,6 +319,15 @@ mcl_itemframes.update_item_entity = function(pos, node, param2) else minetest.log("error", "[mcl_itemframes] Update_Generic_Item: Failed to set Map Item in " .. found_name_to_use .. "'s frame.") end + + -- give maps a refresh timer. + if timer:is_started() == false then + timer:start(TIMER_INTERVAL) + else + timer:stop() + timer:start(TIMER_INTERVAL) + end + end -- finally, set the rotation (roll) of the displayed object. @@ -364,7 +395,7 @@ function mcl_itemframes.create_base_item_entity() textures = { "blank.png" }, _texture = "blank.png", _scale = 1, - + groups = { immortal = 1, }, on_activate = function(self, staticdata) if staticdata and staticdata ~= "" then local data = staticdata:split(";") @@ -395,7 +426,7 @@ function mcl_itemframes.create_base_item_entity() end return "" end, - + on_punch = function() return true end, _update_texture = function(self) if self._texture then self.object:set_properties({ @@ -561,6 +592,23 @@ function mcl_itemframes.custom_register_lbm() end +local function register_frame_achievements() + + awards.register_achievement("mcl_itemframes:glowframe", { + title = S("Glow and Behold!"), + description = S("Craft a glow item frame."), + icon = "mcl_itemframes_glow_item_frame.png", + trigger = { + type = "craft", + item = "mcl_itemframes:glow_item_frame", + target = 1 + }, + type = "Advancement", + group = "Overworld", + }) + +end + function mcl_itemframes.create_base_definitions() if mcl_itemframes.DEBUG then minetest.log("action", "[mcl_itemframes] create_base_definitions.") @@ -590,7 +638,7 @@ function mcl_itemframes.create_base_definitions() paramtype = "light", paramtype2 = "facedir", sunlight_propagates = true, - groups = { dig_immediate = 3, deco_block = 1, dig_by_piston = 1, container = 7, attached_node_facedir = 1 }, + groups = { dig_immediate = 3, deco_block = 1, dig_by_piston = 1, container = 7, }, -- attached_node_facedir = 1 }, -- allows for more placement options. sounds = mcl_sounds.node_sound_defaults(), node_placement_prediction = "", @@ -598,16 +646,19 @@ function mcl_itemframes.create_base_definitions() local inv = minetest.get_meta(pos):get_inventory() local stack = inv:get_stack("main", 1) local itemname = stack:get_name() + local node = {} if minetest.get_item_group(itemname, "clock") > 0 then local new_name = "mcl_clock:clock_" .. (mcl_worlds.clock_works(pos) and mcl_clock.old_time or mcl_clock.random_frame) if itemname ~= new_name then stack:set_name(new_name) inv:set_stack("main", 1, stack) - local node = minetest.get_node(pos) + node = minetest.get_node(pos) mcl_itemframes.update_item_entity(pos, node, node.param2) - end minetest.get_node_timer(pos):start(1.0) + else + node = minetest.get_node(pos) + mcl_itemframes.update_item_entity(pos, node, node.param2) end end, @@ -616,6 +667,14 @@ function mcl_itemframes.create_base_definitions() return itemstack end + local dir = vector.subtract(pointed_thing.under, pointed_thing.above) + local wdir = minetest.dir_to_wallmounted(dir) + + -- remove bottom and top of objects. + if wdir == 0 or wdir == 1 then + return itemstack + end + -- Use pointed node's on_rightclick function first, if present local node = minetest.get_node(pointed_thing.under) if placer and not placer:get_player_control().sneak then @@ -784,15 +843,11 @@ function mcl_itemframes.create_base_definitions() mcl_itemframes.glow_frame_base.inventory_image = "mcl_itemframes_glow_item_frame_item.png" mcl_itemframes.glow_frame_base.wield_image = "mcl_itemframes_glow_item_frame.png" mcl_itemframes.glow_frame_base.mesh = "mcl_itemframes_glow_item_frame.obj" + mcl_itemframes.glow_frame_base.glow = 1 --make the glow frames have some glow at night, but not enough to be a light source. - --[[ - minetest.register_node("mcl_itemframes:glow_item_frame", mcl_itemframes.glow_frame_base) + -- set up the achievement for glow frames. + register_frame_achievements() - mcl_itemframes.update_frame_registry("false", "mcl_itemframes:item_frame", false) - mcl_itemframes.update_frame_registry("false", "mcl_itemframes:glow_item_frame", true) - create_register_lbm("mcl_itemframes:item_frame") - create_register_lbm("mcl_itemframes:glow_item_frame") - --]] end -- for compatibility: diff --git a/mods/ITEMS/mcl_mangrove/schematics/mcl_mangrove_bee_nest.mts b/mods/ITEMS/mcl_mangrove/schematics/mcl_mangrove_bee_nest.mts new file mode 100644 index 000000000..630117463 Binary files /dev/null and b/mods/ITEMS/mcl_mangrove/schematics/mcl_mangrove_bee_nest.mts differ diff --git a/mods/ITEMS/mcl_mobitems/init.lua b/mods/ITEMS/mcl_mobitems/init.lua index 256be9025..e1b39660f 100644 --- a/mods/ITEMS/mcl_mobitems/init.lua +++ b/mods/ITEMS/mcl_mobitems/init.lua @@ -402,11 +402,11 @@ minetest.register_alias("mobs_mc:gold_horse_armor", "mcl_mobitems:gold_horse_arm minetest.register_alias("mobs_mc:diamond_horse_armor", "mcl_mobitems:diamond_horse_armor") minetest.register_craftitem("mcl_mobitems:glow_ink_sac", { - description = S("Glow Ink Sac"), - _doc_items_longdesc = S("Use it to craft the Glow Item Frame."), - _doc_items_usagehelp = S("Use the Glow Ink Sac and the normal Item Frame to craft the Glow Item Frame."), - inventory_image = "extra_mobs_glow_ink_sac.png", - groups = { craftitem = 1 }, + description = S("Glow Ink Sac"), + _doc_items_longdesc = S("Use it to craft the Glow Item Frame."), + _doc_items_usagehelp = S("Use the Glow Ink Sac and the normal Item Frame to craft the Glow Item Frame."), + inventory_image = "extra_mobs_glow_ink_sac.png", + groups = { craftitem = 1 }, }) diff --git a/mods/ITEMS/mcl_ocean/kelp.lua b/mods/ITEMS/mcl_ocean/kelp.lua index 5cddabd30..5957bafb2 100644 --- a/mods/ITEMS/mcl_ocean/kelp.lua +++ b/mods/ITEMS/mcl_ocean/kelp.lua @@ -741,7 +741,7 @@ minetest.register_craftitem("mcl_ocean:kelp", { inventory_image = "mcl_ocean_kelp_item.png", wield_image = "mcl_ocean_kelp_item.png", on_place = kelp.kelp_on_place, - groups = {deco_block = 1, compostability = 30}, + groups = {deco_block = 1, compostability = 30, smoker_cookable = 1}, }) if mod_doc then diff --git a/mods/ITEMS/mcl_signs/README.txt b/mods/ITEMS/mcl_signs/README.txt index 5ef65481c..e4fbead8a 100644 --- a/mods/ITEMS/mcl_signs/README.txt +++ b/mods/ITEMS/mcl_signs/README.txt @@ -2,7 +2,7 @@ --- # Mineclone2-Signs --- -A reworking of MineClone 2's mcl_signs to be colorable and made to glow. Rquires Minetest and Mineclone2. +A reworking of MineClone 2's mcl_signs to be colorable and made to glow. Requires Minetest and Mineclone2. --- Created by Michieal (FaerRaven) @ DateTime: 10/14/22 4:05 PM diff --git a/mods/ITEMS/mcl_signs/init.lua b/mods/ITEMS/mcl_signs/init.lua index 403b53ef8..e724def68 100644 --- a/mods/ITEMS/mcl_signs/init.lua +++ b/mods/ITEMS/mcl_signs/init.lua @@ -125,9 +125,11 @@ mcl_signs.register_sign_craft("mcl_core", "mcl_core:junglewood", "_junglewood") mcl_signs.register_sign("mcl_core", "#ea7479", "_acaciawood", "Acacia Sign") mcl_signs.register_sign_craft("mcl_core", "mcl_core:acaciawood", "_acaciawood") --- mangrove_wood Sign "#c7545c" -mcl_signs.register_sign("mcl_core", "#b8693d", "_mangrove_wood", "Mangrove Sign") -mcl_signs.register_sign_craft("mcl_core", "mcl_core:mangrove_wood", "_mangrove_wood") +if minetest.get_modpath("mcl_mangrove") then + -- mangrove_wood Sign "#c7545c" + mcl_signs.register_sign("mcl_mangrove", "#b8693d", "_mangrove_wood", "Mangrove Sign") + mcl_signs.register_sign_craft("mcl_mangrove", "mcl_mangrove:mangrove_wood", "_mangrove_wood") +end -- add in the nether wood signs if minetest.get_modpath("mcl_crimson") then diff --git a/mods/ITEMS/mcl_signs/signs_api.lua b/mods/ITEMS/mcl_signs/signs_api.lua index 9d88b8ed1..1f7369ba3 100644 --- a/mods/ITEMS/mcl_signs/signs_api.lua +++ b/mods/ITEMS/mcl_signs/signs_api.lua @@ -7,10 +7,9 @@ --local logging = minetest.settings:get_bool("mcl_logging_mcl_signs",true) local DEBUG = minetest.settings:get_bool("mcl_logging_mcl_signs", false) -- special debug setting. -local table = table -- copied from the original signs init file. if DEBUG then - minetest.log("action", "[mcl_signs] Signs API Loading") + minetest.log("action", "[mcl_signs] Signs API Loading") end -- LOCALIZATION @@ -29,12 +28,16 @@ local NUMBER_OF_LINES = 4 local LINE_HEIGHT = 14 local CHAR_WIDTH = 5 +local TIMER_INTERVAL = 40.0 -- ----------------------- +-- CACHE LOCAL COPIES +local table = table +local string = string -- CACHE NODE_SOUNDS local node_sounds if minetest.get_modpath("mcl_sounds") then - node_sounds = mcl_sounds.node_sound_wood_defaults() + node_sounds = mcl_sounds.node_sound_wood_defaults() end -- SET UP THE CHARACTER MAPPING @@ -55,17 +58,17 @@ local chars_file = io.open(modpath .. "/characters.txt", "r") -- FIXME: Support more characters (many characters are missing). Currently ASCII and Latin-1 Supplement are supported. local charmap = {} if not chars_file then - minetest.log("error", "[mcl_signs] : character map file not found") + minetest.log("error", "[mcl_signs] : character map file not found") else - while true do - local char = chars_file:read("*l") - if char == nil then - break - end - local img = chars_file:read("*l") - chars_file:read("*l") - charmap[char] = img - end + while true do + local char = chars_file:read("*l") + if char == nil then + break + end + local img = chars_file:read("*l") + chars_file:read("*l") + charmap[char] = img + end end local pi = 3.1415926 -- enough accuracy, to build an engine for a car. @@ -75,7 +78,7 @@ local math = math -- locally cached copy of the official colors; this way, it updates as mcl_colors updates. local mcl_colors_official = mcl_colors if DEBUG then - minetest.log("verbose", "[mcl_signs]Official MCL_Colors:\n" .. dump(mcl_colors_official)) + minetest.log("verbose", "[mcl_signs]Official MCL_Colors:\n" .. dump(mcl_colors_official)) end -- INITIALIZE THE GLOBAL API FOR SIGNS. @@ -85,22 +88,22 @@ mcl_signs = {} mcl_signs.sign_groups = { handy = 1, axey = 1, deco_block = 1, material_wood = 1, attached_node = 1, dig_by_piston = 1, flammable = -1 } --- colors used for wools. mcl_signs.mcl_wool_colors = { - unicolor_white = "#FFFFFF", - unicolor_dark_orange = "#502A00", - unicolor_grey = "#5B5B5B", - unicolor_darkgrey = "#303030", - unicolor_blue = "#0000CC", - unicolor_dark_green = "#005000", - unicolor_green_or_lime = "#50CC00", - unicolor_violet_purple = "#5000CC", - unicolor_light_red_pink = "#FF5050", - unicolor_yellow = "#CCCC00", - unicolor_orange = "#CC5000", - unicolor_red = "#CC0000", - unicolor_cyan = "#00CCCC", - unicolor_red_violet_magenta = "#CC0050", - unicolor_black = "#000000", - unicolor_light_blue = "#5050FF", + unicolor_white = "#FFFFFF", + unicolor_dark_orange = "#502A00", + unicolor_grey = "#5B5B5B", + unicolor_darkgrey = "#303030", + unicolor_blue = "#0000CC", + unicolor_dark_green = "#005000", + unicolor_green_or_lime = "#50CC00", + unicolor_violet_purple = "#5000CC", + unicolor_light_red_pink = "#FF5050", + unicolor_yellow = "#CCCC00", + unicolor_orange = "#CC5000", + unicolor_red = "#CC0000", + unicolor_cyan = "#00CCCC", + unicolor_red_violet_magenta = "#CC0050", + unicolor_black = "#000000", + unicolor_light_blue = "#5050FF", } mcl_signs.signtext_info_wall = {} mcl_signs.signtext_info_standing = {} -- built in build_signs_info(). @@ -117,400 +120,407 @@ mcl_signs.wall_standard = {} -- initialize mcl_signs.standing_standard = {} -- initialize function mcl_signs.build_signs_info() - local n = 23 / 56 - 1 / 128 -- some required magic number from the original code. - local m = -1 / 16 + 1 / 64 -- " " " " " " " " + local n = 23 / 56 - 1 / 128 -- some required magic number from the original code. + local m = -1 / 16 + 1 / 64 -- " " " " " " " " - mcl_signs.signtext_info_wall = { - { delta = { x = 0, y = 0, z = n }, yaw = 0 }, - { delta = { x = n, y = 0, z = 0 }, yaw = pi / -2 }, - { delta = { x = 0, y = 0, z = -n }, yaw = pi }, - { delta = { x = -n, y = 0, z = 0 }, yaw = pi / 2 }, - } + mcl_signs.signtext_info_wall = { + { delta = { x = 0, y = 0, z = n }, yaw = 0 }, + { delta = { x = n, y = 0, z = 0 }, yaw = pi / -2 }, + { delta = { x = 0, y = 0, z = -n }, yaw = pi }, + { delta = { x = -n, y = 0, z = 0 }, yaw = pi / 2 }, + } - -- PLACE YAW VALUES INTO THE TABLE. - for rot = 0, 15 do - local yaw = pi * 2 - (((pi * 2) / 16) * rot) - local delta = vector.multiply(minetest.yaw_to_dir(yaw), m) - -- Offset because sign is a bit above node boundaries - delta.y = delta.y + 2 / 28 - table.insert(mcl_signs.signtext_info_standing, { delta = delta, yaw = yaw }) - end + -- PLACE YAW VALUES INTO THE TABLE. + for rot = 0, 15 do + local yaw = pi * 2 - (((pi * 2) / 16) * rot) + local delta = vector.multiply(minetest.yaw_to_dir(yaw), m) + -- Offset because sign is a bit above node boundaries + delta.y = delta.y + 2 / 28 + table.insert(mcl_signs.signtext_info_standing, { delta = delta, yaw = yaw }) + end end -- wall signs' & hanging signs' base (definition) mcl_signs.wall_standard = { - description = S("Sign"), - _tt_help = S("Can be written"), - _doc_items_longdesc = S("Signs can be written and come in two variants: Wall sign and sign on a sign post. Signs can be placed on the top and the sides of other blocks, but not below them."), - _doc_items_usagehelp = S("After placing the sign, you can write something on it. You have 4 lines of text with up to 15 characters for each line; anything beyond these limits is lost. Not all characters are supported. The text can not be changed once it has been written; you have to break and place the sign again. Can be colored and made to glow."), - inventory_image = "default_sign.png", - walkable = false, - is_ground_content = false, - wield_image = "default_sign.png", - node_placement_prediction = "", - paramtype = "light", - sunlight_propagates = true, - paramtype2 = "wallmounted", - drawtype = "mesh", - mesh = "mcl_signs_signonwallmount.obj", - selection_box = { type = "wallmounted", wall_side = { -0.5, -7 / 28, -0.5, -23 / 56, 7 / 28, 0.5 } }, - tiles = { "mcl_signs_sign.png" }, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, - groups = mcl_signs.sign_groups, - stack_max = 16, - sounds = node_sounds, + description = S("Sign"), + _tt_help = S("Can be written"), + _doc_items_longdesc = S("Signs can be written and come in two variants: Wall sign and sign on a sign post. Signs can be placed on the top and the sides of other blocks, but not below them."), + _doc_items_usagehelp = S("After placing the sign, you can write something on it. You have 4 lines of text with up to 15 characters for each line; anything beyond these limits is lost. Not all characters are supported. The text can not be changed once it has been written; you have to break and place the sign again. Can be colored and made to glow."), + inventory_image = "default_sign.png", + walkable = false, + is_ground_content = false, + wield_image = "default_sign.png", + node_placement_prediction = "", + paramtype = "light", + sunlight_propagates = true, + paramtype2 = "wallmounted", + drawtype = "mesh", + mesh = "mcl_signs_signonwallmount.obj", + selection_box = { type = "wallmounted", wall_side = { -0.5, -7 / 28, -0.5, -23 / 56, 7 / 28, 0.5 } }, + tiles = { "mcl_signs_sign.png" }, + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, + groups = mcl_signs.sign_groups, + stack_max = 16, + sounds = node_sounds, - on_place = function(itemstack, placer, pointed_thing) - local above = pointed_thing.above - local under = pointed_thing.under + on_timer = function(pos) + -- fix for /ClearObjects + mcl_signs:update_sign(pos) + -- note: update_sign decides to keep the timer running based on if there is text. + -- This prevents every sign from having a timer, when not needed. + end, - -- Use pointed node's on_rightclick function first, if present - local node_under = minetest.get_node(under) - if placer and not placer:get_player_control().sneak then - if minetest.registered_nodes[node_under.name] and minetest.registered_nodes[node_under.name].on_rightclick then - return minetest.registered_nodes[node_under.name].on_rightclick(under, node_under, placer, itemstack) or itemstack - end - end + on_place = function(itemstack, placer, pointed_thing) + local above = pointed_thing.above + local under = pointed_thing.under - local dir = vector.subtract(under, above) + -- Use pointed node's on_rightclick function first, if present + local node_under = minetest.get_node(under) + if placer and not placer:get_player_control().sneak then + if minetest.registered_nodes[node_under.name] and minetest.registered_nodes[node_under.name].on_rightclick then + return minetest.registered_nodes[node_under.name].on_rightclick(under, node_under, placer, itemstack) or itemstack + end + end - -- Only build when it's legal - local abovenodedef = minetest.registered_nodes[minetest.get_node(above).name] - if not abovenodedef or abovenodedef.buildable_to == false then - return itemstack - end + local dir = vector.subtract(under, above) - local wdir = minetest.dir_to_wallmounted(dir) + -- Only build when it's legal + local abovenodedef = minetest.registered_nodes[minetest.get_node(above).name] + if not abovenodedef or abovenodedef.buildable_to == false then + return itemstack + end - --local placer_pos = placer:get_pos() + local wdir = minetest.dir_to_wallmounted(dir) - local fdir = minetest.dir_to_facedir(dir) + --local placer_pos = placer:get_pos() - local sign_info - local nodeitem = ItemStack(itemstack) - -- Ceiling - if wdir == 0 then - --how would you add sign to ceiling? - return itemstack - -- Floor - end + local fdir = minetest.dir_to_facedir(dir) - if wdir == 1 then - -- Standing sign + local sign_info + local nodeitem = ItemStack(itemstack) + -- Ceiling + if wdir == 0 then + --how would you add sign to ceiling? + return itemstack + -- Floor + end - -- Determine the sign rotation based on player's yaw - local yaw = pi * 2 - placer:get_look_horizontal() + if wdir == 1 then + -- Standing sign - -- Select one of 16 possible rotations (0-15) - local rotation_level = mcl_signs:round((yaw / (pi * 2)) * 16) + -- Determine the sign rotation based on player's yaw + local yaw = pi * 2 - placer:get_look_horizontal() - if rotation_level > 15 then - rotation_level = 0 - elseif rotation_level < 0 then - rotation_level = 15 - end + -- Select one of 16 possible rotations (0-15) + local rotation_level = mcl_signs:round((yaw / (pi * 2)) * 16) - -- The actual rotation is a combination of predefined mesh and facedir (see node definition) - if rotation_level % 4 == 0 then - nodeitem:set_name("mcl_signs:standing_sign") - elseif rotation_level % 4 == 1 then - nodeitem:set_name("mcl_signs:standing_sign22_5") - elseif rotation_level % 4 == 2 then - nodeitem:set_name("mcl_signs:standing_sign45") - elseif rotation_level % 4 == 3 then - nodeitem:set_name("mcl_signs:standing_sign67_5") - end - fdir = math.floor(rotation_level / 4) + if rotation_level > 15 then + rotation_level = 0 + elseif rotation_level < 0 then + rotation_level = 15 + end - -- Place the node! - local _, success = minetest.item_place_node(nodeitem, placer, pointed_thing, fdir) - if not success then - return itemstack - end - if not minetest.is_creative_enabled(placer:get_player_name()) then - itemstack:take_item() - end - sign_info = mcl_signs.signtext_info_standing[rotation_level + 1] - -- Side - else - -- Wall sign - local _, success = minetest.item_place_node(itemstack, placer, pointed_thing, wdir) - if not success then - return itemstack - end - sign_info = mcl_signs.signtext_info_wall[fdir + 1] - end + -- The actual rotation is a combination of predefined mesh and facedir (see node definition) + if rotation_level % 4 == 0 then + nodeitem:set_name("mcl_signs:standing_sign") + elseif rotation_level % 4 == 1 then + nodeitem:set_name("mcl_signs:standing_sign22_5") + elseif rotation_level % 4 == 2 then + nodeitem:set_name("mcl_signs:standing_sign45") + elseif rotation_level % 4 == 3 then + nodeitem:set_name("mcl_signs:standing_sign67_5") + end + fdir = math.floor(rotation_level / 4) - -- Determine spawn position of entity - local place_pos - if minetest.registered_nodes[node_under.name].buildable_to then - place_pos = under - else - place_pos = above - end + -- Place the node! + local _, success = minetest.item_place_node(nodeitem, placer, pointed_thing, fdir) + if not success then + return itemstack + end + if not minetest.is_creative_enabled(placer:get_player_name()) then + itemstack:take_item() + end + sign_info = mcl_signs.signtext_info_standing[rotation_level + 1] + -- Side + else + -- Wall sign + local _, success = minetest.item_place_node(itemstack, placer, pointed_thing, wdir) + if not success then + return itemstack + end + sign_info = mcl_signs.signtext_info_wall[fdir + 1] + end - local text_entity = minetest.add_entity({ - x = place_pos.x + sign_info.delta.x, - y = place_pos.y + sign_info.delta.y, - z = place_pos.z + sign_info.delta.z }, "mcl_signs:text") - text_entity:set_yaw(sign_info.yaw) - text_entity:get_luaentity()._signnodename = nodeitem:get_name() - if DEBUG then - minetest.log("verbose", "[mcl_signs]Placed position:" .. dump(place_pos) .. "\nSign_info: " .. dump(sign_info)) - end + -- Determine spawn position of entity + local place_pos + if minetest.registered_nodes[node_under.name].buildable_to then + place_pos = under + else + place_pos = above + end - minetest.sound_play({ name = "default_place_node_hard", gain = 1.0 }, { pos = place_pos }, true) + local text_entity = minetest.add_entity({ + x = place_pos.x + sign_info.delta.x, + y = place_pos.y + sign_info.delta.y, + z = place_pos.z + sign_info.delta.z }, "mcl_signs:text") + text_entity:set_yaw(sign_info.yaw) + text_entity:get_luaentity()._signnodename = nodeitem:get_name() + if DEBUG then + minetest.log("verbose", "[mcl_signs]Placed position:" .. dump(place_pos) .. "\nSign_info: " .. dump(sign_info)) + end - mcl_signs:show_formspec(placer, place_pos) - return itemstack - end, - on_destruct = function(pos) - mcl_signs:destruct_sign(pos) - end, + minetest.sound_play({ name = "default_place_node_hard", gain = 1.0 }, { pos = place_pos }, true) - -- Not Useless Code. force updates the sign. - on_punch = function(pos, node, puncher) - mcl_signs:update_sign(pos) - if DISINTEGRATE then - mcl_signs:destruct_sign(pos) - end - end, - on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - local r = screwdriver.rotate.wallmounted(pos, node, mode) - node.param2 = r - minetest.swap_node(pos, node) - mcl_signs:update_sign(pos, nil, nil, true) - return true - else - return false - end - end, - on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) - if DEBUG then - minetest.log("verbose", "[mcl_signs] Wall_Sign Right Click event.") - end + mcl_signs:show_formspec(placer, place_pos) + return itemstack + end, + on_destruct = function(pos) + mcl_signs:destruct_sign(pos) + end, - -- make sure player is clicking - if not clicker or not clicker:is_player() then - return - end + -- Not Useless Code. force updates the sign. + on_punch = function(pos, node, puncher) + mcl_signs:update_sign(pos) + end, + on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + local r = screwdriver.rotate.wallmounted(pos, node, mode) + node.param2 = r + minetest.swap_node(pos, node) + mcl_signs:update_sign(pos, nil, nil, true) + return true + else + return false + end + end, + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + if DEBUG then + minetest.log("verbose", "[mcl_signs] Wall_Sign Right Click event.") + end - local item = clicker:get_wielded_item() - local iname = item:get_name() + -- make sure player is clicking + if not clicker or not clicker:is_player() then + return + end - if node then - if DEBUG then - minetest.log("verbose", "[mcl_signs] Wall_Sign Right Click event on valid node.") - end + local item = clicker:get_wielded_item() + local iname = item:get_name() - -- handle glow from glow_ink_sac *first* - if (iname == "mcl_mobitems:glow_ink_sac") then - clicker:set_wielded_item(item) - local success = mcl_signs:glow_sign(pos) - if success then - if DEBUG then - minetest.log("verbose", "[mcl_signs] Sign Glow Success.") - end - itemstack:take_item() - end - return - end + if node then + if DEBUG then + minetest.log("verbose", "[mcl_signs] Wall_Sign Right Click event on valid node.") + end - -- "mcl_dye:black" is a special case: it makes the sign's lettering black AND removes glow. - if (iname == "mcl_dye:black") then - clicker:set_wielded_item(item) - local success = mcl_signs:glow_sign(pos, true) - mcl_signs:color_sign(pos, mcl_colors.BLACK) - if success then - if DEBUG then - minetest.log("verbose", "[mcl_signs] Sign Glow removal Success.") - end + -- handle glow from glow_ink_sac *first* + if (iname == "mcl_mobitems:glow_ink_sac") then + clicker:set_wielded_item(item) + local success = mcl_signs:glow_sign(pos) + if success then + if DEBUG then + minetest.log("verbose", "[mcl_signs] Sign Glow Success.") + end + itemstack:take_item() + end + return + end - itemstack:take_item() - end - return - end + -- "mcl_dye:black" is a special case: it makes the sign's lettering black AND removes glow. + if (iname == "mcl_dye:black") then + clicker:set_wielded_item(item) + local success = mcl_signs:glow_sign(pos, true) + mcl_signs:color_sign(pos, mcl_colors.BLACK) + if success then + if DEBUG then + minetest.log("verbose", "[mcl_signs] Sign Glow removal Success.") + end - -- check the wielded item to make sure that it is a dye. - local txt_color = mcl_signs:get_color_for_sign(iname) - if txt_color ~= "false" then - clicker:set_wielded_item(item) - local success = mcl_signs:color_sign(pos, txt_color) - if success then - if DEBUG then - minetest.log("verbose", "[mcl_signs] Sign Color Success.") - end - itemstack:take_item() - end - end - end - end, + itemstack:take_item() + end + return + end - _mcl_hardness = 1, - _mcl_blast_resistance = 1, + -- check the wielded item to make sure that it is a dye. + local txt_color = mcl_signs:get_color_for_sign(iname) + if txt_color ~= "false" then + clicker:set_wielded_item(item) + local success = mcl_signs:color_sign(pos, txt_color) + if success then + if DEBUG then + minetest.log("verbose", "[mcl_signs] Sign Color Success.") + end + itemstack:take_item() + end + end + end + end, + + _mcl_hardness = 1, + _mcl_blast_resistance = 1, } -- standing sign base (definition) mcl_signs.standing_standard = { - paramtype = "light", - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, - sunlight_propagates = true, - walkable = false, - is_ground_content = false, - paramtype2 = "facedir", - drawtype = "mesh", - mesh = "mcl_signs_sign.obj", - selection_box = { type = "fixed", fixed = { -0.2, -0.5, -0.2, 0.2, 0.5, 0.2 } }, - tiles = { "mcl_signs_sign.png" }, - groups = mcl_signs.sign_groups, - drop = "mcl_signs:wall_sign", - stack_max = 16, - sounds = node_sounds, + paramtype = "light", + use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, + sunlight_propagates = true, + walkable = false, + is_ground_content = false, + paramtype2 = "facedir", + drawtype = "mesh", + mesh = "mcl_signs_sign.obj", + selection_box = { type = "fixed", fixed = { -0.2, -0.5, -0.2, 0.2, 0.5, 0.2 } }, + tiles = { "mcl_signs_sign.png" }, + groups = mcl_signs.sign_groups, + drop = "mcl_signs:wall_sign", + stack_max = 16, + sounds = node_sounds, - on_destruct = function(pos) - mcl_signs:destruct_sign(pos) - end, + on_destruct = function(pos) + mcl_signs:destruct_sign(pos) + end, - -- Not Useless Code. this force updates the sign. - on_punch = function(pos, node, puncher) - mcl_signs:update_sign(pos) - if DISINTEGRATE then - mcl_signs:destruct_sign(pos) - end - end, - on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign22_5" - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end, + on_timer = function(pos) + -- fix for /ClearObjects + mcl_signs:update_sign(pos) + minetest.get_node_timer(pos):start(40.0) + end, - on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + -- Not Useless Code. this force updates the sign. + on_punch = function(pos, node, puncher) + mcl_signs:update_sign(pos) + end, + on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign22_5" + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end, - if DEBUG then - minetest.log("verbose", "[mcl_signs] Standing_Sign Right Click event.") - end + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) - -- make sure player is clicking - if not clicker or not clicker:is_player() then - return - end + if DEBUG then + minetest.log("verbose", "[mcl_signs] Standing_Sign Right Click event.") + end - local item = clicker:get_wielded_item() - local iname = item:get_name() + -- make sure player is clicking + if not clicker or not clicker:is_player() then + return + end - if node then - -- handle glow from glow_ink_sac *first* - if DEBUG then - minetest.log("verbose", "[mcl_signs] Standing_Sign Right Click event on valid node.") - end + local item = clicker:get_wielded_item() + local iname = item:get_name() - if (iname == "mcl_mobitems:glow_ink_sac") then - clicker:set_wielded_item(item) - local success = mcl_signs:glow_sign(pos) - if success then - if DEBUG then - minetest.log("verbose", "[mcl_signs] Sign Glow Success.") - end - itemstack:take_item() - end - return - end + if node then + -- handle glow from glow_ink_sac *first* + if DEBUG then + minetest.log("verbose", "[mcl_signs] Standing_Sign Right Click event on valid node.") + end - -- check the wielded item to make sure that it is a dye. - local txt_color = mcl_signs:get_color_for_sign(iname) - if txt_color ~= "false" then - clicker:set_wielded_item(item) - local success = mcl_signs:color_sign(pos, txt_color) - if success then - if DEBUG then - minetest.log("verbose", "[mcl_signs] Sign Color Success.") - end - itemstack:take_item() - end - end - end - end, + if (iname == "mcl_mobitems:glow_ink_sac") then + clicker:set_wielded_item(item) + local success = mcl_signs:glow_sign(pos) + if success then + if DEBUG then + minetest.log("verbose", "[mcl_signs] Sign Glow Success.") + end + itemstack:take_item() + end + return + end - _mcl_hardness = 1, - _mcl_blast_resistance = 1, + -- check the wielded item to make sure that it is a dye. + local txt_color = mcl_signs:get_color_for_sign(iname) + if txt_color ~= "false" then + clicker:set_wielded_item(item) + local success = mcl_signs:color_sign(pos, txt_color) + if success then + if DEBUG then + minetest.log("verbose", "[mcl_signs] Sign Color Success.") + end + itemstack:take_item() + end + end + end + end, + + _mcl_hardness = 1, + _mcl_blast_resistance = 1, } -- HELPER FUNCTIONS' VARIABLES local sign_glow = 6 local Dyes_table = { - { "mcl_dye:aqua", mcl_colors_official.AQUA }, - { "mcl_dye:black", mcl_colors_official.BLACK }, - { "mcl_dye:blue", mcl_colors_official.BLUE }, - { "mcl_dye:brown", mcl_colors_official.brown }, - { "mcl_dye:cyan", mcl_signs.mcl_wool_colors.unicolor_cyan }, - { "mcl_dye:green", mcl_colors_official.GREEN }, - { "mcl_dye:dark_green", mcl_colors_official.DARK_GREEN }, - { "mcl_dye:grey", mcl_colors_official.GRAY }, - { "mcl_dye:dark_grey", mcl_colors_official.DARK_GRAY }, - { "mcl_dye:lightblue", mcl_signs.mcl_wool_colors.unicolor_light_blue }, - { "mcl_dye:lime", mcl_signs.unicolor_green_or_lime }, - { "mcl_dye:magenta", mcl_colors_official.LIGHT_PURPLE }, - { "mcl_dye:orange", mcl_signs.mcl_wool_colors.unicolor_orange }, - { "mcl_dye:pink", mcl_signs.mcl_wool_colors.unicolor_light_red_pink }, - { "mcl_dye:purple", mcl_colors_official.LIGHT_PURPLE }, - { "mcl_dye:red", mcl_signs.mcl_wool_colors.unicolor_red }, - { "mcl_dye:silver", mcl_signs.mcl_wool_colors.unicolor_grey }, - { "mcl_dye:violet", mcl_colors_official.DARK_PURPLE }, - { "mcl_dye:white", mcl_colors_official.WHITE }, - { "mcl_dye:yellow", mcl_colors_official.YELLOW }, + { "mcl_dye:aqua", mcl_colors_official.AQUA }, + { "mcl_dye:black", mcl_colors_official.BLACK }, + { "mcl_dye:blue", mcl_colors_official.BLUE }, + { "mcl_dye:brown", mcl_colors_official.brown }, + { "mcl_dye:cyan", mcl_signs.mcl_wool_colors.unicolor_cyan }, + { "mcl_dye:green", mcl_colors_official.GREEN }, + { "mcl_dye:dark_green", mcl_colors_official.DARK_GREEN }, + { "mcl_dye:grey", mcl_colors_official.GRAY }, + { "mcl_dye:dark_grey", mcl_colors_official.DARK_GRAY }, + { "mcl_dye:lightblue", mcl_signs.mcl_wool_colors.unicolor_light_blue }, + { "mcl_dye:lime", mcl_signs.unicolor_green_or_lime }, + { "mcl_dye:magenta", mcl_colors_official.LIGHT_PURPLE }, + { "mcl_dye:orange", mcl_signs.mcl_wool_colors.unicolor_orange }, + { "mcl_dye:pink", mcl_signs.mcl_wool_colors.unicolor_light_red_pink }, + { "mcl_dye:purple", mcl_colors_official.LIGHT_PURPLE }, + { "mcl_dye:red", mcl_signs.mcl_wool_colors.unicolor_red }, + { "mcl_dye:silver", mcl_signs.mcl_wool_colors.unicolor_grey }, + { "mcl_dye:violet", mcl_colors_official.DARK_PURPLE }, + { "mcl_dye:white", mcl_colors_official.WHITE }, + { "mcl_dye:yellow", mcl_colors_official.YELLOW }, } local function update_sign_registry(type, name) - if type == "wall" then - table.insert(mcl_signs.registered_signs.wall_signs, name) - end - if type == "standing" then - table.insert(mcl_signs.registered_signs.standing_signs, name) - end - if type == "hanging" then - table.insert(mcl_signs.registered_signs.hanging_signs, name) - end + if type == "wall" then + table.insert(mcl_signs.registered_signs.wall_signs, name) + end + if type == "standing" then + table.insert(mcl_signs.registered_signs.standing_signs, name) + end + if type == "hanging" then + table.insert(mcl_signs.registered_signs.hanging_signs, name) + end end function mcl_signs.make_lbm() - local registered_sign_nodenames = {} + local registered_sign_nodenames = {} - for i = 0, #mcl_signs.registered_signs.wall_signs do - table.insert(registered_sign_nodenames, mcl_signs.registered_signs.wall_signs[i]) - end + for i = 0, #mcl_signs.registered_signs.wall_signs do + table.insert(registered_sign_nodenames, mcl_signs.registered_signs.wall_signs[i]) + end - for i = 0, #mcl_signs.registered_signs.standing_signs do - table.insert(registered_sign_nodenames, mcl_signs.registered_signs.standing_signs[i]) - end + for i = 0, #mcl_signs.registered_signs.standing_signs do + table.insert(registered_sign_nodenames, mcl_signs.registered_signs.standing_signs[i]) + end - for i = 0, #mcl_signs.registered_signs.hanging_signs do - table.insert(registered_sign_nodenames, mcl_signs.registered_signs.hanging_signs[i]) - end + for i = 0, #mcl_signs.registered_signs.hanging_signs do + table.insert(registered_sign_nodenames, mcl_signs.registered_signs.hanging_signs[i]) + end - -- the above is not yet used. - minetest.register_lbm({ - name = "mcl_signs:respawn_entities", - label = "Respawn sign text entities", - run_at_every_load = true, - nodenames = registered_sign_nodenames , - action = function(pos, node) - mcl_signs:update_sign(pos) - end, - }) + -- the above is not yet used. + minetest.register_lbm({ + name = "mcl_signs:respawn_entities", + label = "Respawn sign text entities", + run_at_every_load = true, + nodenames = registered_sign_nodenames, + action = function(pos, node) + mcl_signs:update_sign(pos) + end, + }) end function mcl_signs.register_dye (modname, item_name, color_code) - if minetest.get_modpath(modname) then - table.insert(Dyes_table, { item_name, color_code }) - end + if minetest.get_modpath(modname) then + table.insert(Dyes_table, { item_name, color_code }) + end end --- Register a new sign, tint the textures, and gives it an unique node name. Creates both wall and standing signs. @@ -524,227 +534,232 @@ end --- ttsign: the tool tip of the sign that gets translated. Shown when the mouse hovers the inventory sign. --- For example: the basic, default oak (wood) sign is just "Sign"; and a spruce sign would be "Spruce Sign" function mcl_signs.register_sign (modname, color, _name, ttsign) - local mod_name_pass = false - if modname ~= "" and modname ~= "false" then - if minetest.get_modpath(modname) then - mod_name_pass = true - end - if mod_name_pass == false then - return - end - end - local new_sign = {} + local mod_name_pass = false + if modname ~= "" and modname ~= "false" then + if minetest.get_modpath(modname) then + mod_name_pass = true + end + if mod_name_pass == false then + return + end + end + local new_sign = {} - if color == nil or color == "" then - color = "#FFFFFF" - end + if color == nil or color == "" then + color = "#FFFFFF" + end - new_sign = table.copy(mcl_signs.wall_standard) - new_sign.description = S(ttsign) + new_sign = table.copy(mcl_signs.wall_standard) + new_sign.description = S(ttsign) - new_sign.wield_image = "(default_sign.png^[multiply:" .. color .. ")" - new_sign.tiles = { "(mcl_signs_sign.png^[multiply:" .. color .. ")" } - new_sign.inventory_image = "(default_sign.png^[multiply:" .. color .. ")" + new_sign.wield_image = "(default_sign.png^[multiply:" .. color .. ")" + new_sign.tiles = { "(mcl_signs_sign.png^[multiply:" .. color .. ")" } + new_sign.inventory_image = "(default_sign.png^[multiply:" .. color .. ")" - -- currently have to do this, because of how the base node placement works. - new_sign.on_place = function(itemstack, placer, pointed_thing) - local above = pointed_thing.above - local under = pointed_thing.under + -- currently have to do this, because of how the base node placement works. + new_sign.on_place = function(itemstack, placer, pointed_thing) + local above = pointed_thing.above + local under = pointed_thing.under - -- Use pointed node's on_rightclick function first, if present - local node_under = minetest.get_node(under) - if placer and not placer:get_player_control().sneak then - if minetest.registered_nodes[node_under.name] and minetest.registered_nodes[node_under.name].on_rightclick then - return minetest.registered_nodes[node_under.name].on_rightclick(under, node_under, placer, itemstack) or itemstack - end - end + -- Use pointed node's on_rightclick function first, if present + local node_under = minetest.get_node(under) + if placer and not placer:get_player_control().sneak then + if minetest.registered_nodes[node_under.name] and minetest.registered_nodes[node_under.name].on_rightclick then + return minetest.registered_nodes[node_under.name].on_rightclick(under, node_under, placer, itemstack) or itemstack + end + end - local dir = vector.subtract(under, above) + local dir = vector.subtract(under, above) - -- Only build when it's legal - local abovenodedef = minetest.registered_nodes[minetest.get_node(above).name] - if not abovenodedef or abovenodedef.buildable_to == false then - return itemstack - end + -- Only build when it's legal + local abovenodedef = minetest.registered_nodes[minetest.get_node(above).name] + if not abovenodedef or abovenodedef.buildable_to == false then + return itemstack + end - local wdir = minetest.dir_to_wallmounted(dir) - local fdir = minetest.dir_to_facedir(dir) + local wdir = minetest.dir_to_wallmounted(dir) + local fdir = minetest.dir_to_facedir(dir) - local sign_info - local nodeitem = ItemStack(itemstack) - -- Ceiling - if wdir == 0 then - --how would you add sign to ceiling? - return itemstack - -- Floor - elseif wdir == 1 then - -- Standing sign + local sign_info + local nodeitem = ItemStack(itemstack) - -- Determine the sign rotation based on player's yaw - local yaw = pi * 2 - placer:get_look_horizontal() + local yaw = 0 - -- Select one of 16 possible rotations (0-15) - local rotation_level = mcl_signs:round((yaw / (pi * 2)) * 16) + -- Ceiling + if wdir == 0 then + --how would you add sign to ceiling? simple - hanging sign. + -- add code for placement underneath a node. - if rotation_level > 15 then - rotation_level = 0 - elseif rotation_level < 0 then - rotation_level = 15 - end + return itemstack + -- Floor + elseif wdir == 1 then + -- Standing sign - -- The actual rotation is a combination of predefined mesh and facedir (see node definition) - if rotation_level % 4 == 0 then - nodeitem:set_name("mcl_signs:standing_sign" .. _name) - elseif rotation_level % 4 == 1 then - nodeitem:set_name("mcl_signs:standing_sign22_5" .. _name) - elseif rotation_level % 4 == 2 then - nodeitem:set_name("mcl_signs:standing_sign45" .. _name) - elseif rotation_level % 4 == 3 then - nodeitem:set_name("mcl_signs:standing_sign67_5" .. _name) - end - fdir = math.floor(rotation_level / 4) + -- Determine the sign rotation based on player's yaw + yaw = pi * 2 - placer:get_look_horizontal() - -- Place the node! - local _, success = minetest.item_place_node(nodeitem, placer, pointed_thing, fdir) - if not success then - return itemstack - end - if not minetest.is_creative_enabled(placer:get_player_name()) then - itemstack:take_item() - end - sign_info = mcl_signs.signtext_info_standing[rotation_level + 1] - -- Side - else - -- Wall sign - local _, success = minetest.item_place_node(itemstack, placer, pointed_thing, wdir) - if not success then - return itemstack - end - sign_info = mcl_signs.signtext_info_wall[fdir + 1] - end + -- Select one of 16 possible rotations (0-15) + local rotation_level = mcl_signs:round((yaw / (pi * 2)) * 16) - -- Determine spawn position of entity - local place_pos - if minetest.registered_nodes[node_under.name].buildable_to then - place_pos = under - else - place_pos = above - end + if rotation_level > 15 then + rotation_level = 0 + elseif rotation_level < 0 then + rotation_level = 15 + end - if DEBUG then - minetest.log("action", "[mcl_signs] Register_Sign::Placed position:" .. dump(place_pos) .. "\nSign_info: " .. dump(sign_info)) - end + -- The actual rotation is a combination of predefined mesh and facedir (see node definition) + if rotation_level % 4 == 0 then + nodeitem:set_name("mcl_signs:standing_sign" .. _name) + elseif rotation_level % 4 == 1 then + nodeitem:set_name("mcl_signs:standing_sign22_5" .. _name) + elseif rotation_level % 4 == 2 then + nodeitem:set_name("mcl_signs:standing_sign45" .. _name) + elseif rotation_level % 4 == 3 then + nodeitem:set_name("mcl_signs:standing_sign67_5" .. _name) + end + fdir = math.floor(rotation_level / 4) - local text_entity = minetest.add_entity({ - x = place_pos.x + sign_info.delta.x, - y = place_pos.y + sign_info.delta.y, - z = place_pos.z + sign_info.delta.z }, "mcl_signs:text") - text_entity:set_yaw(sign_info.yaw) - text_entity:get_luaentity()._signnodename = nodeitem:get_name() + -- Place the node! + local _, success = minetest.item_place_node(nodeitem, placer, pointed_thing, fdir) + if not success then + return itemstack + end + if not minetest.is_creative_enabled(placer:get_player_name()) then + itemstack:take_item() + end + sign_info = mcl_signs.signtext_info_standing[rotation_level + 1] + -- Side + else + -- Wall sign + local _, success = minetest.item_place_node(itemstack, placer, pointed_thing, wdir) + if not success then + return itemstack + end + sign_info = mcl_signs.signtext_info_wall[fdir + 1] + end - minetest.sound_play({ name = "default_place_node_hard", gain = 1.0 }, { pos = place_pos }, true) + -- Determine spawn position of entity + local place_pos + if minetest.registered_nodes[node_under.name].buildable_to then + place_pos = under + else + place_pos = above + end - mcl_signs:show_formspec(placer, place_pos) - return itemstack - end + if DEBUG then + minetest.log("action", "[mcl_signs] Register_Sign::Placed position:" .. dump(place_pos) .. "\nSign_info: " .. dump(sign_info)) + end - minetest.register_node("mcl_signs:wall_sign" .. _name, new_sign) - update_sign_registry("wall", "mcl_signs:wall_sign" .. _name) + local text_entity = minetest.add_entity({ + x = place_pos.x + sign_info.delta.x, + y = place_pos.y + sign_info.delta.y, + z = place_pos.z + sign_info.delta.z }, "mcl_signs:text") + text_entity:set_yaw(sign_info.yaw) + text_entity:get_luaentity()._signnodename = nodeitem:get_name() - -- debug step - if DEBUG then - minetest.log("action", "[mcl_signs] Registered: mcl_signs:wall_sign" .. _name .. color .. "\n" .. dump(new_sign)) - minetest.log("action", "[mcl_signs] mcl_signs:wall_sign_standard\n" .. dump(mcl_signs.wall_standard)) - end + minetest.sound_play({ name = "default_place_node_hard", gain = 1.0 }, { pos = place_pos }, true) - -- standing sign base. - local new_sign_standing = {} - new_sign_standing = table.copy(mcl_signs.standing_standard) - new_sign_standing.drop = "mcl_signs:wall_sign" .. _name - new_sign_standing.wield_image = "(default_sign.png^[multiply:" .. color .. ")" - new_sign_standing.tiles = { "(mcl_signs_sign.png^[multiply:" .. color .. ")" } - new_sign_standing.inventory_image = "(default_sign.png^[multiply:" .. color .. ")" + mcl_signs:show_formspec(placer, place_pos) + return itemstack + end - new_sign_standing.on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign22_5" .. _name - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end, + minetest.register_node(":mcl_signs:wall_sign" .. _name, new_sign) + update_sign_registry("wall", "mcl_signs:wall_sign" .. _name) - minetest.register_node("mcl_signs:standing_sign" .. _name, new_sign_standing) - update_sign_registry("standing", "mcl_signs:standing_sign" .. _name) - -- debug step - if DEBUG then - minetest.log("action", "[mcl_signs] Registered: mcl_signs:standing_sign" .. _name .. color .. "\n" .. dump(new_sign_standing)) - end + -- debug step + if DEBUG then + minetest.log("action", "[mcl_signs] Registered: mcl_signs:wall_sign" .. _name .. color .. "\n" .. dump(new_sign)) + minetest.log("action", "[mcl_signs] mcl_signs:wall_sign_standard\n" .. dump(mcl_signs.wall_standard)) + end - -- 22.5° - local ssign22_5d = table.copy(new_sign_standing) - ssign22_5d.mesh = "mcl_signs_sign22.5.obj" - ssign22_5d.on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign45" .. _name - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end - minetest.register_node("mcl_signs:standing_sign22_5" .. _name, ssign22_5d) - update_sign_registry("standing", "mcl_signs:standing_sign22_5" .. _name) + -- standing sign base. + local new_sign_standing = {} + new_sign_standing = table.copy(mcl_signs.standing_standard) + new_sign_standing.drop = "mcl_signs:wall_sign" .. _name + new_sign_standing.wield_image = "(default_sign.png^[multiply:" .. color .. ")" + new_sign_standing.tiles = { "(mcl_signs_sign.png^[multiply:" .. color .. ")" } + new_sign_standing.inventory_image = "(default_sign.png^[multiply:" .. color .. ")" - -- 45° - local ssign45d = table.copy(new_sign_standing) - ssign45d.mesh = "mcl_signs_sign45.obj" - ssign45d.on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign67_5" .. _name - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end - minetest.register_node("mcl_signs:standing_sign45" .. _name, ssign45d) - update_sign_registry("standing", "mcl_signs:standing_sign45" .. _name) + new_sign_standing.on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign22_5" .. _name + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end, - -- 67.5° - local ssign67_5d = table.copy(new_sign_standing) - ssign67_5d.mesh = "mcl_signs_sign67.5.obj" - ssign67_5d.on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign" .. _name - node.param2 = (node.param2 + 1) % 4 - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end - minetest.register_node("mcl_signs:standing_sign67_5" .. _name, ssign67_5d) - update_sign_registry("standing", "mcl_signs:standing_sign67_5" .. _name) + minetest.register_node(":mcl_signs:standing_sign" .. _name, new_sign_standing) + update_sign_registry("standing", "mcl_signs:standing_sign" .. _name) + -- debug step + if DEBUG then + minetest.log("action", "[mcl_signs] Registered: mcl_signs:standing_sign" .. _name .. color .. "\n" .. dump(new_sign_standing)) + end - -- register Doc entry - if minetest.get_modpath("doc") then - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:wall_sign" .. _name) - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign" .. _name) - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign22_5" .. _name) - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign45" .. _name) - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign67_5" .. _name) - end + -- 22.5° + local ssign22_5d = table.copy(new_sign_standing) + ssign22_5d.mesh = "mcl_signs_sign22.5.obj" + ssign22_5d.on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign45" .. _name + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end + minetest.register_node(":mcl_signs:standing_sign22_5" .. _name, ssign22_5d) + update_sign_registry("standing", "mcl_signs:standing_sign22_5" .. _name) - --register standing sign's rotation_levels - table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign22_5" .. _name , 1}) - table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign45" .. _name , 2}) - table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign67_5" .. _name , 3}) + -- 45° + local ssign45d = table.copy(new_sign_standing) + ssign45d.mesh = "mcl_signs_sign45.obj" + ssign45d.on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign67_5" .. _name + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end + minetest.register_node(":mcl_signs:standing_sign45" .. _name, ssign45d) + update_sign_registry("standing", "mcl_signs:standing_sign45" .. _name) + + -- 67.5° + local ssign67_5d = table.copy(new_sign_standing) + ssign67_5d.mesh = "mcl_signs_sign67.5.obj" + ssign67_5d.on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign" .. _name + node.param2 = (node.param2 + 1) % 4 + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end + minetest.register_node(":mcl_signs:standing_sign67_5" .. _name, ssign67_5d) + update_sign_registry("standing", "mcl_signs:standing_sign67_5" .. _name) + + -- register Doc entry + if minetest.get_modpath("doc") then + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:wall_sign" .. _name) + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign" .. _name) + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign22_5" .. _name) + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign45" .. _name) + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign67_5" .. _name) + end + + --register standing sign's rotation_levels + table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign22_5" .. _name, 1 }) + table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign45" .. _name, 2 }) + table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign67_5" .. _name, 3 }) end --- The same as register_sign, except caller defines the textures. Note, there is a greyscale version of the sign, @@ -769,205 +784,205 @@ end --- ttsign: the tool tip of the sign that gets translated. Shown when the mouse hovers the inventory sign. --- For example: the basic, default oak (wood) sign is just "Sign"; and a spruce sign would be "Spruce Sign" function mcl_signs.register_sign_custom (modname, _name, tiles, color, inventory_image, wield_image, ttsign) - local mod_name_pass = false - if modname ~= "" and modname ~= "false" then - if minetest.get_modpath(modname) then - mod_name_pass = true - end - if mod_name_pass == false then - return - end - end - local new_sign = {} + local mod_name_pass = false + if modname ~= "" and modname ~= "false" then + if minetest.get_modpath(modname) then + mod_name_pass = true + end + if mod_name_pass == false then + return + end + end + local new_sign = {} - new_sign = table.copy(mcl_signs.wall_standard) + new_sign = table.copy(mcl_signs.wall_standard) - new_sign.wield_image ="("..wield_image.."^[multiply:" .. color .. ")" - new_sign.tiles = { "("..tiles.."^[multiply:" .. color .. ")" } - new_sign.inventory_image = "("..inventory_image.."^[multiply:" .. color .. ")" - new_sign.description = S(ttsign) - -- currently have to do this, because of how the base node placement works. - new_sign.on_place = function(itemstack, placer, pointed_thing) - local above = pointed_thing.above - local under = pointed_thing.under + new_sign.wield_image = "(" .. wield_image .. "^[multiply:" .. color .. ")" + new_sign.tiles = { "(" .. tiles .. "^[multiply:" .. color .. ")" } + new_sign.inventory_image = "(" .. inventory_image .. "^[multiply:" .. color .. ")" + new_sign.description = S(ttsign) + -- currently have to do this, because of how the base node placement works. + new_sign.on_place = function(itemstack, placer, pointed_thing) + local above = pointed_thing.above + local under = pointed_thing.under - -- Use pointed node's on_rightclick function first, if present - local node_under = minetest.get_node(under) - if placer and not placer:get_player_control().sneak then - if minetest.registered_nodes[node_under.name] and minetest.registered_nodes[node_under.name].on_rightclick then - return minetest.registered_nodes[node_under.name].on_rightclick(under, node_under, placer, itemstack) or itemstack - end - end + -- Use pointed node's on_rightclick function first, if present + local node_under = minetest.get_node(under) + if placer and not placer:get_player_control().sneak then + if minetest.registered_nodes[node_under.name] and minetest.registered_nodes[node_under.name].on_rightclick then + return minetest.registered_nodes[node_under.name].on_rightclick(under, node_under, placer, itemstack) or itemstack + end + end - local dir = vector.subtract(under, above) + local dir = vector.subtract(under, above) - -- Only build when it's legal - local abovenodedef = minetest.registered_nodes[minetest.get_node(above).name] - if not abovenodedef or abovenodedef.buildable_to == false then - return itemstack - end + -- Only build when it's legal + local abovenodedef = minetest.registered_nodes[minetest.get_node(above).name] + if not abovenodedef or abovenodedef.buildable_to == false then + return itemstack + end - local wdir = minetest.dir_to_wallmounted(dir) - local fdir = minetest.dir_to_facedir(dir) + local wdir = minetest.dir_to_wallmounted(dir) + local fdir = minetest.dir_to_facedir(dir) - local sign_info - local nodeitem = ItemStack(itemstack) - -- Ceiling - if wdir == 0 then - --how would you add sign to ceiling? - return itemstack - -- Floor - elseif wdir == 1 then - -- Standing sign + local sign_info + local nodeitem = ItemStack(itemstack) + -- Ceiling + if wdir == 0 then + --how would you add sign to ceiling? + return itemstack + -- Floor + elseif wdir == 1 then + -- Standing sign - -- Determine the sign rotation based on player's yaw - local yaw = pi * 2 - placer:get_look_horizontal() + -- Determine the sign rotation based on player's yaw + local yaw = pi * 2 - placer:get_look_horizontal() - -- Select one of 16 possible rotations (0-15) - local rotation_level = mcl_signs:round((yaw / (pi * 2)) * 16) + -- Select one of 16 possible rotations (0-15) + local rotation_level = mcl_signs:round((yaw / (pi * 2)) * 16) - if rotation_level > 15 then - rotation_level = 0 - elseif rotation_level < 0 then - rotation_level = 15 - end + if rotation_level > 15 then + rotation_level = 0 + elseif rotation_level < 0 then + rotation_level = 15 + end - -- The actual rotation is a combination of predefined mesh and facedir (see node definition) - if rotation_level % 4 == 0 then - nodeitem:set_name("mcl_signs:standing_sign" .. _name) - elseif rotation_level % 4 == 1 then - nodeitem:set_name("mcl_signs:standing_sign22_5" .. _name) - elseif rotation_level % 4 == 2 then - nodeitem:set_name("mcl_signs:standing_sign45" .. _name) - elseif rotation_level % 4 == 3 then - nodeitem:set_name("mcl_signs:standing_sign67_5" .. _name) - end - fdir = math.floor(rotation_level / 4) + -- The actual rotation is a combination of predefined mesh and facedir (see node definition) + if rotation_level % 4 == 0 then + nodeitem:set_name("mcl_signs:standing_sign" .. _name) + elseif rotation_level % 4 == 1 then + nodeitem:set_name("mcl_signs:standing_sign22_5" .. _name) + elseif rotation_level % 4 == 2 then + nodeitem:set_name("mcl_signs:standing_sign45" .. _name) + elseif rotation_level % 4 == 3 then + nodeitem:set_name("mcl_signs:standing_sign67_5" .. _name) + end + fdir = math.floor(rotation_level / 4) - -- Place the node! - local _, success = minetest.item_place_node(nodeitem, placer, pointed_thing, fdir) - if not success then - return itemstack - end - if not minetest.is_creative_enabled(placer:get_player_name()) then - itemstack:take_item() - end - sign_info = mcl_signs.signtext_info_standing[rotation_level + 1] - -- Side - else - -- Wall sign - local _, success = minetest.item_place_node(itemstack, placer, pointed_thing, wdir) - if not success then - return itemstack - end - sign_info = mcl_signs.signtext_info_wall[fdir + 1] - end + -- Place the node! + local _, success = minetest.item_place_node(nodeitem, placer, pointed_thing, fdir) + if not success then + return itemstack + end + if not minetest.is_creative_enabled(placer:get_player_name()) then + itemstack:take_item() + end + sign_info = mcl_signs.signtext_info_standing[rotation_level + 1] + -- Side + else + -- Wall sign + local _, success = minetest.item_place_node(itemstack, placer, pointed_thing, wdir) + if not success then + return itemstack + end + sign_info = mcl_signs.signtext_info_wall[fdir + 1] + end - -- Determine spawn position of entity - local place_pos - if minetest.registered_nodes[node_under.name].buildable_to then - place_pos = under - else - place_pos = above - end + -- Determine spawn position of entity + local place_pos + if minetest.registered_nodes[node_under.name].buildable_to then + place_pos = under + else + place_pos = above + end - local text_entity = minetest.add_entity({ - x = place_pos.x + sign_info.delta.x, - y = place_pos.y + sign_info.delta.y, - z = place_pos.z + sign_info.delta.z }, "mcl_signs:text") - text_entity:set_yaw(sign_info.yaw) - text_entity:get_luaentity()._signnodename = nodeitem:get_name() + local text_entity = minetest.add_entity({ + x = place_pos.x + sign_info.delta.x, + y = place_pos.y + sign_info.delta.y, + z = place_pos.z + sign_info.delta.z }, "mcl_signs:text") + text_entity:set_yaw(sign_info.yaw) + text_entity:get_luaentity()._signnodename = nodeitem:get_name() - minetest.sound_play({ name = "default_place_node_hard", gain = 1.0 }, { pos = place_pos }, true) + minetest.sound_play({ name = "default_place_node_hard", gain = 1.0 }, { pos = place_pos }, true) - mcl_signs:show_formspec(placer, place_pos) - return itemstack - end - minetest.register_node("mcl_signs:wall_sign" .. _name, new_sign) - update_sign_registry("wall", "mcl_signs:wall_sign" .. _name) + mcl_signs:show_formspec(placer, place_pos) + return itemstack + end + minetest.register_node(":mcl_signs:wall_sign" .. _name, new_sign) + update_sign_registry("wall", "mcl_signs:wall_sign" .. _name) - -- standing sign base. - local new_sign_standing = {} - new_sign_standing = table.copy(mcl_signs.standing_standard) - new_sign_standing.drop = "mcl_signs:wall_sign" .. _name - new_sign_standing.wield_image ="("..wield_image.."^[multiply:" .. color .. ")" - new_sign_standing.tiles = { "("..tiles.."^[multiply:" .. color .. ")" } - new_sign_standing.inventory_image = "("..inventory_image.."^[multiply:" .. color .. ")" - new_sign_standing.on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign22_5" .. _name - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end, - minetest.register_node("mcl_signs:standing_sign" .. _name, new_sign_standing) - update_sign_registry("standing", "mcl_signs:standing_sign" .. _name) + -- standing sign base. + local new_sign_standing = {} + new_sign_standing = table.copy(mcl_signs.standing_standard) + new_sign_standing.drop = "mcl_signs:wall_sign" .. _name + new_sign_standing.wield_image = "(" .. wield_image .. "^[multiply:" .. color .. ")" + new_sign_standing.tiles = { "(" .. tiles .. "^[multiply:" .. color .. ")" } + new_sign_standing.inventory_image = "(" .. inventory_image .. "^[multiply:" .. color .. ")" + new_sign_standing.on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign22_5" .. _name + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end, + minetest.register_node(":mcl_signs:standing_sign" .. _name, new_sign_standing) + update_sign_registry("standing", "mcl_signs:standing_sign" .. _name) - -- 22.5° - local ssign22_5d = table.copy(new_sign_standing) - ssign22_5d.mesh = "mcl_signs_sign22.5.obj" - ssign22_5d.on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign45" .. _name - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end - minetest.register_node("mcl_signs:standing_sign22_5" .. _name, ssign22_5d) - update_sign_registry("standing", "mcl_signs:standing_sign22_5" .. _name) + -- 22.5° + local ssign22_5d = table.copy(new_sign_standing) + ssign22_5d.mesh = "mcl_signs_sign22.5.obj" + ssign22_5d.on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign45" .. _name + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end + minetest.register_node(":mcl_signs:standing_sign22_5" .. _name, ssign22_5d) + update_sign_registry("standing", "mcl_signs:standing_sign22_5" .. _name) - -- 45° - local ssign45d = table.copy(new_sign_standing) - ssign45d.mesh = "mcl_signs_sign45.obj" - ssign45d.on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign67_5" .. _name - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end - minetest.register_node("mcl_signs:standing_sign45" .. _name, ssign45d) - update_sign_registry("standing", "mcl_signs:standing_sign45" .. _name) + -- 45° + local ssign45d = table.copy(new_sign_standing) + ssign45d.mesh = "mcl_signs_sign45.obj" + ssign45d.on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign67_5" .. _name + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end + minetest.register_node(":mcl_signs:standing_sign45" .. _name, ssign45d) + update_sign_registry("standing", "mcl_signs:standing_sign45" .. _name) - -- 67.5° - local ssign67_5d = table.copy(new_sign_standing) - ssign67_5d.mesh = "mcl_signs_sign67.5.obj" - ssign67_5d.on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign" .. _name - node.param2 = (node.param2 + 1) % 4 - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end - minetest.register_node("mcl_signs:standing_sign67_5" .. _name, ssign67_5d) - update_sign_registry("standing", "mcl_signs:standing_sign67_5" .. _name) + -- 67.5° + local ssign67_5d = table.copy(new_sign_standing) + ssign67_5d.mesh = "mcl_signs_sign67.5.obj" + ssign67_5d.on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign" .. _name + node.param2 = (node.param2 + 1) % 4 + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end + minetest.register_node(":mcl_signs:standing_sign67_5" .. _name, ssign67_5d) + update_sign_registry("standing", "mcl_signs:standing_sign67_5" .. _name) - -- register Doc entry - if minetest.get_modpath("doc") then - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:wall_sign" .. _name) - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign" .. _name) - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign22_5" .. _name) - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign45" .. _name) - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign67_5" .. _name) - end + -- register Doc entry + if minetest.get_modpath("doc") then + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:wall_sign" .. _name) + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign" .. _name) + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign22_5" .. _name) + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign45" .. _name) + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign67_5" .. _name) + end - --register standing sign's rotation_levels - table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign22_5" .. _name , 1}) - table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign45" .. _name , 2}) - table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign67_5" .. _name , 3}) + --register standing sign's rotation_levels + table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign22_5" .. _name, 1 }) + table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign45" .. _name, 2 }) + table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign67_5" .. _name, 3 }) end @@ -982,225 +997,225 @@ end --- ttsign: the tool tip of the sign that gets translated. Shown when the mouse hovers the inventory sign. --- For example: the basic, default oak (wood) sign is just "Sign"; and a spruce sign would be "Spruce Sign" function mcl_signs.reregister_sign (modname, color, _name, ttsign) - local mod_name_pass = false - if modname ~= "" and modname ~= "false" then - if minetest.get_modpath(modname) then - mod_name_pass = true - end - if mod_name_pass == false then - return - end - end - local new_sign = {} + local mod_name_pass = false + if modname ~= "" and modname ~= "false" then + if minetest.get_modpath(modname) then + mod_name_pass = true + end + if mod_name_pass == false then + return + end + end + local new_sign = {} - if color == nil or color == "" then - color = "#FFFFFF" - end + if color == nil or color == "" then + color = "#FFFFFF" + end - new_sign = table.copy(mcl_signs.wall_standard) - new_sign.description = S(ttsign) + new_sign = table.copy(mcl_signs.wall_standard) + new_sign.description = S(ttsign) - new_sign.wield_image = "(default_sign.png^[multiply:" .. color .. ")" - new_sign.tiles = { "(mcl_signs_sign.png^[multiply:" .. color .. ")" } - new_sign.inventory_image = "(default_sign.png^[multiply:" .. color .. ")" + new_sign.wield_image = "(default_sign.png^[multiply:" .. color .. ")" + new_sign.tiles = { "(mcl_signs_sign.png^[multiply:" .. color .. ")" } + new_sign.inventory_image = "(default_sign.png^[multiply:" .. color .. ")" - -- currently have to do this, because of how the base node placement works. - new_sign.on_place = function(itemstack, placer, pointed_thing) - local above = pointed_thing.above - local under = pointed_thing.under + -- currently have to do this, because of how the base node placement works. + new_sign.on_place = function(itemstack, placer, pointed_thing) + local above = pointed_thing.above + local under = pointed_thing.under - -- Use pointed node's on_rightclick function first, if present - local node_under = minetest.get_node(under) - if placer and not placer:get_player_control().sneak then - if minetest.registered_nodes[node_under.name] and minetest.registered_nodes[node_under.name].on_rightclick then - return minetest.registered_nodes[node_under.name].on_rightclick(under, node_under, placer, itemstack) or itemstack - end - end + -- Use pointed node's on_rightclick function first, if present + local node_under = minetest.get_node(under) + if placer and not placer:get_player_control().sneak then + if minetest.registered_nodes[node_under.name] and minetest.registered_nodes[node_under.name].on_rightclick then + return minetest.registered_nodes[node_under.name].on_rightclick(under, node_under, placer, itemstack) or itemstack + end + end - local dir = vector.subtract(under, above) + local dir = vector.subtract(under, above) - -- Only build when it's legal - local abovenodedef = minetest.registered_nodes[minetest.get_node(above).name] - if not abovenodedef or abovenodedef.buildable_to == false then - return itemstack - end + -- Only build when it's legal + local abovenodedef = minetest.registered_nodes[minetest.get_node(above).name] + if not abovenodedef or abovenodedef.buildable_to == false then + return itemstack + end - local wdir = minetest.dir_to_wallmounted(dir) - local fdir = minetest.dir_to_facedir(dir) + local wdir = minetest.dir_to_wallmounted(dir) + local fdir = minetest.dir_to_facedir(dir) - local sign_info - local nodeitem = ItemStack(itemstack) - -- Ceiling - if wdir == 0 then - --how would you add sign to ceiling? - return itemstack - -- Floor - elseif wdir == 1 then - -- Standing sign + local sign_info + local nodeitem = ItemStack(itemstack) + -- Ceiling + if wdir == 0 then + --how would you add sign to ceiling? + return itemstack + -- Floor + elseif wdir == 1 then + -- Standing sign - -- Determine the sign rotation based on player's yaw - local yaw = pi * 2 - placer:get_look_horizontal() + -- Determine the sign rotation based on player's yaw + local yaw = pi * 2 - placer:get_look_horizontal() - -- Select one of 16 possible rotations (0-15) - local rotation_level = mcl_signs:round((yaw / (pi * 2)) * 16) + -- Select one of 16 possible rotations (0-15) + local rotation_level = mcl_signs:round((yaw / (pi * 2)) * 16) - if rotation_level > 15 then - rotation_level = 0 - elseif rotation_level < 0 then - rotation_level = 15 - end + if rotation_level > 15 then + rotation_level = 0 + elseif rotation_level < 0 then + rotation_level = 15 + end - -- The actual rotation is a combination of predefined mesh and facedir (see node definition) - if rotation_level % 4 == 0 then - nodeitem:set_name("mcl_signs:standing_sign" .. _name) - elseif rotation_level % 4 == 1 then - nodeitem:set_name("mcl_signs:standing_sign22_5" .. _name) - elseif rotation_level % 4 == 2 then - nodeitem:set_name("mcl_signs:standing_sign45" .. _name) - elseif rotation_level % 4 == 3 then - nodeitem:set_name("mcl_signs:standing_sign67_5" .. _name) - end - fdir = math.floor(rotation_level / 4) + -- The actual rotation is a combination of predefined mesh and facedir (see node definition) + if rotation_level % 4 == 0 then + nodeitem:set_name("mcl_signs:standing_sign" .. _name) + elseif rotation_level % 4 == 1 then + nodeitem:set_name("mcl_signs:standing_sign22_5" .. _name) + elseif rotation_level % 4 == 2 then + nodeitem:set_name("mcl_signs:standing_sign45" .. _name) + elseif rotation_level % 4 == 3 then + nodeitem:set_name("mcl_signs:standing_sign67_5" .. _name) + end + fdir = math.floor(rotation_level / 4) - -- Place the node! - local _, success = minetest.item_place_node(nodeitem, placer, pointed_thing, fdir) - if not success then - return itemstack - end - if not minetest.is_creative_enabled(placer:get_player_name()) then - itemstack:take_item() - end - sign_info = mcl_signs.signtext_info_standing[rotation_level + 1] - -- Side - else - -- Wall sign - local _, success = minetest.item_place_node(itemstack, placer, pointed_thing, wdir) - if not success then - return itemstack - end - sign_info = mcl_signs.signtext_info_wall[fdir + 1] - end + -- Place the node! + local _, success = minetest.item_place_node(nodeitem, placer, pointed_thing, fdir) + if not success then + return itemstack + end + if not minetest.is_creative_enabled(placer:get_player_name()) then + itemstack:take_item() + end + sign_info = mcl_signs.signtext_info_standing[rotation_level + 1] + -- Side + else + -- Wall sign + local _, success = minetest.item_place_node(itemstack, placer, pointed_thing, wdir) + if not success then + return itemstack + end + sign_info = mcl_signs.signtext_info_wall[fdir + 1] + end - -- Determine spawn position of entity - local place_pos - if minetest.registered_nodes[node_under.name].buildable_to then - place_pos = under - else - place_pos = above - end + -- Determine spawn position of entity + local place_pos + if minetest.registered_nodes[node_under.name].buildable_to then + place_pos = under + else + place_pos = above + end - if DEBUG then - minetest.log("action", "[mcl_signs] Register_Sign::Placed position:" .. dump(place_pos) .. "\nSign_info: " .. dump(sign_info)) - end + if DEBUG then + minetest.log("action", "[mcl_signs] Register_Sign::Placed position:" .. dump(place_pos) .. "\nSign_info: " .. dump(sign_info)) + end - local text_entity = minetest.add_entity({ - x = place_pos.x + sign_info.delta.x, - y = place_pos.y + sign_info.delta.y, - z = place_pos.z + sign_info.delta.z }, "mcl_signs:text") - text_entity:set_yaw(sign_info.yaw) - text_entity:get_luaentity()._signnodename = nodeitem:get_name() + local text_entity = minetest.add_entity({ + x = place_pos.x + sign_info.delta.x, + y = place_pos.y + sign_info.delta.y, + z = place_pos.z + sign_info.delta.z }, "mcl_signs:text") + text_entity:set_yaw(sign_info.yaw) + text_entity:get_luaentity()._signnodename = nodeitem:get_name() - minetest.sound_play({ name = "default_place_node_hard", gain = 1.0 }, { pos = place_pos }, true) + minetest.sound_play({ name = "default_place_node_hard", gain = 1.0 }, { pos = place_pos }, true) - mcl_signs:show_formspec(placer, place_pos) - return itemstack - end + mcl_signs:show_formspec(placer, place_pos) + return itemstack + end - minetest.override_item("mcl_signs:wall_sign" .. _name, new_sign) - update_sign_registry("wall", "mcl_signs:wall_sign" .. _name) + minetest.override_item("mcl_signs:wall_sign" .. _name, new_sign) + update_sign_registry("wall", "mcl_signs:wall_sign" .. _name) - -- debug step - if DEBUG then - minetest.log("action", "[mcl_signs] Registered: mcl_signs:wall_sign" .. _name .. color .. "\n" .. dump(new_sign)) - minetest.log("action", "[mcl_signs] mcl_signs:wall_sign_standard\n" .. dump(mcl_signs.wall_standard)) - end + -- debug step + if DEBUG then + minetest.log("action", "[mcl_signs] Registered: mcl_signs:wall_sign" .. _name .. color .. "\n" .. dump(new_sign)) + minetest.log("action", "[mcl_signs] mcl_signs:wall_sign_standard\n" .. dump(mcl_signs.wall_standard)) + end - -- standing sign base. - local new_sign_standing = {} - new_sign_standing = table.copy(mcl_signs.standing_standard) - new_sign_standing.drop = "mcl_signs:wall_sign" .. _name - new_sign_standing.wield_image = "(default_sign.png^[multiply:" .. color .. ")" - new_sign_standing.tiles = { "(mcl_signs_sign.png^[multiply:" .. color .. ")" } - new_sign_standing.inventory_image = "(default_sign.png^[multiply:" .. color .. ")" - new_sign_standing.on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign22_5" .. _name - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end, - minetest.override_item("mcl_signs:standing_sign" .. _name, new_sign_standing) - update_sign_registry("standing", "mcl_signs:standing_sign" .. _name) - -- debug step - if DEBUG then - minetest.log("action", "[mcl_signs] Registered: mcl_signs:standing_sign" .. _name .. color .. "\n" .. dump(new_sign_standing)) - end + -- standing sign base. + local new_sign_standing = {} + new_sign_standing = table.copy(mcl_signs.standing_standard) + new_sign_standing.drop = "mcl_signs:wall_sign" .. _name + new_sign_standing.wield_image = "(default_sign.png^[multiply:" .. color .. ")" + new_sign_standing.tiles = { "(mcl_signs_sign.png^[multiply:" .. color .. ")" } + new_sign_standing.inventory_image = "(default_sign.png^[multiply:" .. color .. ")" + new_sign_standing.on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign22_5" .. _name + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end, + minetest.override_item("mcl_signs:standing_sign" .. _name, new_sign_standing) + update_sign_registry("standing", "mcl_signs:standing_sign" .. _name) + -- debug step + if DEBUG then + minetest.log("action", "[mcl_signs] Registered: mcl_signs:standing_sign" .. _name .. color .. "\n" .. dump(new_sign_standing)) + end - -- 22.5° - local ssign22_5d = table.copy(new_sign_standing) - ssign22_5d.mesh = "mcl_signs_sign22.5.obj" - ssign22_5d.on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign45" .. _name - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end - minetest.override_item("mcl_signs:standing_sign22_5" .. _name, ssign22_5d) - update_sign_registry("standing", "mcl_signs:standing_sign22_5" .. _name) + -- 22.5° + local ssign22_5d = table.copy(new_sign_standing) + ssign22_5d.mesh = "mcl_signs_sign22.5.obj" + ssign22_5d.on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign45" .. _name + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end + minetest.override_item("mcl_signs:standing_sign22_5" .. _name, ssign22_5d) + update_sign_registry("standing", "mcl_signs:standing_sign22_5" .. _name) - -- 45° - local ssign45d = table.copy(new_sign_standing) - ssign45d.mesh = "mcl_signs_sign45.obj" - ssign45d.on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign67_5" .. _name - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end - minetest.override_item("mcl_signs:standing_sign45" .. _name, ssign45d) - update_sign_registry("standing", "mcl_signs:standing_sign45" .. _name) + -- 45° + local ssign45d = table.copy(new_sign_standing) + ssign45d.mesh = "mcl_signs_sign45.obj" + ssign45d.on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign67_5" .. _name + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end + minetest.override_item("mcl_signs:standing_sign45" .. _name, ssign45d) + update_sign_registry("standing", "mcl_signs:standing_sign45" .. _name) - -- 67.5° - local ssign67_5d = table.copy(new_sign_standing) - ssign67_5d.mesh = "mcl_signs_sign67.5.obj" - ssign67_5d.on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign" .. _name - node.param2 = (node.param2 + 1) % 4 - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end - minetest.override_item("mcl_signs:standing_sign67_5" .. _name, ssign67_5d) - update_sign_registry("standing", "mcl_signs:standing_sign67_5" .. _name) + -- 67.5° + local ssign67_5d = table.copy(new_sign_standing) + ssign67_5d.mesh = "mcl_signs_sign67.5.obj" + ssign67_5d.on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign" .. _name + node.param2 = (node.param2 + 1) % 4 + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end + minetest.override_item("mcl_signs:standing_sign67_5" .. _name, ssign67_5d) + update_sign_registry("standing", "mcl_signs:standing_sign67_5" .. _name) - -- register Doc entry - if minetest.get_modpath("doc") then - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:wall_sign" .. _name) - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign" .. _name) - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign22_5" .. _name) - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign45" .. _name) - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign67_5" .. _name) - end + -- register Doc entry + if minetest.get_modpath("doc") then + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:wall_sign" .. _name) + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign" .. _name) + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign22_5" .. _name) + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign45" .. _name) + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign67_5" .. _name) + end - --register standing sign's rotation_levels - table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign22_5" .. _name , 1}) - table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign45" .. _name , 2}) - table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign67_5" .. _name , 3}) + --register standing sign's rotation_levels + table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign22_5" .. _name, 1 }) + table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign45" .. _name, 2 }) + table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign67_5" .. _name, 3 }) end --- The same as reregister_sign, except caller defines the textures. Note, there is a greyscale version of the sign, @@ -1225,205 +1240,205 @@ end --- ttsign: the tool tip of the sign that gets translated. Shown when the mouse hovers the inventory sign. --- For example: the basic, default oak (wood) sign is just "Sign"; and a spruce sign would be "Spruce Sign" function mcl_signs.reregister_sign_custom (modname, _name, tiles, color, inventory_image, wield_image, ttsign) - local mod_name_pass = false - if modname ~= "" and modname ~= "false" then - if minetest.get_modpath(modname) then - mod_name_pass = true - end - if mod_name_pass == false then - return - end - end - local new_sign = {} + local mod_name_pass = false + if modname ~= "" and modname ~= "false" then + if minetest.get_modpath(modname) then + mod_name_pass = true + end + if mod_name_pass == false then + return + end + end + local new_sign = {} - new_sign = table.copy(mcl_signs.wall_standard) + new_sign = table.copy(mcl_signs.wall_standard) - new_sign.wield_image ="("..wield_image.."^[multiply:" .. color .. ")" - new_sign.tiles = { "("..tiles.."^[multiply:" .. color .. ")" } - new_sign.inventory_image = "("..inventory_image.."^[multiply:" .. color .. ")" - new_sign.description = S(ttsign) - -- currently have to do this, because of how the base node placement works. - new_sign.on_place = function(itemstack, placer, pointed_thing) - local above = pointed_thing.above - local under = pointed_thing.under + new_sign.wield_image = "(" .. wield_image .. "^[multiply:" .. color .. ")" + new_sign.tiles = { "(" .. tiles .. "^[multiply:" .. color .. ")" } + new_sign.inventory_image = "(" .. inventory_image .. "^[multiply:" .. color .. ")" + new_sign.description = S(ttsign) + -- currently have to do this, because of how the base node placement works. + new_sign.on_place = function(itemstack, placer, pointed_thing) + local above = pointed_thing.above + local under = pointed_thing.under - -- Use pointed node's on_rightclick function first, if present - local node_under = minetest.get_node(under) - if placer and not placer:get_player_control().sneak then - if minetest.registered_nodes[node_under.name] and minetest.registered_nodes[node_under.name].on_rightclick then - return minetest.registered_nodes[node_under.name].on_rightclick(under, node_under, placer, itemstack) or itemstack - end - end + -- Use pointed node's on_rightclick function first, if present + local node_under = minetest.get_node(under) + if placer and not placer:get_player_control().sneak then + if minetest.registered_nodes[node_under.name] and minetest.registered_nodes[node_under.name].on_rightclick then + return minetest.registered_nodes[node_under.name].on_rightclick(under, node_under, placer, itemstack) or itemstack + end + end - local dir = vector.subtract(under, above) + local dir = vector.subtract(under, above) - -- Only build when it's legal - local abovenodedef = minetest.registered_nodes[minetest.get_node(above).name] - if not abovenodedef or abovenodedef.buildable_to == false then - return itemstack - end + -- Only build when it's legal + local abovenodedef = minetest.registered_nodes[minetest.get_node(above).name] + if not abovenodedef or abovenodedef.buildable_to == false then + return itemstack + end - local wdir = minetest.dir_to_wallmounted(dir) - local fdir = minetest.dir_to_facedir(dir) + local wdir = minetest.dir_to_wallmounted(dir) + local fdir = minetest.dir_to_facedir(dir) - local sign_info - local nodeitem = ItemStack(itemstack) - -- Ceiling - if wdir == 0 then - --how would you add sign to ceiling? - return itemstack - -- Floor - elseif wdir == 1 then - -- Standing sign + local sign_info + local nodeitem = ItemStack(itemstack) + -- Ceiling + if wdir == 0 then + --how would you add sign to ceiling? + return itemstack + -- Floor + elseif wdir == 1 then + -- Standing sign - -- Determine the sign rotation based on player's yaw - local yaw = pi * 2 - placer:get_look_horizontal() + -- Determine the sign rotation based on player's yaw + local yaw = pi * 2 - placer:get_look_horizontal() - -- Select one of 16 possible rotations (0-15) - local rotation_level = mcl_signs:round((yaw / (pi * 2)) * 16) + -- Select one of 16 possible rotations (0-15) + local rotation_level = mcl_signs:round((yaw / (pi * 2)) * 16) - if rotation_level > 15 then - rotation_level = 0 - elseif rotation_level < 0 then - rotation_level = 15 - end + if rotation_level > 15 then + rotation_level = 0 + elseif rotation_level < 0 then + rotation_level = 15 + end - -- The actual rotation is a combination of predefined mesh and facedir (see node definition) - if rotation_level % 4 == 0 then - nodeitem:set_name("mcl_signs:standing_sign" .. _name) - elseif rotation_level % 4 == 1 then - nodeitem:set_name("mcl_signs:standing_sign22_5" .. _name) - elseif rotation_level % 4 == 2 then - nodeitem:set_name("mcl_signs:standing_sign45" .. _name) - elseif rotation_level % 4 == 3 then - nodeitem:set_name("mcl_signs:standing_sign67_5" .. _name) - end - fdir = math.floor(rotation_level / 4) + -- The actual rotation is a combination of predefined mesh and facedir (see node definition) + if rotation_level % 4 == 0 then + nodeitem:set_name("mcl_signs:standing_sign" .. _name) + elseif rotation_level % 4 == 1 then + nodeitem:set_name("mcl_signs:standing_sign22_5" .. _name) + elseif rotation_level % 4 == 2 then + nodeitem:set_name("mcl_signs:standing_sign45" .. _name) + elseif rotation_level % 4 == 3 then + nodeitem:set_name("mcl_signs:standing_sign67_5" .. _name) + end + fdir = math.floor(rotation_level / 4) - -- Place the node! - local _, success = minetest.item_place_node(nodeitem, placer, pointed_thing, fdir) - if not success then - return itemstack - end - if not minetest.is_creative_enabled(placer:get_player_name()) then - itemstack:take_item() - end - sign_info = mcl_signs.signtext_info_standing[rotation_level + 1] - -- Side - else - -- Wall sign - local _, success = minetest.item_place_node(itemstack, placer, pointed_thing, wdir) - if not success then - return itemstack - end - sign_info = mcl_signs.signtext_info_wall[fdir + 1] - end + -- Place the node! + local _, success = minetest.item_place_node(nodeitem, placer, pointed_thing, fdir) + if not success then + return itemstack + end + if not minetest.is_creative_enabled(placer:get_player_name()) then + itemstack:take_item() + end + sign_info = mcl_signs.signtext_info_standing[rotation_level + 1] + -- Side + else + -- Wall sign + local _, success = minetest.item_place_node(itemstack, placer, pointed_thing, wdir) + if not success then + return itemstack + end + sign_info = mcl_signs.signtext_info_wall[fdir + 1] + end - -- Determine spawn position of entity - local place_pos - if minetest.registered_nodes[node_under.name].buildable_to then - place_pos = under - else - place_pos = above - end + -- Determine spawn position of entity + local place_pos + if minetest.registered_nodes[node_under.name].buildable_to then + place_pos = under + else + place_pos = above + end - local text_entity = minetest.add_entity({ - x = place_pos.x + sign_info.delta.x, - y = place_pos.y + sign_info.delta.y, - z = place_pos.z + sign_info.delta.z }, "mcl_signs:text") - text_entity:set_yaw(sign_info.yaw) - text_entity:get_luaentity()._signnodename = nodeitem:get_name() + local text_entity = minetest.add_entity({ + x = place_pos.x + sign_info.delta.x, + y = place_pos.y + sign_info.delta.y, + z = place_pos.z + sign_info.delta.z }, "mcl_signs:text") + text_entity:set_yaw(sign_info.yaw) + text_entity:get_luaentity()._signnodename = nodeitem:get_name() - minetest.sound_play({ name = "default_place_node_hard", gain = 1.0 }, { pos = place_pos }, true) + minetest.sound_play({ name = "default_place_node_hard", gain = 1.0 }, { pos = place_pos }, true) - mcl_signs:show_formspec(placer, place_pos) - return itemstack - end - minetest.override_item("mcl_signs:wall_sign" .. _name, new_sign) - update_sign_registry("wall", "mcl_signs:wall_sign" .. _name) + mcl_signs:show_formspec(placer, place_pos) + return itemstack + end + minetest.override_item("mcl_signs:wall_sign" .. _name, new_sign) + update_sign_registry("wall", "mcl_signs:wall_sign" .. _name) - -- standing sign base. - local new_sign_standing = {} - new_sign_standing = table.copy(mcl_signs.standing_standard) - new_sign_standing.drop = "mcl_signs:wall_sign" .. _name - new_sign_standing.wield_image ="("..wield_image.."^[multiply:" .. color .. ")" - new_sign_standing.tiles = { "("..tiles.."^[multiply:" .. color .. ")" } - new_sign_standing.inventory_image = "("..inventory_image.."^[multiply:" .. color .. ")" - new_sign_standing.on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign22_5" .. _name - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end, - minetest.override_item("mcl_signs:standing_sign" .. _name, new_sign_standing) - update_sign_registry("standing", "mcl_signs:standing_sign" .. _name) + -- standing sign base. + local new_sign_standing = {} + new_sign_standing = table.copy(mcl_signs.standing_standard) + new_sign_standing.drop = "mcl_signs:wall_sign" .. _name + new_sign_standing.wield_image = "(" .. wield_image .. "^[multiply:" .. color .. ")" + new_sign_standing.tiles = { "(" .. tiles .. "^[multiply:" .. color .. ")" } + new_sign_standing.inventory_image = "(" .. inventory_image .. "^[multiply:" .. color .. ")" + new_sign_standing.on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign22_5" .. _name + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end, + minetest.override_item("mcl_signs:standing_sign" .. _name, new_sign_standing) + update_sign_registry("standing", "mcl_signs:standing_sign" .. _name) - -- 22.5° - local ssign22_5d = table.copy(new_sign_standing) - ssign22_5d.mesh = "mcl_signs_sign22.5.obj" - ssign22_5d.on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign45" .. _name - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end - minetest.override_item("mcl_signs:standing_sign22_5" .. _name, ssign22_5d) - update_sign_registry("standing", "mcl_signs:standing_sign22_5" .. _name) + -- 22.5° + local ssign22_5d = table.copy(new_sign_standing) + ssign22_5d.mesh = "mcl_signs_sign22.5.obj" + ssign22_5d.on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign45" .. _name + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end + minetest.override_item("mcl_signs:standing_sign22_5" .. _name, ssign22_5d) + update_sign_registry("standing", "mcl_signs:standing_sign22_5" .. _name) - -- 45° - local ssign45d = table.copy(new_sign_standing) - ssign45d.mesh = "mcl_signs_sign45.obj" - ssign45d.on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign67_5" .. _name - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end - minetest.override_item("mcl_signs:standing_sign45" .. _name, ssign45d) - update_sign_registry("standing", "mcl_signs:standing_sign45" .. _name) + -- 45° + local ssign45d = table.copy(new_sign_standing) + ssign45d.mesh = "mcl_signs_sign45.obj" + ssign45d.on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign67_5" .. _name + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end + minetest.override_item("mcl_signs:standing_sign45" .. _name, ssign45d) + update_sign_registry("standing", "mcl_signs:standing_sign45" .. _name) - -- 67.5° - local ssign67_5d = table.copy(new_sign_standing) - ssign67_5d.mesh = "mcl_signs_sign67.5.obj" - ssign67_5d.on_rotate = function(pos, node, user, mode) - if mode == screwdriver.ROTATE_FACE then - node.name = "mcl_signs:standing_sign" .. _name - node.param2 = (node.param2 + 1) % 4 - minetest.swap_node(pos, node) - elseif mode == screwdriver.ROTATE_AXIS then - return false - end - mcl_signs:update_sign(pos, nil, nil, true) - return true - end - minetest.override_item("mcl_signs:standing_sign67_5" .. _name, ssign67_5d) - update_sign_registry("standing", "mcl_signs:standing_sign67_5" .. _name) + -- 67.5° + local ssign67_5d = table.copy(new_sign_standing) + ssign67_5d.mesh = "mcl_signs_sign67.5.obj" + ssign67_5d.on_rotate = function(pos, node, user, mode) + if mode == screwdriver.ROTATE_FACE then + node.name = "mcl_signs:standing_sign" .. _name + node.param2 = (node.param2 + 1) % 4 + minetest.swap_node(pos, node) + elseif mode == screwdriver.ROTATE_AXIS then + return false + end + mcl_signs:update_sign(pos, nil, nil, true) + return true + end + minetest.override_item("mcl_signs:standing_sign67_5" .. _name, ssign67_5d) + update_sign_registry("standing", "mcl_signs:standing_sign67_5" .. _name) - -- register Doc entry - if minetest.get_modpath("doc") then - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:wall_sign" .. _name) - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign" .. _name) - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign22_5" .. _name) - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign45" .. _name) - doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign67_5" .. _name) - end + -- register Doc entry + if minetest.get_modpath("doc") then + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:wall_sign" .. _name) + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign" .. _name) + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign22_5" .. _name) + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign45" .. _name) + doc.add_entry_alias("nodes", "mcl_signs:wall_sign", "nodes", "mcl_signs:standing_sign67_5" .. _name) + end - --register standing sign's rotation_levels - table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign22_5" .. _name , 1}) - table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign45" .. _name , 2}) - table.insert(mcl_signs.standing_rotation_levels, {"mcl_signs:standing_sign67_5" .. _name , 3}) + --register standing sign's rotation_levels + table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign22_5" .. _name, 1 }) + table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign45" .. _name, 2 }) + table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign67_5" .. _name, 3 }) end @@ -1438,485 +1453,551 @@ end --- --- _name: the sign's name suffix, such as "_dark" or "_red", etc., appended to "wall_sign" or "standing_sign" function mcl_signs.register_sign_craft(modname, wood_item_string, _name) - local mod_name_pass = false - if modname ~= "" and modname ~= "false" then - if minetest.get_modpath(modname) then - mod_name_pass = true - end - if mod_name_pass == false then - return - end - end + local mod_name_pass = false + if modname ~= "" and modname ~= "false" then + if minetest.get_modpath(modname) then + mod_name_pass = true + end + if mod_name_pass == false then + return + end + end - minetest.register_craft({ - type = "fuel", - recipe = "mcl_signs:wall_sign" .. _name, - burntime = 10, - }) + minetest.register_craft({ + type = "fuel", + recipe = "mcl_signs:wall_sign" .. _name, + burntime = 10, + }) - -- debug step - if DEBUG then - minetest.log("action", "[mcl_signs] Register Sign Crafts: \n" .. modname .. "\n" .. wood_item_string .. "\n" .. _name) - end + -- debug step + if DEBUG then + minetest.log("action", "[mcl_signs] Register Sign Crafts: \n" .. modname .. "\n" .. wood_item_string .. "\n" .. _name) + end - -- register crafts (actual recipe) - if minetest.get_modpath(modname) then + -- register crafts (actual recipe) + if minetest.get_modpath(modname) then - local itemstring = "mcl_signs:wall_sign" + local itemstring = "mcl_signs:wall_sign" - minetest.register_craft({ - output = itemstring .. _name .. " 3", - recipe = { - { wood_item_string, wood_item_string, wood_item_string }, - { wood_item_string, wood_item_string, wood_item_string }, - { "", "mcl_core:stick", "" }, - }, - }) - end + minetest.register_craft({ + output = itemstring .. _name .. " 3", + recipe = { + { wood_item_string, wood_item_string, wood_item_string }, + { wood_item_string, wood_item_string, wood_item_string }, + { "", "mcl_core:stick", "" }, + }, + }) + end +end +function mcl_signs.register_hanging_sign_craft(modname, wood_item_string, _name) + local mod_name_pass = false + if modname ~= "" and modname ~= "false" then + if minetest.get_modpath(modname) then + mod_name_pass = true + end + if mod_name_pass == false then + return + end + end + + minetest.register_craft({ + type = "fuel", + recipe = ":mcl_signs:wall_sign" .. _name, + burntime = 10, + }) + + -- debug step + if DEBUG then + minetest.log("action", "[mcl_signs] Register Sign Crafts: \n" .. modname .. "\n" .. wood_item_string .. "\n" .. _name) + end + + -- register crafts (actual recipe) + if minetest.get_modpath(modname) then + + local itemstring = ":mcl_signs:hanging_sign" + local quantity = "6" + + local bamboo = string.find(wood_item_string, "bamboo") + if bamboo then + quantity = "2" + end + minetest.register_craft({ + output = itemstring .. _name .. " " .. quantity, + recipe = { + { "mcl_lanterns:chain", "", "mcl_lanterns:chain" }, + { wood_item_string, wood_item_string, wood_item_string }, + { wood_item_string, wood_item_string, wood_item_string }, + }, + }) + end end -- Helper functions local function string_to_array(str) - local string_table = {} - for i = 1, string.len(str) do - table.insert(string_table, string.sub(str, i, i)) - end - return string_table + local string_table = {} + for i = 1, string.len(str) do + table.insert(string_table, string.sub(str, i, i)) + end + return string_table end local function string_to_line_array(str) - local linechar_table = {} - local current = 1 - local linechar = 1 - linechar_table[1] = "" - for _, char in ipairs(string_to_array(str)) do - -- New line - if char == "\n" then - current = current + 1 - linechar_table[current] = "" - linechar = 1 - else - linechar_table[current] = linechar_table[current] .. char - linechar = linechar + 1 - end - end - return linechar_table + local linechar_table = {} + local current = 1 + local linechar = 1 + linechar_table[1] = "" + for _, char in ipairs(string_to_array(str)) do + -- New line + if char == "\n" then + current = current + 1 + linechar_table[current] = "" + linechar = 1 + else + linechar_table[current] = linechar_table[current] .. char + linechar = linechar + 1 + end + end + return linechar_table end local function get_rotation_level(facedir, nodename) - local nnames = mcl_signs.standing_rotation_levels -- functional copy... was easier this way. #LazyAF :P + local nnames = mcl_signs.standing_rotation_levels -- functional copy... was easier this way. #LazyAF :P - local rl - local offset = 0 - for x = 1, #nnames do - if nnames[x][1] == nodename then - offset = nnames[x][2] - break - end - end - rl = facedir * 4 + offset - if DEBUG then - minetest.log("action", "[mcl_signs] GetRotationLevel: NodeName: " .. nodename .. " RL value: " .. rl) - end - return rl + local rl + local offset = 0 + for x = 1, #nnames do + if nnames[x][1] == nodename then + offset = nnames[x][2] + break + end + end + rl = facedir * 4 + offset + if DEBUG then + minetest.log("action", "[mcl_signs] GetRotationLevel: NodeName: " .. nodename .. " RL value: " .. rl) + end + return rl end function mcl_signs:round(num, idp) - local mult = 10 ^ (idp or 0) - return math.floor(num * mult + 0.5) / mult + local mult = 10 ^ (idp or 0) + return math.floor(num * mult + 0.5) / mult end function mcl_signs:get_color_for_sign(item_name) - for d = 1, #Dyes_table do - if Dyes_table[d][1] == item_name then - return Dyes_table[d][2] - end - end - return "false" + for d = 1, #Dyes_table do + if Dyes_table[d][1] == item_name then + return Dyes_table[d][2] + end + end + return "false" end function mcl_signs:color_sign (pos, text_color) - local success = mcl_signs:update_sign(pos, nil, nil, true, text_color) + local success = mcl_signs:update_sign(pos, nil, nil, true, text_color) - -- debug step - local meta = minetest.get_meta(pos) - if not meta then - minetest.log("error", "[mcl_signs] Sign Color Fail - Metadata.") + -- debug step + local meta = minetest.get_meta(pos) + if not meta then + minetest.log("error", "[mcl_signs] Sign Color Fail - Metadata.") - return false - end - if DEBUG then - minetest.log("verbose", "[mcl_signs] Post-Sign Color: " .. meta:get_string("mcl_signs:text_color") .. " " .. meta:get_string("mcl_signs:glowing_sign") .. ".\n" .. dump(pos)) - end + return false + end + if DEBUG then + minetest.log("verbose", "[mcl_signs] Post-Sign Color: " .. meta:get_string("mcl_signs:text_color") .. " " .. meta:get_string("mcl_signs:glowing_sign") .. ".\n" .. dump(pos)) + end - return success + return success end function mcl_signs:glow_sign (pos, remove_glow) - local success = true - -- Get Meta Data for the sign. - local meta = minetest.get_meta(pos) + local success = true + -- Get Meta Data for the sign. + local meta = minetest.get_meta(pos) - if not meta then - return false - end - local text = meta:get_string("text") - if text == nil then - text = "" - end + if not meta then + return false + end + local text = meta:get_string("text") + if text == nil then + text = "" + end - -- we can't make the text glow if there isn't any text - if text == "" then - return false - end + -- we can't make the text glow if there isn't any text + if text == "" then + return false + end - if remove_glow == nil then - remove_glow = false - end + if remove_glow == nil then + remove_glow = false + end - -- set up text glow - local objects = minetest.get_objects_inside_radius(pos, 0.5) - local text_entity - for _, v in ipairs(objects) do - local ent = v:get_luaentity() - if ent and ent.name == "mcl_signs:text" then - text_entity = v - break - end - end - if remove_glow == true then - text_entity:set_properties({ - glow = nil, - }) - meta:set_string("mcl_signs:glowing_sign", "false") - else - text_entity:set_properties({ - glow = sign_glow, - }) - meta:set_string("mcl_signs:glowing_sign", "true") - end - if not text_entity then - return false - end - text_entity:get_luaentity()._glowing_sign = meta:get_string("mcl_signs:glowing_sign") + -- set up text glow + local objects = minetest.get_objects_inside_radius(pos, 0.5) + local text_entity + for _, v in ipairs(objects) do + local ent = v:get_luaentity() + if ent and ent.name == "mcl_signs:text" then + text_entity = v + break + end + end + if remove_glow == true then + text_entity:set_properties({ + glow = nil, + }) + meta:set_string("mcl_signs:glowing_sign", "false") + else + text_entity:set_properties({ + glow = sign_glow, + }) + meta:set_string("mcl_signs:glowing_sign", "true") + end + if not text_entity then + return false + end + text_entity:get_luaentity()._glowing_sign = meta:get_string("mcl_signs:glowing_sign") - -- debug step - if DEBUG then - minetest.log("verbose", "[mcl_signs] Post-Sign Glow: " .. meta:get_string("mcl_signs:text_color") .. " " .. meta:get_string("mcl_signs:glowing_sign") .. ".\n" .. dump(pos)) - end - return success + -- debug step + if DEBUG then + minetest.log("verbose", "[mcl_signs] Post-Sign Glow: " .. meta:get_string("mcl_signs:text_color") .. " " .. meta:get_string("mcl_signs:glowing_sign") .. ".\n" .. dump(pos)) + end + return success end function mcl_signs:create_lettering(text, signnodename, sign_color) - if sign_color == nil then - sign_color = mcl_colors.BLACK - end - local texture = mcl_signs:generate_texture(mcl_signs:create_lines(text), signnodename, sign_color) + if sign_color == nil then + sign_color = mcl_colors.BLACK + end + local texture = mcl_signs:generate_texture(mcl_signs:create_lines(text), signnodename, sign_color) - -- debug step - if DEBUG then - minetest.log("action", "[mcl_signs] Creating sign text; text:" .. text) - end + -- debug step + if DEBUG then + minetest.log("action", "[mcl_signs] Creating sign text; text:" .. text) + end - return texture + return texture end function mcl_signs:create_lines(text) - local line_num = 1 - local text_table = {} - for _, line in ipairs(string_to_line_array(text)) do - if line_num > NUMBER_OF_LINES then - break - end - table.insert(text_table, line) - line_num = line_num + 1 - end - return text_table + local line_num = 1 + local text_table = {} + for _, line in ipairs(string_to_line_array(text)) do + if line_num > NUMBER_OF_LINES then + break + end + table.insert(text_table, line) + line_num = line_num + 1 + end + return text_table end function mcl_signs:generate_line(s, ypos) - local i = 1 - local parsed = {} - local width = 0 - local chars = 0 - local printed_char_width = CHAR_WIDTH + 1 - while chars < LINE_LENGTH and i <= #s do - local file - -- Get and render character - if charmap[s:sub(i, i)] then - file = charmap[s:sub(i, i)] - i = i + 1 - elseif i < #s and charmap[s:sub(i, i + 1)] then - file = charmap[s:sub(i, i + 1)] - i = i + 2 - else - -- No character image found. - -- Use replacement character: - file = "_rc" - i = i + 1 - if DEBUG then - minetest.log("verbose", "[mcl_signs] Unknown symbol in '" .. s .. "' at " .. i) - end - end - if file then - width = width + printed_char_width - table.insert(parsed, file) - chars = chars + 1 - end - end - width = width - 1 + local i = 1 + local parsed = {} + local width = 0 + local chars = 0 + local printed_char_width = CHAR_WIDTH + 1 + while chars < LINE_LENGTH and i <= #s do + local file + -- Get and render character + if charmap[s:sub(i, i)] then + file = charmap[s:sub(i, i)] + i = i + 1 + elseif i < #s and charmap[s:sub(i, i + 1)] then + file = charmap[s:sub(i, i + 1)] + i = i + 2 + else + -- No character image found. + -- Use replacement character: + file = "_rc" + i = i + 1 + if DEBUG then + minetest.log("verbose", "[mcl_signs] Unknown symbol in '" .. s .. "' at " .. i) + end + end + if file then + width = width + printed_char_width + table.insert(parsed, file) + chars = chars + 1 + end + end + width = width - 1 - local texture = "" - local xpos = math.floor((SIGN_WIDTH - width) / 2) + local texture = "" + local xpos = math.floor((SIGN_WIDTH - width) / 2) - for j = 1, #parsed do - texture = texture .. ":" .. xpos .. "," .. ypos .. "=" .. parsed[j] .. ".png" - xpos = xpos + printed_char_width - end - return texture + for j = 1, #parsed do + texture = texture .. ":" .. xpos .. "," .. ypos .. "=" .. parsed[j] .. ".png" + xpos = xpos + printed_char_width + end + return texture end function mcl_signs:generate_texture(lines, signnodename, letter_color) - local texture = "[combine:" .. SIGN_WIDTH .. "x" .. SIGN_WIDTH - local ypos = 0 + local texture = "[combine:" .. SIGN_WIDTH .. "x" .. SIGN_WIDTH + local ypos = 0 - -- Handle all of the dynamically created signs. - for x = 1, #mcl_signs.registered_signs.wall_signs do - if signnodename == mcl_signs.registered_signs.wall_signs[x] then - ypos = 30 - break - end - end - for x = 1, #mcl_signs.registered_signs.standing_signs do - if signnodename == mcl_signs.registered_signs.standing_signs[x] then - ypos = 0 - break - end - end - -- for future inclusion, when the hanging sings are made. - --[[ - for x = 1, #mcl_signs.registered_signs.hanging_signs do - if signnodename == mcl_signs.registered_signs.hanging_signs[x] then - ypos = 30 - break - end - end - ]] + -- Handle all of the dynamically created signs. + for x = 1, #mcl_signs.registered_signs.wall_signs do + if signnodename == mcl_signs.registered_signs.wall_signs[x] then + ypos = 30 + break + end + end + for x = 1, #mcl_signs.registered_signs.standing_signs do + if signnodename == mcl_signs.registered_signs.standing_signs[x] then + ypos = 0 + break + end + end + -- for future inclusion, when the hanging sings are made. + --[[ + for x = 1, #mcl_signs.registered_signs.hanging_signs do + if signnodename == mcl_signs.registered_signs.hanging_signs[x] then + ypos = 30 + break + end + end + ]] - -- kept in for now, compatibility with existing hard coded signs. TODO: Remove after done with api. - if signnodename == "mcl_signs:wall_sign" or signnodename == "mcl_signs:wall_sign_dark" then - ypos = 30 - end + -- kept in for now, compatibility with existing hard coded signs. TODO: Remove after done with api. + if signnodename == "mcl_signs:wall_sign" or signnodename == "mcl_signs:wall_sign_dark" then + ypos = 30 + end - -- debug step - if DEBUG then - minetest.log("action", "[mcl_signs] Generate_Texture::Debug_Data:\nSignNodeName: " .. dump(signnodename) .. "\nYPOS: " .. ypos) - end + -- debug step + if DEBUG then + minetest.log("action", "[mcl_signs] Generate_Texture::Debug_Data:\nSignNodeName: " .. dump(signnodename) .. "\nYPOS: " .. ypos) + end - for i = 1, #lines do - texture = texture .. mcl_signs:generate_line(lines[i], ypos) - ypos = ypos + LINE_HEIGHT - end + for i = 1, #lines do + texture = texture .. mcl_signs:generate_line(lines[i], ypos) + ypos = ypos + LINE_HEIGHT + end - texture = "(" .. texture .. "^[multiply:" .. letter_color .. ")" - return texture + texture = "(" .. texture .. "^[multiply:" .. letter_color .. ")" + return texture end function mcl_signs:get_wall_signtext_info(param2, nodename) - local dir = minetest.wallmounted_to_dir(param2) - if dir.x > 0 then - return 2 - elseif dir.z > 0 then - return 1 - elseif dir.x < 0 then - return 4 - else - return 3 - end + local dir = minetest.wallmounted_to_dir(param2) + if dir.x > 0 then + return 2 + elseif dir.z > 0 then + return 1 + elseif dir.x < 0 then + return 4 + else + return 3 + end end function mcl_signs:destruct_sign(pos) - local objects = minetest.get_objects_inside_radius(pos, 0.5) - for _, v in ipairs(objects) do - local ent = v:get_luaentity() - if ent and ent.name == "mcl_signs:text" then - v:remove() - end - end - local players = minetest.get_connected_players() - for p = 1, #players do - if vector.distance(players[p]:get_pos(), pos) <= 30 then - minetest.close_formspec(players[p]:get_player_name(), "mcl_signs:set_text_" .. pos.x .. "_" .. pos.y .. "_" .. pos.z) - end - end + local objects = minetest.get_objects_inside_radius(pos, 0.5) + for _, v in ipairs(objects) do + local ent = v:get_luaentity() + if ent and ent.name == "mcl_signs:text" then + v:remove() + end + end + local players = minetest.get_connected_players() + for p = 1, #players do + if vector.distance(players[p]:get_pos(), pos) <= 30 then + minetest.close_formspec(players[p]:get_player_name(), "mcl_signs:set_text_" .. pos.x .. "_" .. pos.y .. "_" .. pos.z) + end + end end function mcl_signs:update_sign(pos, fields, sender, force_remove, text_color) - -- Get Meta Data for the sign. - local meta = minetest.get_meta(pos) + -- Get Meta Data for the sign. + local meta = minetest.get_meta(pos) - if not meta then - return false - end - local text = meta:get_string("text") - if fields and (text == "" and fields.text) then - meta:set_string("text", fields.text) - text = fields.text - end - if text == nil then - text = "" - end + if not meta then + return false + end + local text = meta:get_string("text", "") + if fields and (text == "" and fields.text) then + meta:set_string("text", fields.text) + text = fields.text + end + if text == nil then + text = "" + end - -- find text color. - local sign_color + -- find text color. + local sign_color - if meta:get_string("mcl_signs:text_color") == "" then - -- if no sign text color has been assigned, make it black. - sign_color = mcl_colors.BLACK - meta:set_string("mcl_signs:text_color", sign_color) - else - sign_color = meta:get_string("mcl_signs:text_color") - end + if meta:get_string("mcl_signs:text_color") == "" then + -- if no sign text color has been assigned, make it black. + sign_color = mcl_colors.BLACK + meta:set_string("mcl_signs:text_color", sign_color) + else + sign_color = meta:get_string("mcl_signs:text_color") + end - if text_color == nil or text == "" then - text_color = "false" - end + if text_color == nil or text == "" then + text_color = "false" + end - if text_color == "false" then - text_color = sign_color --if a new color hasn't been chosen, then keep the existing color. - end + if text_color == "false" then + text_color = sign_color --if a new color hasn't been chosen, then keep the existing color. + end - -- find the sign's glow value - local has_glow = false + -- find the sign's glow value + local has_glow = false - if meta:get_string("mcl_signs:glowing_sign") == "" or meta:get_string("mcl_signs:glowing_sign") == "false" then - has_glow = false - meta:set_string("mcl_signs:glowing_sign", "false") - else - has_glow = true - end + if meta:get_string("mcl_signs:glowing_sign") == "" or meta:get_string("mcl_signs:glowing_sign") == "false" then + has_glow = false + meta:set_string("mcl_signs:glowing_sign", "false") + else + has_glow = true + end - -- debug step - if DEBUG then - minetest.log("action", "[mcl_signs] Update_Signs: Pre-Sign Update: " .. sign_color .. " " .. meta:get_string("mcl_signs:glowing_sign") .. ".\n" .. dump(pos)) - end + -- debug step + if DEBUG then + minetest.log("action", "[mcl_signs] Update_Signs: Pre-Sign Update: " .. sign_color .. " " .. meta:get_string("mcl_signs:glowing_sign") .. ".\n" .. dump(pos)) + end - local sign_info - local npos = minetest.get_node(pos) - local npos_name = npos.name + local sign_info + local npos = minetest.get_node(pos) + local npos_name = npos.name - -- Handle all of the dynamically created signs. - for x = 1, #mcl_signs.registered_signs.wall_signs do - if npos_name == mcl_signs.registered_signs.wall_signs[x] then - sign_info = mcl_signs.signtext_info_wall[mcl_signs:get_wall_signtext_info(npos.param2)] - break - end - end - for x = 1, #mcl_signs.registered_signs.standing_signs do - if npos_name == mcl_signs.registered_signs.standing_signs[x] then - sign_info = mcl_signs.signtext_info_standing[get_rotation_level(npos.param2, npos_name) + 1] - break - end - end - -- for future inclusion, when the hanging sings are made. - --[[ - for x = 1, #mcl_signs.registered_signs.hanging_signs do - if nn == mcl_signs.registered_signs.hanging_signs[x] then - sign_info = mcl_signs.signtext_info_wall[mcl_signs:get_wall_signtext_info(n.param2)] - break - end - end - ]] + -- Handle all of the dynamically created signs. + for x = 1, #mcl_signs.registered_signs.wall_signs do + if npos_name == mcl_signs.registered_signs.wall_signs[x] then + sign_info = mcl_signs.signtext_info_wall[mcl_signs:get_wall_signtext_info(npos.param2)] + break + end + end + for x = 1, #mcl_signs.registered_signs.standing_signs do + if npos_name == mcl_signs.registered_signs.standing_signs[x] then + sign_info = mcl_signs.signtext_info_standing[get_rotation_level(npos.param2, npos_name) + 1] + break + end + end + -- for future inclusion, when the hanging sings are made. + --[[ + for x = 1, #mcl_signs.registered_signs.hanging_signs do + if nn == mcl_signs.registered_signs.hanging_signs[x] then + sign_info = mcl_signs.signtext_info_wall[mcl_signs:get_wall_signtext_info(n.param2)] + break + end + end + ]] - -- the following if..elseif..end block is here for compatibility with the old code. TODO: remove this block after the new api is complete. - if npos_name == "mcl_signs:standing_sign_dark" or npos_name == "mcl_signs:standing_sign22_5_dark" or npos_name == "mcl_signs:standing_sign45_dark" or npos_name == "mcl_signs:standing_sign67_5_dark" then - sign_info = mcl_signs.signtext_info_standing[get_rotation_level(npos.param2, npos_name) + 1] - elseif npos_name == "mcl_signs:wall_sign_dark" then - sign_info = mcl_signs.signtext_info_wall[mcl_signs:get_wall_signtext_info(npos.param2)] - end - if sign_info == nil then - minetest.log("error", "[mcl_signs] Update_Signs: Missing sign_info!") - return false - end + -- the following if..elseif..end block is here for compatibility with the old code. TODO: remove this block after the new api is complete. + if npos_name == "mcl_signs:standing_sign_dark" or npos_name == "mcl_signs:standing_sign22_5_dark" or npos_name == "mcl_signs:standing_sign45_dark" or npos_name == "mcl_signs:standing_sign67_5_dark" then + sign_info = mcl_signs.signtext_info_standing[get_rotation_level(npos.param2, npos_name) + 1] + elseif npos_name == "mcl_signs:wall_sign_dark" then + sign_info = mcl_signs.signtext_info_wall[mcl_signs:get_wall_signtext_info(npos.param2)] + end + if sign_info == nil then + minetest.log("error", "[mcl_signs] Update_Signs: Missing sign_info!") + return false + end - local objects = minetest.get_objects_inside_radius(pos, 0.5) - local text_entity - for _, v in ipairs(objects) do - local ent = v:get_luaentity() - if ent and ent.name == "mcl_signs:text" then - if force_remove then - v:remove() - else - text_entity = v - break - end - end - end + local text_entity + text_entity = mcl_signs:get_text_entity(pos,force_remove) - if not text_entity then - if DEBUG then - minetest.log("action", "[mcl_signs] Update_Sign: Text_Entity - does not exist, creating it now.") - end - text_entity = minetest.add_entity({ - x = pos.x + sign_info.delta.x, - y = pos.y + sign_info.delta.y, - z = pos.z + sign_info.delta.z }, "mcl_signs:text") + if not text_entity then + if DEBUG then + minetest.log("action", "[mcl_signs] Update_Sign: Text_Entity - does not exist, creating it now.") + end + text_entity = minetest.add_entity({ + x = pos.x + sign_info.delta.x, + y = pos.y + sign_info.delta.y, + z = pos.z + sign_info.delta.z }, "mcl_signs:text") - if DEBUG then - minetest.log("action", "[mcl_signs] Update_Sign: Placed position:" .. dump(pos) .. "\nSign_info: " .. dump(sign_info)) - end - end - text_entity:get_luaentity()._signnodename = npos_name + if DEBUG then + minetest.log("action", "[mcl_signs] Update_Sign: Placed position:" .. dump(pos) .. "\nSign_info: " .. dump(sign_info)) + end + end + text_entity:get_luaentity()._signnodename = npos_name - -- set up special case: Dark Oak Sign. Dark Oak signs are soooo dark, they start off with white lettering. - if npos_name == "mcl_signs:wall_sign_darkwood" or - npos_name == "mcl_signs:standing_sign67_5_darkwood" or - npos_name == "mcl_signs:standing_sign45_darkwood" or - npos_name == "mcl_signs:standing_sign22_5_darkwood" or - npos_name == "mcl_signs:standing_sign_darkwood" - then - if text_color == "#000000" then - text_color = "#ffffff" - end - end + -- set up special case: Dark Oak Sign. Dark Oak signs are soooo dark, they start off with white lettering. + if npos_name == "mcl_signs:wall_sign_darkwood" or + npos_name == "mcl_signs:standing_sign67_5_darkwood" or + npos_name == "mcl_signs:standing_sign45_darkwood" or + npos_name == "mcl_signs:standing_sign22_5_darkwood" or + npos_name == "mcl_signs:standing_sign_darkwood" + then + if text_color == "#000000" then + text_color = "#ffffff" + end + end - -- Set the actual properties for the sign + -- Set the actual properties for the sign - text_entity:set_properties({ - textures = { mcl_signs:create_lettering(text, npos_name, text_color) }, - }) + text_entity:set_properties({ + textures = { mcl_signs:create_lettering(text, npos_name, text_color) }, + }) - if has_glow then - text_entity:set_properties({ - glow = sign_glow, - }) - end + if has_glow then + text_entity:set_properties({ + glow = sign_glow, + }) + end - text_entity:set_yaw(sign_info.yaw) - if DEBUG then - minetest.log("verbose", "[mcl_signs] Update_Sign: After texture recreation.") - minetest.log("action","[mcl_signs] Update_Sign: " .. npos_name .. "\nPlaced position:" .. dump(pos) .. "\nSign_info: " .. dump(sign_info)) - end + text_entity:set_yaw(sign_info.yaw) + if DEBUG then + minetest.log("verbose", "[mcl_signs] Update_Sign: After texture recreation.") + minetest.log("action", "[mcl_signs] Update_Sign: " .. npos_name .. "\nPlaced position:" .. dump(pos) .. "\nSign_info: " .. dump(sign_info)) + end - -- save sign metadata. - meta:set_string("mcl_signs:text_color", text_color) - -- debug step - if DEBUG then - minetest.log("action", "[mcl_signs] Update_Sign: Post-Sign Update: " .. meta:get_string("mcl_signs:text_color") .. " " .. meta:get_string("mcl_signs:glowing_sign") .. ".\n" .. dump(pos)) - end + -- save sign metadata. + meta:set_string("mcl_signs:text_color", text_color) - return true + -- Moved timer stuff to here, to make sure that it's called and only has one set of code. + local timer = minetest.get_node_timer(pos) + if text_entity and text ~= "" then + -- Do timer related stuff - but only if there is text to display. + -- Also, prevent excessive use with punching. (see node def.) + if timer:is_started() == false then + timer:start(TIMER_INTERVAL) + else + timer:stop() + timer:start(TIMER_INTERVAL) + end + else + if timer:is_started() == true then + timer:stop() + end + end + + -- debug step + if DEBUG then + minetest.log("action", "[mcl_signs] Update_Sign: Post-Sign Update: " .. meta:get_string("mcl_signs:text_color") .. " " .. meta:get_string("mcl_signs:glowing_sign") .. ".\n" .. dump(pos)) + end + + return true end function mcl_signs:show_formspec(player, pos) - minetest.show_formspec( - player:get_player_name(), - "mcl_signs:set_text_" .. pos.x .. "_" .. pos.y .. "_" .. pos.z, - "size[6,3]textarea[0.25,0.25;6,1.5;text;" .. F(S("Enter sign text:")) .. ";]label[0,1.5;" .. F(S("Maximum line length: 15")) .. "\n" .. F(S("Maximum lines: 4")) .. "]button_exit[0,2.5;6,1;submit;" .. F(S("Done")) .. "]" - ) + minetest.show_formspec( + player:get_player_name(), + "mcl_signs:set_text_" .. pos.x .. "_" .. pos.y .. "_" .. pos.z, + "size[6,3]textarea[0.25,0.25;6,1.5;text;" .. F(S("Enter sign text:")) .. ";]label[0,1.5;" .. F(S("Maximum line length: 15")) .. "\n" .. F(S("Maximum lines: 4")) .. "]button_exit[0,2.5;6,1;submit;" .. F(S("Done")) .. "]" + ) end + +function mcl_signs:get_text_entity (pos, force_remove) + local objects = minetest.get_objects_inside_radius(pos, 0.5) + local text_entity = false -- just to have a check for failure. + for _, v in ipairs(objects) do + local ent = v:get_luaentity() + if ent and ent.name == "mcl_signs:text" then + if force_remove ~= nil and force_remove == true then + v:remove() + else + text_entity = v + break + end + end + end + return text_entity +end \ No newline at end of file diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index d468ae4f4..e39371651 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -1760,6 +1760,21 @@ local function register_dimension_biomes() _mcl_biome_type = "medium", _mcl_palette_index = 0, }) + minetest.register_biome({ + name = "EndBarrens", + node_stone = "air", + node_filler = "air", + node_water = "air", + node_river_water = "air", + node_cave_liquid = "air", + y_min = mcl_vars.mg_end_min, + y_max = mcl_vars.mg_end_max + 80, + heat_point = 1000, + humidity_point = 1000, + vertical_blend = 16, + _mcl_biome_type = "medium", + _mcl_palette_index = 0, + }) minetest.register_biome({ name = "EndMidlands", node_stone = "air", @@ -3160,7 +3175,48 @@ local function register_decorations() flags = "place_center_x, place_center_z", rotation = "random", }) - + minetest.register_decoration({ + deco_type = "schematic", + place_on = {"group:grass_block_no_snow", "mcl_core:dirt"}, + sidelen = 16, + --[[noise_params = { + offset = 0.01, + scale = 0.00001, + spread = {x = 250, y = 250, z = 250}, + seed = 2, + octaves = 3, + persist = 0.33 + },]]-- + fill_ratio = 0.0002, + biomes = {"FlowerForest"}, + y_min = 1, + y_max = mcl_vars.mg_overworld_max, + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic_bee_nest.mts", + flags = "place_center_x, place_center_z", + rotation = "random", + spawn_by = "group:flower", + }) + minetest.register_decoration({ + deco_type = "schematic", + place_on = {"group:grass_block_no_snow", "mcl_core:dirt"}, + sidelen = 16, + --[[noise_params = { + offset = 0.01, + scale = 0.00001, + spread = {x = 250, y = 250, z = 250}, + seed = 2, + octaves = 3, + persist = 0.33 + },]]-- + fill_ratio = 0.00002, + biomes = {"Forest"}, + y_min = 1, + y_max = mcl_vars.mg_overworld_max, + schematic = mod_mcl_core.."/schematics/mcl_core_oak_classic_bee_nest.mts", + flags = "place_center_x, place_center_z", + rotation = "random", + spawn_by = "group:flower", + }) -- Rare balloon oak minetest.register_decoration({ @@ -3269,7 +3325,27 @@ local function register_decorations() flags = "place_center_x, place_center_z, force_placement", rotation = "random", }) - + minetest.register_decoration({ + deco_type = "schematic", + place_on = {"mcl_mud:mud"}, + sidelen = 80, + --[[noise_params = { + offset = 0.01, + scale = 0.00001, + spread = {x = 250, y = 250, z = 250}, + seed = 2, + octaves = 3, + persist = 0.33 + },]]-- + fill_ratio = 0.0005, + biomes = {"MangroveSwamp"}, + y_min = 1, + y_max = mcl_vars.mg_overworld_max, + schematic = mod_mcl_mangrove.."/schematics/mcl_mangrove_bee_nest.mts", + flags = "place_center_x, place_center_z, force_placement", + rotation = "random", + spawn_by = "group:flower", + }) minetest.register_decoration({ deco_type = "simple", place_on = {"mcl_mud:mud"}, @@ -3630,6 +3706,27 @@ local function register_decorations() schematic = mod_mcl_core.."/schematics/mcl_core_birch.mts", flags = "place_center_x, place_center_z", }) + minetest.register_decoration({ + deco_type = "schematic", + place_on = {"group:grass_block_no_snow", "mcl_core:dirt"}, + sidelen = 16, + --[[noise_params = { + offset = 0.01, + scale = 0.00001, + spread = {x = 250, y = 250, z = 250}, + seed = 2, + octaves = 3, + persist = 0.33 + },]]-- + fill_ratio = 0.00002, + biomes = {"Forest", "BirchForest", "BirchForestM"}, + y_min = 1, + y_max = mcl_vars.mg_overworld_max, + schematic = mod_mcl_core.."/schematics/mcl_core_birch_bee_nest.mts", + flags = "place_center_x, place_center_z", + rotation = "random", + spawn_by = "group:flower", + }) -- Dark Oak minetest.register_decoration({ diff --git a/mods/PLAYER/mcl_meshhand/init.lua b/mods/PLAYER/mcl_meshhand/init.lua index 0d4bf091d..904ffa533 100644 --- a/mods/PLAYER/mcl_meshhand/init.lua +++ b/mods/PLAYER/mcl_meshhand/init.lua @@ -10,7 +10,7 @@ local node_def = { drawtype = "mesh", node_placement_prediction = "", on_construct = function(pos) - local name = get_node(pos).name + local name = minetest.get_node(pos).name local message = "[mcl_meshhand] Trying to construct " .. name .. " at " .. minetest.pos_to_string(pos) minetest.log("error", message) minetest.remove_node(pos) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 3d3e5f129..0faa9c53f 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -3,6 +3,8 @@ mcl_playerplus = { is_pressing_jump = {}, } +local hud_water = {} + local get_connected_players = minetest.get_connected_players local dir_to_yaw = minetest.dir_to_yaw local get_item_group = minetest.get_item_group @@ -25,6 +27,26 @@ local mcl_playerplus_internal = {} local time = 0 local look_pitch = 0 + +local function calculate_water_depth(pos) + for i=1, 50 do + if get_item_group(minetest.get_node(vector.new(pos.x,pos.y+i,pos.z)).name, "water") == 0 then + return i + end + end + return 50 +end + +local function remove_water_hud(player) + if hud_water[player] then + mcl_weather.skycolor.update_sky_color() + for i=1, #hud_water[player] do + player:hud_remove(hud_water[player][i]) + end + hud_water[player] = nil + end +end + local function player_collision(player) local pos = player:get_pos() @@ -349,16 +371,16 @@ minetest.register_globalstep(function(dtime) -- set head pitch and yaw when flying local head_rot = vector.new(pitch - degrees(dir_to_pitch(player_velocity)) + 50, player_vel_yaw - yaw, 0) set_bone_pos(player,"Head_Control", nil, head_rot) - + -- sets eye height, and nametag color accordingly set_properties(player, player_props_elytra) - + -- control body bone when flying local body_rot = vector.new((75 - degrees(dir_to_pitch(player_velocity))), -player_vel_yaw + yaw, 0) set_bone_pos(player, "Body_Control", nil, body_rot) elseif parent then set_properties(player, player_props_riding) - + local parent_yaw = degrees(parent:get_yaw()) local head_rot = vector.new(pitch, -limit_vel_yaw(yaw, parent_yaw) + parent_yaw, 0) set_bone_pos(player, "Head_Control", nil, head_rot) @@ -367,10 +389,10 @@ minetest.register_globalstep(function(dtime) -- controls head pitch when sneaking local head_rot = vector.new(pitch, player_vel_yaw - yaw, player_vel_yaw - yaw) set_bone_pos(player, "Head_Control", nil, head_rot) - + -- sets eye height, and nametag color accordingly set_properties(player, player_props_sneaking) - + -- sneaking body conrols set_bone_pos(player, "Body_Control", nil, vector.new(0, -player_vel_yaw + yaw, 0)) elseif get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0 and is_sprinting(name) == true then @@ -378,10 +400,10 @@ minetest.register_globalstep(function(dtime) is_swimming = true local head_rot = vector.new(pitch - degrees(dir_to_pitch(player_velocity)) + 20, player_vel_yaw - yaw, 0) set_bone_pos(player, "Head_Control", nil, head_rot) - + -- sets eye height, and nametag color accordingly set_properties(player, player_props_swimming) - + -- control body bone when swimming local body_rot = vector.new((75 + degrees(dir_to_pitch(player_velocity))), player_vel_yaw - yaw, 180) set_bone_pos(player,"Body_Control", nil, body_rot) @@ -395,6 +417,25 @@ minetest.register_globalstep(function(dtime) set_bone_pos(player,"Body_Control", nil, vector.new(0, -player_vel_yaw + yaw, 0)) end + if get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0 then + if not hud_water[player] or hud_water[player] and calculate_water_depth(player:get_pos()) ~= #hud_water[player] then + remove_water_hud(player) + hud_water[player] = {} + for i=1, calculate_water_depth(player:get_pos()) do + table.insert(hud_water[player], player:hud_add({ + hud_elem_type = "image", + text = "mcl_playerplus_water.png", + position = {x = 0.5, y = 0.5}, + scale = {x = 32, y = 16}, + offset = {x = 0, y = 0}, + z_index = -1002, + })) + end + end + else + remove_water_hud(player) + end + elytra.last_yaw = player:get_look_horizontal() -- Update jump status immediately since we need this info in real time. -- WARNING: This section is HACKY as hell since it is all just based on heuristics. @@ -639,7 +680,7 @@ minetest.register_on_joinplayer(function(player) jump_cooldown = -1, -- Cooldown timer for jumping, we need this to prevent the jump exhaustion to increase rapidly } mcl_playerplus.elytra[player] = {active = false, rocketing = 0, speed = 0} - + -- Minetest bug: get_bone_position() returns all zeros vectors. -- Workaround: call set_bone_position() one time first. player:set_bone_position("Head_Control", vector.new(0, 6.75, 0)) diff --git a/mods/PLAYER/mcl_playerplus/textures/mcl_playerplus_water.png b/mods/PLAYER/mcl_playerplus/textures/mcl_playerplus_water.png new file mode 100644 index 000000000..0524ce8d6 Binary files /dev/null and b/mods/PLAYER/mcl_playerplus/textures/mcl_playerplus_water.png differ diff --git a/mods/PLAYER/mcl_skins/edit_skin.lua b/mods/PLAYER/mcl_skins/edit_skin.lua index 72947d382..3ced41d6d 100644 --- a/mods/PLAYER/mcl_skins/edit_skin.lua +++ b/mods/PLAYER/mcl_skins/edit_skin.lua @@ -25,21 +25,21 @@ mcl_skins = { -- Base color is separate to keep the number of junk nodes registered in check base_color = {0xffeeb592, 0xffb47a57, 0xff8d471d}, color = { - 0xff613915, -- 1 Dark brown Steve hair, Alex bottom + 0xff613915, -- 1 Dark brown 0xff97491b, -- 2 Medium brown 0xffb17050, -- 3 Light brown 0xffe2bc7b, -- 4 Beige 0xff706662, -- 5 Gray 0xff151515, -- 6 Black 0xffc21c1c, -- 7 Red - 0xff178c32, -- 8 Green Alex top + 0xff178c32, -- 8 Green 0xffae2ad3, -- 9 Plum 0xffebe8e4, -- 10 White 0xffe3dd26, -- 11 Yellow - 0xff449acc, -- 12 Light blue Steve top - 0xff124d87, -- 13 Dark blue Steve bottom + 0xff449acc, -- 12 Light blue + 0xff124d87, -- 13 Dark blue 0xfffc0eb3, -- 14 Pink - 0xffd0672a, -- 15 Orange Alex hair + 0xffd0672a, -- 15 Orange }, footwear = {}, mouth = {}, @@ -574,16 +574,16 @@ local function init() for _, item in pairs(json) do mcl_skins.register_item(item) end - mcl_skins.steve.base_color = mcl_skins.base_color[1] - mcl_skins.steve.hair_color = mcl_skins.color[1] - mcl_skins.steve.top_color = mcl_skins.color[12] - mcl_skins.steve.bottom_color = mcl_skins.color[13] + mcl_skins.steve.base_color = mcl_skins.base_color[2] + mcl_skins.steve.hair_color = 0xff5d473b + mcl_skins.steve.top_color = 0xff993535 + mcl_skins.steve.bottom_color = 0xff644939 mcl_skins.steve.slim_arms = false mcl_skins.alex.base_color = mcl_skins.base_color[1] - mcl_skins.alex.hair_color = mcl_skins.color[15] - mcl_skins.alex.top_color = mcl_skins.color[8] - mcl_skins.alex.bottom_color = mcl_skins.color[1] + mcl_skins.alex.hair_color = 0xff715d57 + mcl_skins.alex.top_color = 0xff346840 + mcl_skins.alex.bottom_color = 0xff383532 mcl_skins.alex.slim_arms = true end diff --git a/mods/PLAYER/mcl_skins/list.json b/mods/PLAYER/mcl_skins/list.json index 163111a4c..01bb622e5 100644 --- a/mods/PLAYER/mcl_skins/list.json +++ b/mods/PLAYER/mcl_skins/list.json @@ -18,11 +18,13 @@ }, { "type": "eye", - "texture": "mcl_skins_eye_1.png" + "texture": "mcl_skins_eye_1.png", + "alex": true }, { "type": "eye", - "texture": "mcl_skins_eye_2.png" + "texture": "mcl_skins_eye_2.png", + "steve": true }, { "type": "eye", @@ -34,9 +36,7 @@ }, { "type": "eye", - "texture": "mcl_skins_eye_5.png", - "steve": true, - "alex": true + "texture": "mcl_skins_eye_5.png" }, { "type": "eye", @@ -73,21 +73,23 @@ }, { "type": "mouth", - "texture": "mcl_skins_mouth_7.png", - "alex": true + "texture": "mcl_skins_mouth_7.png" }, { - "type": "mouth" + "type": "mouth", + "alex": true }, { "type": "hair", "texture": "mcl_skins_hair_1.png", - "mask": "mcl_skins_hair_1_mask.png" + "mask": "mcl_skins_hair_1_mask.png", + "alex": true }, { "type": "hair", "texture": "mcl_skins_hair_2.png", - "mask": "mcl_skins_hair_2_mask.png" + "mask": "mcl_skins_hair_2_mask.png", + "steve": true }, { "type": "hair", @@ -127,14 +129,12 @@ { "type": "hair", "texture": "mcl_skins_hair_10.png", - "mask": "mcl_skins_hair_10_mask.png", - "steve": true + "mask": "mcl_skins_hair_10_mask.png" }, { "type": "hair", "texture": "mcl_skins_hair_11.png", - "mask": "mcl_skins_hair_11_mask.png", - "alex": true + "mask": "mcl_skins_hair_11_mask.png" }, { "type": "hair" @@ -145,7 +145,8 @@ }, { "type": "headwear", - "texture": "mcl_skins_headwear_2.png" + "texture": "mcl_skins_headwear_2.png", + "alex": true }, { "type": "headwear", @@ -173,13 +174,14 @@ }, { "type": "headwear", - "steve": true, - "alex": true + "steve": true }, { "type": "bottom", "texture": "mcl_skins_bottom_1.png", - "mask": "mcl_skins_bottom_1_mask.png" + "mask": "mcl_skins_bottom_1_mask.png", + "steve": true, + "alex": true }, { "type": "bottom", @@ -194,14 +196,14 @@ { "type": "bottom", "texture": "mcl_skins_bottom_4.png", - "mask": "mcl_skins_bottom_4_mask.png", - "steve": true, - "alex": true + "mask": "mcl_skins_bottom_4_mask.png" }, { "type": "top", "texture": "mcl_skins_top_1.png", - "mask": "mcl_skins_top_1_mask.png" + "mask": "mcl_skins_top_1_mask.png", + "steve": true, + "alex": true }, { "type": "top", @@ -241,14 +243,12 @@ { "type": "top", "texture": "mcl_skins_top_9.png", - "mask": "mcl_skins_top_9_mask.png", - "alex": true + "mask": "mcl_skins_top_9_mask.png" }, { "type": "top", "texture": "mcl_skins_top_10.png", - "mask": "mcl_skins_top_10_mask.png", - "steve": true + "mask": "mcl_skins_top_10_mask.png" }, { "type": "base", diff --git a/mods/PLAYER/mcl_skins/media_credits.txt b/mods/PLAYER/mcl_skins/media_credits.txt index b81058356..cda321d60 100644 --- a/mods/PLAYER/mcl_skins/media_credits.txt +++ b/mods/PLAYER/mcl_skins/media_credits.txt @@ -20,6 +20,7 @@ mcl_skins_top_6.png mcl_skins_bottom_3.png mcl_skins_eye_7.png mcl_skins_mouth_7.png +mcl_skins_hair_10.png Original work by MrRar License: CC BY-SA 4.0 @@ -99,7 +100,6 @@ Source: http://minetest.fensta.bplaced.net/#id=1258 mcl_skins_bottom_4.png mcl_skins_top_9.png mcl_skins_top_10.png -mcl_skins_hair_10.png mcl_skins_hair_11.png Name: Pixel Perfection Legacy 1.19 Author: Nova_Wostra. Adapted for mcl_skins by MrRar. diff --git a/mods/PLAYER/mcl_skins/textures/mcl_skins_hair_1.png b/mods/PLAYER/mcl_skins/textures/mcl_skins_hair_1.png index df2397d32..789468518 100644 Binary files a/mods/PLAYER/mcl_skins/textures/mcl_skins_hair_1.png and b/mods/PLAYER/mcl_skins/textures/mcl_skins_hair_1.png differ diff --git a/mods/PLAYER/mcl_skins/textures/mcl_skins_hair_10.png b/mods/PLAYER/mcl_skins/textures/mcl_skins_hair_10.png index 72a50f722..962d1aa70 100644 Binary files a/mods/PLAYER/mcl_skins/textures/mcl_skins_hair_10.png and b/mods/PLAYER/mcl_skins/textures/mcl_skins_hair_10.png differ diff --git a/mods/PLAYER/mcl_skins/textures/mcl_skins_hair_10_mask.png b/mods/PLAYER/mcl_skins/textures/mcl_skins_hair_10_mask.png index 7c8822cf6..775d8cd96 100644 Binary files a/mods/PLAYER/mcl_skins/textures/mcl_skins_hair_10_mask.png and b/mods/PLAYER/mcl_skins/textures/mcl_skins_hair_10_mask.png differ