aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--damage.lua5
-rw-r--r--wagons.lua4
2 files changed, 7 insertions, 2 deletions
diff --git a/damage.lua b/damage.lua
index 860feaa..3fc1d97 100644
--- a/damage.lua
+++ b/damage.lua
@@ -1,5 +1,8 @@
--damage.lua
--a globalstep that damages players overrolled by trains.
+
+advtrains.player_to_wagon_mapping={}
+
local tmr=0
minetest.register_globalstep(function(dtime)
tmr=tmr-dtime
@@ -10,7 +13,7 @@ minetest.register_globalstep(function(dtime)
for _, object in pairs(minetest.get_objects_inside_radius(pos, 1)) do
local le=object:get_luaentity()
if le and le.is_wagon and le.initialized and le:train() then
- if le.driver~=player and math.abs(le:train().velocity)>2 then
+ if (not advtrains.player_to_wagon_mapping[player:get_player_name()] or le.train_id~=advtrains.player_to_wagon_mapping[player:get_player_name()].train_id) and math.abs(le:train().velocity)>2 then
--player:punch(object, 1000, {damage={fleshy=3*math.abs(le:train().velocity)}})
player:set_hp(player:get_hp()-math.abs(le:train().velocity)-3)
end
diff --git a/wagons.lua b/wagons.lua
index 57553d5..6e737d5 100644
--- a/wagons.lua
+++ b/wagons.lua
@@ -37,12 +37,14 @@ function wagon:on_rightclick(clicker)
return
end
if self.driver and clicker == self.driver then
+ advtrains.player_to_wagon_mapping[self.driver:get_player_name()]=nil
advtrains.set_trainhud(self.driver:get_player_name(), "")
self.driver = nil
clicker:set_detach()
clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0})
elseif not self.driver then
self.driver = clicker
+ advtrains.player_to_wagon_mapping[clicker:get_player_name()]=self
clicker:set_attach(self.object, "", self.attach_offset, {x=0,y=0,z=0})
clicker:set_eye_offset(self.view_offset, self.view_offset)
end
@@ -355,7 +357,7 @@ advtrains.register_wagon("newlocomotive", "steam",{
textures = {"advtrains_newlocomotive.png"},
is_locomotive=true,
attach_offset={x=5, y=10, z=-10},
- view_offset={x=0, y=6, z=18},
+ view_offset={x=0, y=6, z=0},
visual_size = {x=1, y=1},
wagon_span=1.85,
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},