nodes.lua 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511
  1. -- mods/default/nodes.lua
  2. minetest.register_node("default:stone", {
  3. description = "Stone",
  4. tiles = {"default_stone.png"},
  5. is_ground_content = true,
  6. groups = {cracky=3, stone=1},
  7. drop = 'default:cobble',
  8. legacy_mineral = true,
  9. sounds = default.node_sound_stone_defaults(),
  10. })
  11. minetest.register_node("default:desert_stone", {
  12. description = "Desert Stone",
  13. tiles = {"default_desert_stone.png"},
  14. is_ground_content = true,
  15. groups = {cracky=3, stone=1},
  16. drop = 'default:desert_cobble',
  17. legacy_mineral = true,
  18. sounds = default.node_sound_stone_defaults(),
  19. })
  20. minetest.register_node("default:stone_with_coal", {
  21. description = "Coal Ore",
  22. tiles = {"default_stone.png^default_mineral_coal.png"},
  23. is_ground_content = true,
  24. groups = {cracky=3, stone=1},
  25. drop = 'default:coal_lump',
  26. sounds = default.node_sound_stone_defaults(),
  27. })
  28. minetest.register_node("default:stone_with_iron", {
  29. description = "Iron Ore",
  30. tiles = {"default_stone.png^default_mineral_iron.png"},
  31. is_ground_content = true,
  32. groups = {cracky=2, stone=1},
  33. drop = 'default:iron_lump',
  34. sounds = default.node_sound_stone_defaults(),
  35. })
  36. minetest.register_node("default:stone_with_copper", {
  37. description = "Copper Ore",
  38. tiles = {"default_stone.png^default_mineral_copper.png"},
  39. is_ground_content = true,
  40. groups = {cracky=2},
  41. drop = 'default:copper_lump',
  42. sounds = default.node_sound_stone_defaults(),
  43. })
  44. minetest.register_node("default:stone_with_mese", {
  45. description = "Mese Ore",
  46. tiles = {"default_stone.png^default_mineral_mese.png"},
  47. is_ground_content = true,
  48. groups = {cracky=1},
  49. drop = "default:mese_crystal",
  50. sounds = default.node_sound_stone_defaults(),
  51. })
  52. minetest.register_node("default:stone_with_gold", {
  53. description = "Gold Ore",
  54. tiles = {"default_stone.png^default_mineral_gold.png"},
  55. is_ground_content = true,
  56. groups = {cracky=2},
  57. drop = "default:gold_lump",
  58. sounds = default.node_sound_stone_defaults(),
  59. })
  60. minetest.register_node("default:stonebrick", {
  61. description = "Stone Brick",
  62. tiles = {"default_stone_brick.png"},
  63. groups = {cracky=2, stone=1},
  64. sounds = default.node_sound_stone_defaults(),
  65. })
  66. minetest.register_node("default:stone_block", {
  67. description = "Stone Block",
  68. tiles = {"default_stone_block.png"},
  69. groups = {cracky=2, stone=1},
  70. sounds = default.node_sound_stone_defaults(),
  71. })
  72. minetest.register_node("default:cracked_stonebrick", {
  73. description = "Cracked Stone Brick",
  74. tiles = {"default_cracked_stone_brick.png"},
  75. groups = {cracky=2, stone=1},
  76. sounds = default.node_sound_stone_defaults(),
  77. })
  78. minetest.register_node("default:desert_stonebrick", {
  79. description = "Desert Stone Brick",
  80. tiles = {"default_desert_stone_brick.png"},
  81. groups = {cracky=2, stone=1},
  82. sounds = default.node_sound_stone_defaults(),
  83. })
  84. minetest.register_node("default:desert_stone_block", {
  85. description = "Desert Stone Block",
  86. tiles = {"default_desert_stone_block.png"},
  87. groups = {cracky=2, stone=1},
  88. sounds = default.node_sound_stone_defaults(),
  89. })
  90. minetest.register_node("default:dirt_with_grass", {
  91. description = "Dirt with Grass",
  92. tiles = {"default_grass.png", "default_dirt.png", {name = "default_dirt.png^default_grass_side.png", tileable_vertical = false}},
  93. is_ground_content = true,
  94. groups = {crumbly=3,soil=1},
  95. drop = 'default:dirt',
  96. sounds = default.node_sound_dirt_defaults({
  97. footstep = {name="default_grass_footstep", gain=0.25},
  98. }),
  99. })
  100. minetest.register_node("default:dirt_with_grass_footsteps", {
  101. description = "Dirt with Grass and Footsteps",
  102. tiles = {"default_grass_footsteps.png", "default_dirt.png", {name = "default_dirt.png^default_grass_side.png", tileable_vertical = false}},
  103. is_ground_content = true,
  104. groups = {crumbly=3,soil=1,not_in_creative_inventory=1},
  105. drop = 'default:dirt',
  106. sounds = default.node_sound_dirt_defaults({
  107. footstep = {name="default_grass_footstep", gain=0.25},
  108. }),
  109. })
  110. minetest.register_node("default:dirt_with_snow", {
  111. description = "Dirt with Snow",
  112. tiles = {"default_snow.png", "default_dirt.png", {name = "default_dirt.png^default_snow_side.png", tileable_vertical = false}},
  113. is_ground_content = true,
  114. groups = {crumbly=3},
  115. drop = 'default:dirt',
  116. sounds = default.node_sound_dirt_defaults({
  117. footstep = {name="default_snow_footstep", gain=0.25},
  118. }),
  119. })
  120. minetest.register_node("default:dirt", {
  121. description = "Dirt",
  122. tiles = {"default_dirt.png"},
  123. is_ground_content = true,
  124. groups = {crumbly=3,soil=1},
  125. sounds = default.node_sound_dirt_defaults(),
  126. })
  127. minetest.register_abm({
  128. nodenames = {"default:dirt"},
  129. interval = 2,
  130. chance = 200,
  131. action = function(pos, node)
  132. local above = {x=pos.x, y=pos.y+1, z=pos.z}
  133. local name = minetest.get_node(above).name
  134. local nodedef = minetest.registered_nodes[name]
  135. if nodedef and (nodedef.sunlight_propagates or nodedef.paramtype == "light")
  136. and nodedef.liquidtype == "none"
  137. and (minetest.get_node_light(above) or 0) >= 13 then
  138. if name == "default:snow" or name == "default:snowblock" then
  139. minetest.set_node(pos, {name = "default:dirt_with_snow"})
  140. else
  141. minetest.set_node(pos, {name = "default:dirt_with_grass"})
  142. end
  143. end
  144. end
  145. })
  146. minetest.register_abm({
  147. nodenames = {"default:dirt_with_grass"},
  148. interval = 2,
  149. chance = 20,
  150. action = function(pos, node)
  151. local above = {x=pos.x, y=pos.y+1, z=pos.z}
  152. local name = minetest.get_node(above).name
  153. local nodedef = minetest.registered_nodes[name]
  154. if name ~= "ignore" and nodedef
  155. and not ((nodedef.sunlight_propagates or nodedef.paramtype == "light")
  156. and nodedef.liquidtype == "none") then
  157. minetest.set_node(pos, {name = "default:dirt"})
  158. end
  159. end
  160. })
  161. minetest.register_node("default:gravel", {
  162. description = "Gravel",
  163. tiles = {"default_gravel.png"},
  164. is_ground_content = true,
  165. groups = {crumbly=2, falling_node=1},
  166. sounds = default.node_sound_dirt_defaults({
  167. footstep = {name="default_gravel_footstep", gain=0.5},
  168. dug = {name="default_gravel_footstep", gain=1.0},
  169. }),
  170. })
  171. minetest.register_node("default:sand", {
  172. description = "Sand",
  173. tiles = {"default_sand.png"},
  174. is_ground_content = true,
  175. groups = {crumbly=3, falling_node=1, sand=1},
  176. sounds = default.node_sound_sand_defaults(),
  177. })
  178. minetest.register_node("default:sandstone", {
  179. description = "Sandstone",
  180. tiles = {"default_sandstone.png"},
  181. is_ground_content = true,
  182. groups = {crumbly=2,cracky=3},
  183. sounds = default.node_sound_stone_defaults(),
  184. })
  185. minetest.register_node("default:sandstone_block", {
  186. description = "Sandstone Block",
  187. tiles = {"default_sandstone_block.png"},
  188. is_ground_content = true,
  189. groups = {cracky=3},
  190. sounds = default.node_sound_stone_defaults(),
  191. })
  192. minetest.register_node("default:sandstonebrick", {
  193. description = "Sandstone Brick",
  194. tiles = {"default_sandstone_brick.png"},
  195. is_ground_content = true,
  196. groups = {cracky=2},
  197. sounds = default.node_sound_stone_defaults(),
  198. })
  199. minetest.register_node("default:desert_sand", {
  200. description = "Desert Sand",
  201. tiles = {"default_desert_sand.png"},
  202. is_ground_content = true,
  203. groups = {crumbly=3, falling_node=1, sand=1},
  204. sounds = default.node_sound_sand_defaults(),
  205. })
  206. minetest.register_node("default:desert_sandstone", {
  207. description = "Desert Sandstone",
  208. tiles = {"default_desert_sandstone.png"},
  209. is_ground_content = true,
  210. groups = {crumbly=2,cracky=3},
  211. sounds = default.node_sound_stone_defaults(),
  212. })
  213. minetest.register_node("default:desert_sandstone_block", {
  214. description = "Desert Sandstone Block",
  215. tiles = {"default_desert_sandstone_block.png"},
  216. is_ground_content = true,
  217. groups = {cracky=3},
  218. sounds = default.node_sound_stone_defaults(),
  219. })
  220. minetest.register_node("default:desert_sandstonebrick", {
  221. description = "Desert Sandstone Brick",
  222. tiles = {"default_desert_sandstone_brick.png"},
  223. is_ground_content = true,
  224. groups = {cracky=2},
  225. sounds = default.node_sound_stone_defaults(),
  226. })
  227. minetest.register_node("default:silver_sand", {
  228. description = "Silver Sand",
  229. tiles = {"default_silver_sand.png"},
  230. is_ground_content = true,
  231. groups = {crumbly=3, falling_node=1, sand=1},
  232. sounds = default.node_sound_sand_defaults(),
  233. })
  234. minetest.register_node("default:silver_sandstone", {
  235. description = "Silver Sandstone",
  236. tiles = {"default_silver_sandstone.png"},
  237. is_ground_content = true,
  238. groups = {crumbly=2,cracky=3},
  239. sounds = default.node_sound_stone_defaults(),
  240. })
  241. minetest.register_node("default:silver_sandstone_block", {
  242. description = "Siver Sandstone Block",
  243. tiles = {"default_silver_sandstone_block.png"},
  244. is_ground_content = true,
  245. groups = {cracky=3},
  246. sounds = default.node_sound_stone_defaults(),
  247. })
  248. minetest.register_node("default:silver_sandstonebrick", {
  249. description = "Silver Sandstone Brick",
  250. tiles = {"default_silver_sandstone_brick.png"},
  251. is_ground_content = true,
  252. groups = {cracky=2},
  253. sounds = default.node_sound_stone_defaults(),
  254. })
  255. minetest.register_node("default:clay", {
  256. description = "Clay",
  257. tiles = {"default_clay.png"},
  258. is_ground_content = true,
  259. groups = {crumbly=3},
  260. drop = 'default:clay_lump 4',
  261. sounds = default.node_sound_dirt_defaults(),
  262. })
  263. minetest.register_node("default:brick", {
  264. description = "Brick Block",
  265. tiles = {"default_brick.png"},
  266. is_ground_content = false,
  267. groups = {cracky=3},
  268. sounds = default.node_sound_stone_defaults(),
  269. })
  270. minetest.register_node("default:tree", {
  271. description = "Tree",
  272. tiles = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"},
  273. paramtype2 = "facedir",
  274. is_ground_content = false,
  275. groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
  276. sounds = default.node_sound_wood_defaults(),
  277. on_place = minetest.rotate_node,
  278. on_dig = function(pos, node, digger)
  279. default.dig_tree(pos, node, "default:tree", digger, 20, 2)
  280. end,
  281. })
  282. minetest.register_node("default:jungletree", {
  283. description = "Jungle Tree",
  284. tiles = {"default_jungletree_top.png", "default_jungletree_top.png", "default_jungletree.png"},
  285. paramtype2 = "facedir",
  286. is_ground_content = false,
  287. groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
  288. sounds = default.node_sound_wood_defaults(),
  289. on_place = minetest.rotate_node,
  290. on_dig = function(pos, node, digger)
  291. default.dig_tree(pos, node, "default:jungletree", digger, 12, 5)
  292. end,
  293. })
  294. minetest.register_node("default:junglewood", {
  295. description = "Junglewood Planks",
  296. tiles = {"default_junglewood.png"},
  297. groups = {choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
  298. sounds = default.node_sound_wood_defaults(),
  299. })
  300. minetest.register_node("default:jungleleaves", {
  301. description = "Jungle Leaves",
  302. drawtype = "allfaces_optional",
  303. visual_scale = 1.3,
  304. tiles = {"default_jungleleaves.png"},
  305. paramtype = "light",
  306. waving = 1,
  307. is_ground_content = false,
  308. groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
  309. drop = {
  310. max_items = 1,
  311. items = {
  312. {
  313. -- player will get sapling with 1/20 chance
  314. items = {'default:junglesapling'},
  315. rarity = 20,
  316. },
  317. {
  318. -- player will get leaves only if he get no saplings,
  319. -- this is because max_items is 1
  320. items = {'default:jungleleaves'},
  321. }
  322. }
  323. },
  324. sounds = default.node_sound_leaves_defaults(),
  325. })
  326. minetest.register_node("default:junglesapling", {
  327. description = "Jungle Sapling",
  328. drawtype = "plantlike",
  329. visual_scale = 1.0,
  330. tiles = {"default_junglesapling.png"},
  331. inventory_image = "default_junglesapling.png",
  332. wield_image = "default_junglesapling.png",
  333. paramtype = "light",
  334. walkable = false,
  335. selection_box = {
  336. type = "fixed",
  337. fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
  338. },
  339. groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1},
  340. sounds = default.node_sound_leaves_defaults(),
  341. })
  342. minetest.register_node("default:junglegrass", {
  343. description = "Jungle Grass",
  344. drawtype = "plantlike",
  345. visual_scale = 1.3,
  346. tiles = {"default_junglegrass.png"},
  347. inventory_image = "default_junglegrass.png",
  348. wield_image = "default_junglegrass.png",
  349. paramtype = "light",
  350. walkable = false,
  351. buildable_to = true,
  352. is_ground_content = true,
  353. groups = {snappy=3,flammable=2,flora=1,attached_node=1},
  354. sounds = default.node_sound_leaves_defaults(),
  355. selection_box = {
  356. type = "fixed",
  357. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
  358. },
  359. })
  360. minetest.register_node("default:leaves", {
  361. description = "Leaves",
  362. drawtype = "allfaces_optional",
  363. visual_scale = 1.3,
  364. tiles = {"default_leaves.png"},
  365. paramtype = "light",
  366. waving = 1,
  367. is_ground_content = false,
  368. groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
  369. drop = {
  370. max_items = 1,
  371. items = {
  372. {
  373. -- player will get sapling with 1/20 chance
  374. items = {'default:sapling'},
  375. rarity = 20,
  376. },
  377. {
  378. -- player will get leaves only if he get no saplings,
  379. -- this is because max_items is 1
  380. items = {'default:leaves'},
  381. }
  382. }
  383. },
  384. sounds = default.node_sound_leaves_defaults(),
  385. })
  386. minetest.register_node("default:cactus", {
  387. description = "Cactus",
  388. tiles = {"default_cactus_top.png", "default_cactus_top.png", "default_cactus_side.png"},
  389. paramtype2 = "facedir",
  390. is_ground_content = true,
  391. groups = {snappy=1,choppy=3,flammable=2},
  392. sounds = default.node_sound_wood_defaults(),
  393. on_place = minetest.rotate_node
  394. })
  395. minetest.register_node("default:papyrus", {
  396. description = "Papyrus",
  397. drawtype = "plantlike",
  398. tiles = {"default_papyrus.png"},
  399. inventory_image = "default_papyrus.png",
  400. wield_image = "default_papyrus.png",
  401. paramtype = "light",
  402. paramtype2 = "meshoptions",
  403. place_param2 = 3,
  404. walkable = false,
  405. is_ground_content = true,
  406. selection_box = {
  407. type = "fixed",
  408. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  409. },
  410. groups = {snappy=3,flammable=2},
  411. sounds = default.node_sound_leaves_defaults(),
  412. after_dig_node = function(pos, node, metadata, digger)
  413. default.dig_up(pos, node, digger)
  414. end,
  415. })
  416. default.bookshelf_formspec =
  417. "size[8,7;]"..
  418. "background[8,7;1,1;gui_chestbg.png;true]"..
  419. "listcolors[#606060AA;#888;#141318;#30434C;#FFF]"..
  420. "list[context;books;0,0.3;8,2;]"..
  421. "list[current_player;main;0,2.85;8,1;]"..
  422. "list[current_player;main;0,4.08;8,3;8]"..
  423. "listring[context;books]"..
  424. "listring[current_player;main]"
  425. minetest.register_node("default:bookshelf", {
  426. description = "Bookshelf",
  427. tiles = {"default_wood.png", "default_wood.png", "default_bookshelf.png"},
  428. is_ground_content = false,
  429. groups = {choppy=3,oddly_breakable_by_hand=2,flammable=3},
  430. sounds = default.node_sound_wood_defaults(),
  431. on_construct = function(pos)
  432. local meta = minetest.get_meta(pos)
  433. meta:set_string("formspec", default.bookshelf_formspec)
  434. local inv = meta:get_inventory()
  435. inv:set_size("books", 8*2)
  436. end,
  437. can_dig = function(pos,player)
  438. local meta = minetest.get_meta(pos);
  439. local inv = meta:get_inventory()
  440. return inv:is_empty("books")
  441. end,
  442. allow_metadata_inventory_put = function(pos, listname, index, stack, player)
  443. local meta = minetest.get_meta(pos)
  444. local inv = meta:get_inventory()
  445. local to_stack = inv:get_stack(listname, index)
  446. if listname == "books" then
  447. if stack:get_definition().groups["book"] == 1
  448. and to_stack:is_empty() then
  449. return 1
  450. else
  451. return 0
  452. end
  453. end
  454. end,
  455. allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
  456. local meta = minetest.get_meta(pos)
  457. local inv = meta:get_inventory()
  458. local stack = inv:get_stack(from_list, from_index)
  459. local to_stack = inv:get_stack(to_list, to_index)
  460. if to_list == "books" then
  461. if stack:get_definition().groups["book"] == 1
  462. and to_stack:is_empty() then
  463. return 1
  464. else
  465. return 0
  466. end
  467. end
  468. end,
  469. on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
  470. minetest.log("action", player:get_player_name()..
  471. " moves stuff in bookshelf at "..minetest.pos_to_string(pos))
  472. end,
  473. on_metadata_inventory_put = function(pos, listname, index, stack, player)
  474. minetest.log("action", player:get_player_name()..
  475. " moves stuff to bookshelf at "..minetest.pos_to_string(pos))
  476. end,
  477. on_metadata_inventory_take = function(pos, listname, index, stack, player)
  478. minetest.log("action", player:get_player_name()..
  479. " takes stuff from bookshelf at "..minetest.pos_to_string(pos))
  480. end,
  481. })
  482. minetest.register_node("default:glass", {
  483. description = "Glass",
  484. drawtype = "glasslike_framed_optional",
  485. tiles = {"default_glass.png", "default_glass_detail.png"},
  486. paramtype = "light",
  487. sunlight_propagates = true,
  488. is_ground_content = false,
  489. groups = {cracky=3,oddly_breakable_by_hand=3},
  490. sounds = default.node_sound_glass_defaults(),
  491. })
  492. minetest.register_node("default:rail", {
  493. description = "Rail",
  494. drawtype = "raillike",
  495. tiles = {"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"},
  496. inventory_image = "default_rail.png",
  497. wield_image = "default_rail.png",
  498. paramtype = "light",
  499. walkable = false,
  500. is_ground_content = false,
  501. selection_box = {
  502. type = "fixed",
  503. -- but how to specify the dimensions for curved and sideways rails?
  504. fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
  505. },
  506. groups = {bendy=2,dig_immediate=2,attached_node=1},
  507. })
  508. minetest.register_node("default:wood", {
  509. description = "Wooden Planks",
  510. tiles = {"default_wood.png"},
  511. groups = {choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
  512. sounds = default.node_sound_wood_defaults(),
  513. })
  514. minetest.register_node("default:cloud", {
  515. description = "Cloud",
  516. tiles = {"default_cloud.png"},
  517. sounds = default.node_sound_defaults(),
  518. groups = {not_in_creative_inventory=1},
  519. })
  520. minetest.register_node("default:water_flowing", {
  521. description = "Flowing Water",
  522. drawtype = "flowingliquid",
  523. tiles = {"default_water.png"},
  524. special_tiles = {
  525. {
  526. image="default_water_flowing_animated.png",
  527. backface_culling=false,
  528. animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=0.8}
  529. },
  530. {
  531. image="default_water_flowing_animated.png",
  532. backface_culling=true,
  533. animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=0.8}
  534. },
  535. },
  536. alpha = WATER_ALPHA,
  537. paramtype = "light",
  538. paramtype2 = "flowingliquid",
  539. walkable = false,
  540. pointable = false,
  541. diggable = false,
  542. buildable_to = true,
  543. drop = "",
  544. drowning = 1,
  545. liquidtype = "flowing",
  546. liquid_alternative_flowing = "default:water_flowing",
  547. liquid_alternative_source = "default:water_source",
  548. liquid_viscosity = WATER_VISC,
  549. freezemelt = "default:snow",
  550. post_effect_color = {a=64, r=100, g=100, b=200},
  551. groups = {water=3, liquid=3, puts_out_fire=1, not_in_creative_inventory=1, freezes=1, melt_around=1},
  552. })
  553. minetest.register_node("default:water_source", {
  554. description = "Water Source",
  555. drawtype = "liquid",
  556. tiles = {
  557. {name="default_water_source_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}}
  558. },
  559. special_tiles = {
  560. -- New-style water source material (mostly unused)
  561. {
  562. name="default_water_source_animated.png",
  563. animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0},
  564. backface_culling = false,
  565. }
  566. },
  567. alpha = WATER_ALPHA,
  568. paramtype = "light",
  569. walkable = false,
  570. pointable = false,
  571. diggable = false,
  572. buildable_to = true,
  573. drop = "",
  574. drowning = 1,
  575. liquidtype = "source",
  576. liquid_alternative_flowing = "default:water_flowing",
  577. liquid_alternative_source = "default:water_source",
  578. liquid_viscosity = WATER_VISC,
  579. freezemelt = "default:ice",
  580. post_effect_color = {a=64, r=100, g=100, b=200},
  581. groups = {water=3, liquid=3, puts_out_fire=1, freezes=1},
  582. })
  583. minetest.register_node("default:river_water_source", {
  584. description = "River Water Source",
  585. drawtype = "liquid",
  586. tiles = {
  587. {
  588. name = "default_river_water_source_animated.png",
  589. animation = {
  590. type = "vertical_frames",
  591. aspect_w = 16,
  592. aspect_h = 16,
  593. length = 2.0,
  594. },
  595. },
  596. },
  597. special_tiles = {
  598. {
  599. name = "default_river_water_source_animated.png",
  600. animation = {
  601. type = "vertical_frames",
  602. aspect_w = 16,
  603. aspect_h = 16,
  604. length = 2.0,
  605. },
  606. backface_culling = false,
  607. },
  608. },
  609. alpha = 160,
  610. paramtype = "light",
  611. walkable = false,
  612. pointable = false,
  613. diggable = false,
  614. buildable_to = true,
  615. is_ground_content = false,
  616. drop = "",
  617. drowning = 1,
  618. liquidtype = "source",
  619. liquid_alternative_flowing = "default:river_water_flowing",
  620. liquid_alternative_source = "default:river_water_source",
  621. liquid_viscosity = 1,
  622. liquid_renewable = false,
  623. liquid_range = 2,
  624. post_effect_color = {a = 120, r = 30, g = 76, b = 90},
  625. groups = {water = 3, liquid = 3, puts_out_fire = 1},
  626. })
  627. minetest.register_node("default:river_water_flowing", {
  628. description = "Flowing River Water",
  629. drawtype = "flowingliquid",
  630. tiles = {"default_river_water.png"},
  631. special_tiles = {
  632. {
  633. name = "default_river_water_flowing_animated.png",
  634. backface_culling = false,
  635. animation = {
  636. type = "vertical_frames",
  637. aspect_w = 16,
  638. aspect_h = 16,
  639. length = 0.8,
  640. },
  641. },
  642. {
  643. name = "default_river_water_flowing_animated.png",
  644. backface_culling = true,
  645. animation = {
  646. type = "vertical_frames",
  647. aspect_w = 16,
  648. aspect_h = 16,
  649. length = 0.8,
  650. },
  651. },
  652. },
  653. alpha = 160,
  654. paramtype = "light",
  655. paramtype2 = "flowingliquid",
  656. walkable = false,
  657. pointable = false,
  658. diggable = false,
  659. buildable_to = true,
  660. is_ground_content = false,
  661. drop = "",
  662. drowning = 1,
  663. liquidtype = "flowing",
  664. liquid_alternative_flowing = "default:river_water_flowing",
  665. liquid_alternative_source = "default:river_water_source",
  666. liquid_viscosity = 1,
  667. liquid_renewable = false,
  668. liquid_range = 2,
  669. post_effect_color = {a = 120, r = 30, g = 76, b = 90},
  670. groups = {water = 3, liquid = 3, puts_out_fire = 1,
  671. not_in_creative_inventory = 1},
  672. })
  673. minetest.register_node("default:lava_flowing", {
  674. description = "Flowing Lava",
  675. drawtype = "flowingliquid",
  676. tiles = {"default_lava.png"},
  677. special_tiles = {
  678. {
  679. image="default_lava_flowing_animated.png",
  680. backface_culling=false,
  681. animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3}
  682. },
  683. {
  684. image="default_lava_flowing_animated.png",
  685. backface_culling=true,
  686. animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3}
  687. },
  688. },
  689. paramtype = "light",
  690. paramtype2 = "flowingliquid",
  691. light_source = LIGHT_MAX - 1,
  692. walkable = false,
  693. pointable = false,
  694. diggable = false,
  695. buildable_to = true,
  696. drop = "",
  697. drowning = 1,
  698. liquidtype = "flowing",
  699. liquid_alternative_flowing = "default:lava_flowing",
  700. liquid_alternative_source = "default:lava_source",
  701. liquid_viscosity = LAVA_VISC,
  702. liquid_renewable = false,
  703. damage_per_second = 4*2,
  704. post_effect_color = {a=192, r=255, g=64, b=0},
  705. groups = {lava=3, liquid=2, hot=3, igniter=1, not_in_creative_inventory=1},
  706. })
  707. minetest.register_node("default:lava_source", {
  708. description = "Lava Source",
  709. drawtype = "liquid",
  710. tiles = {
  711. {name="default_lava_source_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}}
  712. },
  713. special_tiles = {
  714. -- New-style lava source material (mostly unused)
  715. {
  716. name="default_lava_source_animated.png",
  717. animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0},
  718. backface_culling = false,
  719. }
  720. },
  721. paramtype = "light",
  722. light_source = LIGHT_MAX - 1,
  723. walkable = false,
  724. pointable = false,
  725. diggable = false,
  726. buildable_to = true,
  727. drop = "",
  728. drowning = 1,
  729. liquidtype = "source",
  730. liquid_alternative_flowing = "default:lava_flowing",
  731. liquid_alternative_source = "default:lava_source",
  732. liquid_viscosity = LAVA_VISC,
  733. liquid_renewable = false,
  734. damage_per_second = 4*2,
  735. post_effect_color = {a=192, r=255, g=64, b=0},
  736. groups = {lava=3, liquid=2, hot=3, igniter=1},
  737. })
  738. minetest.register_node("default:sign_wall", {
  739. description = "Sign",
  740. drawtype = "nodebox",
  741. tiles = {"default_sign.png"},
  742. inventory_image = "default_sign_wall.png",
  743. wield_image = "default_sign_wall.png",
  744. paramtype = "light",
  745. paramtype2 = "wallmounted",
  746. sunlight_propagates = true,
  747. is_ground_content = false,
  748. walkable = false,
  749. node_box = {
  750. type = "wallmounted",
  751. wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125},
  752. wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
  753. wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375},
  754. },
  755. groups = {choppy = 2, dig_immediate = 2, attached_node = 1},
  756. legacy_wallmounted = true,
  757. sounds = default.node_sound_defaults(),
  758. on_construct = function(pos)
  759. --local n = minetest.get_node(pos)
  760. local meta = minetest.get_meta(pos)
  761. meta:set_string("formspec", "field[text;;${text}]")
  762. meta:set_string("infotext", "\"\"")
  763. end,
  764. on_receive_fields = function(pos, formname, fields, sender)
  765. --print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
  766. if minetest.is_protected(pos, sender:get_player_name()) then
  767. minetest.record_protection_violation(pos, sender:get_player_name())
  768. return
  769. end
  770. local meta = minetest.get_meta(pos)
  771. if not fields.text then return end
  772. minetest.log("action", (sender:get_player_name() or "") .. " wrote \"" ..
  773. fields.text .. "\" to sign at " .. minetest.pos_to_string(pos))
  774. meta:set_string("text", fields.text)
  775. meta:set_string("infotext", '"' .. fields.text .. '"')
  776. end,
  777. })
  778. default.chest_formspec =
  779. "size[8,9]"..
  780. "list[current_name;main;0,0;8,4;]"..
  781. "list[current_player;main;0,5;8,4;]"..
  782. "listring[current_name;main]"..
  783. "listring[current_player;main]"..
  784. "background[-0.5,-0.65;9,10.35;gui_chestbg.png]"..
  785. "listcolors[#606060AA;#888;#141318;#30434C;#FFF]"
  786. function default.get_chest_formspec(pos,image)
  787. local spos = pos.x .. "," .. pos.y .. "," ..pos.z
  788. local lid_state = "neither"
  789. local formspec =
  790. "size[8,9]"..
  791. "list[nodemeta:".. spos .. ";main;0,0;8,4;]"..
  792. "list[current_player;main;0,5;8,4;]"..
  793. "listring[nodemeta:".. spos .. ";main]"..
  794. "listring[current_player;main]"..
  795. "background[-0.5,-0.65;9,10.35;"..image.."]"..
  796. "listcolors[#606060AA;#888;#141318;#30434C;#FFF]"
  797. return formspec
  798. end
  799. minetest.register_node("default:chest", {
  800. description = "Chest",
  801. tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
  802. "default_chest_side.png", "default_chest_side.png", "default_chest_front.png"},
  803. paramtype2 = "facedir",
  804. groups = {choppy=2,oddly_breakable_by_hand=2},
  805. legacy_facedir_simple = true,
  806. is_ground_content = false,
  807. sounds = default.node_sound_wood_defaults(),
  808. on_construct = function(pos)
  809. local meta = minetest.get_meta(pos)
  810. meta:set_string("infotext", "Chest")
  811. meta:set_string("formspec", default.chest_formspec)
  812. local inv = meta:get_inventory()
  813. inv:set_size("main", 8*4)
  814. end,
  815. can_dig = function(pos,player)
  816. local meta = minetest.get_meta(pos);
  817. local inv = meta:get_inventory()
  818. return inv:is_empty("main")
  819. end,
  820. on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
  821. minetest.log("action", player:get_player_name()..
  822. " moves stuff in chest at "..minetest.pos_to_string(pos))
  823. end,
  824. on_metadata_inventory_put = function(pos, listname, index, stack, player)
  825. minetest.log("action", player:get_player_name()..
  826. " moves stuff to chest at "..minetest.pos_to_string(pos))
  827. end,
  828. on_metadata_inventory_take = function(pos, listname, index, stack, player)
  829. minetest.log("action", player:get_player_name()..
  830. " takes stuff from chest at "..minetest.pos_to_string(pos))
  831. end,
  832. --backwards compatibility: punch to set formspec
  833. on_punch = function(pos,player)
  834. local meta = minetest.get_meta(pos)
  835. meta:set_string("infotext", "Chest")
  836. meta:set_string("formspec",default.chest_formspec)
  837. end
  838. })
  839. local function has_locked_chest_privilege(meta, player)
  840. if player:get_player_name() ~= meta:get_string("owner") then
  841. return false
  842. end
  843. return true
  844. end
  845. minetest.register_node("default:chest_locked", {
  846. description = "Locked Chest",
  847. tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
  848. "default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"},
  849. paramtype2 = "facedir",
  850. groups = {choppy=2,oddly_breakable_by_hand=2},
  851. legacy_facedir_simple = true,
  852. is_ground_content = false,
  853. sounds = default.node_sound_wood_defaults(),
  854. after_place_node = function(pos, placer)
  855. local meta = minetest.get_meta(pos)
  856. meta:set_string("owner", placer:get_player_name() or "")
  857. meta:set_string("infotext", "Locked Chest (owned by " ..
  858. meta:get_string("owner") .. ")")
  859. end,
  860. on_construct = function(pos)
  861. local meta = minetest.get_meta(pos)
  862. meta:set_string("infotext", "Locked Chest")
  863. meta:set_string("owner", "")
  864. local inv = meta:get_inventory()
  865. inv:set_size("main", 8*4)
  866. end,
  867. can_dig = function(pos,player)
  868. local meta = minetest.get_meta(pos);
  869. local inv = meta:get_inventory()
  870. return inv:is_empty("main") and has_locked_chest_privilege(meta, player)
  871. end,
  872. allow_metadata_inventory_move = function(pos, from_list, from_index,
  873. to_list, to_index, count, player)
  874. local meta = minetest.get_meta(pos)
  875. if not has_locked_chest_privilege(meta, player) then
  876. return 0
  877. end
  878. return count
  879. end,
  880. allow_metadata_inventory_put = function(pos, listname, index, stack, player)
  881. local meta = minetest.get_meta(pos)
  882. if not has_locked_chest_privilege(meta, player) then
  883. return 0
  884. end
  885. return stack:get_count()
  886. end,
  887. allow_metadata_inventory_take = function(pos, listname, index, stack, player)
  888. local meta = minetest.get_meta(pos)
  889. if not has_locked_chest_privilege(meta, player) then
  890. return 0
  891. end
  892. return stack:get_count()
  893. end,
  894. on_metadata_inventory_put = function(pos, listname, index, stack, player)
  895. minetest.log("action", player:get_player_name() ..
  896. " moves stuff to locked chest at " .. minetest.pos_to_string(pos))
  897. end,
  898. on_metadata_inventory_take = function(pos, listname, index, stack, player)
  899. minetest.log("action", player:get_player_name() ..
  900. " takes stuff from locked chest at " .. minetest.pos_to_string(pos))
  901. end,
  902. on_rightclick = function(pos, node, clicker)
  903. local meta = minetest.get_meta(pos)
  904. if has_locked_chest_privilege(meta, clicker) then
  905. minetest.show_formspec(
  906. clicker:get_player_name(),
  907. "default:chest_locked",
  908. default.get_chest_formspec(pos, "gui_chestbg.png")
  909. )
  910. end
  911. end,
  912. })
  913. function default.get_furnace_active_formspec(pos, percent, item_percent)
  914. local formspec =
  915. "size[8,9]"..
  916. "image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
  917. (100-percent)..":default_furnace_fire_fg.png]"..
  918. "image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:"..
  919. (item_percent)..":gui_furnace_arrow_fg.png^[transformR270]"..
  920. "list[current_name;fuel;2,3;1,1;]"..
  921. "list[current_name;src;2,1;1,1;]"..
  922. "list[current_name;dst;5,1;2,2;]"..
  923. "list[current_player;main;0,5;8,4;]"..
  924. "background[-0.5,-0.65;9,10.35;gui_furnacebg.png]"..
  925. "listcolors[#606060AA;#888;#141318;#30434C;#FFF]" ..
  926. "listring[current_name;src]"..
  927. "listring[current_player;main]"
  928. return formspec
  929. end
  930. default.furnace_inactive_formspec =
  931. "size[8,9]"..
  932. "image[2,2;1,1;default_furnace_fire_bg.png]"..
  933. "image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
  934. "list[current_name;fuel;2,3;1,1;]"..
  935. "list[current_name;src;2,1;1,1;]"..
  936. "list[current_name;dst;5,1;2,2;]"..
  937. "list[current_player;main;0,5;8,4;]"..
  938. "background[-0.5,-0.65;9,10.35;gui_furnacebg.png]"..
  939. "listcolors[#606060AA;#888;#141318;#30434C;#FFF]" ..
  940. "listring[current_name;src]"..
  941. "listring[current_player;main]"
  942. minetest.register_node("default:furnace", {
  943. description = "Furnace",
  944. tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png",
  945. "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front.png"},
  946. paramtype2 = "facedir",
  947. groups = {cracky=2},
  948. legacy_facedir_simple = true,
  949. is_ground_content = false,
  950. sounds = default.node_sound_stone_defaults(),
  951. on_construct = function(pos)
  952. local meta = minetest.get_meta(pos)
  953. meta:set_string("formspec", default.furnace_inactive_formspec)
  954. meta:set_string("infotext", "Furnace")
  955. local inv = meta:get_inventory()
  956. inv:set_size("fuel", 1)
  957. inv:set_size("src", 1)
  958. inv:set_size("dst", 4)
  959. end,
  960. can_dig = function(pos,player)
  961. local meta = minetest.get_meta(pos);
  962. local inv = meta:get_inventory()
  963. if not inv:is_empty("fuel") then
  964. return false
  965. elseif not inv:is_empty("dst") then
  966. return false
  967. elseif not inv:is_empty("src") then
  968. return false
  969. end
  970. return true
  971. end,
  972. allow_metadata_inventory_put = function(pos, listname, index, stack, player)
  973. local meta = minetest.get_meta(pos)
  974. local inv = meta:get_inventory()
  975. if listname == "fuel" then
  976. if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
  977. if inv:is_empty("src") then
  978. meta:set_string("infotext","Furnace is empty")
  979. end
  980. return stack:get_count()
  981. else
  982. return 0
  983. end
  984. elseif listname == "src" then
  985. return stack:get_count()
  986. elseif listname == "dst" then
  987. return 0
  988. end
  989. end,
  990. allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
  991. local meta = minetest.get_meta(pos)
  992. local inv = meta:get_inventory()
  993. local stack = inv:get_stack(from_list, from_index)
  994. if to_list == "fuel" then
  995. if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
  996. if inv:is_empty("src") then
  997. meta:set_string("infotext","Furnace is empty")
  998. end
  999. return count
  1000. else
  1001. return 0
  1002. end
  1003. elseif to_list == "src" then
  1004. return count
  1005. elseif to_list == "dst" then
  1006. return 0
  1007. end
  1008. end,
  1009. --backwards compatibility: punch to set formspec
  1010. on_punch = function(pos,player)
  1011. local meta = minetest.get_meta(pos)
  1012. meta:set_string("infotext", "Furnace")
  1013. meta:set_string("formspec",default.furnace_inactive_formspec)
  1014. end
  1015. })
  1016. minetest.register_node("default:furnace_active", {
  1017. description = "Furnace",
  1018. tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png",
  1019. "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front_active.png"},
  1020. paramtype2 = "facedir",
  1021. light_source = 8,
  1022. drop = "default:furnace",
  1023. groups = {cracky=2, not_in_creative_inventory=1,hot=1},
  1024. legacy_facedir_simple = true,
  1025. is_ground_content = false,
  1026. sounds = default.node_sound_stone_defaults(),
  1027. on_construct = function(pos)
  1028. local meta = minetest.get_meta(pos)
  1029. meta:set_string("formspec", default.furnace_inactive_formspec)
  1030. meta:set_string("infotext", "Furnace");
  1031. local inv = meta:get_inventory()
  1032. inv:set_size("fuel", 1)
  1033. inv:set_size("src", 1)
  1034. inv:set_size("dst", 4)
  1035. end,
  1036. can_dig = function(pos,player)
  1037. local meta = minetest.get_meta(pos);
  1038. local inv = meta:get_inventory()
  1039. if not inv:is_empty("fuel") then
  1040. return false
  1041. elseif not inv:is_empty("dst") then
  1042. return false
  1043. elseif not inv:is_empty("src") then
  1044. return false
  1045. end
  1046. return true
  1047. end,
  1048. allow_metadata_inventory_put = function(pos, listname, index, stack, player)
  1049. local meta = minetest.get_meta(pos)
  1050. local inv = meta:get_inventory()
  1051. if listname == "fuel" then
  1052. if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
  1053. if inv:is_empty("src") then
  1054. meta:set_string("infotext","Furnace is empty")
  1055. end
  1056. return stack:get_count()
  1057. else
  1058. return 0
  1059. end
  1060. elseif listname == "src" then
  1061. return stack:get_count()
  1062. elseif listname == "dst" then
  1063. return 0
  1064. end
  1065. end,
  1066. allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
  1067. local meta = minetest.get_meta(pos)
  1068. local inv = meta:get_inventory()
  1069. local stack = inv:get_stack(from_list, from_index)
  1070. if to_list == "fuel" then
  1071. if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
  1072. if inv:is_empty("src") then
  1073. meta:set_string("infotext","Furnace is empty")
  1074. end
  1075. return count
  1076. else
  1077. return 0
  1078. end
  1079. elseif to_list == "src" then
  1080. return count
  1081. elseif to_list == "dst" then
  1082. return 0
  1083. end
  1084. end,
  1085. })
  1086. local function swap_node(pos,name)
  1087. local node = minetest.get_node(pos)
  1088. if node.name == name then
  1089. return
  1090. end
  1091. node.name = name
  1092. minetest.swap_node(pos,node)
  1093. end
  1094. minetest.register_abm({
  1095. nodenames = {"default:furnace","default:furnace_active"},
  1096. interval = 1.0,
  1097. chance = 1,
  1098. action = function(pos, node, active_object_count, active_object_count_wider)
  1099. local meta = minetest.get_meta(pos)
  1100. for i, name in ipairs({
  1101. "fuel_totaltime",
  1102. "fuel_time",
  1103. "src_totaltime",
  1104. "src_time"
  1105. }) do
  1106. if meta:get_string(name) == "" then
  1107. meta:set_float(name, 0.0)
  1108. end
  1109. end
  1110. local inv = meta:get_inventory()
  1111. local srclist = inv:get_list("src")
  1112. local cooked = nil
  1113. local aftercooked
  1114. if srclist then
  1115. cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
  1116. end
  1117. local was_active = false
  1118. if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
  1119. was_active = true
  1120. meta:set_float("fuel_time", meta:get_float("fuel_time") + 1)
  1121. meta:set_float("src_time", meta:get_float("src_time") + 1)
  1122. if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then
  1123. -- check if there's room for output in "dst" list
  1124. if inv:room_for_item("dst",cooked.item) then
  1125. -- Put result in "dst" list
  1126. inv:add_item("dst", cooked.item)
  1127. -- take stuff from "src" list
  1128. inv:set_stack("src", 1, aftercooked.items[1])
  1129. else
  1130. --print("Could not insert '"..cooked.item:to_string().."'")
  1131. end
  1132. meta:set_string("src_time", 0)
  1133. end
  1134. end
  1135. if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
  1136. local percent = math.floor(meta:get_float("fuel_time") /
  1137. meta:get_float("fuel_totaltime") * 100)
  1138. local item_percent = math.floor(meta:get_float("src_time") / cooked.time * 100)
  1139. meta:set_string("infotext","Furnace active: "..percent.."%")
  1140. swap_node(pos,"default:furnace_active")
  1141. meta:set_string("formspec",default.get_furnace_active_formspec(pos, percent, item_percent))
  1142. return
  1143. end
  1144. local fuel = nil
  1145. local afterfuel
  1146. local cooked = nil
  1147. local fuellist = inv:get_list("fuel")
  1148. local srclist = inv:get_list("src")
  1149. if srclist then
  1150. cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
  1151. end
  1152. if fuellist then
  1153. fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
  1154. end
  1155. if not fuel or fuel.time <= 0 then
  1156. meta:set_string("infotext","Furnace out of fuel")
  1157. swap_node(pos,"default:furnace")
  1158. meta:set_string("formspec", default.furnace_inactive_formspec)
  1159. return
  1160. end
  1161. if cooked.item:is_empty() then
  1162. if was_active then
  1163. meta:set_string("infotext","Furnace is empty")
  1164. swap_node(pos,"default:furnace")
  1165. meta:set_string("formspec", default.furnace_inactive_formspec)
  1166. end
  1167. return
  1168. end
  1169. meta:set_string("fuel_totaltime", fuel.time)
  1170. meta:set_string("fuel_time", 0)
  1171. inv:set_stack("fuel", 1, afterfuel.items[1])
  1172. end,
  1173. })
  1174. minetest.register_node("default:cobble", {
  1175. description = "Cobblestone",
  1176. tiles = {"default_cobble.png"},
  1177. is_ground_content = true,
  1178. groups = {cracky=3, stone=2},
  1179. sounds = default.node_sound_stone_defaults(),
  1180. })
  1181. minetest.register_node("default:desert_cobble", {
  1182. description = "Desert Cobble",
  1183. tiles = {"default_desert_cobble.png"},
  1184. is_ground_content = true,
  1185. groups = {cracky=3, stone=2},
  1186. sounds = default.node_sound_stone_defaults(),
  1187. })
  1188. minetest.register_node("default:mossycobble", {
  1189. description = "Mossy Cobblestone",
  1190. tiles = {"default_mossycobble.png"},
  1191. is_ground_content = true,
  1192. groups = {cracky=3},
  1193. sounds = default.node_sound_stone_defaults(),
  1194. })
  1195. minetest.register_node("default:coalblock", {
  1196. description = "Coal Block",
  1197. tiles = {"default_coal_block.png"},
  1198. is_ground_content = true,
  1199. groups = {cracky=3},
  1200. sounds = default.node_sound_stone_defaults(),
  1201. })
  1202. minetest.register_node("default:steelblock", {
  1203. description = "Steel Block",
  1204. tiles = {"default_steel_block.png"},
  1205. is_ground_content = true,
  1206. groups = {cracky=1,level=2},
  1207. sounds = default.node_sound_stone_defaults(),
  1208. })
  1209. minetest.register_node("default:copperblock", {
  1210. description = "Copper Block",
  1211. tiles = {"default_copper_block.png"},
  1212. is_ground_content = true,
  1213. groups = {cracky=1,level=2},
  1214. sounds = default.node_sound_stone_defaults(),
  1215. })
  1216. minetest.register_node("default:bronzeblock", {
  1217. description = "Bronze Block",
  1218. tiles = {"default_bronze_block.png"},
  1219. is_ground_content = true,
  1220. groups = {cracky=1,level=2},
  1221. sounds = default.node_sound_stone_defaults(),
  1222. })
  1223. minetest.register_node("default:mese", {
  1224. description = "Mese Block",
  1225. tiles = {"default_mese_block.png"},
  1226. is_ground_content = true,
  1227. groups = {cracky=1,level=2},
  1228. sounds = default.node_sound_stone_defaults(),
  1229. })
  1230. minetest.register_alias("default:mese_block", "default:mese")
  1231. minetest.register_node("default:goldblock", {
  1232. description = "Gold Block",
  1233. tiles = {"default_gold_block.png"},
  1234. is_ground_content = true,
  1235. groups = {cracky=1},
  1236. sounds = default.node_sound_stone_defaults(),
  1237. })
  1238. minetest.register_node("default:obsidian_glass", {
  1239. description = "Obsidian Glass",
  1240. drawtype = "glasslike_framed_optional",
  1241. tiles = {"default_obsidian_glass.png", "default_obsidian_glass_detail.png"},
  1242. paramtype = "light",
  1243. is_ground_content = false,
  1244. sunlight_propagates = true,
  1245. sounds = default.node_sound_glass_defaults(),
  1246. groups = {cracky=3,oddly_breakable_by_hand=3},
  1247. })
  1248. minetest.register_node("default:obsidian", {
  1249. description = "Obsidian",
  1250. tiles = {"default_obsidian.png"},
  1251. is_ground_content = true,
  1252. sounds = default.node_sound_stone_defaults(),
  1253. groups = {cracky=1,level=2},
  1254. })
  1255. minetest.register_node("default:sapling", {
  1256. description = "Sapling",
  1257. drawtype = "plantlike",
  1258. visual_scale = 1.0,
  1259. tiles = {"default_sapling.png"},
  1260. inventory_image = "default_sapling.png",
  1261. wield_image = "default_sapling.png",
  1262. paramtype = "light",
  1263. walkable = false,
  1264. is_ground_content = true,
  1265. selection_box = {
  1266. type = "fixed",
  1267. fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
  1268. },
  1269. groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1},
  1270. sounds = default.node_sound_leaves_defaults(),
  1271. })
  1272. minetest.register_node("default:apple", {
  1273. description = "Apple",
  1274. drawtype = "plantlike",
  1275. visual_scale = 1.0,
  1276. tiles = {"default_apple.png"},
  1277. inventory_image = "default_apple.png",
  1278. paramtype = "light",
  1279. sunlight_propagates = true,
  1280. walkable = false,
  1281. is_ground_content = true,
  1282. selection_box = {
  1283. type = "fixed",
  1284. fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
  1285. },
  1286. groups = {fleshy=3,dig_immediate=3,flammable=2,leafdecay=3,leafdecay_drop=1},
  1287. on_use = minetest.item_eat(1),
  1288. sounds = default.node_sound_leaves_defaults(),
  1289. after_place_node = function(pos, placer, itemstack)
  1290. if placer:is_player() then
  1291. minetest.set_node(pos, {name="default:apple", param2=1})
  1292. end
  1293. end,
  1294. })
  1295. minetest.register_node("default:dry_shrub", {
  1296. description = "Dry Shrub",
  1297. drawtype = "plantlike",
  1298. visual_scale = 1.0,
  1299. tiles = {"default_dry_shrub.png"},
  1300. inventory_image = "default_dry_shrub.png",
  1301. wield_image = "default_dry_shrub.png",
  1302. paramtype = "light",
  1303. paramtype2 = "meshoptions",
  1304. place_param2 = 42,
  1305. waving = 1,
  1306. walkable = false,
  1307. is_ground_content = true,
  1308. buildable_to = true,
  1309. groups = {snappy=3,flammable=3,attached_node=1},
  1310. sounds = default.node_sound_leaves_defaults(),
  1311. selection_box = {
  1312. type = "fixed",
  1313. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
  1314. },
  1315. })
  1316. minetest.register_node("default:grass_1", {
  1317. description = "Grass",
  1318. drawtype = "plantlike",
  1319. tiles = {"default_grass_1.png"},
  1320. -- use a bigger inventory image
  1321. inventory_image = "default_grass_3.png",
  1322. wield_image = "default_grass_3.png",
  1323. paramtype = "light",
  1324. paramtype2 = "meshoptions",
  1325. walkable = false,
  1326. is_ground_content = true,
  1327. buildable_to = true,
  1328. groups = {snappy=3,flammable=3,flora=1,attached_node=1},
  1329. sounds = default.node_sound_leaves_defaults(),
  1330. selection_box = {
  1331. type = "fixed",
  1332. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
  1333. },
  1334. on_place = function(itemstack, placer, pointed_thing)
  1335. -- place a random grass node
  1336. local stack = ItemStack("default:grass_"..math.random(1,5))
  1337. local ret = minetest.item_place(stack, placer, pointed_thing, 40)
  1338. return ItemStack("default:grass_1 "..itemstack:get_count()-(1-ret:get_count()))
  1339. end,
  1340. })
  1341. for i = 2, 5 do
  1342. minetest.register_node("default:grass_" .. i, {
  1343. description = "Grass",
  1344. drawtype = "plantlike",
  1345. tiles = {"default_grass_" .. i .. ".png"},
  1346. inventory_image = "default_grass_" .. i .. ".png",
  1347. wield_image = "default_grass_" .. i .. ".png",
  1348. paramtype = "light",
  1349. paramtype2 = "meshoptions",
  1350. walkable = false,
  1351. buildable_to = true,
  1352. is_ground_content = true,
  1353. drop = "default:grass_1",
  1354. groups = {snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1},
  1355. sounds = default.node_sound_leaves_defaults(),
  1356. selection_box = {
  1357. type = "fixed",
  1358. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
  1359. },
  1360. })
  1361. end
  1362. minetest.register_node("default:ice", {
  1363. description = "Ice",
  1364. tiles = {"default_ice.png"},
  1365. is_ground_content = true,
  1366. paramtype = "light",
  1367. freezemelt = "default:water_source",
  1368. groups = {cracky=3, melts=1},
  1369. sounds = default.node_sound_glass_defaults(),
  1370. })
  1371. minetest.register_node("default:snow", {
  1372. description = "Snow",
  1373. tiles = {"default_snow.png"},
  1374. inventory_image = "default_snowball.png",
  1375. wield_image = "default_snowball.png",
  1376. is_ground_content = true,
  1377. paramtype = "light",
  1378. buildable_to = true,
  1379. leveled = 7,
  1380. drawtype = "nodebox",
  1381. freezemelt = "default:water_flowing",
  1382. node_box = {
  1383. type = "leveled",
  1384. fixed = {
  1385. {-0.5, -0.5, -0.5, 0.5, -0.5+2/16, 0.5},
  1386. },
  1387. },
  1388. groups = {crumbly=3,falling_node=1, melts=1, float=1},
  1389. sounds = default.node_sound_dirt_defaults({
  1390. footstep = {name="default_snow_footstep", gain=0.25},
  1391. dug = {name="default_snow_footstep", gain=0.75},
  1392. }),
  1393. on_construct = function(pos)
  1394. pos.y = pos.y - 1
  1395. if minetest.get_node(pos).name == "default:dirt_with_grass" then
  1396. minetest.set_node(pos, {name="default:dirt_with_snow"})
  1397. end
  1398. end,
  1399. })
  1400. minetest.register_alias("snow", "default:snow")
  1401. minetest.register_node("default:snowblock", {
  1402. description = "Snow Block",
  1403. tiles = {"default_snow.png"},
  1404. is_ground_content = true,
  1405. freezemelt = "default:water_source",
  1406. groups = {crumbly=3, melts=1},
  1407. sounds = default.node_sound_dirt_defaults({
  1408. footstep = {name="default_snow_footstep", gain=0.25},
  1409. dug = {name="default_snow_footstep", gain=0.75},
  1410. }),
  1411. })