Added getting on and off by walking in and out. Default seat on subway is now passeng...
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Sun, 29 Jan 2017 11:37:47 +0000 (12:37 +0100)
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Sun, 29 Jan 2017 11:37:47 +0000 (12:37 +0100)
advtrains/advtrains/damage.lua
advtrains/advtrains/wagons.lua
advtrains/advtrains_train_subway/init.lua

index b39fe67..e05d00d 100644 (file)
@@ -15,7 +15,9 @@ minetest.register_globalstep(function(dtime)
                        if le and le.is_wagon and le.initialized and le:train() then
                                if (not advtrains.player_to_train_mapping[player:get_player_name()] or le.train_id~=advtrains.player_to_train_mapping[player:get_player_name()]) and math.abs(le:train().velocity)>2 then
                                        --player:punch(object, 1000, {damage={fleshy=3*math.abs(le:train().velocity)}})
-                                       player:set_hp(player:get_hp()-math.abs(le:train().velocity)-3)
+                                  player:set_hp(player:get_hp()-math.abs(le:train().velocity)-3)
+                               elseif (not advtrains.player_to_train_mapping[player:get_player_name()] or le.train_id~=advtrains.player_to_train_mapping[player:get_player_name()]) and le:train().door_open~=0 then
+                                  le:on_rightclick(player)
                                end
                        end
                end
index 9d63ab5..163dc73 100644 (file)
@@ -257,6 +257,14 @@ function wagon:on_step(dtime)
                                        advtrains.update_driver_hud(driver:get_player_name(), self:train(), self.wagon_flipped)\r
                                end\r
                        end\r
+               else\r
+                  local pass = self.seatp[seatno] and minetest.get_player_by_name(self.seatp[seatno])\r
+                  if pass and self:train().door_open~=0 then\r
+                     local pc=pass:get_player_control()\r
+                     if pc.up or pc.down then\r
+                        self:get_off(seatno)\r
+                     end\r
+                  end                \r
                end\r
        end\r
 \r
@@ -744,7 +752,7 @@ function advtrains.register_wagon(sysname, prototype, desc, inv_img)
                                return\r
                        end\r
                        \r
-
+\r
                        local node=minetest.get_node_or_nil(pointed_thing.under)\r
                        if not node then atprint("[advtrains]Ignore at placer position") return itemstack end\r
                        local nodename=node.name\r
index 5625418..1282ec7 100644 (file)
@@ -55,7 +55,7 @@ advtrains.register_wagon("subway_wagon", {
                        require_doors_open=true,
                },
        },
-       assign_to_seat_group = {"dstand", "pass"},
+       assign_to_seat_group = {"pass","dstand"},
        doors={
                open={
                        [-1]={frames={x=0, y=20}, time=1},
@@ -68,7 +68,7 @@ advtrains.register_wagon("subway_wagon", {
        },
        visual_size = {x=1, y=1},
        wagon_span=2,
-       collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
+       collisionbox = {-1.0,-0.5,-1.8, 1.0,2.5,1.8},
        is_locomotive=true,
        drops={"default:steelblock 4"},
        --custom_on_activate = function(self, dtime_s)