aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2017-01-19 19:00:52 +0100
committerGitHub <noreply@github.com>2017-01-19 19:00:52 +0100
commit9d3542d4a4b98c140d5d2384a5b8a2ed9736679c (patch)
tree4a5fb198d21a0a5d1fbb83a2eeda22ec28ca61cd
parent4bc5163787c6c4c42fd14016c1c5103529d0e239 (diff)
parent647b3c8a4c80689fef41663fdad3619d006d38ac (diff)
downloadadvtrains-9d3542d4a4b98c140d5d2384a5b8a2ed9736679c.tar.gz
advtrains-9d3542d4a4b98c140d5d2384a5b8a2ed9736679c.tar.bz2
advtrains-9d3542d4a4b98c140d5d2384a5b8a2ed9736679c.zip
Merge pull request #17 from gpcf/master
privilege to remove trains and replaced occurences of deprecated minetest.env:
-rw-r--r--advtrains/advtrains/trainlogic.lua2
-rw-r--r--advtrains/advtrains/wagons.lua22
2 files changed, 17 insertions, 7 deletions
diff --git a/advtrains/advtrains/trainlogic.lua b/advtrains/advtrains/trainlogic.lua
index 5bedfec..d2c86a4 100644
--- a/advtrains/advtrains/trainlogic.lua
+++ b/advtrains/advtrains/trainlogic.lua
@@ -487,7 +487,7 @@ function advtrains.update_trainpart_properties(train_id, invert_flipstate)
if not wagon then
if advtrains.wagon_save[w_id] then
--spawn a new and initialize it with the properties from wagon_save
- wagon=minetest.env:add_entity(train.last_pos, advtrains.wagon_save[w_id].entity_name):get_luaentity()
+ wagon=minetest.add_entity(train.last_pos, advtrains.wagon_save[w_id].entity_name):get_luaentity()
if not wagon then
minetest.chat_send_all("[advtrains] Warning: Wagon "..advtrains.wagon_save[w_id].entity_name.." does not exist. Make sure all required modules are loaded!")
else
diff --git a/advtrains/advtrains/wagons.lua b/advtrains/advtrains/wagons.lua
index 13811ad..029d2d1 100644
--- a/advtrains/advtrains/wagons.lua
+++ b/advtrains/advtrains/wagons.lua
@@ -1,5 +1,14 @@
--atan2 counts angles clockwise, minetest does counterclockwise
+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,
@@ -171,9 +180,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
@@ -541,8 +550,9 @@ function advtrains.register_wagon(sysname, prototype, desc, inv_img)
return
end
- local node=minetest.env:get_node_or_nil(pointed_thing.under)
- if not node then atprint("Ignore at placer position") return itemstack end
+
+ local node=minetest.get_node_or_nil(pointed_thing.under)
+ if not node then atprint("[advtrains]Ignore at placer position") return itemstack end
local nodename=node.name
if(not advtrains.is_track_and_drives_on(nodename, prototype.drives_on)) then
atprint("no track here, not placing.")
@@ -551,7 +561,7 @@ function advtrains.register_wagon(sysname, 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))
- 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
atprint("couldn't add_entity, aborting")
end