From 9a73acd24606f2256052d254bd301294b5e4cda1 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Thu, 22 Oct 2020 20:23:47 +0200 Subject: [PATCH] initial D00Med/vehicles support --- init.lua | 1 + mod.conf | 2 +- player.lua | 15 +++++++++++++++ vehicles.lua | 23 +++++++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 vehicles.lua diff --git a/init.lua b/init.lua index d23ab73..000335e 100644 --- a/init.lua +++ b/init.lua @@ -19,6 +19,7 @@ dofile(creative_regions.modpath.."/chatcommands.lua") dofile(creative_regions.modpath.."/items.lua") dofile(creative_regions.modpath.."/mod_areas.lua") dofile(creative_regions.modpath.."/arena.lua") +dofile(creative_regions.modpath.."/vehicles.lua") function creative_regions:update_player(player) diff --git a/mod.conf b/mod.conf index d82557e..804f9eb 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,4 @@ name = creative_regions description = Toggle privs in areas depends = default, sfinv -optional_depends = areas, unified_inventory, hunger_ng +optional_depends = areas, unified_inventory, hunger_ng, vehicles diff --git a/player.lua b/player.lua index b73a5d7..a04dec2 100644 --- a/player.lua +++ b/player.lua @@ -81,6 +81,21 @@ function creative_regions:player_enter_region(player, new_privs_table) new_mode = "survival" end + if minetest.get_modpath("vehicles") then + if privs_revoke.vehicles and not privs_grant.vehicles then + local attached_to = player:get_attach() + if attached_to and attached_to:get_luaentity() then + local entity = attached_to:get_luaentity() + if entity ~= nil and entity.driver then + minetest.chat_send_player(name, "attached to something") + vehicles.object_detach(entity, entity.driver, {x=1, y=0, z=1}) + vehicles.explodinate(entity, 5) + entity.object:remove() + end + end + end + end + if new_mode ~= old_mode then if old_mode == "arena" then diff --git a/vehicles.lua b/vehicles.lua new file mode 100644 index 0000000..a968860 --- /dev/null +++ b/vehicles.lua @@ -0,0 +1,23 @@ +if minetest.get_modpath("vehicles") then + + minetest.register_privilege("vehicles", { + description = "Player is allowed to drive vehicles.", + give_to_singleplayer= true, + }) + + minetest.register_node("creative_regions:protector_vehicles", { + description = "No driving protector", + tiles = {"default_cobble.png^vehicles_wheel.png"}, + is_ground_content = true, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=1}, + light_source = 1, + after_place_node = function(pos, placer, itemstack, pointed_thing) + return creative_regions.protector_set_area_privs(pos, placer, itemstack, pointed_thing, "-vehicles", "No driving Protector") + end, + can_dig = creative_regions.protector_can_dig, + after_dig_node = function(pos, oldnode, oldmetadata, digger) + return creative_regions.protector_remove_area_privs(pos, oldnode, oldmetadata, digger, "No driving protector") + end + }) + +end