reactor.lua 20 KB

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