diff --git a/README.md b/README.md index 2765530..bafc5b8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,33 @@ # panes_embedded Mod for MineTest. Want to place xpanes, but there's already an arc? Now you can. + +No textures included! + +xpanes as such are nice and can be used for many purposes. + +But have you ever used arcs, stairs, slabs or similar things and wondered how +to get your glass pane into the place under the arc? You usually can't. +With this mod you can. Its embedded glass pane sits *visually* inside another +block (i.e. your arc), even *physically* seems to be at that place (you can +run against it) - but is *stored* in the node in front of the glass pane +(where you can't place anything else now - but what would you want to place +in front of the window anyway?) + +There are some situations where xpanes may have the right texture for your +purpose - but you don't want the glass pane to sit in the center of the +block, but rather at its front/back - like a thin glass slab from the circular +saw in moreblocks. For that purpose, the *unconnected* panes have been added. +They behave just like thin glass slabs from the saw. + +Crafting: + xpanes glass pane -> unconnected pane -> embedded pane -> xpanes glass pane + +The two new pane types (embedded and unconnected) are added for each pane that +has been added by/through xpanes (more precisely: for each node with the group +"pane"). + +If some xpanes panes don't show up, make sure that this mod here optionally +depends on the mod that defines the desired panes. + +Note: The panes defined here do not automaticly connect to other blocks. +They're just normal blocks in that regard. diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..22a7e8c --- /dev/null +++ b/depends.txt @@ -0,0 +1,3 @@ +xpanes? +yl_xpanes? +jonez? diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..9e097cb --- /dev/null +++ b/init.lua @@ -0,0 +1,108 @@ +panes_embedded = {} + +panes_embedded.add_pane = function(name, def, orig_name) + -- xpanes defines *two* nodes per pane; we only need one here + if(minetest.registered_nodes[ "panes_embedded:" .. name .. "_embedded" ]) then + return false + end + -- this cannot register as a pane because auto-connecting would screw things up + local groups_without_pane = table.copy(def.groups) + groups_without_pane.pane = nil + -- when two textures take up the same place, it might get a bit messy; + -- thus: make the pane a tiny bit smaller + local no_flicker = 1/4096 + minetest.register_node(":panes_embedded:" .. name .. "_embedded", { + description = "Embedded "..tostring(def.description), + drawtype = "nodebox", + paramtype = "light", + is_ground_content = false, + sunlight_propagates = true, + inventory_image = def.inventory_image, + wield_image = def.wield_image, + paramtype2 = "facedir", + tiles = def.tiles, +-- change compared to xpanes: it is *not* a pane in the technical sense (relevant for abms) + groups = groups_without_pane, +-- change compared to xpanes: drops itself +-- drop = "xpanes:" .. name .. "_flat", -- no: drops itself + sounds = def.sounds, + use_texture_alpha = def.use_texture_alpha and "blend" or "clip", + -- this pane does not (visually) sit in the middle of the node it is placed (and stoerd) in + -- but in the node *behind* that one + node_box = { + type = "fixed", + fixed = {{-1/2+no_flicker, -1/2+no_flicker, -1/32+1, 1/2-no_flicker, 1/2-no_flicker, 1/32+1}}, + }, + selection_box = { + type = "fixed", + fixed = {{-1/2, -1/2, -8/32+0.5, 1/2, 1/2, 1.0}}, + }, +-- change compared to xpanes: no connected sides - the pane visually sits elsewhere; +-- behaving as a normal pane would be very problematic +-- connect_sides = { "left", "right" }, + }) + + -- lone-standing pane; more or less the same as above, but not moved to the node behind - only + -- to the edge of its own node (sometimes helpful for building something; those xpanes can be + -- terribly annoying when they decide to connect to chairs and the like) + no_flicker = 0 + minetest.register_node(":panes_embedded:" .. name.."_unconnected", { + description = "Unconnected "..tostring(def.description), + drawtype = "nodebox", + paramtype = "light", + is_ground_content = false, + sunlight_propagates = true, + inventory_image = def.inventory_image, + wield_image = def.wield_image, + paramtype2 = "facedir", + tiles = def.tiles, +-- change compared to xpanes: it is *not* a pane in the technical sense (relevant for abms) + groups = groups_without_pane, +-- change compared to xpanes: drops itself +-- drop = "xpanes:" .. name .. "_flat", -- no: drops itself + sounds = def.sounds, + use_texture_alpha = def.use_texture_alpha and "blend" or "clip", + node_box = { + type = "fixed", + fixed = {{-1/2, -1/2, 0.5, 1/2, 1/2, 0.5-2/32}}, + }, + selection_box = { + type = "fixed", + fixed = {{-1/2, -1/2, 0.5, 1/2, 1/2, 1/2-4/32}}, + }, +-- change compared to xpanes: no connected sides - the pane visually sits elsewhere; +-- behaving as a normal pane would be very problematic +-- connect_sides = { "left", "right" }, + }) + + -- craft chain: from xpane to the unconnected to the embedded one + minetest.register_craft({ + output = "panes_embedded:" .. name.."_unconnected", + recipe = { + {orig_name}, + } + }) + + minetest.register_craft({ + output = "panes_embedded:" .. name .. "_embedded", + recipe = { + {"panes_embedded:" .. name.."_unconnected"}, + } + }) + + minetest.register_craft({ + output = orig_name, + recipe = { + {"panes_embedded:" .. name.."_embedded"}, + } + }) + -- embedded pane successfully created + return ture +end + +for k, v in pairs(minetest.registered_nodes) do + if(minetest.get_item_group(k, "pane") > 0) then + local parts = string.split(k, ":") + panes_embedded.add_pane(parts[1].."_"..parts[2], v, k) + end +end diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..09553c3 --- /dev/null +++ b/mod.conf @@ -0,0 +1,5 @@ +name = panes_embedded +description = Place glass panes into arcs, slabs and other nodes. +optional_depends = xpanes, yl_xpanes, jonez +author = Sokomine +title = Panes embedded in other nodes diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..2bc79cf Binary files /dev/null and b/screenshot.png differ