123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- --U.N.C.M: Unbreakable Node Clone Maker - By Genshin
- local path = minetest.get_modpath("uncm")
- local nodes_cloned = false
- local count = 0
- print("[Unbreakable Node Clone Maker] Activated!")
- --Dupe dem nodes! :D
- local register_unbreakable_duplicate_node = function(name, def)
- local nodename = "uncm:"..name
- count = count + 1
- --Don't even ask...
- minetest.register_node(nodename,{
- description = def.description.." (Unbreakable)",
- drawtype = def.drawtype,
- mesh = def.mesh, --For fancy schmancy modelers that made nice looking custom nodes
- visual_scale = def.visual_scale,
- tiles = def.tiles,
- groups = {unbreakable = 1, not_in_creative_inventory = 1},
- special_tiles = def. special_tiles,
- use_texture_alpha = def.use_texture_alpha,
- alpha = def.alpha,
- post_effect_color = def.post_effect_color,
- inventory_image = def.inventory_image,
- wield_image = def.wield_image,
- paramtype = def.paramtype,
- none = def.none, --I don't even know why this key exists on the node registration table... ¯\_(ツ)_/¯
- light = def.light,
- paramtype2 = def.paramtype2,
- wallmounted = def.wallmounted,
- facedir = def.facedir,
- is_ground_content = def.is_ground_content,
- sunlight_propagates = def.sunlight_propagates,
- walkable = def.walkable,
- pointable = def.pointable,
- diggable = def.diggable,
- climbable = def.climbable,
- buildable_to = def.buildable_to,
- drop = def.drop,
- stack_max = def.stack_max,
- liquidtype = def.liquidtype,
- liquid_alternative_flowing = def.liquid_alternative_flowing,
- liquid_alternative_source = def.liquid_alternative_source,
- liquid_viscosity = def.liquid_viscosity,
- liquid_renewable = def.liquid_renewable,
- light_source = def.light_source,
- damage_per_second = def.damage_per_second,
- node_box = def.node_box,
- selection_box = def.selection_box,
- collision_box = def.collision_box,
- legacy_facedir_simple = def.legacy_facedir_simple,
- legacy_wallmounted = def.legacy_wallmounted,
- sounds = def.sounds,
- dig = def.dig,
- dug = def.dug,
- on_construct = def.on_construct,
- on_destruct = def.on_destruct,
- after_destruct = def.after_destruct,
- on_place = def.on_place,
- on_drop = def.on_drop,
- on_use = def.on_use,
- on_punch = def.on_punch,
- on_blast = function() end, --Ignores explosions
- on_dig = def.on_dig,
- on_timer = def.on_timer,
- on_receive_fields = def.on_receive_fields,
- allow_metadata_inventory_move = def.allow_metadata_inventory_move,
- allow_metadata_inventory_put = def.allow_metadata_inventory_put,
- allow_metadata_inventory_take = def.allow_metadata_inventory_take,
- on_metadata_inventory_move = def.on_metadata_inventory_move,
- on_metadata_inventory_put = def.on_metadata_inventory_put,
- on_metadata_inventory_take = def.on_metadata_inventory_take,
- after_place_node = def.after_place_node,
- can_dig = def.can_dig,
- after_dig_node = def.after_dig_node,
- on_rightclick = def.on_rightclick,
- on_blast = def.on_blast,
- })
- --And alias this node too so /give would be convenient
- minetest.register_alias("unb_"..name, nodename)
- end
- --The Node Duplication Code
- if nodes_cloned == false then
- --Go through every registered node from the game
- for k,v in pairs(minetest.registered_nodes) do
- local get = tostring(string.match(tostring(k), ":[%w_]+"))
- local nodename = tostring(string.match(get, "[%w_]+")) --only get the name of the node without naming convention
- local nodedef = v
- --Dont make a duplicate of yourself
- if k == "uncm:"..nodename then
- elseif --Would be pointless to duplicate airlike, liquids or things that are unbreakable or not in creative inventory already...
- not (nodedef.drawtype == "airlike" or nodedef.drawtype == "liquid" or nodedef.drawtype == "flowingliquid" or nodedef.groups["unbreakable"] == 1 or nodedef.groups["not_in_creative_inventory"] == 1 ) then
- minetest.log("action", "registered node \""..k.."\" is being duplicated.")
- register_unbreakable_duplicate_node(nodename, nodedef)
- end
- end
- nodes_cloned = true
- end
- --To see results, look at your logs :P
- minetest.log("action", count.." registered nodes were successfully duplicated, each copied node are unbreakable and properly aliased!")
- print("[Unbreakable Node Clone Maker] Node duplication procedure completed!")
|