summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstujones11 <stujones111@gmail.com>2016-01-13 19:51:50 +0000
committerstujones11 <stujones111@gmail.com>2016-01-13 21:06:38 +0000
commit4416e9b8ad399afa9016a9454e2f84926797cbb5 (patch)
tree26ebd2fc79da9181d26c2dd78cdd32ed7d013381
parent6dfdaf78522a9c92e4323fa5bb77eb3a7c11aa30 (diff)
Remove placement privs until a better solution is found & misc fixes
-rw-r--r--railcart/init.lua6
-rw-r--r--railtrack/init.lua13
-rw-r--r--railtrack/railtrack.lua20
3 files changed, 21 insertions, 18 deletions
diff --git a/railcart/init.lua b/railcart/init.lua
index df9d4f1..417b429 100644
--- a/railcart/init.lua
+++ b/railcart/init.lua
@@ -32,6 +32,10 @@ minetest.register_globalstep(function(dtime)
end
end)
+minetest.register_on_shutdown(function()
+ railcart:save()
+end)
+
minetest.register_privilege("carts", "Player can pick-up and place carts.")
minetest.register_entity("railcart:cart_entity", {
@@ -58,6 +62,7 @@ minetest.register_entity("railcart:cart_entity", {
if self.cart then
if self.cart.id then
railcart.allcarts[self.cart.id] = nil
+ railcart:save()
end
end
self.object:remove()
@@ -136,6 +141,7 @@ minetest.register_craftitem("railcart:cart", {
cart.prev = vector.new(pos)
cart.accel = railtrack:get_acceleration(pos)
table.insert(railcart.allcarts, cart)
+ railcart:save()
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
diff --git a/railtrack/init.lua b/railtrack/init.lua
index 373fcaa..353249f 100644
--- a/railtrack/init.lua
+++ b/railtrack/init.lua
@@ -96,11 +96,14 @@ minetest.register_tool("railtrack:fixer", {
end
end
local node = minetest.get_node(pos)
- minetest.remove_node(pos)
- set_node(pos, node)
- local def = minetest.registered_items[node.name] or {}
- if type(def.after_place_node) == "function" then
- def.after_place_node(pos, user, node)
+ if node then
+ minetest.remove_node(pos)
+ minetest.set_node(pos, node)
+ local def = minetest.registered_items[node.name] or {}
+ local itemstack = ItemStack(node.name)
+ if type(def.after_place_node) == "function" then
+ def.after_place_node(pos, user, itemstack)
+ end
end
end,
})
diff --git a/railtrack/railtrack.lua b/railtrack/railtrack.lua
index 3a1f714..9b4c2c9 100644
--- a/railtrack/railtrack.lua
+++ b/railtrack/railtrack.lua
@@ -22,18 +22,6 @@ railtrack.default_rail = {
groups = {bendy = 2, dig_immediate = 2, attached_node = 1,
connect_to_raillike = minetest.raillike_group("rail")},
railtype = "rail",
- on_place = function(itemstack, placer, pointed_thing)
- local name = placer:get_player_name()
- if not name or pointed_thing.type ~= "node" then
- return
- end
- if not minetest.is_singleplayer() then
- if not minetest.check_player_privs(name, {rails=true}) then
- minetest.chat_send_player(name, "Requires rails privilege")
- return
- end
- end
- end,
after_place_node = function(pos, placer, itemstack)
local meta = minetest.get_meta(pos)
local def = itemstack:get_definition() or {}
@@ -57,7 +45,13 @@ railtrack.default_rail = {
on_construct = function(pos)
railtrack:update_rails(pos)
end,
- after_destruct = function(pos)
+ after_destruct = function(pos, oldnode)
+ if not minetest.is_singleplayer() then
+ if not minetest.check_player_privs(name, {rails=true}) then
+ minetest.chat_send_player(name, "Requires rails privilege")
+ minetest.set_node(pos, oldnode)
+ end
+ end
local cons = railtrack:get_connections(pos)
for _, p in pairs(cons) do
railtrack:update_rails(p)