Merge pull request #17 from gpcf/master

privilege to remove trains and replaced occurences of deprecated minetest.env:
master
orwell96 2017-01-19 19:00:52 +01:00 committed by GitHub
commit 9d3542d4a4
2 changed files with 17 additions and 7 deletions

View File

@ -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

View File

@ -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