aboutsummaryrefslogtreecommitdiff
path: root/wagons.lua
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2016-12-29 00:27:07 +0100
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2016-12-29 00:27:07 +0100
commit176ee0627ebc397c60650fc5b059829788fe3cdc (patch)
tree2608687c638bd8a7f24f38a812c95e63e22e0213 /wagons.lua
parentb4b4936b15127b48f527eccdcee0a5de82a2a2fb (diff)
downloadadvtrains-176ee0627ebc397c60650fc5b059829788fe3cdc.tar.gz
advtrains-176ee0627ebc397c60650fc5b059829788fe3cdc.tar.bz2
advtrains-176ee0627ebc397c60650fc5b059829788fe3cdc.zip
Added privilege to remove trains
Diffstat (limited to 'wagons.lua')
-rw-r--r--wagons.lua19
1 files changed, 14 insertions, 5 deletions
diff --git a/wagons.lua b/wagons.lua
index ca31590..8a96c39 100644
--- a/wagons.lua
+++ b/wagons.lua
@@ -2,6 +2,15 @@
--local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end
local print=function() end
+minetest.register_privilege("train_place", {
+ description = "Player can place trains on tracks not owned by player",
+ give_to_singleplayer= false,
+});
+minetest.register_privilege("train_remove", {
+ description = "Player can remove trains not owned by player",
+ give_to_singleplayer= false,
+});
+
local wagon={
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
--physical = true,
@@ -164,9 +173,9 @@ function wagon:on_punch(puncher, time_from_last_punch, tool_capabilities, direct
if not puncher or not puncher:is_player() then
return
end
- if self.owner and puncher:get_player_name()~=self.owner then
- minetest.chat_send_player(puncher:get_player_name(), "This wagon is owned by "..self.owner..", you can't destroy it.")
- return
+ if self.owner and puncher:get_player_name()~=self.owner and (not minetest.check_player_privs(puncher, {train_remove = true })) then
+ minetest.chat_send_player(puncher:get_player_name(), "This wagon is owned by "..self.owner..", you can't destroy it.");
+ return
end
if minetest.setting_getbool("creative_mode") then
@@ -534,7 +543,7 @@ function advtrains.register_wagon(sysname, traintype, prototype, desc, inv_img)
return
end
- local node=minetest.env:get_node_or_nil(pointed_thing.under)
+ local node=minetest.get_node_or_nil(pointed_thing.under)
if not node then print("[advtrains]Ignore at placer position") return itemstack end
local nodename=node.name
if(not advtrains.is_track_and_drives_on(nodename, advtrains.all_traintypes[traintype].drives_on)) then
@@ -544,7 +553,7 @@ function advtrains.register_wagon(sysname, traintype, prototype, desc, inv_img)
local conn1=advtrains.get_track_connections(node.name, node.param2)
local id=advtrains.create_new_train_at(pointed_thing.under, advtrains.dirCoordSet(pointed_thing.under, conn1), traintype)
- local ob=minetest.env:add_entity(pointed_thing.under, "advtrains:"..sysname)
+ local ob=minetest.add_entity(pointed_thing.under, "advtrains:"..sysname)
if not ob then
print("[advtrains]couldn't add_entity, aborting")
end