aboutsummaryrefslogtreecommitdiff
path: root/damage.lua
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2016-06-02 14:42:01 +0200
committerorwell96 <mono96.mml@gmail.com>2016-06-02 14:42:01 +0200
commite449704a92c8c1931fb687e58f095bea27db3ddc (patch)
tree4e8eec18b018cb47a30ca24a4338520d82b284c2 /damage.lua
parenta7bd6e96afa02e4bddfbd105e31616900be2edfb (diff)
downloadadvtrains-e449704a92c8c1931fb687e58f095bea27db3ddc.tar.gz
advtrains-e449704a92c8c1931fb687e58f095bea27db3ddc.tar.bz2
advtrains-e449704a92c8c1931fb687e58f095bea27db3ddc.zip
use real pos-in-train calculation also for trainlen calculation, fix bugs and add damage by trains
Diffstat (limited to 'damage.lua')
-rw-r--r--damage.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/damage.lua b/damage.lua
new file mode 100644
index 0000000..860feaa
--- /dev/null
+++ b/damage.lua
@@ -0,0 +1,23 @@
+--damage.lua
+--a globalstep that damages players overrolled by trains.
+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 le.driver~=player 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)