wire_std.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. -- naming scheme: wire:(xp)(zp)(xm)(zm)_on/off
  2. -- The conditions in brackets define whether there is a digiline at that place or not
  3. -- 1 = there is one; 0 = there is none
  4. -- y always means y+
  5. local box_center = {-1/16, -.5, -1/16, 1/16, -.5+1/16, 1/16}
  6. local box_bump1 = { -2/16, -8/16, -2/16, 2/16, -13/32, 2/16 }
  7. local box_bump2 = { -3/32, -13/32, -3/32, 3/32, -12/32, 3/32 }
  8. local box_xp = {1/16, -.5, -1/16, 8/16, -.5+1/16, 1/16}
  9. local box_zp = {-1/16, -.5, 1/16, 1/16, -.5+1/16, 8/16}
  10. local box_xm = {-8/16, -.5, -1/16, -1/16, -.5+1/16, 1/16}
  11. local box_zm = {-1/16, -.5, -8/16, 1/16, -.5+1/16, -1/16}
  12. local box_xpy = {.5-1/16, -.5+1/16, -1/16, .5, .4999+1/16, 1/16}
  13. local box_zpy = {-1/16, -.5+1/16, .5-1/16, 1/16, .4999+1/16, .5}
  14. local box_xmy = {-.5, -.5+1/16, -1/16, -.5+1/16, .4999+1/16, 1/16}
  15. local box_zmy = {-1/16, -.5+1/16, -.5, 1/16, .4999+1/16, -.5+1/16}
  16. for xp=0, 1 do
  17. for zp=0, 1 do
  18. for xm=0, 1 do
  19. for zm=0, 1 do
  20. for xpy=0, 1 do
  21. for zpy=0, 1 do
  22. for xmy=0, 1 do
  23. for zmy=0, 1 do
  24. if (xpy == 1 and xp == 0) or (zpy == 1 and zp == 0)
  25. or (xmy == 1 and xm == 0) or (zmy == 1 and zm == 0) then break end
  26. local groups
  27. local nodeid = tostring(xp )..tostring(zp )..tostring(xm )..tostring(zm )..
  28. tostring(xpy)..tostring(zpy)..tostring(xmy)..tostring(zmy)
  29. local wiredesc
  30. if nodeid == "00000000" then
  31. groups = {dig_immediate = 3}
  32. wiredesc = "Digiline"
  33. else
  34. groups = {dig_immediate = 3, not_in_creative_inventory = 1}
  35. end
  36. local nodebox = {}
  37. local adjx = false
  38. local adjz = false
  39. if xp == 1 then table.insert(nodebox, box_xp) adjx = true end
  40. if zp == 1 then table.insert(nodebox, box_zp) adjz = true end
  41. if xm == 1 then table.insert(nodebox, box_xm) adjx = true end
  42. if zm == 1 then table.insert(nodebox, box_zm) adjz = true end
  43. if xpy == 1 then table.insert(nodebox, box_xpy) end
  44. if zpy == 1 then table.insert(nodebox, box_zpy) end
  45. if xmy == 1 then table.insert(nodebox, box_xmy) end
  46. if zmy == 1 then table.insert(nodebox, box_zmy) end
  47. local tiles
  48. if adjx and adjz and (xp + zp + xm + zm > 2) then
  49. table.insert(nodebox, box_bump1)
  50. table.insert(nodebox, box_bump2)
  51. tiles = {
  52. "digiline_std_bump.png",
  53. "digiline_std_bump.png",
  54. "digiline_std_vertical.png",
  55. "digiline_std_vertical.png",
  56. "digiline_std_vertical.png",
  57. "digiline_std_vertical.png"
  58. }
  59. else
  60. table.insert(nodebox, box_center)
  61. tiles = {
  62. "digiline_std.png",
  63. "digiline_std.png",
  64. "digiline_std_vertical.png",
  65. "digiline_std_vertical.png",
  66. "digiline_std_vertical.png",
  67. "digiline_std_vertical.png"
  68. }
  69. end
  70. if nodeid == "00000000" then
  71. nodebox = {-8/16, -.5, -1/16, 8/16, -.5+1/16, 1/16}
  72. end
  73. minetest.register_node("digilines:wire_std_"..nodeid, {
  74. description = wiredesc,
  75. drawtype = "nodebox",
  76. tiles = tiles,
  77. inventory_image = "digiline_std_inv.png",
  78. wield_image = "digiline_std_inv.png",
  79. paramtype = "light",
  80. paramtype2 = "facedir",
  81. sunlight_propagates = true,
  82. digiline =
  83. {
  84. wire =
  85. {
  86. basename = "digilines:wire_std_",
  87. use_autoconnect = true
  88. }
  89. },
  90. selection_box = {
  91. type = "fixed",
  92. fixed = {-.5, -.5, -.5, .5, -.5+1/16, .5}
  93. },
  94. node_box = {
  95. type = "fixed",
  96. fixed = nodebox
  97. },
  98. groups = groups,
  99. walkable = false,
  100. stack_max = 99,
  101. drop = "digilines:wire_std_00000000"
  102. })
  103. end
  104. end
  105. end
  106. end
  107. end
  108. end
  109. end
  110. end