--atan2 counts angles clockwise, minetest does counterclockwise
local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end
local wagon={
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
--physical = true,
visual = "mesh",
mesh = "wagon.b3d",
visual_size = {x=3, y=3},
textures = {"black.png"},
is_wagon=true,
wagon_span=1,--how many index units of space does this wagon consume
attach_offset={x=0, y=0, z=0},
view_offset={x=0, y=0, z=0},
}
function wagon:on_rightclick(clicker)
print("[advtrains] wagon rightclick")
if not clicker or not clicker:is_player() then
return
end
if not self.initialized then
print("[advtrains] not initiaalized")
return
end
if clicker:get_player_control().sneak then
advtrains.split_train_at_wagon(self)
return
end
if clicker:get_player_control().aux1 then
--advtrains.dumppath(self:train().path)
--minetest.chat_send_all("at index "..(self:train().index or "nil"))
--advtrains.invert_train(self.train_id)
minetest.chat_send_all(dump(self:train()))
return
end
if self.driver and clicker == self.driver then
|