Advertisement
Guest User

Untitled

a guest
Aug 16th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.39 KB | None | 0 0
  1. print (" moredoors Mod Loading ")
  2. --
  3. --moredoors
  4. --
  5. --------------------------------------------------------------------------------
  6.  
  7. local WALLMX = 3
  8. local WALLMZ = 5
  9. local WALLPX = 2
  10. local WALLPZ = 4
  11.  
  12. --------------------------------------------------------------------------------
  13.  
  14. minetest.register_alias('door_steel', 'moredoors:door_steel')
  15. minetest.register_alias('door_cobble', 'moredoors:door_cobble')
  16.  
  17. use on_dig = function( 'moredoors:door_steel', {
  18. description = 'Steel Door',
  19. drawtype = 'signlike',
  20. tile_images = { 'door_steel.png' },
  21. inventory_image = 'door_steel.png',
  22. wield_image = 'door_steel.png',
  23. paramtype2 = 'wallmounted',
  24. selection_box = { type = 'wallmounted' },
  25. groups = { choppy=2, dig_immediate=2 },
  26. })
  27.  
  28. minetest.register_craft( {
  29. output = 'moredoors:door_steel',
  30. recipe = {
  31. { 'default:steel', 'default:steel' },
  32. { 'default:steel', 'default:steel' },
  33. { 'default:steel', 'default:steel' },
  34. },
  35. })
  36.  
  37.  
  38. use on_dig = function( 'moredoors:door_cobble', {
  39. Description = 'Cobble door',
  40. drawtype = 'signlike',
  41. tile_images = { 'door_cobble.png' },
  42. inventory_image = 'door_cobble.png',
  43. paramtype = 'light',
  44. paramtype2 = 'wallmounted',
  45. walkable = true,
  46. selection_box = { type = "wallmounted", },
  47. groups = { choppy=2, dig_immediate=2 },
  48. legacy_wallmounted = true,
  49. drop = 'moredoors:door_cobble',
  50. })
  51.  
  52. minetest.register_craft( {
  53. output = 'moredoors:door_cobble',
  54. recipe = {
  55. { 'default:cobble', 'default:cooble' },
  56. { 'default:cobble', 'default:cobble' },
  57. { 'default:cobble', 'default:cobble' },
  58. },
  59. })
  60.  
  61.  
  62. --------------------------------------------------------------------------------
  63.  
  64. local round = function( n )
  65. if n >= 0 then
  66. return math.floor( n + 0.5 )
  67. else
  68. return math.ceil( n - 0.5 )
  69. end
  70. end
  71.  
  72. local on_door_placed = function( pos, node, placer )
  73. if node.name ~= 'moredoors:door_steel' then return end
  74.  
  75. upos = { x = pos.x, y = pos.y - 1, z = pos.z }
  76. apos = { x = pos.x, y = pos.y + 1, z = pos.z }
  77. und = minetest.env:get_node( upos )
  78. abv = minetest.env:get_node( apos )
  79.  
  80. dir = placer:get_look_dir()
  81.  
  82. if round( dir.x ) == 1 then
  83. newparam = WALLMX
  84. elseif round( dir.x ) == -1 then
  85. newparam = WALLPX
  86. elseif round( dir.z ) == 1 then
  87. newparam = WALLMZ
  88. elseif round( dir.z ) == -1 then
  89. newparam = WALLPZ
  90. end
  91.  
  92. if und.name == 'air' then
  93. minetest.env:add_node( pos, { name = 'moredoors:door_steel', param2 = newparam } )
  94. minetest.env:add_node( upos, { name = 'moredoors:door_steel', param2 = newparam } )
  95. elseif abv.name == 'air' then
  96. minetest.env:add_node( pos, { name = 'moredoors:door_steel', param2 = newparam } )
  97. minetest.env:add_node( apos, { name = 'moredoors:door_steel', param2 = newparam } )
  98. else
  99. minetest.env:remove_node( pos )
  100. placer:get_inventory():add_item( "main", 'moredoors:door_steel' )
  101. minetest.chat_send_player( placer:get_player_name(), 'not enough space' )
  102. end
  103. end
  104.  
  105. local on_door_punched = function( pos, node, puncher )
  106. if string.find( node.name, 'moredoors:door_steel' ) == nil then return end
  107.  
  108. upos = { x = pos.x, y = pos.y - 1, z = pos.z }
  109. apos = { x = pos.x, y = pos.y + 1, z = pos.z }
  110.  
  111. if string.find( node.name, '_c', -2 ) ~= nil then
  112. if node.param2 == WALLPX then
  113. newparam = WALLMZ
  114. elseif node.param2 == WALLMZ then
  115. newparam = WALLMX
  116. elseif node.param2 == WALLMX then
  117. newparam = WALLPZ
  118. elseif node.param2 == WALLPZ then
  119. newparam = WALLPX
  120. end
  121. elseif string.find( node.name, '_o', -2 ) ~= nil then
  122. if node.param2 == WALLMZ then
  123. newparam = WALLPX
  124. elseif node.param2 == WALLMX then
  125. newparam = WALLMZ
  126. elseif node.param2 == WALLPZ then
  127. newparam = WALLMX
  128. elseif node.param2 == WALLPX then
  129. newparam = WALLPZ
  130. end
  131. end
  132.  
  133. local round = function( n )
  134. if n >= 0 then
  135. return math.floor( n + 0.5 )
  136. else
  137. return math.ceil( n - 0.5 )
  138. end
  139. end
  140.  
  141. local on_door_placed = function( pos, node, placer )
  142. if node.name ~= 'moredoors:door_cobble' then return end
  143.  
  144. upos = { x = pos.x, y = pos.y - 1, z = pos.z }
  145. apos = { x = pos.x, y = pos.y + 1, z = pos.z }
  146. und = minetest.env:get_node( upos )
  147. abv = minetest.env:get_node( apos )
  148.  
  149. dir = placer:get_look_dir()
  150.  
  151. if round( dir.x ) == 1 then
  152. newparam = WALLMX
  153. elseif round( dir.x ) == -1 then
  154. newparam = WALLPX
  155. elseif round( dir.z ) == 1 then
  156. newparam = WALLMZ
  157. elseif round( dir.z ) == -1 then
  158. newparam = WALLPZ
  159. end
  160.  
  161. if und.name == 'air' then
  162. minetest.env:add_node( pos, { name = 'moredoors:door_cobble', param2 = newparam } )
  163. minetest.env:add_node( upos, { name = 'moredoors:door_cobble', param2 = newparam } )
  164. elseif abv.name == 'air' then
  165. minetest.env:add_node( pos, { name = 'moredoors:door_cobble', param2 = newparam } )
  166. minetest.env:add_node( apos, { name = 'moredoors:door_cobble', param2 = newparam } )
  167. else
  168. minetest.env:remove_node( pos )
  169. placer:get_inventory():add_item( "main", 'moredoors:door_cobble' )
  170. minetest.chat_send_player( placer:get_player_name(), 'not enough space' )
  171. end
  172. end
  173.  
  174. local on_door_punched = function( pos, node, puncher )
  175. if string.find( node.name, 'moredoors:door_cobble' ) == nil then return end
  176.  
  177. upos = { x = pos.x, y = pos.y - 1, z = pos.z }
  178. apos = { x = pos.x, y = pos.y + 1, z = pos.z }
  179.  
  180. if string.find( node.name, '_c', -2 ) ~= nil then
  181. if node.param2 == WALLPX then
  182. newparam = WALLMZ
  183. elseif node.param2 == WALLMZ then
  184. newparam = WALLMX
  185. elseif node.param2 == WALLMX then
  186. newparam = WALLPZ
  187. elseif node.param2 == WALLPZ then
  188. newparam = WALLPX
  189. end
  190. elseif string.find( node.name, '_o', -2 ) ~= nil then
  191. if node.param2 == WALLMZ then
  192. newparam = WALLPX
  193. elseif node.param2 == WALLMX then
  194. newparam = WALLMZ
  195. elseif node.param2 == WALLPZ then
  196. newparam = WALLMX
  197. elseif node.param2 == WALLPX then
  198. newparam = WALLPZ
  199. end
  200. end
  201. end
  202. --------------------------------------------------------------------------------
  203.  
  204. on_construct = func(pos),( on_door_placed )
  205. on_construct = func(pos),( on_door_punched )
  206. on_construct = func(pos),( on_door_digged )
  207.  
  208. --------------------------------------------------------------------------------
  209. print (" moredoors Mod Loaded ")
  210. print (" Edited by Keegan ")
  211. print (" Lisence - LGPLv2 ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement