aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2017-01-25 21:36:17 +0100
committerorwell96 <mono96.mml@gmail.com>2017-01-25 21:38:08 +0100
commit54b566e7a7c3446e8f41d06d322f085f4c156852 (patch)
treeacb1124681e7324a9431d462cfb1e89f7b2a6ed5
parentffc49f097224b028c1d4c70c7e21a22ed127a367 (diff)
downloadadvtrains-54b566e7a7c3446e8f41d06d322f085f4c156852.tar.gz
advtrains-54b566e7a7c3446e8f41d06d322f085f4c156852.tar.bz2
advtrains-54b566e7a7c3446e8f41d06d322f085f4c156852.zip
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.
-rw-r--r--advtrains/advtrains/api_doc.txt3
-rw-r--r--advtrains/advtrains/wagons.lua15
2 files changed, 13 insertions, 5 deletions
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