diff options
author | orwell96 <mono96.mml@gmail.com> | 2017-03-11 22:19:01 +0100 |
---|---|---|
committer | orwell96 <mono96.mml@gmail.com> | 2017-03-11 22:19:01 +0100 |
commit | 0dd40c2434fee15395496e87fff706b34c0964a7 (patch) | |
tree | 81da23d5413fbfbea7a7fd20d7d267532922f426 /advtrains | |
parent | 4187d2504cf00bc321ae57f50e3feeb911987d06 (diff) | |
download | advtrains-0dd40c2434fee15395496e87fff706b34c0964a7.tar.gz advtrains-0dd40c2434fee15395496e87fff706b34c0964a7.tar.bz2 advtrains-0dd40c2434fee15395496e87fff706b34c0964a7.zip |
Don't drop items in creative mode when player gets overrun by train
Diffstat (limited to 'advtrains')
-rw-r--r-- | advtrains/advtrains/trainlogic.lua | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/advtrains/advtrains/trainlogic.lua b/advtrains/advtrains/trainlogic.lua index 6b9d1aa..d9edd6d 100644 --- a/advtrains/advtrains/trainlogic.lua +++ b/advtrains/advtrains/trainlogic.lua @@ -523,21 +523,23 @@ function advtrains.train_step_b(id, train, dtime) advtrains.collide_and_spawn_couple(id, testpos, advtrains.detector.on_node[testpts], train.movedir==-1) end --- 8b damage players --- - local player=advtrains.playersbypts[testpts] - if player 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 not minetest.setting_getbool("creative_mode") then + local player=advtrains.playersbypts[testpts] + if player 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)) + 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 - 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 end |