aboutsummaryrefslogtreecommitdiff
path: root/advtrains/trainlogic.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2019-03-09 11:29:22 +0100
committerorwell96 <orwell@bleipb.de>2019-03-09 11:29:22 +0100
commit7149137990dce85d856feb126df711c3c43087db (patch)
tree92cc201e1cc5c3be6eeb7b64a04644e39f71f80e /advtrains/trainlogic.lua
parentbc31f205cd7433e2f364491d8c76ce0d6504d457 (diff)
downloadadvtrains-7149137990dce85d856feb126df711c3c43087db.tar.gz
advtrains-7149137990dce85d856feb126df711c3c43087db.tar.bz2
advtrains-7149137990dce85d856feb126df711c3c43087db.zip
Add setting for death behavior and implement damage checks better
Diffstat (limited to 'advtrains/trainlogic.lua')
-rw-r--r--advtrains/trainlogic.lua30
1 files changed, 17 insertions, 13 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index 2371490..523e51d 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -1,6 +1,7 @@
--trainlogic.lua
--controls train entities stuff about connecting/disconnecting/colliding trains and other things
+local setting_overrun_mode = minetest.settings:get("advtrains_overrun_mode")
local benchmark=false
local bm={}
@@ -534,22 +535,25 @@ function advtrains.train_step_c(id, train, dtime)
collided = true
end
--- 8b damage players ---
- if not minetest.settings:get_bool("creative_mode") then
+ if setting_overrun_mode=="drop" or setting_overrun_mode=="normal" then
local testpts = minetest.pos_to_string(testpos)
local player=advtrains.playersbypts[testpts]
- if player and not minetest.check_player_privs(player, "creative") and train.velocity>3 then
- --instantly kill player
- --drop inventory contents first, to not to spawn bones
- local player_inv=player:get_inventory()
- for i=1,player_inv:get_size("main") do
- minetest.add_item(testpos, player_inv:get_stack("main", i))
+ if player and train.velocity>3 and player:get_hp()>0 and advtrains.is_damage_enabled(player:get_player_name()) then
+ --atdebug("damage found",player:get_player_name())
+ if setting_overrun_mode=="drop" then
+ --instantly kill player
+ --drop inventory contents first, to not to spawn bones
+ local player_inv=player:get_inventory()
+ for i=1,player_inv:get_size("main") do
+ minetest.add_item(testpos, player_inv:get_stack("main", i))
+ end
+ for i=1,player_inv:get_size("craft") do
+ minetest.add_item(testpos, player_inv:get_stack("craft", i))
+ end
+ -- empty lists main and craft
+ player_inv:set_list("main", {})
+ player_inv:set_list("craft", {})
end
- for i=1,player_inv:get_size("craft") do
- minetest.add_item(testpos, player_inv:get_stack("craft", i))
- end
- -- empty lists main and craft
- player_inv:set_list("main", {})
- player_inv:set_list("craft", {})
player:set_hp(0)
end
end