aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/api_doc.txt4
-rw-r--r--advtrains/trainhud.lua7
-rw-r--r--advtrains/wagons.lua4
3 files changed, 9 insertions, 6 deletions
diff --git a/advtrains/api_doc.txt b/advtrains/api_doc.txt
index 4ad554a..a9f54ab 100644
--- a/advtrains/api_doc.txt
+++ b/advtrains/api_doc.txt
@@ -125,6 +125,8 @@ advtrains.register_wagon(name, prototype, description, inventory_image)
graphical_hud = function(train, flip) end
^- optional: Graphical HUD to show to the driver.
The HUD formats defined by advtrains are used by default.
+ hud_without_text_inside = false
+ ^- optional: whether the inside display should be excluded from the text HUD
custom_on_step = function(self, dtime) end
^- optional: Execute custom code on every step
@@ -160,7 +162,7 @@ If you can't enter or leave a train because the doors are closed, holding the Sn
# Train HUD
The text_hud and graphical_hud fields of the wagons allow you to specify the look of your driver HUDs.
-* The text_hud function should return a string that will be shown to the driver. This should usually include the inside display as well
+* The text_hud function should return a string that will be shown to the driver. Usually this should not include the inside display.
* The graphical_hud function should return a texture string and the height of the texture. This is used to allow proper positioning of the text HUD.
There are currently a few pre-defined elements that can help create the graphical HUD. These functions are in the advtrains.hud table:
diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua
index 3e5e6fd..bb5841f 100644
--- a/advtrains/trainhud.lua
+++ b/advtrains/trainhud.lua
@@ -86,11 +86,11 @@ function advtrains.on_control_change(pc, train, flip)
end
end
end
-function advtrains.update_driver_hud(pname, train, flip, thud, ghud)
- local inside=train.text_inside or ""
+function advtrains.update_driver_hud(pname, train, flip, thud, ghud, nointext)
+ local inside=nointext and "" or (train.text_inside or "").."\n"
local ft = (thud or advtrains.hud.dtext)(train, flip)
local ht, gs = (ghud or advtrains.hud.dgraphical)(train, flip)
- advtrains.set_trainhud(pname, inside.."\n"..ft, ht, gs)
+ advtrains.set_trainhud(pname, inside..ft, ht, gs)
end
function advtrains.clear_driver_hud(pname)
advtrains.set_trainhud(pname, "")
@@ -185,6 +185,7 @@ end
function advtrains.hud.dtext(train, flip)
local st = {}
if train.debug then st = {train.debug} end
+ local res = advtrains.speed_restriction
st[#st+1] = attrans("Train ID: @1", train.id)
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index 5e21a93..eeffd4f 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -307,10 +307,10 @@ function wagon:on_step(dtime)
local has_driverstand = pname and advtrains.check_driving_couple_protection(pname, data.owner, data.whitelist)
has_driverstand = has_driverstand and self:is_driver_stand(seat)
if has_driverstand and driver then
- advtrains.update_driver_hud(driver:get_player_name(), self:train(), data.wagon_flipped, self.text_hud, self.graphical_hud)
+ advtrains.update_driver_hud(driver:get_player_name(), self:train(), data.wagon_flipped, self.text_hud, self.graphical_hud, self.hud_without_text_inside)
elseif driver then
--only show the inside text
- local inside=self:train().text_inside or ""
+ local inside=(not self.hud_without_text_inside) and 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