5 goal - > go to goal - > check all this and repeat
8 minecart does check axis dir then -1 1 on opposite axis (x and z)
10 minecart checks in front and above
12 minecart checks in front and below
14 if in front above start moving up
16 if in front below start moving down
18 minecart checks if rail in front then if not check sides and if none then stop
20 if a rail in front of minecart then when past center of node center, turn towards the available rail and then recenter self onto rail on the new axis
28 local path = minetest.get_modpath("minecart")
29 dofile(path.."/rail.lua")
34 initial_properties = {
35 physical = false, -- otherwise going uphill breaks
36 collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
38 mesh = "minecart.b3d",
39 visual_size = {x=1, y=1},
40 textures = {"minecart.png"},
41 automatic_face_movement_dir = 90.0,
49 function minecart:on_rightclick(clicker)
50 if not clicker or not clicker:is_player() then
53 local player_name = clicker:get_player_name()
54 if self.rider and player_name == self.rider then
56 carts:manage_attachment(clicker, nil)
57 elseif not self.rider then
58 self.rider = player_name
59 carts:manage_attachment(clicker, self.object)
61 -- player_api does not update the animation
62 -- when the player is attached, reset to default animation
64 --player_api.set_animation(clicker, "stand")
68 function minecart:on_activate(staticdata, dtime_s)
69 self.object:set_armor_groups({immortal=1})
70 if string.sub(staticdata, 1, string.len("return")) ~= "return" then
73 local data = minetest.deserialize(staticdata)
74 if type(data) ~= "table" then
77 self.railtype = data.railtype
79 self.old_dir = data.old_dir
83 function minecart:get_staticdata()
84 return minetest.serialize({
87 function minecart:on_punch(puncher, time_from_last_punch, tool_capabilities, dir, damage)
96 --repel from players on track "push"
97 function minecart:push(self)
98 local pos = self.object:getpos()
99 for _,object in ipairs(minetest.get_objects_inside_radius(pos, 2)) do
100 if object:is_player() then
101 local player_pos = object:getpos()
106 function minecart:ride_rail(self)
108 print("goal: "..dump(self.goal))
114 function minecart:on_step(dtime)
116 minecart:ride_rail(self)
119 minetest.register_entity("minecart:minecart", minecart)
140 minetest.register_craftitem("minecart:minecart", {
141 description = "Minecart",
142 inventory_image = "minecartitem.png",
143 wield_image = "minecartitem.png",
144 on_place = function(itemstack, placer, pointed_thing)
145 if not pointed_thing.type == "node" then
149 if minetest.get_item_group(minetest.get_node(pointed_thing.under).name, "rail")>0 then
150 minetest.add_entity(pointed_thing.under, "minecart:minecart")
155 itemstack:take_item()
161 minetest.register_craft({
162 output = "minecart:minecart",
164 {"main:iron", "", "main:iron"},
165 {"main:iron", "main:iron", "main:iron"},