init.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. -- The BLINKY_PLANT
  2. local toggle_timer = function (pos)
  3. local timer = minetest.get_node_timer(pos)
  4. if timer:is_started() then
  5. timer:stop()
  6. else
  7. timer:start(mesecon.setting("blinky_plant_interval", 3))
  8. end
  9. end
  10. local on_timer = function (pos)
  11. local node = minetest.get_node(pos)
  12. if(mesecon.flipstate(pos, node) == "on") then
  13. mesecon.receptor_on(pos)
  14. else
  15. mesecon.receptor_off(pos)
  16. end
  17. toggle_timer(pos)
  18. end
  19. mesecon.register_node("mesecons_blinkyplant:blinky_plant", {
  20. description="Blinky Plant",
  21. drawtype = "plantlike",
  22. inventory_image = "jeija_blinky_plant_off.png",
  23. paramtype = "light",
  24. walkable = false,
  25. sounds = default.node_sound_leaves_defaults(),
  26. selection_box = {
  27. type = "fixed",
  28. fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3},
  29. },
  30. on_timer = on_timer,
  31. on_rightclick = toggle_timer,
  32. on_construct = toggle_timer
  33. },{
  34. tiles = {"jeija_blinky_plant_off.png"},
  35. groups = {dig_immediate=3},
  36. mesecons = {receptor = { state = mesecon.state.off }}
  37. },{
  38. tiles = {"jeija_blinky_plant_on.png"},
  39. groups = {dig_immediate=3, not_in_creative_inventory=1},
  40. mesecons = {receptor = { state = mesecon.state.on }}
  41. })
  42. minetest.register_craft({
  43. output = "mesecons_blinkyplant:blinky_plant_off 1",
  44. recipe = { {"","group:mesecon_conductor_craftable",""},
  45. {"","group:mesecon_conductor_craftable",""},
  46. {"group:sapling","group:sapling","group:sapling"}}
  47. })