Added privilege to remove trains
This commit is contained in:
parent
b4b4936b15
commit
176ee0627e
|
@ -327,8 +327,10 @@ function advtrains.train_step(id, train, dtime)
|
|||
elseif advtrains.wagon_save[w_id] then
|
||||
--print(w_id.." not loaded, but save available")
|
||||
--spawn a new and initialize it with the properties from wagon_save
|
||||
local le=minetest.env:add_entity(ori_pos, advtrains.wagon_save[w_id].entity_name):get_luaentity()
|
||||
local le=minetest.add_entity(ori_pos, advtrains.wagon_save[w_id].entity_name):get_luaentity()
|
||||
if le then -- Don't crash if traintype has been removed
|
||||
le:init_from_wagon_save(w_id)
|
||||
end
|
||||
else
|
||||
print(w_id.." not loaded and no save available")
|
||||
--what the hell...
|
||||
|
|
17
wagons.lua
17
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,8 +173,8 @@ 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.")
|
||||
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
|
||||
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue