123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- -- [Mod] Simple Arcs [pkarcs]
- -- by PEAK
- -- 06-05-2017
- pkarcs = {}
- -- define nodes
- function pkarcs.register_all(nodename, desc, tile, sound, group, craftmaterial)
- local tile_collection
- if type(tile) == "string" then
- tile_collection[1] = tile
- else
- tile_collection = table.copy(tile)
- end
- minetest.register_node(":pkarcs:"..nodename.."_arc", {
- description = desc.." Arc",
- paramtype = "light",
- paramtype2 = "facedir",
- tiles = tile_collection,
- drawtype = "mesh",
- mesh = 'pkarcs_center.obj',
- groups = group,
- sounds = sound,
- on_place = function(itemstack, placer, pointed_thing)
- if pointed_thing.type ~= "node" then
- return itemstack
- end
- local p1 = pointed_thing.under
- local p0 = pointed_thing.above
- local param2 = 0
- local placer_pos = placer:get_pos()
- if placer_pos then
- local dir = {
- x = p1.x - placer_pos.x,
- y = p1.y - placer_pos.y,
- z = p1.z - placer_pos.z
- }
- param2 = minetest.dir_to_facedir(dir)
- end
- if p0.y-1 == p1.y then
- param2 = param2 + 20
- if param2 == 21 then
- param2 = 23
- elseif param2 == 23 then
- param2 = 21
- end
- end
- local NROT = 4 -- Number of possible "rotations" (4 Up down left right)
- local rot = param2 % NROT
- local wall = math.floor(param2/NROT)
- if rot >=3 then
- rot = 0
- else
- rot = rot +1
- end
- param2 = wall*NROT+rot
- return minetest.item_place(itemstack, placer, pointed_thing, param2)
- end,
- })
- minetest.register_node(":pkarcs:"..nodename.."_outer_arc", {
- description = desc.." Outer Arc",
- paramtype = "light",
- paramtype2 = "facedir",
- tiles = tile_collection,
- drawtype = "mesh",
- mesh = 'pkarcs_O_corner.obj',
- groups = group,
- sounds = sound,
- on_place = function(itemstack, placer, pointed_thing)
- if pointed_thing.type ~= "node" then
- return itemstack
- end
- local p1 = pointed_thing.under
- local p0 = pointed_thing.above
- local param2 = 0
- local placer_pos = placer:get_pos()
- if placer_pos then
- local dir = {
- x = p1.x - placer_pos.x,
- y = p1.y - placer_pos.y,
- z = p1.z - placer_pos.z
- }
- param2 = minetest.dir_to_facedir(dir)
- end
- if p0.y-1 == p1.y then
- param2 = param2 + 20
- if param2 == 21 then
- param2 = 23
- elseif param2 == 23 then
- param2 = 21
- end
- end
- local NROT = 4 -- Number of possible "rotations" (4 Up down left right)
- local rot = param2 % NROT
- local wall = math.floor(param2/NROT)
- if rot >=3 then
- rot = 0
- else
- rot = rot +1
- end
- param2 = wall*NROT+rot
- return minetest.item_place(itemstack, placer, pointed_thing, param2)
- end,
- })
- minetest.register_node(":pkarcs:"..nodename.."_inner_arc", {
- description = desc.." Inner Arc",
- paramtype = "light",
- paramtype2 = "facedir",
- tiles = tile_collection,
- drawtype = "mesh",
- mesh = 'pkarcs_I_corner.obj',
- groups = group,
- sounds = sound,
- on_place = function(itemstack, placer, pointed_thing)
- if pointed_thing.type ~= "node" then
- return itemstack
- end
- local p1 = pointed_thing.under
- local p0 = pointed_thing.above
- local param2 = 0
- local placer_pos = placer:get_pos()
- if placer_pos then
- local dir = {
- x = p1.x - placer_pos.x,
- y = p1.y - placer_pos.y,
- z = p1.z - placer_pos.z
- }
- param2 = minetest.dir_to_facedir(dir)
- end
- if p0.y-1 == p1.y then
- param2 = param2 + 20
- if param2 == 21 then
- param2 = 23
- elseif param2 == 23 then
- param2 = 21
- end
- end
- local NROT = 4 -- Number of possible "rotations" (4 Up down left right)
- local rot = param2 % NROT
- local wall = math.floor(param2/NROT)
- if rot >=3 then
- rot = 0
- else
- rot = rot +1
- end
- param2 = wall*NROT+rot
- return minetest.item_place(itemstack, placer, pointed_thing, param2)
- end,
- })
- end
- -- register nodes
- function pkarcs.register_node(name)
- local node_def = minetest.registered_nodes[name]
- if not node_def then
- minetest.log("warning", "[pkarcs] Skipping unknown node: ".. name)
- return
- end
- local node_name = name:split(':')[2]
- if not node_def.tiles then
- node_def.tiles = table.copy(node_def.tile_images)
- node_def.tile_images = nil
- end
- pkarcs.register_all(node_name, node_def.description, node_def.tiles, node_def.sounds, node_def.groups, name)
- end
- function pkarcs.register_craft(station, mod, node)
- pkarcs.register_node(mod..':'..node)
- stations.dual_register_recipe(station, {
- input = {
- [mod..':'..node] = 1,
- },
- output = 'pkarcs:'..node..'_outer_arc 3',
- })
- stations.dual_register_recipe(station, {
- input = {
- [mod..':'..node] = 1,
- },
- output = 'pkarcs:'..node..'_arc 2',
- })
- stations.dual_register_recipe(station, {
- input = {
- [mod..':'..node] = 1,
- },
- output = 'pkarcs:'..node..'_inner_arc',
- })
- end
- pkarcs.register_craft('woodworking', 'default', 'wood')
- pkarcs.register_craft('woodworking', 'default', 'junglewood')
- pkarcs.register_craft('woodworking', 'default', 'pine_wood')
- pkarcs.register_craft('woodworking', 'default', 'acacia_wood')
- pkarcs.register_craft('woodworking', 'default', 'aspen_wood')
- pkarcs.register_craft('stone_carving', 'asteroid', 'redstone')
- pkarcs.register_craft('stone_carving', 'caverealms', 'glow_obsidian')
- pkarcs.register_craft('stone_carving', 'caverealms', 'glow_obsidian_2')
- pkarcs.register_craft('stone_carving', 'darkage', 'basalt')
- pkarcs.register_craft('stone_carving', 'darkage', 'gneiss')
- pkarcs.register_craft('stone_carving', 'darkage', 'rhyolitic_tuff')
- pkarcs.register_craft('stone_carving', 'darkage', 'marble')
- pkarcs.register_craft('stone_carving', 'darkage', 'ors')
- pkarcs.register_craft('stone_carving', 'darkage', 'schist')
- pkarcs.register_craft('stone_carving', 'darkage', 'serpentine')
- pkarcs.register_craft('stone_carving', 'darkage', 'shale')
- pkarcs.register_craft('stone_carving', 'darkage', 'slate')
- pkarcs.register_craft('stone_carving', 'darkage', 'tuff')
- pkarcs.register_craft('stone_carving', 'default', 'brick')
- pkarcs.register_craft('stone_carving', 'default', 'desert_stone')
- pkarcs.register_craft('stone_carving', 'default', 'desert_sandstone')
- pkarcs.register_craft('stone_carving', 'default', 'obsidian')
- pkarcs.register_craft('stone_carving', 'default', 'sandstone')
- pkarcs.register_craft('stone_carving', 'default', 'silver_sandstone')
- pkarcs.register_craft('stone_carving', 'default', 'stone')
- pkarcs.register_craft('stone_carving', 'default', 'obsidian')
- pkarcs.register_craft('stone_carving', 'moreblocks', 'coal_stone')
- pkarcs.register_craft('stone_carving', 'moreblocks', 'iron_stone')
- pkarcs.register_craft('stone_carving', 'nether', 'rack')
|