stones.lua 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. local stone_cbox = {
  2. type = 'fixed',
  3. fixed = {
  4. {-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
  5. }
  6. }
  7. local sstone_cbox = {
  8. type = 'fixed',
  9. fixed = {
  10. {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5},
  11. }
  12. }
  13. local sq_cbox = {
  14. type = 'fixed',
  15. fixed = {
  16. {-0.4375, -0.5, -0.4375, 0.4375, -0.3125, 0.4375},
  17. {-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
  18. }
  19. }
  20. local s_sq_cbox = {
  21. type = 'fixed',
  22. fixed = {
  23. {-0.4375, -0.5, -0.4375, 0.4375, 0.5, 0.4375},
  24. {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5},
  25. }
  26. }
  27. local smsq_cbox = {
  28. type = 'fixed',
  29. fixed = {
  30. {-0.4375, -0.5, -0.4375, -0.0625, -0.3125, -0.0625},
  31. {-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
  32. {-0.4375, -0.5, 0.0625, -0.0625, -0.3125, 0.4375},
  33. {0.0625, -0.5, -0.4375, 0.4375, -0.3125, -0.0625},
  34. {0.0625, -0.5, 0.0625, 0.4375, -0.3125, 0.4375},
  35. }
  36. }
  37. local s_smsq_cbox = {
  38. type = 'fixed',
  39. fixed = {
  40. {-0.4375, -0.5, -0.4375, -0.0625, 0.5, -0.0625},
  41. {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5},
  42. {-0.4375, -0.5, 0.0625, -0.0625, 0.5, 0.4375},
  43. {0.0625, -0.5, -0.4375, 0.4375, 0.5, -0.0625},
  44. {0.0625, -0.5, 0.0625, 0.4375, 0.5, 0.4375},
  45. }
  46. }
  47. local xsmsq_cbox = {
  48. type = 'fixed',
  49. fixed = {
  50. {-0.4375, -0.5, -0.4375, -0.1875, -0.3125, -0.1875},
  51. {-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
  52. {-0.4375, -0.5, 0.1875, -0.1875, -0.3125, 0.4375},
  53. {0.1875, -0.5, -0.4375, 0.4375, -0.3125, -0.1875},
  54. {0.1875, -0.5, 0.1875, 0.4375, -0.3125, 0.4375},
  55. {-0.4375, -0.5, -0.125, -0.1875, -0.3125, 0.125},
  56. {-0.125, -0.5, 0.1875, 0.125, -0.3125, 0.4375},
  57. {-0.125, -0.5, -0.125, 0.125, -0.3125, 0.125},
  58. {0.1875, -0.5, -0.125, 0.4375, -0.3125, 0.125},
  59. {-0.125, -0.5, -0.4375, 0.125, -0.3125, -0.1875},
  60. }
  61. }
  62. local s_xsmsq_cbox = {
  63. type = 'fixed',
  64. fixed = {
  65. {-0.4375, -0.5, -0.4375, -0.1875, 0.5, -0.1875},
  66. {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5},
  67. {-0.4375, -0.5, 0.1875, -0.1875, 0.5, 0.4375},
  68. {0.1875, -0.5, -0.4375, 0.4375, 0.5, -0.1875},
  69. {0.1875, -0.5, 0.1875, 0.4375, 0.5, 0.4375},
  70. {-0.4375, -0.5, -0.125, -0.1875, 0.5, 0.125},
  71. {-0.125, -0.5, 0.1875, 0.125, 0.5, 0.4375},
  72. {-0.125, -0.5, -0.125, 0.125, 0.5, 0.125},
  73. {0.1875, -0.5, -0.125, 0.4375, 0.5, 0.125},
  74. {-0.125, -0.5, -0.4375, 0.125, 0.5, -0.1875},
  75. }
  76. }
  77. local paver_cbox = {
  78. type = 'fixed',
  79. fixed = {
  80. {-0.5, -0.5, 0.3125, -0.3125, -0.3125, 0.5},
  81. {-0.25, -0.5, 0.3125, -0.0625, -0.3125, 0.5},
  82. {-0.5, -0.5, 0.0625, -0.0625, -0.3125, 0.25},
  83. {0, -0.5, 0.0625, 0.1875, -0.3125, 0.5},
  84. {-0.5, -0.5, -0.4375, -0.3125, -0.3125, 0},
  85. {-0.25, -0.5, -0.1875, 0.1875, -0.3125, 0},
  86. {0.25, -0.5, 0.3125, 0.5, -0.3125, 0.5},
  87. {0.25, -0.5, -0.1875, 0.4375, -0.3125, 0.25},
  88. {-0.25, -0.5, -0.5, -0.0625, -0.3125, -0.25},
  89. {0, -0.5, -0.4375, 0.4375, -0.3125, -0.25},
  90. {-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
  91. }
  92. }
  93. local spaver_cbox = {
  94. type = 'fixed',
  95. fixed = {
  96. {-0.5, -0.5, 0.3125, -0.3125, 0.5, 0.5},
  97. {-0.25, -0.5, 0.3125, -0.0625, 0.5, 0.5},
  98. {-0.5, -0.5, 0.0625, -0.0625, 0.5, 0.25},
  99. {0, -0.5, 0.0625, 0.1875, 0.5, 0.5},
  100. {-0.5, -0.5, -0.4375, -0.3125, 0.5, 0},
  101. {-0.25, -0.5, -0.1875, 0.1875, 0.5, 0},
  102. {0.25, -0.5, 0.3125, 0.5, 0.5, 0.5},
  103. {0.25, -0.5, -0.1875, 0.4375, 0.5, 0.25},
  104. {-0.25, -0.5, -0.5, -0.0625, 0.5, -0.25},
  105. {0, -0.5, -0.4375, 0.4375, 0.5, -0.25},
  106. {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5},
  107. }
  108. }
  109. local ashlar_cbox = {
  110. type = 'fixed',
  111. fixed = {
  112. {-0.5, -0.5, 0.375, -0.375, -0.3125, 0.5},
  113. {-0.5, -0.5, 0.1875, -0.375, -0.3125, 0.3125},
  114. {-0.3125, -0.5, 0.1875, -0.0625, -0.3125, 0.5},
  115. {0, -0.5, 0.375, 0.25, -0.3125, 0.5},
  116. {0.3125, -0.5, 0.375, 0.5, -0.3125, 0.5},
  117. {-0.5, -0.5, -0.1875, -0.1875, -0.3125, 0.125},
  118. {-0.5, -0.5, -0.5, -0.375, -0.3125, -0.25},
  119. {-0.3125, -0.5, -0.375, -0.1875, -0.3125, -0.25},
  120. {-0.125, -0.5, -0.0625, -0.0625, -0.3125, 0.125},
  121. {-0.125, -0.5, -0.375, 0.0625, -0.3125, -0.125},
  122. {0, -0.5, -0.0625, 0.0625, -0.3125, 0},
  123. {0, -0.5, 0.0625, 0.3125, -0.3125, 0.3125},
  124. {0.375, -0.5, 0.1875, 0.5, -0.3125, 0.3125},
  125. {0.375, -0.5, -0.1875, 0.5, -0.3125, 0.125},
  126. {0.125, -0.5, -0.1875, 0.3125, -0.3125, 0},
  127. {0.125, -0.5, -0.375, 0.25, -0.3125, -0.25},
  128. {-0.3125, -0.5, -0.5, -0.0625, -0.3125, -0.4375},
  129. {0, -0.5, -0.5, 0.25, -0.3125, -0.4375},
  130. {0.3125, -0.5, -0.5, 0.5, -0.3125, -0.25},
  131. {-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
  132. }
  133. }
  134. local sashlar_cbox = {
  135. type = 'fixed',
  136. fixed = {
  137. {-0.5, -0.5, 0.375, -0.375, 0.5, 0.5},
  138. {-0.5, -0.5, 0.1875, -0.375, 0.5, 0.3125},
  139. {-0.3125, -0.5, 0.1875, -0.0625, 0.5, 0.5},
  140. {0, -0.5, 0.375, 0.25, 0.5, 0.5},
  141. {0.3125, -0.5, 0.375, 0.5, 0.5, 0.5},
  142. {-0.5, -0.5, -0.1875, -0.1875, 0.5, 0.125},
  143. {-0.5, -0.5, -0.5, -0.375, 0.5, -0.25},
  144. {-0.3125, -0.5, -0.375, -0.1875, 0.5, -0.25},
  145. {-0.125, -0.5, -0.0625, -0.0625, 0.5, 0.125},
  146. {-0.125, -0.5, -0.375, 0.0625, 0.5, -0.125},
  147. {0, -0.5, -0.0625, 0.0625, 0.5, 0},
  148. {0, -0.5, 0.0625, 0.3125, 0.5, 0.3125},
  149. {0.375, -0.5, 0.1875, 0.5, 0.5, 0.3125},
  150. {0.375, -0.5, -0.1875, 0.5, 0.5, 0.125},
  151. {0.125, -0.5, -0.1875, 0.3125, 0.5, 0},
  152. {0.125, -0.5, -0.375, 0.25, 0.5, -0.25},
  153. {-0.3125, -0.5, -0.5, -0.0625, 0.5, -0.4375},
  154. {0, -0.5, -0.5, 0.25, 0.5, -0.4375},
  155. {0.3125, -0.5, -0.5, 0.5, 0.5, -0.25},
  156. {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5},
  157. }
  158. }
  159. local flag_cbox = {
  160. type = 'fixed',
  161. fixed = {
  162. {-0.5, -0.5, 0.0625, -0.0625, -0.3125, 0.5},
  163. {-0.5, -0.5, -0.1875, -0.25, -0.3125, 0},
  164. {-0.5, -0.5, -0.4375, -0.25, -0.3125, -0.25},
  165. {0, -0.5, 0.3125, 0.4375, -0.3125, 0.5},
  166. {0, -0.5, 0.0625, 0.1875, -0.3125, 0.25},
  167. {-0.1875, -0.5, -0.4375, 0.1875, -0.3125, 0},
  168. {0.25, -0.5, -0.1875, 0.4375, -0.3125, 0.25},
  169. {0.25, -0.5, -0.4375, 0.5, -0.3125, -0.25},
  170. {-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
  171. }
  172. }
  173. local sflag_cbox = {
  174. type = 'fixed',
  175. fixed = {
  176. {-0.5, -0.5, 0.0625, -0.0625, 0.5, 0.5},
  177. {-0.5, -0.5, -0.1875, -0.25, 0.5, 0},
  178. {-0.5, -0.5, -0.4375, -0.25, 0.5, -0.25},
  179. {0, -0.5, 0.3125, 0.4375, 0.5, 0.5},
  180. {0, -0.5, 0.0625, 0.1875, 0.5, 0.25},
  181. {-0.1875, -0.5, -0.4375, 0.1875, 0.5, 0},
  182. {0.25, -0.5, -0.1875, 0.4375, 0.5, 0.25},
  183. {0.25, -0.5, -0.4375, 0.5, 0.5, -0.25},
  184. {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5},
  185. }
  186. }
  187. local pin_cbox = {
  188. type = 'fixed',
  189. fixed = {
  190. {-0.5, -0.5, -0.125, -0.25, -0.3125, 0.5},
  191. {-0.5, -0.5, -0.4375, 0.125, -0.3125, -0.1875},
  192. {0.1875, -0.5, -0.4375, 0.4375, -0.3125, 0.1875},
  193. {-0.1875, -0.5, 0.25, 0.4375, -0.3125, 0.5},
  194. {-0.1875, -0.5, -0.125, 0.125, -0.3125, 0.1875},
  195. {-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
  196. }
  197. }
  198. local spin_cbox = {
  199. type = 'fixed',
  200. fixed = {
  201. {-0.5, -0.5, -0.125, -0.25, 0.5, 0.5},
  202. {-0.5, -0.5, -0.4375, 0.125, 0.5, -0.1875},
  203. {0.1875, -0.5, -0.4375, 0.4375, 0.5, 0.1875},
  204. {-0.1875, -0.5, 0.25, 0.4375, 0.5, 0.5},
  205. {-0.1875, -0.5, -0.125, 0.125, 0.5, 0.1875},
  206. {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5},
  207. }
  208. }
  209. local stone_types = { --style, desc, img1, img2
  210. {'square', 'Square', 'concrete', 'square',sq_cbox,s_sq_cbox},
  211. {'square_sm', 'Small Square', 'concrete', 'square_sm',smsq_cbox,s_smsq_cbox},
  212. {'square_xsm', 'Extra Small Square', 'concrete', 'square_xsm',xsmsq_cbox,s_xsmsq_cbox},
  213. {'pavers', 'Paver', 'concrete', 'pavers',paver_cbox,spaver_cbox},
  214. {'ashlar', 'Ashlar', 'concrete', 'ashlar',ashlar_cbox,sashlar_cbox},
  215. {'flagstone', 'Flagstone', 'concrete', 'flagstone',flag_cbox,sflag_cbox},
  216. {'pinwheel', 'Pinwheel', 'concrete', 'pinwheel',pin_cbox,spin_cbox},
  217. }
  218. for i in ipairs (stone_types) do
  219. local style = stone_types[i][1]
  220. local desc = stone_types[i][2]
  221. local img1 = stone_types[i][3]
  222. local img2 = stone_types[i][4]
  223. local cbox = stone_types[i][5]
  224. local scbox = stone_types[i][6]
  225. local color_tab = {
  226. {'black', 'Black', '^[multiply:#2c2c2c'},
  227. {'blue', 'Blue', '^[multiply:#0041f4'},
  228. {'brown', 'Brown', '^[multiply:#6c3800'},
  229. {'cyan', 'Cyan', '^[multiply:cyan'},
  230. {'dark_green', 'Dark Green', '^[multiply:#2b7b00'},
  231. {'dark_grey', 'Dark Grey', '^[multiply:#464646'},
  232. {'green', 'Green', '^[multiply:#67eb1c'},
  233. {'grey', 'Grey', '^[multiply:#818181'},
  234. {'magenta', 'Magenta', '^[multiply:#d80481'},
  235. {'orange', 'Orange', '^[multiply:#e0601a'},
  236. {'pink', 'Pink', '^[multiply:#ffa5a5'},
  237. {'red', 'Red', '^[multiply:#c91818'},
  238. {'violet', 'Violet', '^[multiply:#480680'},
  239. {'white', 'White', '^[multiply:white'},
  240. {'yellow', 'Yellow', '^[multiply:#fcf611'},
  241. {'cement', 'Concrete', ''},
  242. }
  243. for i in ipairs (color_tab) do
  244. local col = color_tab[i][1]
  245. local coldesc = color_tab[i][2]
  246. local alpha = color_tab[i][3]
  247. minetest.register_alias('mylandscaping:stone_'..style,'mylandscaping:stone_'..style..'cement')
  248. minetest.register_node('mylandscaping:stone_'..style..col,{
  249. _doc_items_create_entry = false,
  250. description = desc..' Patio Stone '..coldesc,
  251. drawtype = 'nodebox',
  252. tiles = {
  253. 'mylandscaping_'..img1..'.png^mylandscaping_'..img2..'.png'..alpha,
  254. 'mylandscaping_'..img1..'.png'..alpha,
  255. 'mylandscaping_'..img1..'.png'..alpha,
  256. 'mylandscaping_'..img1..'.png'..alpha,
  257. 'mylandscaping_'..img1..'.png'..alpha,
  258. 'mylandscaping_'..img1..'.png'..alpha,
  259. },
  260. paramtype = 'light',
  261. groups = {cracky = 2, not_in_creative_inventory=ml_visible, ml=1,},
  262. node_box = cbox,
  263. selection_box = stone_cbox,
  264. collision_box = stone_cbox,
  265. sounds = default.node_sound_stone_defaults(),
  266. after_place_node = function(pos, placer, itemstack, pointed_thing)
  267. local nodeu = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
  268. if minetest.get_item_group(nodeu, 'sand') > 0 then
  269. minetest.set_node({x=pos.x, y=pos.y-1, z=pos.z},{name = 'mylandscaping:stone_'..style..'_sand'..col})
  270. minetest.set_node(pos,{name = 'air'})
  271. end
  272. end,
  273. })
  274. minetest.register_node('mylandscaping:stone_'..style..'_sand'..col,{
  275. _doc_items_create_entry = false,
  276. description = desc..' Patio Stone in Sand '..coldesc,
  277. drawtype = 'nodebox',
  278. tiles = {
  279. 'mylandscaping_'..img1..'.png^mylandscaping_'..img2..'.png'..alpha,
  280. 'mylandscaping_'..img1..'.png'..alpha,
  281. 'mylandscaping_'..img1..'.png'..alpha,
  282. 'mylandscaping_'..img1..'.png'..alpha,
  283. 'mylandscaping_'..img1..'.png'..alpha,
  284. 'mylandscaping_'..img1..'.png'..alpha,
  285. },
  286. drop = 'mylandscaping:stone_'..style,
  287. paramtype = 'light',
  288. groups = {cracky = 2, not_in_creative_inventory = 1},
  289. node_box = scbox,
  290. selection_box = sstone_cbox,
  291. collision_box = sstone_cbox,
  292. sounds = default.node_sound_stone_defaults(),
  293. after_dig_node = function(pos, oldnode, oldmetadata, digger)
  294. minetest.set_node(pos,{name = 'default:silver_sand'})
  295. end,
  296. })
  297. end
  298. end