init.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. local dice = {
  2. {"1","1","2","3","4","5","6",1},
  3. {"2","2","3","4","5","6","1",1},
  4. {"3","3","4","5","6","1","2",0},
  5. {"4","4","5","6","1","2","3",1},
  6. {"5","5","6","1","2","3","4",1},
  7. {"6","6","1","2","3","4","5",1},
  8. }
  9. for i in ipairs (dice) do
  10. local d1 = dice [i][1]
  11. local i1 = dice [i][2]
  12. local i2 = dice [i][3]
  13. local i3 = dice [i][4]
  14. local i4 = dice [i][5]
  15. local i5 = dice [i][6]
  16. local i6 = dice [i][7]
  17. local nici = dice [i][8]
  18. minetest.register_node("my_game_pieces:dice_"..d1,{
  19. description = "Dice",
  20. tiles = {"my_game_pieces_"..i1..".png",
  21. "my_game_pieces_"..i2..".png",
  22. "my_game_pieces_"..i3..".png",
  23. "my_game_pieces_"..i4..".png",
  24. "my_game_pieces_"..i5..".png",
  25. "my_game_pieces_"..i6..".png"},
  26. drawtype = "normal",
  27. paramtype = "light",
  28. drop = "my_game_pieces:dice_3",
  29. groups = {dig_immediate=3, not_in_creative_inventory=nici},
  30. after_place_node = function(pos, placer, itemstack, pointed_thing)
  31. minetest.set_node(pos,{name="my_game_pieces:roll"})
  32. end,
  33. })
  34. end
  35. minetest.register_node("my_game_pieces:roll",{
  36. description = "Rolling",
  37. tiles = {
  38. {name="my_game_pieces_ani.png", animation={type="vertical_frames",aspect_w=16, aspect_h=16, length=0.3}},
  39. {name="my_game_pieces_ani.png", animation={type="vertical_frames",aspect_w=16, aspect_h=16, length=0.3}},
  40. {name="my_game_pieces_ani.png", animation={type="vertical_frames",aspect_w=16, aspect_h=16, length=0.3}},
  41. {name="my_game_pieces_ani.png", animation={type="vertical_frames",aspect_w=16, aspect_h=16, length=0.3}},
  42. {name="my_game_pieces_ani.png", animation={type="vertical_frames",aspect_w=16, aspect_h=16, length=0.3}},
  43. {name="my_game_pieces_ani.png", animation={type="vertical_frames",aspect_w=16, aspect_h=16, length=0.3}},
  44. },
  45. drawtype = "normal",
  46. paramtype = "light",
  47. drop = "my_game_pieces:dice_3",
  48. groups = {dig_immediate=3, not_in_creative_inventory=1},
  49. after_place_node = function(pos, placer, itemstack, pointed_thing)
  50. minetest.after(2, function()
  51. local ran = math.random(1,6)
  52. minetest.set_node(pos,{name="my_game_pieces:dice_"..ran})
  53. end)
  54. end,
  55. })
  56. local pieces = {
  57. {"Red","red","^[colorize:red:120"},
  58. {"Green","green","^[colorize:green:120"},
  59. {"Yellow","yellow","^[colorize:yellow:120"},
  60. {"Blue","blue","^[colorize:blue:120"},
  61. {"Pink","pink","^[colorize:pink:120"},
  62. {"White","white","^[colorize:white:120"},
  63. {"Black","black","^[colorize:black:120"},
  64. }
  65. for i in ipairs (pieces) do
  66. local desc = pieces[i][1]
  67. local item = pieces[i][2]
  68. local col = pieces[i][3]
  69. minetest.register_node("my_game_pieces:"..item,{
  70. description = desc.." Player",
  71. tiles = {"default_gravel.png"..col},
  72. drawtype = "nodebox",
  73. paramtype = "light",
  74. light_source = 11,
  75. groups = {dig_immediate=3, not_in_creative_inventory=0},
  76. node_box = {
  77. type = "fixed",
  78. fixed = {
  79. {-0.3125, -0.5, -0.3125, 0.3125, -0.3125, 0.3125},
  80. {-0.125, -0.3125, -0.125, 0.125, 0.125, 0.125},
  81. {-0.1875, 0.125, -0.1875, 0.1875, 0.3125, 0.1875},
  82. }
  83. }
  84. })
  85. end