dofile(minetest.get_modpath("item_drop").."/item_entity.lua")
time_pick = 3
-minetest.register_globalstep(function(dtime)
- for _,player in ipairs(minetest.get_connected_players()) do
- local pos = player:getpos()
- pos.y = pos.y+0.5
- local inv = player:get_inventory()
- for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 2)) do
- if not object:is_player() and object:get_luaentity() then
- local obj=object:get_luaentity()
- if obj.name == "__builtin:item" then
- if inv:room_for_item("main", ItemStack(obj.itemstring)) then
- if obj.timer > time_pick then
- inv:add_item("main", ItemStack(obj.itemstring))
- if obj.itemstring ~= "" then
- minetest.sound_play("item_drop_pickup",{pos = pos, gain = 1.0, max_hear_distance = 10})
- end
- if object:get_luaentity() then
- object:get_luaentity().itemstring = ""
- object:remove()
+
+if technic.config:getBool("enable_item_pickup") then
+ minetest.register_globalstep(function(dtime)
+ for _,player in ipairs(minetest.get_connected_players()) do
+ local pos = player:getpos()
+ pos.y = pos.y+0.5
+ local inv = player:get_inventory()
+ for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 2)) do
+ if not object:is_player() and object:get_luaentity() then
+ local obj=object:get_luaentity()
+ if obj.name == "__builtin:item" then
+ if inv:room_for_item("main", ItemStack(obj.itemstring)) then
+ if obj.timer > time_pick then
+ inv:add_item("main", ItemStack(obj.itemstring))
+ if obj.itemstring ~= "" then
+ minetest.sound_play("item_drop_pickup",{pos = pos, gain = 1.0, max_hear_distance = 10})
+ end
+ if object:get_luaentity() then
+ object:get_luaentity().itemstring = ""
+ object:remove()
+ end
end
end
end
end
end
end
- end
-end)
+ end)
+end
-function minetest.handle_node_drops(pos, drops, digger)
- for _,item in ipairs(drops) do
- local count, name
- if type(item) == "string" then
- count = 1
- name = item
- else
- count = item:get_count()
- name = item:get_name()
- end
- for i=1,count do
- local obj = minetest.env:add_item(pos, name)
- if obj ~= nil then
- obj:get_luaentity().collect = true
- local x = math.random(1, 5)
- if math.random(1,2) == 1 then
- x = -x
- end
- local z = math.random(1, 5)
- if math.random(1,2) == 1 then
- z = -z
- end
- obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
- obj:get_luaentity().timer = time_pick
- -- FIXME this doesnt work for deactiveted objects
- if minetest.setting_get("remove_items") and tonumber(minetest.setting_get("remove_items")) then
- minetest.after(tonumber(minetest.setting_get("remove_items")), function(obj)
- obj:remove()
- end, obj)
+if technic.config:getBool("enable_item_drop") then
+ function minetest.handle_node_drops(pos, drops, digger)
+ for _,item in ipairs(drops) do
+ local count, name
+ if type(item) == "string" then
+ count = 1
+ name = item
+ else
+ count = item:get_count()
+ name = item:get_name()
+ end
+ for i=1,count do
+ local obj = minetest.env:add_item(pos, name)
+ if obj ~= nil then
+ obj:get_luaentity().collect = true
+ local x = math.random(1, 5)
+ if math.random(1,2) == 1 then
+ x = -x
+ end
+ local z = math.random(1, 5)
+ if math.random(1,2) == 1 then
+ z = -z
+ end
+ obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
+ obj:get_luaentity().timer = time_pick
+ -- FIXME this doesnt work for deactiveted objects
+ if minetest.setting_get("remove_items") and tonumber(minetest.setting_get("remove_items")) then
+ minetest.after(tonumber(minetest.setting_get("remove_items")), function(obj)
+ obj:remove()
+ end, obj)
+ end
end
end
end
end
end
+
--[[
minetest.register_on_dieplayer(function(name, pos)
local inv = name:get_inventory()
-enable_technic_inventory=true
-enable_mining_drill=true
-enable_mining_laser=true
-enable_flashlight=true
-enable_rubber_tree_generation=true
-enable_marble_generation=true
-enable_granite_generation=true
+technic.config = {}
+
+technic.config.loaded = {}
+
+technic.config.default = {
+ enable_mining_drill = "true",
+ enable_mining_laser = "true",
+ enable_flashlight = "true",
+ enable_item_drop = "true",
+ enable_item_pickup = "true",
+ enable_rubber_tree_generation = "true",
+ enable_marble_generation = "true",
+ enable_granite_generation = "true"
+}
+
+function technic.config:load(filename)
+ file, error = io.open(filename, "r")
+ if error then return end
+ local line = file:read("*l")
+ while line do
+ local found, _, setting, value = line:find("^([^#%s=]+)%s?=%s?([^%s#]+)")
+ if found then
+ self.loaded[setting] = value
+ end
+ line = file:read("*l")
+ end
+ file:close()
+end
+
+technic.config:load(minetest.get_worldpath().."/technic.conf")
+
+function technic.config:get(setting)
+ if self.loaded[setting] then
+ return self.loaded[setting]
+ else
+ return self.default[setting]
+ end
+end
+
+function technic.config:getBool(setting)
+ return string.lower(self:get(setting)) == "true"
+end
end
})
-minetest.register_on_generated(function(minp, maxp, blockseed)
- if math.random(1, 100) > 5 then
- return
- end
- local tmp = {x=(maxp.x-minp.x)/2+minp.x, y=(maxp.y-minp.y)/2+minp.y, z=(maxp.z-minp.z)/2+minp.z}
- local pos = minetest.env:find_node_near(tmp, maxp.x-minp.x, {"default:dirt_with_grass"})
- if pos ~= nil then
- rubber_tree={
+if technic.config:getBool("enable_rubber_tree_generation") then
+ minetest.register_on_generated(function(minp, maxp, blockseed)
+ if math.random(1, 100) > 5 then
+ return
+ end
+ local rubber_tree={
axiom="FFFFA",
rules_a="[&FFBFA]////[&BFFFA]////[&FBFFA]",
rules_b="[&FFA]////[&FFA]////[&FFA]",
thin_trunks=false;
fruit_tree=false,
fruit=""
- }
- minetest.env:spawn_tree({x=pos.x, y=pos.y+1, z=pos.z},rubber_tree)
- end
-end)
+ }
+ local tmp = {x=(maxp.x-minp.x)/2+minp.x, y=(maxp.y-minp.y)/2+minp.y, z=(maxp.z-minp.z)/2+minp.z}
+ local pos = minetest.env:find_node_near(tmp, maxp.x-minp.x, {"default:dirt_with_grass"})
+ if pos ~= nil then
+ minetest.env:spawn_tree({x=pos.x, y=pos.y+1, z=pos.z}, rubber_tree)
+ end
+ end)
+end
-- ========= FUEL =========