aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2017-03-30 21:51:45 +0200
committerorwell96 <mono96.mml@gmail.com>2017-03-30 21:51:45 +0200
commit606c129f5796eb56e9abd1049954cf1ca0b8f410 (patch)
tree3fccf8a941f8a51c3f7472a50db4ac0026e2be2d /advtrains
parentb5a5d9035f83c47e64b3b0e3343c9de519391907 (diff)
downloadadvtrains-606c129f5796eb56e9abd1049954cf1ca0b8f410.tar.gz
advtrains-606c129f5796eb56e9abd1049954cf1ca0b8f410.tar.bz2
advtrains-606c129f5796eb56e9abd1049954cf1ca0b8f410.zip
Add support to display text to passengers and on the outside of the train
Outside is currently displayed as infotext. TODO: signs-like draw it on the wagon FIXME: When object properties are set, for some reason the animation restarts
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/advtrains/trainhud.lua3
-rw-r--r--advtrains/advtrains/wagons.lua50
-rw-r--r--advtrains/advtrains_luaautomation/README.txt4
-rw-r--r--advtrains/advtrains_luaautomation/atc_rail.lua10
4 files changed, 57 insertions, 10 deletions
diff --git a/advtrains/advtrains/trainhud.lua b/advtrains/advtrains/trainhud.lua
index 637fce2..967acfc 100644
--- a/advtrains/advtrains/trainhud.lua
+++ b/advtrains/advtrains/trainhud.lua
@@ -75,7 +75,8 @@ function advtrains.on_control_change(pc, train, flip)
end
end
function advtrains.update_driver_hud(pname, train, flip)
- advtrains.set_trainhud(pname, advtrains.hud_train_format(train, flip))
+ local inside=train.text_inside or ""
+ advtrains.set_trainhud(pname, inside.."\n"..advtrains.hud_train_format(train, flip))
end
function advtrains.clear_driver_hud(pname)
advtrains.set_trainhud(pname, "")
diff --git a/advtrains/advtrains/wagons.lua b/advtrains/advtrains/wagons.lua
index 5f7e3de..641b8b4 100644
--- a/advtrains/advtrains/wagons.lua
+++ b/advtrains/advtrains/wagons.lua
@@ -244,6 +244,10 @@ function wagon:on_step(dtime)
local driver=self.seatp[seatno] and minetest.get_player_by_name(self.seatp[seatno])
if seat.driving_ctrl_access and driver then
advtrains.update_driver_hud(driver:get_player_name(), self:train(), self.wagon_flipped)
+ elseif driver then
+ --only show the inside text
+ local inside=self:train().text_inside or ""
+ advtrains.set_trainhud(driver:get_player_name(), inside)
end
if driver and driver:get_player_control_bits()~=self.seatpc[seatno] then
local pc=driver:get_player_control()
@@ -267,7 +271,13 @@ function wagon:on_step(dtime)
end
end
end
-
+
+ --check infotext
+ local outside=self:train().text_outside or ""
+ if self.object:get_properties().infotext~=outside then
+ self.object:set_properties({infotext=outside})
+ end
+
local gp=self:train()
local fct=self.wagon_flipped and -1 or 1
--door animation
@@ -662,8 +672,9 @@ function wagon:show_get_on_form(pname)
minetest.show_formspec(pname, "advtrains_geton_"..self.unique_id, form)
end
function wagon:show_wagon_properties(pname)
- if not self.seat_groups then
- return
+ local numsgr=0
+ if self.seat_groups then
+ numsgr=#self.seat_groups
end
if not self.seat_access then
self.seat_access={}
@@ -673,15 +684,21 @@ function wagon:show_wagon_properties(pname)
checkbox: lock couples
button: save
]]
- local form="size[5,"..(#self.seat_groups*1.5+5).."]"
+ local form="size[5,"..(numsgr*1.5+7).."]"
local at=0
- for sgr,sgrdef in pairs(self.seat_groups) do
- local text = attrans("Access to @1",sgrdef.name)
- form=form.."field[0.5,"..(0.5+at*1.5)..";4,1;sgr_"..sgr..";"..text..";"..(self.seat_access[sgr] or "").."]"
- at=at+1
+ if self.seat_groups then
+ for sgr,sgrdef in pairs(self.seat_groups) do
+ local text = attrans("Access to @1",sgrdef.name)
+ form=form.."field[0.5,"..(0.5+at*1.5)..";4,1;sgr_"..sgr..";"..text..";"..(self.seat_access[sgr] or "").."]"
+ at=at+1
+ end
end
form=form.."checkbox[0,"..(at*1.5)..";lock_couples;"..attrans("Lock couples")..";"..(self.lock_couples and "true" or "false").."]"
- form=form.."button_exit[0.5,"..(1+at*1.5)..";4,1;save;"..attrans("Save wagon properties").."]"
+ if self:train() then --just in case
+ form=form.."field[0.5,"..(1.5+at*1.5)..";4,1;text_outside;"..attrans("Text displayed outside on train")..";"..(self:train().text_outside or "").."]"
+ form=form.."field[0.5,"..(2.5+at*1.5)..";4,1;text_inside;"..attrans("Text displayed inside train")..";"..(self:train().text_inside or "").."]"
+ end
+ form=form.."button_exit[0.5,"..(3+at*1.5)..";4,1;save;"..attrans("Save wagon properties").."]"
minetest.show_formspec(pname, "advtrains_prop_"..self.unique_id, form)
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
@@ -737,6 +754,21 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.lock_couples then
wagon.lock_couples = fields.lock_couples == "true"
end
+ if fields.text_outside then
+ if fields.text_outside~="" then
+ wagon:train().text_outside=fields.text_outside
+ else
+ wagon:train().text_outside=nil
+ end
+ end
+ if fields.text_inside then
+ if fields.text_inside~="" then
+ wagon:train().text_inside=fields.text_inside
+ else
+ wagon:train().text_inside=nil
+ end
+ end
+
end
end
end
diff --git a/advtrains/advtrains_luaautomation/README.txt b/advtrains/advtrains_luaautomation/README.txt
index 1d29786..907b2fb 100644
--- a/advtrains/advtrains_luaautomation/README.txt
+++ b/advtrains/advtrains_luaautomation/README.txt
@@ -122,6 +122,10 @@ atc_id
Train ID of the train currently passing the controller. Nil if there's no train.
atc_speed
Speed of the train, or nil if there is no train.
+atc_set_text_outside(text)
+ Set text shown on the outside of the train. Pass nil to show no text.
+atc_set_text_inside(text)
+ Set text shown to train passengers. Pass nil to show no text.
# Operator panel
This simple node executes its actions when punched. It can be used to change a switch and update the corresponding signals or similar applications.
diff --git a/advtrains/advtrains_luaautomation/atc_rail.lua b/advtrains/advtrains_luaautomation/atc_rail.lua
index 78ef8f0..141f119 100644
--- a/advtrains/advtrains_luaautomation/atc_rail.lua
+++ b/advtrains/advtrains_luaautomation/atc_rail.lua
@@ -61,6 +61,16 @@ function r.fire_event(pos, evtdata)
atc_arrow = atc_arrow,
atc_id = train_id,
atc_speed = tvel,
+ atc_set_text_outside = function(text)
+ if not train_id then return false end
+ advtrains.trains[train_id].text_outside=text
+ return true
+ end,
+ atc_set_text_inside = function(text)
+ if not train_id then return false end
+ advtrains.trains[train_id].text_inside=text
+ return true
+ end,
}
atlatc.active.run_in_env(pos, evtdata, customfct)