From be82518f20c5bdeea836b0c9fafea8a465360e00 Mon Sep 17 00:00:00 2001 From: wintersknight94 <62315647+wintersknight94@users.noreply.github.com> Date: Fri, 10 Mar 2023 11:47:53 -0600 Subject: [PATCH] Add files via upload --- carpet.lua | 97 +++++++++++++++ glowstone.lua | 67 ++++++++++ hardbricks.lua | 37 ++++++ init.lua | 41 ++++++ lodestone.lua | 67 ++++++++++ mod.conf | 7 ++ moredoor.lua | 154 +++++++++++++++++++++++ popeggcorn.lua | 48 +++++++ reinforced.lua | 81 ++++++++++++ settingtypes.txt | 5 + sierpinski.lua | 131 +++++++++++++++++++ syrup.lua | 111 +++++++++++++++++ textures/wc_noditions_sap.png | Bin 0 -> 589 bytes torch.lua | 228 ++++++++++++++++++++++++++++++++++ treesap.lua | 65 ++++++++++ 15 files changed, 1139 insertions(+) create mode 100644 carpet.lua create mode 100644 glowstone.lua create mode 100644 hardbricks.lua create mode 100644 init.lua create mode 100644 lodestone.lua create mode 100644 mod.conf create mode 100644 moredoor.lua create mode 100644 popeggcorn.lua create mode 100644 reinforced.lua create mode 100644 settingtypes.txt create mode 100644 sierpinski.lua create mode 100644 syrup.lua create mode 100644 textures/wc_noditions_sap.png create mode 100644 torch.lua create mode 100644 treesap.lua diff --git a/carpet.lua b/carpet.lua new file mode 100644 index 0000000..40564f0 --- /dev/null +++ b/carpet.lua @@ -0,0 +1,97 @@ +-- LUALOCALS < --------------------------------------------------------- +local minetest, nodecore, string, vector + = minetest, nodecore, string, vector +local string_gsub + = string.gsub +-- LUALOCALS > --------------------------------------------------------- +local modname = minetest.get_current_modname() +-- ================================================================== -- +-- <><><><> Slice (Menger) Sponges into (Sierpinski) Carpets <><><><> -- +-- ================================================================== -- +minetest.register_node(modname .. ":carpet", { + description = "Carpet", + use_texture_alpha = "clip", + drawtype = "nodebox", + node_box = nodecore.fixedbox({-0.5, -15/32, -0.5, 0.5, -14/32, 0.5}), + tiles = {"nc_sponge.png"}, + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = true, + walkable = false, + floodable = false, + groups = { + snappy = 1, + flammable = 3, + fire_fuel = 3, + carpet = 1 + }, + air_pass = true, + sounds = nodecore.sounds("nc_terrain_swishy"), + on_place = minetest.rotate_node +}) +------------------------------------------------------------------------ +minetest.register_node(modname .. ":carpet_wet", { + description = "Wet Carpet", + use_texture_alpha = "clip", + drawtype = "nodebox", + node_box = nodecore.fixedbox({-0.5, -15/32, -0.5, 0.5, -14/32, 0.5}), + tiles = {"nc_sponge.png^(nc_terrain_water.png^[opacity:96)"}, + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = true, + walkable = false, + floodable = false, + groups = { + snappy = 1, + coolant = 1, + moist = 1, + carpet = 1 + }, + sounds = nodecore.sounds("nc_terrain_swishy"), + on_place = minetest.rotate_node +}) +------------------------------------------------------------------------ +-- To me it makes the most sense to get 16 carpets per sponge, but that seemed +-- a bit op, so I only made it 8 until testing shows it should be more/less. +-- It could just as well be 6, given that a cube has 6 faces, and a sierpinski carpet +-- is a 2d plane, rather than an actual carpet, but whatever. +------------------------------------------------------------------------ +nodecore.register_craft({ + label = "slice sponge into carpet", + action = "pummel", + indexkeys = {"nc_sponge:sponge"}, + nodes = { + {match = "nc_sponge:sponge", replace = "air"} + }, + items = { + {name = modname.. ":carpet", count = 8, scatter = 4}, + }, + toolgroups = {choppy = 3}, + itemscatter = 4 +}) +nodecore.register_craft({ + label = "slice wet sponge into wet carpet", + action = "pummel", + indexkeys = {"nc_sponge:sponge_wet"}, + nodes = { + {match = "nc_sponge:sponge_wet", replace = "air"} + }, + items = { + {name = modname.. ":carpet_wet", count = 8, scatter = 4}, + }, + toolgroups = {choppy = 3}, + itemscatter = 4 +}) +------------------------------------------------------------------------ +nodecore.register_craft({ + label = "compress carpets back to sponges", + action = "pummel", + toolgroups = {thumpy = 1}, + indexkeys = {modname .. ":carpet"}, + nodes = { + { + match = {name = modname .. ":carpet", count = 8}, + replace = "nc_sponge:sponge" + } + } +}) diff --git a/glowstone.lua b/glowstone.lua new file mode 100644 index 0000000..8b7065b --- /dev/null +++ b/glowstone.lua @@ -0,0 +1,67 @@ +-- LUALOCALS < --------------------------------------------------------- +local minetest, nodecore + = minetest, nodecore +-- LUALOCALS > --------------------------------------------------------- +local modname = minetest.get_current_modname() +------------------------------------------------------------------------ +minetest.register_ore({ + name = "nc_lux:cobble", + ore_type = "scatter", + ore = "nc_lux:cobble1", + wherein = "nc_terrain:stone", + random_factor = 0, + noise_params = { + offset = 0, + scale = 3, + spread = {x = 32, y = 12, z = 32}, + seed = 782917, + octaves = 3, + persist = 0.5, + flags = "eased", + }, + noise_threshold = 1.2, + y_max = -40, + y_min = -31000, + clust_num_ores = 1, + clust_size = 1, + clust_scarcity = 16 * 16 * 16 * 8 + }) +------------------------------------------------------------------------ +-- Doesn't make sense to find partially dug ore buried in solid stone +-- so only caves are worth searching as it must be exposed to air +------------------------------------------------------------------------ +local c_lux = minetest.get_content_id("nc_lux:cobble1") +local c_glowstone = minetest.get_content_id("nc_terrain:stone") +local c_air = minetest.get_content_id("air") + +nodecore.register_mapgen_shared({ + label = "lux cobble exposure", + func = function(minp, maxp, area, data) + local ai = area.index + for z = minp.z, maxp.z do + for y = minp.y, maxp.y do + local offs = ai(area, 0, y, z) + for x = minp.x, maxp.x do + local i = offs + x + if data[i] == c_lux then + if x == minp.x + or x == maxp.x + or y == minp.y + or y == maxp.y + or z == minp.z + or z == maxp.z + or (data[i - 1] ~= c_air + and data[i + 1] ~= c_air + and data[i - area.ystride] ~= c_air + and data[i + area.ystride] ~= c_air + and data[i - area.zstride] ~= c_air + and data[i + area.zstride] ~= c_air) + then data[i] = c_glowstone + end + end + end + end + end + end +}) + diff --git a/hardbricks.lua b/hardbricks.lua new file mode 100644 index 0000000..21099b0 --- /dev/null +++ b/hardbricks.lua @@ -0,0 +1,37 @@ +-- LUALOCALS < --------------------------------------------------------- +local ipairs, minetest, nodecore, pairs, type, math + = ipairs, minetest, nodecore, pairs, type, math +-- LUALOCALS > --------------------------------------------------------- +local modname = minetest.get_current_modname() +------------------------------------------------------------------------ +for i = 1, 7 do +local o = (120 + (i * 20)) +------------------------------------------------------------------------ +local stonetile = nodecore.hard_stone_tile(i) +local bricktile = "nc_stonework_bricks.png^[opacity:" ..o +------------------------------------------------------------------------ + minetest.register_node(modname.. ":bricks_hard_stone_" ..i.. "_bonded", { + description = "Stone Bricks", + tiles = {"(" ..stonetile.. ")^(" ..bricktile.. ")"}, + groups = { + stone = i + 1, + rock = i, + cracky = i + 2, + stone_bricks = i + 2, + hard_stone = i, + hard_bricks = i + }, + silktouch = false, + crush_damage = 4, + sounds = nodecore.sounds("nc_terrain_stony"), + drop_in_place = modname .. ((i > 1) + and (":bricks_hard_stone_" .. (i - 1) .. "_bonded") or ":bricks_stone_bonded"), + }) +end +------------------------------------------------------------------------ +minetest.register_alias(modname .. ":bricks_stone_bonded", "nc_stonework:bricks_stone_bonded") +------------------------------------------------------------------------ +-- Here's the node registry, Warr. Idk how to deal with your stone hardening abm. +-- I had my own simplified version but it wasn't consistent with vanilla stone hardening. +-- On top of that, my version caused abm bogging for some reason. Major fps drop. +-- I'm certain that you can do it both better and easier than I can. diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..746ab8d --- /dev/null +++ b/init.lua @@ -0,0 +1,41 @@ + -- LUALOCALS < --------------------------------------------------------- +local include, minetest, nodecore + = include, minetest, nodecore +-- LUALOCALS > --------------------------------------------------------- +local modname = minetest.get_current_modname() +-- ================================================================== -- + +include("popeggcorn") + +------------------------------------------------------------------------ + +include("carpet") +if minetest.settings:get_bool(modname .. ".sierpinski", true) then + include("sierpinski") +end + +------------------------------------------------------------------------ + +if minetest.settings:get_bool(modname .. ".syrup", true) then + include("syrup") + else include("treesap") +end +include("torch") + +------------------------------------------------------------------------ + +include("lodestone") +include("glowstone") + +------------------------------------------------------------------------ + +include("moredoor") + +------------------------------------------------------------------------ + +include("hardbricks") + +------------------------------------------------------------------------ + +include("reinforced") + diff --git a/lodestone.lua b/lodestone.lua new file mode 100644 index 0000000..812cfc6 --- /dev/null +++ b/lodestone.lua @@ -0,0 +1,67 @@ +-- LUALOCALS < --------------------------------------------------------- +local minetest, nodecore + = minetest, nodecore +-- LUALOCALS > --------------------------------------------------------- +local modname = minetest.get_current_modname() +------------------------------------------------------------------------ +minetest.register_ore({ + name = "nc_lode:cobble", + ore_type = "scatter", + ore = "nc_lode:cobble", + wherein = "nc_lode:stone", + random_factor = 0, + noise_params = { + offset = 0, + scale = 4, + spread = {x = 32, y = 12, z = 32}, + seed = 23565, + octaves = 3, + persist = 0.5, + flags = "eased", + }, + noise_threshold = 0.5, + y_max = 600, + y_min = -600, + clust_num_ores = 1, + clust_size = 1, + clust_scarcity = 8 * 8 * 8 * 4 + }) +------------------------------------------------------------------------ +-- Doesn't make sense to find partially dug ore buried in solid stone +-- so only caves are worth searching as it must be exposed to air +------------------------------------------------------------------------ +local c_lode = minetest.get_content_id("nc_lode:cobble") +local c_lodestone = minetest.get_content_id("nc_lode:stone") +local c_air = minetest.get_content_id("air") + +nodecore.register_mapgen_shared({ + label = "lode cobble exposure", + func = function(minp, maxp, area, data) + local ai = area.index + for z = minp.z, maxp.z do + for y = minp.y, maxp.y do + local offs = ai(area, 0, y, z) + for x = minp.x, maxp.x do + local i = offs + x + if data[i] == c_lode then + if x == minp.x + or x == maxp.x + or y == minp.y + or y == maxp.y + or z == minp.z + or z == maxp.z + or (data[i - 1] ~= c_air + and data[i + 1] ~= c_air + and data[i - area.ystride] ~= c_air + and data[i + area.ystride] ~= c_air + and data[i - area.zstride] ~= c_air + and data[i + area.zstride] ~= c_air) + then data[i] = c_lodestone + end + end + end + end + end + end +}) + diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..f0c35a2 --- /dev/null +++ b/mod.conf @@ -0,0 +1,7 @@ +depends = nc_api_all, nc_items, nc_terrain, nc_tree, nc_woodwork, nc_sponge, nc_optics, nc_flora, nc_optics, nc_lux, nc_lode +optional_depends = wc_vulcan --to prevent strange conflict +author = Winter94 +description = Ask and Ye Shall Recieve (Multiple Small Additions Requested in NC Documentation ) +name = wc_noditions + +title = NodeCore Additional Content \ No newline at end of file diff --git a/moredoor.lua b/moredoor.lua new file mode 100644 index 0000000..6498c5e --- /dev/null +++ b/moredoor.lua @@ -0,0 +1,154 @@ +-- LUALOCALS < --------------------------------------------------------- +local ItemStack, minetest, nodecore, pairs, vector + = ItemStack, minetest, nodecore, pairs, vector +-- LUALOCALS > --------------------------------------------------------- +local modname = minetest.get_current_modname() + +-- ================================================================== -- +-- <> One Does Not Simply Walk Into Moredoor <> -- +-- ================================================================== -- + +local function doorop(pos, node, clicker, _, pointed) + if nodecore.protection_test(pos, clicker) then return end + if (not pointed.above) or (not pointed.under) then return end + local force = vector.subtract(pointed.under, pointed.above) + nodecore.operate_door(pos, node, force) +end + +local tilemods = { + {idx = 1, part = "end", tran = "R180"}, + {idx = 2, part = "end", tran = "FX"}, + {idx = 3, part = "side", tran = "I"}, + {idx = 6, part = "side", tran = "R180"} +} + +function nodecore.register_door(basemod, basenode, desc, pin, lv, basedef) + local basefull = basemod .. ":" .. basenode + basedef = basedef or minetest.registered_nodes[basefull] + + local tiles = nodecore.underride({}, basedef.tiles) + while #tiles < 6 do tiles[#tiles + 1] = tiles[#tiles] end + for k, v in pairs(tiles) do tiles[k] = v.name or v end + for _, v in pairs(tilemods) do + tiles[v.idx] = tiles[v.idx] .. "^nc_doors_hinge_" .. v.part + .. "_base.png^[transform" .. v.tran + end + local scuff = "^(nc_doors_hinge_scuff.png^[opacity:" + .. (basedef.groups.nc_door_scuff_opacity or 64) + tiles[4] = tiles[4] .. scuff .. ")" + tiles[5] = tiles[5] .. scuff .. "^[transformR180)" + + local spin = nodecore.node_spin_filtered(function(a, b) + return vector.equals(a.f, b.r) + and vector.equals(a.r, b.f) + end) + + local doorname = modname .. ":door_" .. basenode + local groups = nodecore.underride({door_panel = lv}, basedef.groups) + local paneldef = nodecore.underride({}, { + name = modname .. ":panel_" .. basenode, + description = (desc or basedef.description) .. " Panel", + tiles = tiles, + paramtype2 = "facedir", + silktouch = false, + groups = groups, + on_rightclick = function(pos, node, clicker, stack, pointed, ...) + if nodecore.protection_test(pos, clicker) then return end + stack = stack and ItemStack(stack) + if (not stack) or (stack:get_name() ~= pin) then + return spin(pos, node, clicker, stack, pointed, ...) + end + local fd = node and node.param2 or 0 + fd = nodecore.facedirs[fd] + local dir = vector.subtract(pointed.above, pointed.under) + if vector.equals(dir, fd.t) or vector.equals(dir, fd.b) then + node.name = doorname + nodecore.player_discover(clicker, "craft:door pin " + .. basenode:lower()) + nodecore.set_loud(pos, node) + stack:take_item(1) + return stack + end + end + }, basedef) + paneldef.drop = nil + paneldef.alternate_loose = nil + paneldef.drop_in_place = nil + paneldef.after_dig_node = nil + + minetest.register_node(":" .. paneldef.name, paneldef) + + local t = minetest.registered_items[pin].tiles + t = t[3] or t[2] or t[1] + t = t.name or t + tiles = nodecore.underride({}, tiles) + for _, v in pairs(tilemods) do + tiles[v.idx] = tiles[v.idx] .. "^((" .. t .. ")^[mask:nc_doors_hinge_" .. v.part + .. "_mask.png^[transform" .. v.tran .. ")" + end + + groups = nodecore.underride({door = lv}, basedef.groups) + local doordef = nodecore.underride({ + name = doorname, + description = (desc or basedef.description) .. " Hinged Panel", + tiles = tiles, + drop = pin, + drop_in_place = paneldef.name, + on_rightclick = doorop, + groups = groups + }, paneldef) + + minetest.register_node(":" .. doordef.name, doordef) + + nodecore.register_craft({ + label = "drill door " .. basenode:lower(), + action = "pummel", + toolgroups = {thumpy = 3}, + normal = {y = 1}, + indexkeys = {"group:chisel"}, + nodes = { + { + match = { + lode_temper_tempered = true, + groups = {chisel = 2} + }, + dig = true + }, + { + y = -1, + match = basefull, + replace = paneldef.name + } + } + }) +end + +-- ================================================================== -- +-- <> One Does Not Simply Walk Into Moredoor <> -- +-- ================================================================== -- + +nodecore.register_door(modname, "cornplank", "Popped", "nc_woodwork:staff", 1) +nodecore.register_door("nc_flora", "thatch", "Rattan", "nc_woodwork:staff", 1) +--nodecore.register_door("nc_flora", "wicker", "Wicker", "nc_woodwork:staff", 1) +--nodecore.register_door("nc_optics", "glass", "Glass", "nc_lode:rod_tempered", 3) +--nodecore.register_door("nc_optics", "glass_float", "Clear", "nc_lode:rod_tempered", 3) +nodecore.register_door("nc_optics", "glass_opaque", "Chromatic", "nc_lode:rod_tempered", 3) +nodecore.register_door("nc_lode", "block_annealed", "Lode", "nc_lode:rod_tempered", 5) + +-- ================================================================== -- +-- <> One Does Not Simply Walk Into Moredoor <> -- Never gets old -- +-- ================================================================== -- + +-- I see what the problem with adding allfaces and allfaces_optional doortypes is now. +-- Even the overrides with alpha blending seem broken due to MT rendering issues. + +--minetest.override_item(modname.. ":panel_wicker",{drawtype = "normal", use_texture_alpha = true,}) +--minetest.override_item(modname.. ":door_wicker",{drawtype = "normal", use_texture_alpha = true,}) + +--minetest.override_item(modname.. ":panel_glass",{drawtype = "normal", use_texture_alpha = true,}) +--minetest.override_item(modname.. ":door_glass",{drawtype = "normal", use_texture_alpha = true,}) + +--minetest.override_item(modname.. ":panel_glass_float",{drawtype = "normal", use_texture_alpha = true,}) +--minetest.override_item(modname.. ":door_glass_float",{drawtype = "normal", use_texture_alpha = true,}) + + diff --git a/popeggcorn.lua b/popeggcorn.lua new file mode 100644 index 0000000..5f03b15 --- /dev/null +++ b/popeggcorn.lua @@ -0,0 +1,48 @@ +-- LUALOCALS < --------------------------------------------------------- +local minetest, nodecore, pairs, vector + = minetest, nodecore, pairs, vector +-- LUALOCALS > --------------------------------------------------------- +local modname = minetest.get_current_modname() +local popcorn = "nc_woodwork_plank.png^(nc_fire_ash.png^[mask:nc_concrete_mask.png)" +-- ================================================================== -- +-- I don't even like popcorn ya'll, it hurts my teeth! -- Wintersknight94 +-- ================================================================== -- +minetest.register_node(modname .. ":cornplank", { + description = "Popeggcorn", + tiles = {popcorn}, + groups = { + choppy = 1, + flammable = 2, -- be careful, as you can easily burn your popeggcorn after it pops! + fire_fuel = 2, + falling_node = 1 + }, + sounds = nodecore.sounds("nc_tree_corny"), + visinv_bulk_optimize = true +}) +------------------------------------------------------------------------ +-- This allows eggcorns to be used in a cook recipe while still allowing you to 'burn the popcorn' +minetest.override_item("nc_tree:eggcorn", + {groups = {flammable = 20}} +) +------------------------------------------------------------------------ +local function findheat(pos) + return nodecore.find_nodes_around(pos, "group:damage_radiant") +end +-- gentle application of heat is important -- +nodecore.register_aism({ + label = "pop eggcorns", + interval = 4, + chance = 4, + arealoaded = 1, + itemnames = {"nc_tree:eggcorn"}, + action = function(stack, data) + if #findheat(data.pos) > 1 then + nodecore.sound_play("nc_api_craft_hiss", {gain = 0.02, pos = data.pos}) + local taken = stack:take_item(1) + taken:set_name(modname .. ":cornplank") + if data.inv then taken = data.inv:add_item("main", taken) end + if not taken:is_empty() then nodecore.item_eject(data.pos, taken) end + return stack + end + end +}) diff --git a/reinforced.lua b/reinforced.lua new file mode 100644 index 0000000..251c6fb --- /dev/null +++ b/reinforced.lua @@ -0,0 +1,81 @@ +-- LUALOCALS < --------------------------------------------------------- +local minetest, nodecore, pairs, vector + = minetest, nodecore, pairs, vector +-- LUALOCALS > --------------------------------------------------------- +local modname = minetest.get_current_modname() +------------------------------------------------------------------------ +local glare = "nc_optics_glass_glare.png" +local edges = "nc_optics_glass_edges.png" +local clear = glare.. "^" ..edges +local alode = "nc_lode_annealed.png" +local tlode = "nc_lode_tempered.png" +local lmesh = alode.. "^[mask:nc_concrete_pattern_hashy.png" +local frame = alode.. "^[mask:nc_api_storebox_frame.png" +------------------------------------------------------------------------ +local rglass = glare.. "^" ..lmesh +local rgedge = frame.. "^" ..edges +------------------------------------------------------------------------ +local src = "nc_optics:glass_hot_source" +local flow = "nc_optics:glass_hot_flowing" +------------------------------------------------------------------------ +local function near(pos, crit) + return #nodecore.find_nodes_around(pos, crit, {1, 1, 1}, {1, 0, 1}) > 0 +end +-- ================================================================== -- +minetest.register_node(modname .. ":glass_hard", { + description = "Reinforced Glass", + drawtype = "glasslike_framed", + tiles = { + "(" ..rglass.. ")^(" ..rgedge.. ")", + rglass + }, + groups = { + silica = 1, + silica_reinforced = 1, + cracky = 4, + lux_absorb = 20, + scaling_time = 300 + }, + sunlight_propagates = true, + paramtype = "light", + sounds = nodecore.sounds("nc_optics_glassy") +}) +-- ================================================================== -- +nodecore.register_craft({ + label = "cool reinforced glass", + action = "cook", + duration = 120, + touchgroups = {flame = 0}, + neargroups = {coolant = 0}, + cookfx = {smoke = true, hiss = true}, + check = function(pos) + return not near(pos, {flow}) + end, + indexkeys = {src}, + nodes = { + { + match = src, + replace = "air" + }, + { + y = -1, + match = "nc_lode:frame_annealed", + replace = modname .. ":glass_hard" + } + } +}) +-- ================================================================== -- +nodecore.register_craft({ + label = "hammer reinforced glass to crude", + action = "pummel", + priority = -1, + toolgroups = {thumpy = 5}, + nodes = { + { + match = {groups = {silica_reinforced = true, visinv = false}}, + replace = "nc_lode:form" + } + }, + items = {"nc_optics:glass_crude"} + }) +-- ================================================================== -- diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..62a71f6 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,5 @@ +# If enabled, stumps exude 'syrup', which then solidifies to lumps of sap. Otherwise stumps simply exude the lumps of sap. +wc_noditions.syrup (Use Syrup Method) bool true + +# If enabled, carpets behave like non-living sponges in almost every way. +wc_noditions.sierpinski (Carpets Behave Like Sponges) bool true \ No newline at end of file diff --git a/sierpinski.lua b/sierpinski.lua new file mode 100644 index 0000000..e5065d6 --- /dev/null +++ b/sierpinski.lua @@ -0,0 +1,131 @@ +-- LUALOCALS < --------------------------------------------------------- +local minetest, nodecore, pairs, vector + = minetest, nodecore, pairs, vector +-- LUALOCALS > --------------------------------------------------------- +local modname = minetest.get_current_modname() +------------------------------------------------------------------------ +local carpetdirs = { + {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 carpetwet = modname .. ":carpet_wet" +------------------------------------------------------------------------ +local function findwater(pos) + return nodecore.find_nodes_around(pos, "group:water") +end + +local function soakup(pos) + local any + for _, p in pairs(findwater(pos)) do + nodecore.node_sound(p, "dig") + minetest.remove_node(p) + any = true + end + return any +end +------------------------------------------------------------------------ +minetest.register_abm({ + label = "carpet wet", + interval = 1, + chance = 10, + nodenames = {modname .. ":carpet"}, + neighbors = {"group:water"}, + action = function(pos) + if soakup(pos) then + nodecore.set_loud(pos, {name = modname .. ":carpet_wet"}) + return nodecore.fallcheck(pos) + end + end + }) + +nodecore.register_aism({ + label = "carpet stack wet", + interval = 1, + chance = 10, + itemnames = {modname .. ":carpet"}, + action = function(stack, data) + if data.pos and soakup(data.pos) then + local taken = stack:take_item(1) + taken:set_name(modname .. ":carpet_wet") + if data.inv then taken = data.inv:add_item("main", taken) end + if not taken:is_empty() then nodecore.item_eject(data.pos, taken) end + return stack + end + end + }) + +minetest.register_abm({ + label = "carpet sun dry", + interval = 1, + chance = 100, + nodenames = {modname .. ":carpet_wet"}, + arealoaded = 1, + action = function(pos) + local above = {x = pos.x, y = pos.y + 1, z = pos.z} + if nodecore.is_full_sun(above) and #findwater(pos) < 1 then + nodecore.sound_play("nc_api_craft_hiss", {gain = 0.02, pos = pos}) + return minetest.set_node(pos, {name = modname .. ":carpet"}) + end + end + }) + +nodecore.register_aism({ + label = "carpet stack sun dry", + interval = 1, + chance = 100, + arealoaded = 1, + itemnames = {modname .. ":carpet_wet"}, + action = function(stack, data) + if data.player and (data.list ~= "main" + or data.slot ~= data.player:get_wield_index()) then return end + if data.pos and nodecore.is_full_sun(data.pos) + and #findwater(data.pos) < 1 then + nodecore.sound_play("nc_api_craft_hiss", {gain = 0.02, pos = data.pos}) + local taken = stack:take_item(1) + taken:set_name(modname .. ":carpet") + if data.inv then taken = data.inv:add_item("main", taken) end + if not taken:is_empty() then nodecore.item_eject(data.pos, taken) end + return stack + end + end + }) + +minetest.register_abm({ + label = "carpet fire dry", + interval = 1, + chance = 20, + nodenames = {modname .. ":carpet_wet"}, + neighbors = {"group:igniter"}, + action = function(pos) + nodecore.sound_play("nc_api_craft_hiss", {gain = 0.02, pos = pos}) + return minetest.set_node(pos, {name = modname .. ":carpet"}) + end + }) +------------------------------------------------------------------------ +nodecore.register_craft({ + label = "squeeze carpet", + action = "pummel", + toolgroups = {thumpy = 1}, + indexkeys = {carpetwet}, + nodes = { + { + match = carpetwet + } + }, + after = function(pos) + local found + for _, d in pairs(carpetdirs) do + local p = vector.add(pos, d) + if nodecore.artificial_water(p, { + matchpos = pos, + match = spongewet, + minttl = 1, + maxttl = 10 + }) then found = true end + end + if found then nodecore.node_sound(pos, "dig") end + end + }) + diff --git a/syrup.lua b/syrup.lua new file mode 100644 index 0000000..128a424 --- /dev/null +++ b/syrup.lua @@ -0,0 +1,111 @@ +-- LUALOCALS < --------------------------------------------------------- +local math, minetest, nodecore, pairs, string, type + = math, minetest, nodecore, pairs, string, type +local math_random + = math.random +local string_sub + = string.sub +-- LUALOCALS > --------------------------------------------------------- +local modname = minetest.get_current_modname() +local saptxr = modname.. "_sap.png" +local sapball = modname .. ":lump_sap" +local sapflam = 60 -- Seems ok for now, will likely adjust after researching chemical properties of various tree saps. +local suff = "_glued" +-- ================================================================== -- +minetest.register_craftitem(sapball, { + description = "Resin", --"Sap Lump", + inventory_image = saptxr.. "^[mask:nc_fire_lump.png", + groups = { + sap = 1, + flammable = sapflam + }, + sounds = nodecore.sounds("nc_terrain_crunchy") +}) +------------------------------------------------------------------------ +minetest.register_node(modname .. ":root_dry", + nodecore.underride({ + tiles = { + "nc_tree_tree_top.png^[colorize:tan:25", + "nc_terrain_dirt.png", + "nc_terrain_dirt.png^(nc_tree_roots.png^[colorize:tan:25)" + } + }, minetest.registered_items["nc_tree:root"]) +) +------------------------------------------------------------------------ +local sapdef = { + description = "Syrup", + drawtype = "liquid", + tiles = {saptxr}, + special_tiles = {saptxr, saptxr}, + use_texture_alpha = "blend", + paramtype = "light", + liquid_viscosity = 20, + liquid_renewable = false, + liquid_range = 1, + walkable = false, + buildable_to = false, + drowning = 6, + drop = "", + groups = { + syrup = 1, + flammable = sapflam, + concrete_wet = 1, -- A humorous afterthought, bonding bricks with syrup/sap + }, + post_effect_color = {a = 225, r = 80, g = 60, b = 20}, + liquid_alternative_flowing = modname .. ":syrup_flowing", + liquid_alternative_source = modname .. ":syrup_source", + sounds = nodecore.sounds("nc_terrain_crunchy") +} +minetest.register_node(modname .. ":syrup_source", + nodecore.underride({ + liquidtype = "source" + }, sapdef)) +minetest.register_node(modname .. ":syrup_flowing", + nodecore.underride({ + liquidtype = "flowing", + drawtype = "flowingliquid", + paramtype2 = "flowingliquid" + }, sapdef)) +-- ================================================================== -- +minetest.register_abm({ -- soaking abm or dnt might be better + label = "syrup exuding", + interval = 12, + chance = 10, + nodenames = {"nc_tree:root"}, + action = function(pos, node) + local above = {x = pos.x, y = pos.y + 1, z = pos.z} + local above_node = minetest.get_node(above) + if above_node.name == "air" then + minetest.set_node(pos, {name = modname.. ":root_dry"}) + nodecore.item_eject(above, {name = modname .. ":syrup_source"}) + end + end +}) +-- ================================================================== -- +minetest.register_abm({ -- might need to make this a dnt when i learn how dnts work + label = "syrup congealing", + interval = 120, + chance = 2, + nodenames = {"group:syrup"}, + action = function(pos, node) + minetest.set_node(pos, {name = "air"}) + if math_random(1, 2) == 1 then return end + nodecore.item_eject(pos, {name = sapball}) + end +}) +-- ================================================================== -- +nodecore.register_craft({ + label = "glue optic", + action = "pummel", + wield = {name = sapball}, + consumewield = 1, + indexkeys = "group:optic_gluable", + duration = 2, + nodes = {{ + match = {groups = {optic_gluable = true}}, stacked = false + }}, + after = function(pos, data) + data.node.name = data.node.name .. suff + return minetest.swap_node(pos, data.node) + end + }) diff --git a/textures/wc_noditions_sap.png b/textures/wc_noditions_sap.png new file mode 100644 index 0000000000000000000000000000000000000000..daebfb6d23d709ef1d4c67d7b1327bf780b5a60a GIT binary patch literal 589 zcmV-T0N2bPDNB8 zb~7$DE;u(kfL#Cp0m?~4K~y+TO_SM9LNO4A`&cM~$f_Xfg&{E_K_e)FvV%f!gSZ3( z(HMQcc@xh!he0lyp0+dp)*kmW*q3oNDYs`^I>yz6^v@#la+8wBN?h87usmHQWK@pH zM>{Q@Vptma4LzgYz1FvN!2ui0tmoZb8Jzp;W+9}&qjFTb#Z74~KquEJaUe4cppg&C zWiFt_un$X7JwpWpLiV0LK!DuCMSN+YejLCFzxr7P;9D(t`v6-m1nQ84FAnfcA%i9)zBP6fgdnj-t%VAZ zgB|Y-0I-BAV~5pb6EKep5N=HYXrh3i%nExj1EQ8Z60^k(K>#5@9zayXL$ZN!K --------------------------------------------------------- +local modname = minetest.get_current_modname() +local checkdirs = { + {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 = 0, y = 1, z = 0} +} +---------------------------------------------------------------------- +nodecore.saptorch_life_base = 600 -- 5x longer than regular torch +function nodecore.get_saptorch_expire(meta, name) + local expire = meta:get_float("expire") or 0 + if expire > 0 then return expire end + local ttl = nodecore.saptorch_life_base + * (nodecore.boxmuller() * 0.1 + 1) + if name then + local id = tonumber(string_sub(name, -1)) + if id and id > 1 then + ttl = ttl * 0.5 ^ (id - 1) + end + end + expire = nodecore.gametime + ttl + meta:set_float("expire", expire) + return expire, true +end +---------------------------------------------------------------------- +local resin = "nc_fire_coal_4.png^(" ..modname.. "_sap.png^[opacity:100)" +minetest.register_alias(modname .. ":saptorch_lit", modname .. ":saptorch_lit_1") +-- ================================================================ -- +minetest.register_node(modname .. ":saptorch", { + description = "Resinated Torch", + drawtype = "mesh", + mesh = "nc_torch_torch.obj", + tiles = { + resin, + "nc_tree_tree_top.png", + resin.. "^[lowpart:50:nc_tree_tree_side.png", + "[combine:1x1" + }, + backface_culling = true, + use_texture_alpha = "clip", + selection_box = nodecore.fixedbox(-1/8, -0.5, -1/8, 1/8, 0.5, 1/8), + collision_box = nodecore.fixedbox(-1/16, -0.5, -1/16, 1/16, 0.5, 1/16), + paramtype = "light", + sunlight_propagates = true, + groups = { + snappy = 1, + falling_node = 1, + flammable = 1, + firestick = 4, + stack_as_node = 1 + }, + sounds = nodecore.sounds("nc_tree_sticky"), + on_ignite = function(pos, node) + minetest.set_node(pos, {name = modname.. ":saptorch_lit"}) + nodecore.get_saptorch_expire(minetest.get_meta(pos)) + nodecore.sound_play("nc_fire_ignite", {gain = 1, pos = pos}) + if node and node.count and node.count > 1 then + nodecore.item_disperse(pos, node.name, node.count - 1) + end + return true + end + }) +nodecore.register_craft({ + label = "assemble saptorch", + normal = {y = 1}, + indexkeys = {modname.. ":lump_sap"}, + nodes = { + {match = modname.. ":lump_sap", replace = "air"}, + {y = -1, match = "nc_torch:torch", replace = modname .. ":saptorch"}, + } + }) +---------------------------------------------------------------------- +nodecore.saptorch_life_stages = 4 +for i = 1, nodecore.saptorch_life_stages do + local alpha = (i - 1) * (256 / nodecore.saptorch_life_stages) + if alpha > 255 then alpha = 255 end + local txr = resin.. "^nc_fire_ember_4.png^(nc_fire_ash.png^[opacity:" + .. alpha .. ")" + minetest.register_node(modname .. ":saptorch_lit_" .. i, { + description = "Lit Resinated Torch", + drawtype = "mesh", + mesh = "nc_torch_torch.obj", + tiles = { + txr, + "nc_tree_tree_top.png", + txr .. "^[lowpart:50:nc_tree_tree_side.png", + { + name = "nc_torch_flame.png", + animation = { + ["type"] = "vertical_frames", + aspect_w = 3, + aspect_h = 8, + length = 0.6 + } + } + }, + backface_culling = true, + use_texture_alpha = "clip", + selection_box = nodecore.fixedbox(-1/8, -0.5, -1/8, 1/8, 0.5, 1/8), + collision_box = nodecore.fixedbox(-1/16, -0.5, -1/16, 1/16, 0.5, 1/16), + paramtype = "light", + sunlight_propagates = true, + light_source = 10 - i, + groups = { + snappy = 1, + falling_node = 1, + stack_as_node = 1, + saptorch_lit = 1, + flame_ambiance = 1 + }, + stack_max = 1, + sounds = nodecore.sounds("nc_tree_sticky"), + preserve_metadata = function(_, _, oldmeta, drops) + drops[1]:get_meta():from_table({fields = oldmeta}) + end, + after_place_node = function(pos, _, itemstack) + minetest.get_meta(pos):from_table(itemstack:get_meta():to_table()) + end, + node_dig_prediction = nodecore.dynamic_light_node(16 - i), + after_destruct = function(pos) + nodecore.dynamic_light_add(pos, 16 - i) + end + }) +end +------------------------------------------------------------------------ +minetest.register_abm({ + label = "saptorch ignite", + interval = 2, + chance = 1, + nodenames = {"group:saptorch_lit"}, + neighbors = {"group:flammable"}, + action_delay = true, + action = function(pos) + for _, ofst in pairs(checkdirs) do + local npos = vector.add(pos, ofst) + local nbr = minetest.get_node(npos) + if minetest.get_item_group(nbr.name, "flammable") > 0 + and not nodecore.quenched(npos) then + nodecore.fire_check_ignite(npos, nbr) + end + end + end + }) +------------------------------------------------------------------------ +local log2 = math_log(2) +local function saptorchlife(expire, pos) + local max = nodecore.saptorch_life_stages + if expire <= nodecore.gametime then return max end + local life = (expire - nodecore.gametime) / nodecore.saptorch_life_base + if life > 1 then return 1 end + local stage = 1 - math_ceil(math_log(life) / log2) + if stage < 1 then return 1 end + if stage > max then return max end + if pos and (stage >= 2) then + nodecore.smokefx(pos, { + time = 1, + rate = (stage - 1) / 2, + scale = 0.25 + }) + end + return stage +end + +local function snufffx(pos) + nodecore.smokeburst(pos, 4) + return nodecore.sound_play("nc_fire_snuff", {gain = 1, pos = pos}) +end +------------------------------------------------------------------------ +minetest.register_abm({ + label = "saptorch snuff", + interval = 1, + chance = 1, + nodenames = {"group:saptorch_lit"}, + action = function(pos, node) + local expire = nodecore.get_saptorch_expire(minetest.get_meta(pos), node.name) + if nodecore.quenched(pos) or nodecore.gametime > expire then + minetest.remove_node(pos) + minetest.add_item(pos, {name = "nc_fire:lump_ash"}) + snufffx(pos) + return + end + local nn = modname .. ":saptorch_lit_" .. saptorchlife(expire, pos) + if node.name ~= nn then + node.name = nn + return minetest.swap_node(pos, node) + end + end + }) +------------------------------------------------------------------------ +nodecore.register_aism({ + label = "saptorch stack interact", + itemnames = {"group:saptorch_lit"}, + action = function(stack, data) + local pos = data.pos + local player = data.player + local wield + if player and data.list == "main" + and player:get_wield_index() == data.slot then + wield = true + pos = vector.add(pos, vector.multiply(player:get_look_dir(), 0.5)) + end + + local expire, dirty = nodecore.get_saptorch_expire(stack:get_meta(), stack:get_name()) + if (expire < nodecore.gametime) + or nodecore.quenched(pos, data.node and 1 or 0.3) then + snufffx(pos) + return "nc_fire:lump_ash" + end + + if wield and math_random() < 0.1 then nodecore.fire_check_ignite(pos) end + + local nn = modname .. ":saptorch_lit_" .. saptorchlife(expire, pos) + if stack:get_name() ~= nn then + stack:set_name(nn) + return stack + elseif dirty then + return stack + end + end + }) +-- ================================================================ -- diff --git a/treesap.lua b/treesap.lua new file mode 100644 index 0000000..f0e76ba --- /dev/null +++ b/treesap.lua @@ -0,0 +1,65 @@ +-- LUALOCALS < --------------------------------------------------------- +local math, minetest, nodecore, pairs, string, type + = math, minetest, nodecore, pairs, string, type +local math_random + = math.random +local string_sub + = string.sub +-- LUALOCALS > --------------------------------------------------------- +local modname = minetest.get_current_modname() +local saptxr = modname.. "_sap.png" +local sapball = modname .. ":lump_sap" +local sapflam = 60 -- Seems ok for now, will likely adjust after researching chemical properties of various tree saps. +local suff = "_glued" +-- ================================================================== -- +minetest.register_craftitem(sapball, { + description = "Resin", --"Sap Lump", + inventory_image = saptxr.. "^[mask:nc_fire_lump.png", + groups = { + sap = 1, + flammable = sapflam + }, + sounds = nodecore.sounds("nc_terrain_crunchy") +}) +------------------------------------------------------------------------ +minetest.register_node(modname .. ":root_dry", + nodecore.underride({ + tiles = { + "nc_tree_tree_top.png^[colorize:tan:25", + "nc_terrain_dirt.png", + "nc_terrain_dirt.png^(nc_tree_roots.png^[colorize:tan:25)" + } + }, minetest.registered_items["nc_tree:root"]) +) +-- ================================================================== -- +minetest.register_abm({ -- soaking abm or dnt might be better + label = "sap exuding", + interval = 60, + chance = 20, + nodenames = {"nc_tree:root"}, + action = function(pos, node) + local above = {x = pos.x, y = pos.y + 1, z = pos.z} + local above_node = minetest.get_node(above) + if above_node.name == "air" then + nodecore.item_eject(above, {name = sapball}) + if math_random(1, 2) == 1 then return end + minetest.set_node(pos, {name = modname.. ":root_dry"}) + end + end +}) +-- ================================================================== -- +nodecore.register_craft({ + label = "glue optic", + action = "pummel", + wield = {name = sapball}, + consumewield = 1, + indexkeys = "group:optic_gluable", + duration = 2, + nodes = {{ + match = {groups = {optic_gluable = true}}, stacked = false + }}, + after = function(pos, data) + data.node.name = data.node.name .. suff + return minetest.swap_node(pos, data.node) + end + })