From 54b566e7a7c3446e8f41d06d322f085f4c156852 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 25 Jan 2017 21:36:17 +0100 Subject: Add forced get-on/off to prevent trains being unusable due to closed doors. else you would be able to lock yourself out of trains or lock players in trains with no escape. --- advtrains/advtrains/api_doc.txt | 3 +-- advtrains/advtrains/wagons.lua | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'advtrains') diff --git a/advtrains/advtrains/api_doc.txt b/advtrains/advtrains/api_doc.txt index ca894b1..da0bd8c 100644 --- a/advtrains/advtrains/api_doc.txt +++ b/advtrains/advtrains/api_doc.txt @@ -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. diff --git a/advtrains/advtrains/wagons.lua b/advtrains/advtrains/wagons.lua index ef7f238..331f857 100644 --- a/advtrains/advtrains/wagons.lua +++ b/advtrains/advtrains/wagons.lua @@ -461,6 +461,12 @@ function wagon:on_rightclick(clicker) end if not self.seat_groups[sgr].require_doors_open or self:train().door_open~=0 then poss[#poss+1]={name="Get off", key="off"} + else + if clicker:get_player_control().sneak then + poss[#poss+1]={name="Get off (forced)", key="off"} + else + poss[#poss+1]={name="(Doors closed)", key="dcwarn"} + end end if #poss==0 then --can't do anything. @@ -485,11 +491,10 @@ function wagon:on_rightclick(clicker) return end - local doors_open = self:train().door_open~=0 + local doors_open = self:train().door_open~=0 or clicker:get_player_control().sneak for _,sgr in ipairs(self.assign_to_seat_group) do if self:check_seat_group_access(pname, sgr) then for seatid, seatdef in ipairs(self.seats) do - atprint(sgr, seatid, seatdef, self.seat_groups[sgr], doors_open) if seatdef.group==sgr and not self.seatp[seatid] and (not self.seat_groups[sgr].require_doors_open or doors_open) then self:get_on(clicker, seatid) return @@ -498,6 +503,7 @@ function wagon:on_rightclick(clicker) end end minetest.chat_send_player(pname, "Can't get on: wagon full or doors closed!") + minetest.chat_send_player(pname, "Use shift+click to open doors forcefully!") else self:show_get_on_form(pname) end @@ -641,7 +647,10 @@ function wagon:seating_from_key_helper(pname, fields, no) if fields.prop and self.owner==pname then self:show_wagon_properties(pname) end - if fields.off and (not self.seat_groups[sgr].require_doors_open or self:train().door_open~=0) then + if fields.dcwarn then + minetest.chat_send_player(pname, "Use shift-rightclick to open doors with force and get off!") + end + if fields.off then self:get_off(no) end end -- cgit v1.2.3