aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2017-01-19 20:36:00 +0100
committerorwell96 <mono96.mml@gmail.com>2017-01-19 20:36:00 +0100
commit203a36a5ebb4853da8ce120d0ae0df1a3f568c00 (patch)
tree070d8b057f7422863177511ba1bdfbac622c5cb5 /advtrains
parent6060556796f71328f781677cdbbd2b90fe4635d9 (diff)
parent9d3542d4a4b98c140d5d2384a5b8a2ed9736679c (diff)
downloadadvtrains-203a36a5ebb4853da8ce120d0ae0df1a3f568c00.tar.gz
advtrains-203a36a5ebb4853da8ce120d0ae0df1a3f568c00.tar.bz2
advtrains-203a36a5ebb4853da8ce120d0ae0df1a3f568c00.zip
Merge branch 'master' of https://github.com/orwell96/advtrains
Diffstat (limited to 'advtrains')
-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 265a84c..b46ed81 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,
@@ -174,9 +183,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
@@ -584,8 +593,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.")
@@ -594,7 +604,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