init.lua 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. local dice = {
  2. {"mylittle_bg:1",{"mylittle_bg_1.png","mylittle_bg_2.png","mylittle_bg_3.png","mylittle_bg_4.png","mylittle_bg_5.png","mylittle_bg_6.png"},"1"},
  3. {"mylittle_bg:2",{"mylittle_bg_2.png","mylittle_bg_3.png","mylittle_bg_4.png","mylittle_bg_5.png","mylittle_bg_6.png","mylittle_bg_1.png"},"2"},
  4. {"mylittle_bg:3",{"mylittle_bg_3.png","mylittle_bg_4.png","mylittle_bg_5.png","mylittle_bg_6.png","mylittle_bg_1.png","mylittle_bg_2.png"},"3"},
  5. {"mylittle_bg:4",{"mylittle_bg_4.png","mylittle_bg_5.png","mylittle_bg_6.png","mylittle_bg_1.png","mylittle_bg_2.png","mylittle_bg_3.png"},"4"},
  6. {"mylittle_bg:5",{"mylittle_bg_5.png","mylittle_bg_6.png","mylittle_bg_1.png","mylittle_bg_2.png","mylittle_bg_3.png","mylittle_bg_4.png"},"5"},
  7. {"mylittle_bg:6",{"mylittle_bg_6.png","mylittle_bg_1.png","mylittle_bg_2.png","mylittle_bg_3.png","mylittle_bg_4.png","mylittle_bg_5.png"},"6"},
  8. }
  9. for i in ipairs (dice) do
  10. local d1 = dice [i][1]
  11. local d2 = dice [i][2]
  12. local d3 = dice [i][3]
  13. minetest.register_node(d1,{
  14. description = d3,
  15. tiles = d2,
  16. drawtype = "normal",
  17. paramtype = "light",
  18. groups = {cracky = 3, not_in_creative_inventory=1},
  19. on_punch = function(pos, node, puncher, pointed_thing)
  20. local timer = minetest.get_node_timer(pos)
  21. local ran = math.random(1,6)
  22. minetest.set_node(pos,{name="mylittle_bg:roll"})
  23. timer:start(2)
  24. end,
  25. })
  26. end
  27. minetest.register_node("mylittle_bg:roll",{
  28. description = "roll",
  29. tiles = {
  30. {name="mylittle_bg_ani.png", animation={type="vertical_frames",aspect_w=16, aspect_h=16, length=0.3}},
  31. {name="mylittle_bg_ani.png", animation={type="vertical_frames",aspect_w=16, aspect_h=16, length=0.3}},
  32. {name="mylittle_bg_ani.png", animation={type="vertical_frames",aspect_w=16, aspect_h=16, length=0.3}},
  33. {name="mylittle_bg_ani.png", animation={type="vertical_frames",aspect_w=16, aspect_h=16, length=0.3}},
  34. {name="mylittle_bg_ani.png", animation={type="vertical_frames",aspect_w=16, aspect_h=16, length=0.3}},
  35. {name="mylittle_bg_ani.png", animation={type="vertical_frames",aspect_w=16, aspect_h=16, length=0.3}},
  36. },
  37. drawtype = "normal",
  38. paramtype = "light",
  39. groups = {cracky = 3, not_in_creative_inventory=1},
  40. on_timer = function(pos, elapsed)
  41. local ran = math.random(1,6)
  42. minetest.set_node(pos,{name="mylittle_bg:"..ran})
  43. end
  44. })
  45. local pieces = {
  46. {"Red","red","^[colorize:red:120"},
  47. {"Green","green","^[colorize:green:120"},
  48. {"Yellow","yellow","^[colorize:yellow:120"},
  49. {"Blue","blue","^[colorize:blue:120"},
  50. }
  51. for i in ipairs (pieces) do
  52. local desc = pieces[i][1]
  53. local item = pieces[i][2]
  54. local col = pieces[i][3]
  55. minetest.register_node("mylittle_bg:"..item,{
  56. description = desc.." Player",
  57. tiles = {"default_gravel.png"..col},
  58. drawtype = "nodebox",
  59. paramtype = "light",
  60. light_source = 11,
  61. groups = {cracky = 1, dig_immediate=3, not_in_creative_inventory=1},
  62. node_box = {
  63. type = "fixed",
  64. fixed = {
  65. {-0.3125, -0.5, -0.3125, 0.3125, -0.3125, 0.3125},
  66. {-0.125, -0.3125, -0.125, 0.125, 0.125, 0.125},
  67. {-0.1875, 0.125, -0.1875, 0.1875, 0.3125, 0.1875},
  68. }
  69. }
  70. })
  71. end
  72. minetest.register_node("mylittle_bg:board",{
  73. description = "Little Board Game",
  74. inventory_image = "mylittle_bg_inv.png",
  75. wield_image = "mylittle_bg_inv.png",
  76. tiles = {"mylittle_bg_inv.png"},
  77. drawtype = "normal",
  78. paramtype = "light",
  79. light_source = 8,
  80. groups = {cracky = 1},
  81. on_rightclick = function(pos, node, player, itemstack, pointed_thing)
  82. local schem = minetest.get_modpath("mylittle_bg").."/schems/my_little_bg.mts"
  83. minetest.place_schematic({x=pos.x,y=pos.y-2,z=pos.z},schem,0, "air", true)
  84. end,
  85. after_place_node = function(pos, placer, itemstack, pointed_thing)
  86. if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then
  87. else
  88. minetest.remove_node(pos)
  89. return true
  90. end
  91. end,
  92. })
  93. local signs = {
  94. {"1","red","^[colorize:red:120"},
  95. {"2","green","^[colorize:green:120"},
  96. {"3","yellow","^[colorize:yellow:120"},
  97. {"4","blue","^[colorize:blue:120"},
  98. }
  99. for i in ipairs (signs) do
  100. local desc = signs[i][1]
  101. local item = signs[i][2]
  102. local col = signs[i][3]
  103. minetest.register_node("mylittle_bg:sign"..desc,{
  104. description = "sign"..desc,
  105. tiles = {"mylittle_bg_sign"..desc..".png"},
  106. drawtype = "nodebox",
  107. paramtype = "light",
  108. paramtype2 = "facedir",
  109. light_source = 11,
  110. groups = {cracky = 1, not_in_creative_inventory=1},
  111. node_box = {
  112. type = "fixed",
  113. fixed = {
  114. {-0.4375, -0.375, 0.4375, 0.4375, 0.3125, 0.5},
  115. }
  116. }
  117. })
  118. end