Add forced get-on/off to prevent trains being unusable due to closed doors.
authororwell96 <mono96.mml@gmail.com>
Wed, 25 Jan 2017 20:36:17 +0000 (21:36 +0100)
committerorwell96 <mono96.mml@gmail.com>
Wed, 25 Jan 2017 20:38:08 +0000 (21:38 +0100)
else you would be able to lock yourself out of trains or lock players in trains with no escape.

advtrains/advtrains/api_doc.txt
advtrains/advtrains/wagons.lua

index ca894b1..da0bd8c 100644 (file)
@@ -97,8 +97,7 @@ On a train, right-clicking the wagon will make you get off the train unless:
 In case there's no possibility, does nothing.
 In case there are multiple possibilities, will show a form.
 
-If you can't enter a train because the doors are closed, any of the train's wagon owners or people authorized by them can open the doors(on the side they are standing) with shift-click.
-
+If you can't enter or get off a train because the doors are closed, use shift-rightclick
 ### Tracks
 Most modders will be satisfied with the built-in tracks. If cog railways, maglev trains and mine trains are added, it is necessary to understand the definition of tracks. Although the tracks API is there, explaining it would require more effort than me creating the wanted definitions myself. Contact me if you need to register your own rails using my registration functions.
 
index ef7f238..331f857 100644 (file)
@@ -461,6 +461,12 @@ function wagon:on_rightclick(clicker)
                        end\r
                        if not self.seat_groups[sgr].require_doors_open or self:train().door_open~=0 then\r
                                poss[#poss+1]={name="Get off", key="off"}\r
+                       else\r
+                               if clicker:get_player_control().sneak then\r
+                                       poss[#poss+1]={name="Get off (forced)", key="off"}\r
+                               else\r
+                                       poss[#poss+1]={name="(Doors closed)", key="dcwarn"}\r
+                               end\r
                        end\r
                        if #poss==0 then\r
                                --can't do anything.\r
@@ -485,11 +491,10 @@ function wagon:on_rightclick(clicker)
                                return\r
                        end\r
                        \r
-                       local doors_open = self:train().door_open~=0\r
+                       local doors_open = self:train().door_open~=0 or clicker:get_player_control().sneak\r
                        for _,sgr in ipairs(self.assign_to_seat_group) do\r
                                if self:check_seat_group_access(pname, sgr) then\r
                                        for seatid, seatdef in ipairs(self.seats) do\r
-                                               atprint(sgr, seatid, seatdef, self.seat_groups[sgr], doors_open)\r
                                                if seatdef.group==sgr and not self.seatp[seatid] and (not self.seat_groups[sgr].require_doors_open or doors_open) then\r
                                                        self:get_on(clicker, seatid)\r
                                                        return\r
@@ -498,6 +503,7 @@ function wagon:on_rightclick(clicker)
                                end\r
                        end\r
                        minetest.chat_send_player(pname, "Can't get on: wagon full or doors closed!")\r
+                       minetest.chat_send_player(pname, "Use shift+click to open doors forcefully!")\r
                else\r
                        self:show_get_on_form(pname)\r
                end\r
@@ -641,7 +647,10 @@ function wagon:seating_from_key_helper(pname, fields, no)
        if fields.prop and self.owner==pname then\r
                self:show_wagon_properties(pname)\r
        end\r
-       if fields.off and (not self.seat_groups[sgr].require_doors_open or self:train().door_open~=0) then\r
+       if fields.dcwarn then\r
+               minetest.chat_send_player(pname, "Use shift-rightclick to open doors with force and get off!")\r
+       end\r
+       if fields.off then\r
                self:get_off(no)\r
        end\r
 end\r