reactor.lua 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. -- Functions for the generator nodes.
  2. reactor = reactor or {}
  3. reactor_inactive = reactor_inactive or {}
  4. reactor_active = reactor_active or {}
  5. reactor.siren = reactor.siren or {}
  6. local BUFFER_SIZE = tech.reactor.buffer
  7. local ENERGY_TIME = tech.reactor.time
  8. local TOTAL_COOK_TIME = tech.reactor.totaltime
  9. local ENERGY_AMOUNT = tech.reactor.power
  10. local REACTOR_TIER = "hv"
  11. local SS_OFF = 0
  12. local SS_DANGER = 1
  13. local SS_CLEAR = 2
  14. local reactor_siren = reactor.siren
  15. local function siren_set_state(pos, state)
  16. local hpos = minetest.hash_node_position(pos)
  17. local siren = reactor_siren[hpos]
  18. if not siren then
  19. if state == SS_OFF then return end
  20. siren = {state=SS_OFF}
  21. reactor_siren[hpos] = siren
  22. end
  23. if state == SS_DANGER and siren.state ~= SS_DANGER then
  24. if siren.handle then minetest.sound_stop(siren.handle) end
  25. siren.handle = minetest.sound_play("technic_hv_nuclear_reactor_siren_danger_loop",
  26. {pos=pos, gain=1.5, loop=true, max_hear_distance=48})
  27. siren.state = SS_DANGER
  28. elseif state == SS_CLEAR then
  29. if siren.handle then minetest.sound_stop(siren.handle) end
  30. local clear_handle = minetest.sound_play("technic_hv_nuclear_reactor_siren_clear",
  31. {pos=pos, gain=1.5, loop=false, max_hear_distance=48})
  32. siren.handle = clear_handle
  33. siren.state = SS_CLEAR
  34. minetest.after(10, function()
  35. if siren.handle ~= clear_handle then return end
  36. minetest.sound_stop(clear_handle)
  37. if reactor_siren[hpos] == siren then
  38. reactor_siren[hpos] = nil
  39. end
  40. end)
  41. elseif state == SS_OFF and siren.state ~= SS_OFF then
  42. if siren.handle then minetest.sound_stop(siren.handle) end
  43. reactor_siren[hpos] = nil
  44. end
  45. end
  46. local function siren_danger(pos, meta)
  47. meta:set_int("siren", 1)
  48. siren_set_state(pos, SS_DANGER)
  49. end
  50. local function siren_clear(pos, meta)
  51. if meta:get_int("siren") ~= 0 then
  52. siren_set_state(pos, SS_CLEAR)
  53. meta:set_int("siren", 0)
  54. end
  55. end
  56. local function get_reactor_damage(pos)
  57. local meta = minetest.get_meta(pos)
  58. local owner = meta:get_string("owner")
  59. local vm = VoxelManip()
  60. local pos1 = vector.subtract(pos, 4)
  61. local pos2 = vector.add(pos, 4)
  62. local MinEdge, MaxEdge = vm:read_from_map(pos1, pos2)
  63. local data = vm:get_data()
  64. local area = VoxelArea:new({MinEdge=MinEdge, MaxEdge=MaxEdge})
  65. local c_blast_concrete = minetest.get_content_id("concrete:brc")
  66. local c_lead = minetest.get_content_id("lead:block")
  67. local c_steel = minetest.get_content_id("stainless_steel:block")
  68. local c_water_source = minetest.get_content_id("default:water_source")
  69. local c_water_flowing = minetest.get_content_id("default:water_flowing")
  70. local c_cw_source = minetest.get_content_id("cw:water_source")
  71. local c_cw_flowing = minetest.get_content_id("cw:water_flowing")
  72. local c_river_source = minetest.get_content_id("default:river_water_source")
  73. local c_river_flowing = minetest.get_content_id("default:river_water_flowing")
  74. local c_concrete = minetest.get_content_id("concrete:concrete")
  75. local concrete_layer, blast_layer, lead_layer, water_layer = 0, 0, 0, 0
  76. for z = pos1.z, pos2.z do
  77. for y = pos1.y, pos2.y do
  78. for x = pos1.x, pos2.x do
  79. local cid = data[area:index(x, y, z)]
  80. if x == pos1.x+0 or x == pos2.x-0 or
  81. y == pos1.y+0 or y == pos2.y-0 or
  82. z == pos1.z+0 or z == pos2.z-0 then
  83. if cid == c_concrete then
  84. concrete_layer = concrete_layer + 1
  85. end
  86. elseif x == pos1.x+1 or x == pos2.x-1 or
  87. y == pos1.y+1 or y == pos2.y-1 or
  88. z == pos1.z+1 or z == pos2.z-1 then
  89. if cid == c_blast_concrete then
  90. blast_layer = blast_layer + 1
  91. end
  92. elseif x == pos1.x+2 or x == pos2.x-2 or
  93. y == pos1.y+2 or y == pos2.y-2 or
  94. z == pos1.z+2 or z == pos2.z-2 then
  95. if cid == c_lead or cid == c_steel then
  96. lead_layer = lead_layer + 1
  97. end
  98. elseif x == pos1.x+3 or x == pos2.x-3 or
  99. y == pos1.y+3 or y == pos2.y-3 or
  100. z == pos1.z+3 or z == pos2.z-3 then
  101. if cid == c_water_source or cid == c_water_flowing or
  102. cid == c_river_source or cid == c_river_flowing or
  103. cid == c_cw_source or cid == c_cw_flowing then
  104. water_layer = water_layer + 1
  105. end
  106. end
  107. end
  108. end
  109. end
  110. --minetest.chat_send_player("MustTest", "Checking reactor!")
  111. -- Debug!
  112. --if minetest.is_singleplayer() or gdac.player_is_admin(owner) then
  113. -- return 0
  114. --end
  115. if water_layer > 25 then water_layer = 25 end
  116. if lead_layer > 96 then lead_layer = 96 end
  117. if blast_layer > 216 then blast_layer = 216 end
  118. if concrete_layer > 384 then concrete_layer = 384 end
  119. return (25 - water_layer) +
  120. (96 - lead_layer) +
  121. (216 - blast_layer) +
  122. (384 - concrete_layer)
  123. end
  124. local function check_environment(pos, meta)
  125. --minetest.chat_send_player("MustTest", "Check env!")
  126. local timer = meta:get_int("chktmr")
  127. --local active = meta:get_int("active")
  128. if timer <= 0 then
  129. local result = false
  130. local good = false
  131. local damage = get_reactor_damage(pos)
  132. if damage == 0 then
  133. good = true
  134. end
  135. --minetest.chat_send_player("MustTest", "Reactor damage: " .. damage .. "!")
  136. if good then
  137. meta:set_string("error", "DUMMY")
  138. result = false
  139. else
  140. meta:set_string("error", "INSUFFICIENT REACTOR SHIELDING!")
  141. result = true -- Bad
  142. end
  143. -- Randomize time to next nodecheck.
  144. meta:set_int("chktmr", math.random(1*60, 3*60))
  145. return result
  146. end
  147. -- Decrement check timer.
  148. timer = timer - 1
  149. meta:set_int("chktmr", timer)
  150. -- No check performed.
  151. return nil
  152. end
  153. for k, v in ipairs({
  154. {name="inactive"},
  155. {name="active"},
  156. }) do
  157. -- Which function table are we operating on?
  158. local func = _G["reactor_" .. v.name]
  159. func.on_energy_get =
  160. function(pos, energy)
  161. local meta = minetest.get_meta(pos)
  162. local inv = meta:get_inventory()
  163. local have = inv:get_stack("out", 1):get_count()
  164. if have < energy then
  165. inv:set_stack("out", 1, ItemStack(""))
  166. func.trigger_update(pos)
  167. return have
  168. end
  169. have = have - energy
  170. inv:set_stack("out", 1, ItemStack("atomic:energy " .. have))
  171. func.trigger_update(pos)
  172. return energy
  173. end
  174. func.reactor_destroy =
  175. function(pos)
  176. minetest.after(0, function()
  177. tnt.boom(pos, {
  178. radius = 20,
  179. ignore_protection = false,
  180. ignore_on_blast = false,
  181. damage_radius = 30,
  182. disable_drops = true,
  183. })
  184. local minp = vector.subtract(pos, 1)
  185. local maxp = vector.add(pos, 1)
  186. -- Transform reactor and all water around it into lava.
  187. -- Must be done *after* explosion runs.
  188. for x=minp.x, maxp.x do
  189. for y=minp.y, maxp.y do
  190. for z=minp.z, maxp.z do
  191. local p = {x=x, y=y, z=z}
  192. if p.y < -14 then
  193. minetest.add_node(p, {name="default:lava_source"})
  194. minetest.transforming_liquid_add(p)
  195. else
  196. minetest.add_node(p, {name="fire:basic_flame"})
  197. end
  198. end
  199. end
  200. end
  201. end)
  202. end
  203. func.trigger_update =
  204. function(pos)
  205. local timer = minetest.get_node_timer(pos)
  206. -- Restart timer even if already running.
  207. timer:start(1.0)
  208. end
  209. func.on_punch =
  210. function(pos, node, puncher, pointed_thing)
  211. --minetest.chat_send_player("MustTest", "Punched!")
  212. func.trigger_update(pos)
  213. -- Check reactor integrity.
  214. local meta = minetest.get_meta(pos)
  215. meta:set_int("chktmr", 0)
  216. func.privatize(meta)
  217. end
  218. func.compose_formspec =
  219. function(fuel_percent, item_percent)
  220. local formspec =
  221. "size[8,8.5]" ..
  222. default.formspec.get_form_colors() ..
  223. default.formspec.get_form_image() ..
  224. default.formspec.get_slot_colors() ..
  225. "label[1,0.5;Uranium Rod Compartment]" ..
  226. "list[context;fuel;1,1;3,2;]" ..
  227. "image[4,1.5;1,1;default_furnace_fire_bg.png^[lowpart:" ..
  228. (fuel_percent) .. ":default_furnace_fire_fg.png]" ..
  229. "image[5,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:"..
  230. (item_percent)..":gui_furnace_arrow_fg.png^[transformR270]"..
  231. "label[6,1.0;Charge Buffer]" ..
  232. "list[context;out;6,1.5;1,1;]" ..
  233. "list[current_player;main;0,4.25;8,1;]" ..
  234. "list[current_player;main;0,5.5;8,3;8]" ..
  235. "listring[context;fuel]" ..
  236. "listring[current_player;main]" ..
  237. default.get_hotbar_bg(0, 4.25)
  238. return formspec
  239. end
  240. func.compose_infotext =
  241. function(pos, keeprunning)
  242. local meta = minetest.get_meta(pos)
  243. local eups = meta:get_int("eups")
  244. local machine_state = "Standby"
  245. if keeprunning then machine_state = "Active" end
  246. local output = math.floor(eups / ENERGY_TIME)
  247. if not keeprunning then
  248. output = 0
  249. end
  250. local infotext = "Fission Reactor (" .. machine_state .. ")\n" ..
  251. "Output: " .. output .. " EU Per/Sec"
  252. local err = meta:get_string("error") or "DUMMY"
  253. if err ~= "" and err ~= "DUMMY" then
  254. infotext = infotext .. "\n" .. err
  255. end
  256. local damage = meta:get_int("damage")
  257. if damage > 0 then
  258. infotext = infotext .. "\nReactor damage: " .. damage .. "!"
  259. end
  260. return infotext
  261. end
  262. func.can_dig =
  263. function(pos, player)
  264. local meta = minetest.get_meta(pos)
  265. local inv = meta:get_inventory()
  266. -- The energy output inventory does not count.
  267. return inv:is_empty("fuel")
  268. end
  269. func.allow_metadata_inventory_put =
  270. function(pos, listname, index, stack, player)
  271. if minetest.test_protection(pos, player:get_player_name()) then
  272. return 0
  273. end
  274. if listname == "fuel" then
  275. local node = minetest.get_node(pos)
  276. -- Cannot put rods in an active reactor.
  277. if node.name == "reactor:inactive" and stack:get_name() == "uranium:rod" then
  278. return stack:get_count()
  279. end
  280. end
  281. return 0
  282. end
  283. func.allow_metadata_inventory_move =
  284. function(pos, from_list, from_index, to_list, to_index, count, player)
  285. return 0
  286. end
  287. func.allow_metadata_inventory_take =
  288. function(pos, listname, index, stack, player)
  289. if minetest.test_protection(pos, player:get_player_name()) then
  290. return 0
  291. end
  292. if listname == "fuel" then
  293. return stack:get_count()
  294. end
  295. return 0
  296. end
  297. func.on_timer =
  298. function(pos, elapsed)
  299. --minetest.chat_send_all("# Server: On Timer! " .. minetest.get_gametime())
  300. local keeprunning = false
  301. local meta = minetest.get_meta(pos)
  302. local owner = meta:get_string("owner")
  303. local inv = meta:get_inventory()
  304. local fuellist = inv:get_list("fuel")
  305. local time = meta:get_int("time")
  306. local time2 = meta:get_float("time2")
  307. local maxtime = meta:get_int("maxtime")
  308. local maxtime2 = ENERGY_TIME
  309. local eups = meta:get_int("eups")
  310. local fuel_percent = 0
  311. local item_percent = 0
  312. local need_discharge = false
  313. -- This sets infotext, so must always call this.
  314. local bad = check_environment(pos, meta)
  315. if v.name == "active" then
  316. if bad ~= nil then
  317. if bad then
  318. meta:set_int("bad", 1)
  319. siren_danger(pos, meta)
  320. else
  321. if meta:get_int("bad") == 1 then
  322. siren_clear(pos, meta)
  323. end
  324. meta:set_int("bad", 0)
  325. end
  326. end
  327. -- Damage reactor over time if bad.
  328. if meta:get_int("bad") == 1 then
  329. local damage = meta:get_int("damage")
  330. damage = damage + 1
  331. meta:set_int("damage", damage)
  332. -- Destroy reactor after 10 minutes of continous damage.
  333. if damage > 60*10 then
  334. func.reactor_destroy(pos)
  335. return
  336. end
  337. else
  338. -- Slowly decrease damage if not bad.
  339. local damage = meta:get_int("damage")
  340. if damage > 0 then
  341. damage = damage - 1
  342. meta:set_int("damage", damage)
  343. end
  344. end
  345. else
  346. -- Slowly decrease damage when inactive.
  347. local damage = meta:get_int("damage")
  348. if damage > 0 then
  349. damage = damage - 1
  350. meta:set_int("damage", damage)
  351. end
  352. end
  353. -- Radiation damage to nearby players.
  354. if v.name == "active" then
  355. local entities = minetest.get_objects_inside_radius(pos, 4.5)
  356. for k, v in ipairs(entities) do
  357. if v:is_player() then
  358. v:set_hp(v:get_hp() - 1)
  359. -- Radiation exhausts player.
  360. sprint.set_stamina(v, 0)
  361. end
  362. end
  363. end
  364. do
  365. local stack = inv:get_stack("out", 1)
  366. --minetest.chat_send_player("MustTest", "# Server: " .. stack:get_count() .. " charge!")
  367. if stack:get_count() >= BUFFER_SIZE then
  368. need_discharge = true
  369. end
  370. end
  371. -- Manage fuel.
  372. if time > 0 then
  373. -- Keep burning current fuel item.
  374. time = time - 1
  375. -- Restart timer.
  376. keeprunning = true
  377. -- Generate energy.
  378. time2 = time2 + 1
  379. if time2 >= maxtime2 then
  380. if not need_discharge then
  381. local energy = "atomic:energy " .. eups
  382. if inv:room_for_item("out", energy) then
  383. inv:add_item("out", energy)
  384. else
  385. -- No room? Huh. Discharge reactor!
  386. -- Note: this can happen because charge to be added would be
  387. -- greater than stack_max. This bug was actually observed.
  388. -- It is only likely to affect high-output machines.
  389. need_discharge = true
  390. end
  391. end
  392. time2 = 0
  393. end
  394. else
  395. -- Burntime has run out, get new fuel item.
  396. if fuellist[1]:get_count() > 0 and not need_discharge then
  397. local fuel, afterfuel
  398. local is_mese = false
  399. meta:set_int("eups", 0)
  400. -- Check if we have enough fuel.
  401. local rods = 0
  402. for i = 1, 6, 1 do
  403. local stack = inv:get_stack("fuel", i)
  404. if stack:get_name() == "uranium:rod" and stack:get_count() > 0 then
  405. rods = rods + 1
  406. end
  407. end
  408. -- Try to get fuel.
  409. fuel, afterfuel = minetest.get_craft_result({
  410. method="coalfuel", width=1, items=fuellist,
  411. })
  412. if rods == 6 then
  413. -- We got uranium rods, consume them.
  414. for i = 1, 6, 1 do
  415. inv:set_stack("fuel", i, ItemStack(""))
  416. end
  417. time = TOTAL_COOK_TIME
  418. meta:set_int("maxtime", TOTAL_COOK_TIME)
  419. machines.swap_node(pos, "reactor:active")
  420. fuel_percent = 100
  421. keeprunning = true -- Restart timer.
  422. meta:set_int("eups", ENERGY_AMOUNT)
  423. else
  424. -- No valid fuel in fuel slot.
  425. machines.swap_node(pos, "reactor:inactive")
  426. --minetest.get_node_timer(pos):stop()
  427. time2 = 0
  428. end
  429. else
  430. -- No more fuel, shutdown generator.
  431. machines.swap_node(pos, "reactor:inactive")
  432. --minetest.get_node_timer(pos):stop()
  433. meta:set_int("eups", 0)
  434. time2 = 0
  435. end
  436. end
  437. -- Discharge energy into the network.
  438. if need_discharge then
  439. --minetest.chat_send_player("MustTest", "# Server: Discharging reactor!")
  440. local energy = inv:get_stack("out", 1)
  441. local old = energy:get_count()
  442. energy:set_count(net2.put_energy(pos, owner, old, REACTOR_TIER))
  443. inv:set_stack("out", 1, energy)
  444. if energy:get_count() < old then
  445. -- If we succeeded in discharging energy, keep doing so.
  446. -- Otherwise, batteries are full.
  447. keeprunning = true
  448. end
  449. end
  450. -- If generator is no longer producing energy,
  451. -- unload the buffered energy.
  452. if not keeprunning then
  453. local energy = inv:get_stack("out", 1)
  454. energy:set_count(net2.put_energy(pos, owner, energy:get_count(), REACTOR_TIER))
  455. inv:set_stack("out", 1, energy)
  456. end
  457. -- Update infotext & formspec.
  458. meta:set_int("time", time)
  459. meta:set_float("time2", time2)
  460. fuel_percent = math.floor(time / maxtime * 100)
  461. item_percent = math.floor(time2 / maxtime2 * 100)
  462. meta:set_string("infotext", func.compose_infotext(pos, keeprunning))
  463. meta:set_string("formspec", func.compose_formspec(fuel_percent, item_percent))
  464. -- Determine mode (active or sleep) and set timer accordingly.
  465. if keeprunning then
  466. minetest.get_node_timer(pos):start(1.0)
  467. -- Change water to salt water sometimes.
  468. if math.random(1, 60) == 1 then
  469. local minp = {x=pos.x-1, y=pos.y-1, z=pos.z-1}
  470. local maxp = {x=pos.x+1, y=pos.y+1, z=pos.z+1}
  471. local nodes = minetest.find_nodes_in_area(minp, maxp, {
  472. "default:water_source",
  473. "default:water_flowing",
  474. "default:river_water_flowing",
  475. })
  476. if nodes and #nodes > 0 then
  477. minetest.add_node(nodes[math.random(1, #nodes)], {name="default:river_water_source"})
  478. end
  479. end
  480. else
  481. -- Slow down timer during sleep periods to reduce load.
  482. minetest.get_node_timer(pos):start(math.random(1, 3*60))
  483. end
  484. end
  485. func.on_blast =
  486. function(pos)
  487. local drops = {}
  488. -- Ignore contents of fuel inventory.
  489. minetest.remove_node(pos)
  490. if v.name == "active" then
  491. func.reactor_destroy(pos)
  492. else
  493. -- Only save reactor if it wasn't active.
  494. drops[#drops+1] = "reactor:inactive"
  495. end
  496. return drops
  497. end
  498. func.on_construct =
  499. function(pos)
  500. local meta = minetest.get_meta(pos)
  501. local inv = meta:get_inventory()
  502. meta:set_string("infotext", func.compose_infotext(pos, false))
  503. meta:set_string("formspec", func.compose_formspec(0, 0))
  504. --minetest.chat_send_player("MustTest", "Constructed!")
  505. inv:set_size("fuel", 6)
  506. inv:set_size("out", 1)
  507. meta:set_string("owner", "DUMMY")
  508. meta:set_string("error", "DUMMY")
  509. meta:set_string("nodename", "DUMMY")
  510. meta:set_int("siren", 0)
  511. meta:set_int("chktmr", 0)
  512. meta:set_int("eups", 0)
  513. meta:set_int("damage", 0)
  514. meta:set_int("time", 0)
  515. meta:set_int("maxtime", 0)
  516. meta:set_int("bad", 0)
  517. meta:set_float("time2", 0.0)
  518. func.privatize(meta)
  519. end
  520. func.privatize =
  521. function(meta)
  522. meta:mark_as_private({
  523. "nodename", "bad", "time2", "maxtime", "siren", "owner",
  524. "chktmr", "error", "eups", "damage", "time",
  525. })
  526. end
  527. func.on_destruct =
  528. function(pos)
  529. local meta = minetest.get_meta(pos)
  530. siren_set_state(pos, SS_OFF)
  531. net2.clear_caches(pos, meta:get_string("owner"), REACTOR_TIER)
  532. nodestore.del_node(pos)
  533. if v.name == "active" then
  534. func.reactor_destroy(pos)
  535. end
  536. end
  537. func.after_place_node =
  538. function(pos, placer, itemstack, pointed_thing)
  539. local meta = minetest.get_meta(pos)
  540. local node = minetest.get_node(pos)
  541. local owner = placer:get_player_name()
  542. meta:set_string("nodename", node.name)
  543. meta:set_string("owner", owner)
  544. net2.clear_caches(pos, owner, REACTOR_TIER)
  545. nodestore.add_node(pos)
  546. end
  547. func.on_metadata_inventory_move =
  548. function(pos)
  549. func.trigger_update(pos)
  550. end
  551. func.on_metadata_inventory_put =
  552. function(pos)
  553. func.trigger_update(pos)
  554. end
  555. func.on_metadata_inventory_take =
  556. function(pos, listname, index, stack, player)
  557. func.trigger_update(pos)
  558. end
  559. end
  560. if not reactor.run_once then
  561. for k, v in ipairs({
  562. {name="inactive", light=0},
  563. {name="active", light=14},
  564. }) do
  565. -- Which function table are we operating on?
  566. local func = _G["reactor_" .. v.name]
  567. minetest.register_node(":reactor:" .. v.name, {
  568. description = "Fission Reactor Core\n\nConnects to an HV power-network.\nGenerates huge amounts of power.\nExplosion danger, requires shielding!",
  569. tiles = {"reactor_core.png"},
  570. groups = utility.dig_groups("machine", {immovable=1}),
  571. paramtype2 = "facedir",
  572. is_ground_content = false,
  573. sounds = default.node_sound_metal_defaults(),
  574. drop = "reactor:inactive",
  575. light_source = v.light,
  576. on_energy_get = function(...)
  577. return func.on_energy_get(...) end,
  578. on_rotate = function(...)
  579. return screwdriver.rotate_simple(...) end,
  580. on_punch = function(...)
  581. return func.on_punch(...) end,
  582. can_dig = function(...)
  583. return func.can_dig(...) end,
  584. on_timer = function(...)
  585. return func.on_timer(...) end,
  586. on_construct = function(...)
  587. return func.on_construct(...) end,
  588. on_destruct = function(...)
  589. return func.on_destruct(...) end,
  590. after_place_node = function(...)
  591. return func.after_place_node(...) end,
  592. on_blast = function(...)
  593. return func.on_blast(...) end,
  594. on_metadata_inventory_move = function(...)
  595. return func.on_metadata_inventory_move(...) end,
  596. on_metadata_inventory_put = function(...)
  597. return func.on_metadata_inventory_put(...) end,
  598. on_metadata_inventory_take = function(...)
  599. return func.on_metadata_inventory_take(...) end,
  600. allow_metadata_inventory_put = function(...)
  601. return func.allow_metadata_inventory_put(...) end,
  602. allow_metadata_inventory_move = function(...)
  603. return func.allow_metadata_inventory_move(...) end,
  604. allow_metadata_inventory_take = function(...)
  605. return func.allow_metadata_inventory_take(...) end,
  606. })
  607. end
  608. minetest.register_craft({
  609. output = 'reactor:inactive',
  610. recipe = {
  611. {'techcrafts:carbon_plate', 'default:obsidian_glass', 'techcrafts:carbon_plate'},
  612. {'techcrafts:composite_plate', 'gen2:hv_inactive', 'techcrafts:composite_plate'},
  613. {'stainless_steel:ingot', 'geo2:lv_inactive', 'stainless_steel:ingot'},
  614. }
  615. })
  616. local c = "reactor:core"
  617. local f = machines.modpath .. "/reactor.lua"
  618. reload.register_file(c, f, false)
  619. reactor.run_once = true
  620. end