diff options
author | orwell96 <mono96.mml@gmail.com> | 2016-12-20 14:17:39 +0100 |
---|---|---|
committer | orwell96 <mono96.mml@gmail.com> | 2016-12-20 14:17:39 +0100 |
commit | f806ed9eee8c13eb0b4868641311d25257c63f46 (patch) | |
tree | 0657366d21caf17881266054baa1dfae2365b9d8 /advtrains/damage.lua | |
parent | 05ce694decc0653997f45fa4f9a24b40057dbd01 (diff) | |
download | advtrains-f806ed9eee8c13eb0b4868641311d25257c63f46.tar.gz advtrains-f806ed9eee8c13eb0b4868641311d25257c63f46.tar.bz2 advtrains-f806ed9eee8c13eb0b4868641311d25257c63f46.zip |
Turning mod into a modpack and separating the trains from the core mod
Diffstat (limited to 'advtrains/damage.lua')
-rw-r--r-- | advtrains/damage.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/advtrains/damage.lua b/advtrains/damage.lua new file mode 100644 index 0000000..b39fe67 --- /dev/null +++ b/advtrains/damage.lua @@ -0,0 +1,26 @@ +--damage.lua +--a globalstep that damages players overrolled by trains. + +advtrains.player_to_train_mapping={} + +local tmr=0 +minetest.register_globalstep(function(dtime) + tmr=tmr-dtime + if tmr<=0 then + + for _, player in pairs(minetest.get_connected_players()) do + local pos=player:getpos() + 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 (not advtrains.player_to_train_mapping[player:get_player_name()] or le.train_id~=advtrains.player_to_train_mapping[player:get_player_name()]) 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 + end + end + end + + tmr=0.5 + end +end) |