Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dofile(minetest.get_modpath("train").."/helper_functions.lua")
- --straight rail
- minetest.register_node("train:rail", {
- description = "rail",
- paramtype = "light",
- paramtype2 = "facedir",
- tiles = {"default_steel_block.png"},
- drawtype = "nodebox",
- groups = {crumbly=3,rail=1},
- node_box = {
- type = "fixed",
- fixed = {
- {-0.4,-0.3,-0.5,-0.3,-0.1,0.5},
- {0.3,-0.3,-0.5,0.4,-0.1,0.5}
- },
- },
- selection_box = {
- type = "fixed",
- fixed = {-0.5,-0.5,-0.5,0.5,-0.1,0.5}
- },
- })
- --turn rail
- minetest.register_node("train:rail_turn", {
- description = "rail",
- paramtype = "light",
- paramtype2 = "facedir",
- tiles = {"default_steel_block.png"},
- drawtype = "nodebox",
- groups = {crumbly=3,rail=1},
- node_box = {
- type = "fixed",
- fixed = {
- {-0.4,-0.3,-0.5,-0.3,-0.1,0.4},
- {-0.4,-0.3,0.3,0.5,-0.1,0.4},
- {0.3,-0.3,-0.5,0.4,-0.1,-0.3},
- {0.3,-0.3,-0.4,0.5,-0.1,-0.3},
- },
- },
- selection_box = {
- type = "fixed",
- fixed = {-0.5,-0.5,-0.5,0.5,-0.1,0.5}
- },
- })
- --train bogie
- train = {
- physical = true,
- collisionbox = {-0.3,-0.3,-0.3,0.3,0.3,0.3},
- --textures =,
- visual = "cube",
- --mesh = "boat.x",
- visual_size = {x=0.5, y=0.5},
- textures = {"default_stone.png"},
- timer = 0,
- speed = 0,
- direction = left,
- lastpos = nil,
- other = nil,
- lead = false,
- speed = {},
- }
- train.on_rightclick = function(self)
- print(dump(self.lead))
- end
- train.on_activate = function(self)
- --on activate
- end
- train.on_step = function(self)
- self.speed = self.object:getvelocity()
- calculate_train_dir(self, self.object:getpos())
- self.object:setvelocity(self.direction)
- end
- minetest.register_entity("train:train", train)
- --[[
- --train body
- train = {
- physical = true,
- collisionbox = {-0.5,-0.5,-0.5,0.5,0.5,0.5},
- --textures =,
- visual = "mesh",
- mesh = "train.x",
- visual_size = {x=1, y=1},
- textures = {"default_stone.png"},
- timer = 0,
- speed = 0,
- direction = left,
- lastpos = nil,
- }
- train.on_activate = function(self)
- --on activate
- end
- train.on_step = function(self)
- --on step
- end
- minetest.register_entity("train:train", train)
- ]]--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement