mg76

riventest.init.lua

Dec 21st, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.62 KB | None | 0 0
  1. GLOWLIKE = function(nodeid,nodename,drawtype)
  2.     if drawtype == nil then
  3.         drawtype = 'glasslike'
  4.         inv_image = minetest.inventorycube("riventest_"..nodeid..".png")
  5.     else
  6.         inv_image = "riventest_"..nodeid..".png"
  7.     end
  8.     minetest.register_node("riventest:"..nodeid, {
  9.         description = nodename,
  10.         drawtype = drawtype,
  11.         tiles = {"riventest_"..nodeid..".png"},
  12.         inventory_image = inv_image,
  13.         light_propagates = true,
  14.         paramtype = "light",
  15.         sunlight_propagates = true,
  16.         light_source = 15   ,
  17.         is_ground_content = true,
  18.         groups = {snappy=2,cracky=3},
  19.         sounds = riventest.node_sound_glass_defaults(),
  20.         node_box = {
  21.             type = "fixed",
  22.             fixed = {-0.125, -0.5, -0.125, 0.125, 0.3, 0.125}
  23.         },
  24.         selection_box = {
  25.             type = "fixed",
  26.             fixed = {-0.14, -0.5, -0.14, 0.14, 0.3, 0.14}
  27.         },
  28.  
  29.     })
  30. end
  31. METALLIKE = function(nodeid, nodename,fence)
  32.     minetest.register_node("riventest:"..nodeid, {
  33.         description = nodename,
  34.         tiles = {"riventest_"..nodeid..".png"},
  35.         is_ground_content = true,
  36.         groups = {bendy=2,cracky=1,melty=2},
  37.         sounds = riventest.node_sound_metal_defaults()
  38.     })
  39.     if fence == true then
  40.         minetest.register_node("riventest:"..nodeid.."_fence", {
  41.             description = nodename.." fence",
  42.             drawtype = "fencelike",
  43.             tiles = {"riventest_"..nodeid..".png"},
  44.             inventory_image = "riventest_"..nodeid.."_fence.png",
  45.             wield_image = "riventest_"..nodeid.."_fence.png",
  46.             paramtype = "light",
  47.             is_ground_content = true,
  48.             selection_box = {
  49.                 type = "fixed",
  50.                 fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
  51.             },
  52.             groups = {bendy=2,cracky=1,melty=2},
  53.             sounds = riventest.node_sound_metal_defaults()
  54.         })
  55.     end
  56. end
  57.  
  58. TREELIKE = function(nodeid, nodename,fence)
  59.     minetest.register_node("riventest:"..nodeid, {
  60.         description = nodename,
  61.         tiles = {"riventest_"..nodeid..".png"},
  62.         is_ground_content = true,
  63.         groups = {snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
  64.         sounds = riventest.node_sound_wood_defaults(),
  65.     })
  66.     if fence == true then
  67.         minetest.register_node("riventest:"..nodeid.."_fence", {
  68.             description = nodename.." fence",
  69.             drawtype = "fencelike",
  70.             tiles = {"riventest_"..nodeid..".png"},
  71.             inventory_image = "riventest_"..nodeid.."_fence.png",
  72.             wield_image = "riventest_"..nodeid.."_fence.png",
  73.             paramtype = "light",
  74.             is_ground_content = true,
  75.             selection_box = {
  76.                 type = "fixed",
  77.                 fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
  78.             },
  79.             groups = {snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2,tree=1},
  80.             sounds = riventest.node_sound_wood_defaults()
  81.         })
  82.     end
  83. end
  84.  
  85. STONELIKE = function(nodeid, nodename)
  86.     minetest.register_node("riventest:"..nodeid, {
  87.         description = nodename,
  88.         tiles = {"riventest_"..nodeid..".png"},
  89.         is_ground_content = true,
  90.         groups = {cracky=3, stone=1},
  91.         sounds = riventest.node_sound_stone_defaults()
  92.     })
  93. end
  94.  
  95. local SOUNDS = {}
  96. SOUNDNODE = function(nodeid, nodename,drawtype)
  97.     SOUNDS[nodeid] = {}
  98.     SOUNDS[nodeid].sounds = {}
  99.     local on_punch = function(pos,node)
  100.         local sound = SOUNDS[nodeid].sounds[minetest.hash_node_position(pos)]
  101.         if sound == nil then
  102.             local wanted_sound = {name=nodeid, gain=1.5}
  103.             SOUNDS[nodeid].sounds[minetest.hash_node_position(pos)] = { handle = minetest.sound_play(wanted_sound, {pos=pos, loop=true}),   name = wanted_sound.name, }
  104.  
  105.         else
  106.             minetest.sound_stop(sound.handle)
  107.             SOUNDS[nodeid].sounds[minetest.hash_node_position(pos)] = nil
  108.         end
  109.  
  110.     end
  111.     after_dig_node = function(pos,node)
  112.         local sound = SOUNDS[nodeid].sounds[minetest.hash_node_position(pos)]
  113.         if sound ~= nil then
  114.             minetest.sound_stop(sound.handle)
  115.             SOUNDS[nodeid].sounds[minetest.hash_node_position(pos)] = nil
  116.             nodeupdate(pos)
  117.         end
  118.     end
  119.     if drawtype == 'signlike' then
  120.         minetest.register_node("riventest:"..nodeid, {
  121.             description = nodename,
  122.             drawtype = "signlike",
  123.             tiles = {"riventest_"..nodeid..'.png'},
  124.             inventory_image = "riventest_"..nodeid..'.png',
  125.             wield_image = "riventest_"..nodeid..'.png',
  126.             paramtype = "light",
  127.             paramtype2 = "wallmounted",
  128.             sunlight_propagates = true,
  129.             walkable = false,
  130.             metadata_name = "sign",
  131.             selection_box = {
  132.                 type = "wallmounted",
  133.             },
  134.             groups = {snappy=2,choppy=2,dig_immediate=2,flammable=2},
  135.             legacy_wallmounted = true,
  136.             sounds = riventest.node_sound_defaults(),
  137.             on_punch = on_punch,
  138.             after_dig_node = after_dig_node,       
  139.         })
  140.     else
  141.         minetest.register_node("riventest:"..nodeid, {
  142.             description = nodename,
  143.             drawtype = 'plantlike',
  144.             tiles = {"riventest_"..nodeid..'.png'},
  145.             inventory_image = "riventest_"..nodeid..'.png',
  146.             wield_image = "riventest_"..nodeid..'.png',
  147.             paramtype = "light",
  148.             groups = {cracky=3},
  149.             sounds = riventest.node_sound_stone_defaults(),
  150.             on_punch = on_punch,   
  151.             after_dig_node = after_dig_node,
  152.         })
  153.     end
  154. end
  155. PLANTLIKE = function(nodeid, nodename,type,option)
  156.     if option == nil then option = false end
  157.  
  158.     local params ={ description = nodename, drawtype = "plantlike", tiles = {"riventest_"..nodeid..'.png'},
  159.     inventory_image = "riventest_"..nodeid..'.png', wield_image = "riventest_"..nodeid..'.png', paramtype = "light",
  160.     sunlight_propagates=true,
  161.     }
  162.        
  163.     if type == 'veg' then
  164.         params.groups = {snappy=2,dig_immediate=3,flammable=2}
  165.         params.sounds = riventest.node_sound_leaves_defaults()
  166.         if option == false then params.walkable = false end
  167.     elseif type == 'met' then           -- metallic
  168.         params.groups = {snappy=1,bendy=2,cracky=1,melty=2}
  169.         params.sounds = riventest.node_sound_stone_defaults()
  170.     elseif type == 'cri' then           -- craft items
  171.         params.groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3}
  172.         params.sounds = riventest.node_sound_wood_defaults()
  173.         if option == false then params.walkable = false end
  174.     elseif type == 'eat' then           -- edible
  175.         params.groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3}
  176.         params.sounds = riventest.node_sound_wood_defaults()
  177.         params.walkable = false
  178.         params.on_use = minetest.item_eat(option)
  179.     end
  180.     minetest.register_node("riventest:"..nodeid, params)
  181. end
  182.  
  183. STONELIKE('rt1','inward-squared brownstone')
  184. METALLIKE('rt2','flower-patterned metal')
  185. STONELIKE('rt3','lined brownestone')
  186. METALLIKE('rt4','metal block')
  187. METALLIKE('rt5','golden block')
  188. PLANTLIKE('rt6_mushroom','mushroom','veg')
  189. STONELIKE('rt7','outward-squared brownstone')
  190. STONELIKE('rt8','cobble brightstone')
  191. GLOWLIKE('rt9_lamppost','turquiose lamppost','plantlike')
  192. GLOWLIKE('rt17_lamppost','orange lamppost','plantlike')
  193. GLOWLIKE('rt18_lamppost','green lamppost','plantlike')
  194. GLOWLIKE('rt19_lamppost','red lamppost','plantlike')
  195. METALLIKE('rt10','rusted metal block')
  196. STONELIKE('rt11','flower-patterned brightstone')
  197. STONELIKE('rt12','mosaic brightstone')
  198.  
  199.  
  200. SOUNDNODE('1','art (1)','signlike')
  201. SOUNDNODE('2','art (2)','signlike')
  202. SOUNDNODE('3','art (3)','signlike')
  203. TREELIKE('wood','wood')
  204. TREELIKE('woodblue','bluewood')
  205. STONELIKE('stone1','brownstone')
  206. STONELIKE('stone2','graystone')
  207. STONELIKE('stoneblue','bluestone')
  208. METALLIKE('metal','black metal')
  209. METALLIKE('bulkhead','metal bulkhead')
  210. STONELIKE('goldstone1','brightstone')
  211. STONELIKE('goldstone2','goldstone')
  212.  
  213. minetest.register_node("riventest:rt15", {
  214.     description = "stained glass",
  215.     drawtype = "nodebox",
  216.     tiles = {"riventest_rt15.png"},
  217. --  inventory_image = minetest.inventorycube("riventest_rt15.png"),
  218.     paramtype = "light",
  219.     paramtype2 = "facedir",
  220.     light_source = LIGHT_MAX-1,
  221.     sunlight_propagates = true,
  222.     is_ground_content = true,
  223.     groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
  224.     sounds = riventest.node_sound_glass_defaults(),
  225. node_box = {
  226.             type = "fixed",
  227.             fixed = {
  228.                 {-0.5, -0.5, -0.1, 0.5,0.5, 0.1},
  229. --              {-0.1, -0.5, -0.5, 0.1, -0.1, 0.5},
  230.  
  231. --              {-0.5, 0.4, 0, 0.5, 0.5, 0.5},
  232. --              {-0.1, -0.1, 0, 0.1, 0.4, 0.5},
  233.             },
  234.         },
  235. selection_box = {
  236.             type = "fixed",
  237.             fixed = {
  238.                 {-0.5, -0.5, -0.1, 0.5,0.5, 0.1},
  239. --              {-0.1, -0.5, -0.5, 0.1, -0.1, 0.5},
  240.  
  241. --              {-0.5, 0.4, 0, 0.5, 0.5, 0.5},
  242. --              {-0.1, -0.1, 0, 0.1, 0.4, 0.5},
  243.             },
  244.         },     
  245. })
  246. minetest.register_node("riventest:glass", {
  247.     description = "glass",
  248.     drawtype = "glasslike",
  249.     tiles = {"riventest_glass.png"},
  250.     inventory_image = minetest.inventorycube("riventest_glass.png"),
  251.     paramtype = "light",
  252.     sunlight_propagates = true,
  253.     is_ground_content = true,
  254.     groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
  255.     sounds = riventest.node_sound_glass_defaults(),
  256. })
  257. minetest.register_node("riventest:rt16", {
  258.     description = "puzzle book",
  259.     drawtype = "signlike",
  260.     tiles = {"riventest_rt16.png"},
  261.     inventory_image = "riventest_rt16.png",
  262.     wield_image = "riventest_rt16.png",
  263.     paramtype = "light",
  264.     paramtype2 = "wallmounted",
  265.     light_propagates = true,
  266.     sunlight_propagates = true,
  267.     light_source = 10,
  268.     walkable = false,
  269.  
  270.     selection_box = {
  271.         type = "wallmounted",
  272.     },
  273.     groups = {choppy=2,dig_immediate=2,flammable=3},
  274.     legacy_wallmounted = true,
  275.     sounds = riventest.node_sound_defaults(),
  276. })
  277. extend_chain = function(pos)
  278.    
  279.     local upos = {x=pos.x,y=pos.y-1,z=pos.z}
  280.     local apos = {x=pos.x,y=pos.y+1,z=pos.z}
  281.    
  282.     local unode = minetest.env:get_node(upos)
  283.     local anode = minetest.env:get_node(apos)
  284.     if unode.name == 'air' then
  285.         minetest.env:add_node( upos, { name = 'riventest:chain'} ) 
  286.         extend_chain(upos)
  287.     end
  288.     if anode.name == 'air' then
  289.         minetest.env:add_node( apos, { name = 'riventest:chain'} ) 
  290.         extend_chain(apos)
  291.     end
  292.  
  293. end
  294. minetest.register_node("riventest:chain", {
  295.     description = "chain",
  296.     drawtype = "plantlike",
  297.     visual_scale = 1.0,
  298.     tiles = {"riventest_chain.png"},
  299.     inventory_image = "riventest_chain.png",
  300.     wield_image = "riventest_chain.png",
  301.     paramtype = "light",
  302.     walkable = false,
  303.     climbable = true,
  304.     buildable_to = true,
  305.     groups = {snappy=2,melty=2,dig_immediate=3},
  306.     sounds = riventest.node_sound_wood_defaults(),
  307.     after_place_node = extend_chain,
  308. })
  309. minetest.register_node("riventest:water_flowing", {
  310.     description = "flowing water",
  311.     inventory_image = minetest.inventorycube("riventest_altwater.png"),
  312.     drawtype = "flowingliquid",
  313.     tiles = {"riventest_altwater.png"},
  314.     alpha = WATER_ALPHA,
  315.     paramtype = "light",
  316.     light_source = 0,  
  317.     walkable = false,
  318.     pointable = false,
  319.     diggable = false,
  320.     buildable_to = true,
  321.     drop = "",
  322.     liquidtype = "flowing",
  323.     liquid_alternative_flowing = "riventest:water_flowing",
  324.     liquid_alternative_source = "riventest:water_source",
  325.     liquid_viscosity = WATER_VISC,
  326.     post_effect_color = {a=64, r=100, g=100, b=200},
  327.     special_materials = {
  328.         {image="riventest_altwater.png", backface_culling=false},
  329.         {image="riventest_altwater.png", backface_culling=true},
  330.     },
  331.     groups = {water=3, liquid=3, puts_out_fire=1, not_in_creative_inventory=1 },
  332. })
  333.  
  334. minetest.register_node("riventest:water_source", {
  335.     description = "water source",
  336.     inventory_image = minetest.inventorycube("riventest_altwater.png"),
  337.     drawtype = "liquid",
  338.     tiles = {"riventest_altwater.png"},
  339.     alpha = WATER_ALPHA,
  340.     paramtype = "light",
  341.     light_source = 0,
  342.     walkable = false,
  343.     pointable = false,
  344.     diggable = false,
  345.     buildable_to = true,
  346.     drop = "",
  347.     liquidtype = "source",
  348.     liquid_alternative_flowing = "riventest:water_flowing",
  349.     liquid_alternative_source = "riventest:water_source",
  350.     liquid_viscosity = WATER_VISC,
  351.     post_effect_color = {a=64, r=100, g=100, b=200},
  352.     special_materials = {
  353.         -- New-style water source material (mostly unused)
  354.         {image="riventest_altwater.png", backface_culling=false},
  355.     },
  356.     groups = {water=3, liquid=3, puts_out_fire=1},
  357. })
  358.  
  359. minetest.register_node("riventest:beetle", {
  360.     description = "decorational beetle",
  361.     drawtype = "signlike",
  362.     tiles = {"riventest_beetle.png"},
  363.     inventory_image = "riventest_beetle.png",
  364.     wield_image = "riventest_beetle.png",
  365.     paramtype = "light",
  366.     paramtype2 = "wallmounted",
  367.     light_propagates = true,
  368.     sunlight_propagates = true,
  369.     light_source = 10,
  370.     walkable = false,
  371.  
  372.     selection_box = {
  373.         type = "wallmounted",
  374.     },
  375.     groups = {choppy=2,dig_immediate=2},
  376.     legacy_wallmounted = true,
  377.     sounds = riventest.node_sound_defaults(),
  378. })
  379. minetest.register_node("riventest:dagger", {
  380.     description = "decorational dagger",
  381.     drawtype = "signlike",
  382.     tiles = {"riventest_dagger.png"},
  383.     inventory_image = "riventest_dagger.png",
  384.     wield_image = "riventest_dagger.png",
  385.     paramtype = "light",
  386.     paramtype2 = "wallmounted",
  387.     sunlight_propagates = true,
  388.     walkable = false,
  389.     metadata_name = "sign",
  390.     selection_box = {
  391.         type = "wallmounted",
  392.         wall_top =  {-0.5, 0.45, -0.1875,   0.5,  0.5,  0.1875},
  393.         wall_bottom =   {-0.5, -0.5, -0.1875,   0.5, -0.45, 0.1875},
  394.         wall_side = {-0.5, -0.5, -0.1875, -0.45,  0.5,  0.1875},
  395.     },
  396.     groups = {choppy=2,dig_immediate=2},
  397.     legacy_wallmounted = true,
  398.     sounds = riventest.node_sound_defaults(),
  399. })
  400. minetest.register_tool("riventest:tool", {
  401.     description = "dagger",
  402.     inventory_image = "riventest_tool.png",
  403.     tool_capabilities = {
  404.         full_punch_interval = 0.5,
  405.         max_drop_level=3,
  406.         groupcaps={
  407.             fleshy={times={[1]=6.00, [2]=3, [3]=1}, uses=10, maxlevel=3},
  408.             cracky={times={[1]=0.1, [2]=0.1, [3]=0.1}, uses=5000, maxlevel=3},
  409.             crumbly={times={[1]=0.1, [2]=0.1, [3]=0.1}, uses=5000, maxlevel=3},
  410.             snappy={times={[1]=0.1, [2]=0.1, [3]=0.1}, uses=5000, maxlevel=3}
  411.         }
  412.     },
  413. })
  414.  
  415. minetest.register_alias('rtt1', 'riventest:1')
  416. minetest.register_alias('rtt2', 'riventest:2')
  417. minetest.register_alias('rtt3', 'riventest:3')
  418. minetest.register_alias('rtbluewood', 'riventest:woodblue')
  419. minetest.register_alias('rtstone1', 'riventest:stone1')
  420. minetest.register_alias('rtstone2', 'riventest:stone2')
  421. minetest.register_alias('rtbluestone', 'riventest:stoneblue')
  422. minetest.register_alias('rtmetal', 'riventest:metal')
  423. minetest.register_alias('rtbulkhead', 'riventest:bulkhead')
  424. minetest.register_alias('rtgold1', 'riventest:goldstone1')
  425. minetest.register_alias('rtgold2', 'riventest:goldstone2')
  426. minetest.register_alias('rtglass', 'riventest:glass')
  427. minetest.register_alias('rtwood', 'riventest:wood')
  428. minetest.register_alias('rtchain', 'riventest:chain')
  429. minetest.register_alias('rtbeetle', 'riventest:beetle')
  430. minetest.register_alias('rtdagger', 'riventest:dagger')
  431. minetest.register_alias('rttool', 'riventest:tool')
  432. minetest.register_alias('rtwater', 'riventest:water_source')
  433. minetest.register_alias('bluebook', 'riventest:linkingbook')
  434. minetest.register_alias('redbook', 'riventest:plinkingbook')
  435. minetest.register_alias('blankbook', 'riventest:blinkingbook')
  436. minetest.register_alias('rttlamp', 'riventest:rt9_lamppost')
  437. minetest.register_alias('rtolamp', 'riventest:rt17_lamppost')
  438. minetest.register_alias('rtglamp', 'riventest:rt18_lamppost')
  439. minetest.register_alias('rtrlamp', 'riventest:rt19_lamppost')
  440. minetest.register_alias('rtpuzzle', 'riventest:rt16')
  441. minetest.register_alias('rtmushroom', 'riventest:rt6_mushroom')
Advertisement
Add Comment
Please, Sign In to add comment