Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2012
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1.  
  2. dofile(minetest.get_modpath("train").."/helper_functions.lua")
  3. --straight rail
  4. minetest.register_node("train:rail", {
  5. description = "rail",
  6. paramtype = "light",
  7. paramtype2 = "facedir",
  8. tiles = {"default_steel_block.png"},
  9. drawtype = "nodebox",
  10. groups = {crumbly=3,rail=1},
  11. node_box = {
  12. type = "fixed",
  13. fixed = {
  14. {-0.4,-0.3,-0.5,-0.3,-0.1,0.5},
  15. {0.3,-0.3,-0.5,0.4,-0.1,0.5}
  16. },
  17. },
  18. selection_box = {
  19. type = "fixed",
  20. fixed = {-0.5,-0.5,-0.5,0.5,-0.1,0.5}
  21. },
  22. })
  23. --turn rail
  24. minetest.register_node("train:rail_turn", {
  25. description = "rail",
  26. paramtype = "light",
  27. paramtype2 = "facedir",
  28. tiles = {"default_steel_block.png"},
  29. drawtype = "nodebox",
  30. groups = {crumbly=3,rail=1},
  31. node_box = {
  32. type = "fixed",
  33. fixed = {
  34. {-0.4,-0.3,-0.5,-0.3,-0.1,0.4},
  35. {-0.4,-0.3,0.3,0.5,-0.1,0.4},
  36. {0.3,-0.3,-0.5,0.4,-0.1,-0.3},
  37. {0.3,-0.3,-0.4,0.5,-0.1,-0.3},
  38. },
  39. },
  40. selection_box = {
  41. type = "fixed",
  42. fixed = {-0.5,-0.5,-0.5,0.5,-0.1,0.5}
  43. },
  44. })
  45.  
  46. --train bogie
  47. train = {
  48. physical = true,
  49. collisionbox = {-0.3,-0.3,-0.3,0.3,0.3,0.3},
  50. --textures =,
  51. visual = "cube",
  52. --mesh = "boat.x",
  53. visual_size = {x=0.5, y=0.5},
  54. textures = {"default_stone.png"},
  55. timer = 0,
  56. speed = 0,
  57. direction = left,
  58. lastpos = nil,
  59. other = nil,
  60. lead = false,
  61. speed = {},
  62. }
  63.  
  64. train.on_rightclick = function(self)
  65. print(dump(self.lead))
  66. end
  67.  
  68. train.on_activate = function(self)
  69. --on activate
  70. end
  71.  
  72. train.on_step = function(self)
  73. self.speed = self.object:getvelocity()
  74. calculate_train_dir(self, self.object:getpos())
  75. self.object:setvelocity(self.direction)
  76. end
  77. minetest.register_entity("train:train", train)
  78.  
  79.  
  80. --[[
  81. --train body
  82. train = {
  83. physical = true,
  84. collisionbox = {-0.5,-0.5,-0.5,0.5,0.5,0.5},
  85. --textures =,
  86. visual = "mesh",
  87. mesh = "train.x",
  88. visual_size = {x=1, y=1},
  89. textures = {"default_stone.png"},
  90. timer = 0,
  91. speed = 0,
  92. direction = left,
  93. lastpos = nil,
  94. }
  95.  
  96. train.on_activate = function(self)
  97. --on activate
  98. end
  99.  
  100. train.on_step = function(self)
  101. --on step
  102. end
  103. minetest.register_entity("train:train", train)
  104. ]]--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement