mirror of
https://github.com/minetest-mods/technic.git
synced 2024-12-24 18:00:29 +01:00
Store configuration in the world directory.
This commit is contained in:
parent
31b1393b21
commit
00328622d9
1
item_drop/depends.txt
Normal file
1
item_drop/depends.txt
Normal file
@ -0,0 +1 @@
|
||||
technic
|
@ -1,6 +1,8 @@
|
||||
dofile(minetest.get_modpath("item_drop").."/item_entity.lua")
|
||||
time_pick = 3
|
||||
minetest.register_globalstep(function(dtime)
|
||||
|
||||
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
|
||||
@ -25,9 +27,11 @@ minetest.register_globalstep(function(dtime)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
function minetest.handle_node_drops(pos, drops, digger)
|
||||
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
|
||||
@ -60,7 +64,9 @@ function minetest.handle_node_drops(pos, drops, digger)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
minetest.register_on_dieplayer(function(name, pos)
|
||||
local inv = name:get_inventory()
|
||||
|
@ -1,7 +1,42 @@
|
||||
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
|
||||
|
@ -2,5 +2,3 @@ default
|
||||
moreores
|
||||
pipeworks
|
||||
mesecons
|
||||
technic_worldgen
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
-- namespace: technic
|
||||
-- (c) 2012-2013 by RealBadAngel <mk@realbadangel.pl>
|
||||
|
||||
technic = {}
|
||||
|
||||
modpath=minetest.get_modpath("technic")
|
||||
|
||||
--Read technic config file
|
||||
@ -38,9 +40,9 @@ dofile(modpath.."/forcefield.lua")
|
||||
dofile(modpath.."/wires_hv.lua")
|
||||
|
||||
--Tools
|
||||
if enable_mining_drill==true then dofile(modpath.."/mining_drill.lua") end
|
||||
if enable_mining_laser==true then dofile(modpath.."/mining_laser_mk1.lua") end
|
||||
if enable_flashlight==true then dofile(modpath.."/flashlight.lua") end
|
||||
if technic.config:getBool("enable_mining_drill") then dofile(modpath.."/mining_drill.lua") end
|
||||
if technic.config:getBool("enable_mining_laser") then dofile(modpath.."/mining_laser_mk1.lua") end
|
||||
if technic.config:getBool("enable_flashlight") then dofile(modpath.."/flashlight.lua") end
|
||||
dofile(modpath.."/cans.lua")
|
||||
dofile(modpath.."/chainsaw.lua")
|
||||
dofile(modpath.."/tree_tap.lua")
|
||||
|
@ -88,14 +88,12 @@ minetest.register_abm({
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
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 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={
|
||||
local rubber_tree={
|
||||
axiom="FFFFA",
|
||||
rules_a="[&FFBFA]////[&BFFFA]////[&FBFFA]",
|
||||
rules_b="[&FFA]////[&FFA]////[&FFA]",
|
||||
@ -108,9 +106,13 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
fruit_tree=false,
|
||||
fruit=""
|
||||
}
|
||||
minetest.env:spawn_tree({x=pos.x, y=pos.y+1, z=pos.z},rubber_tree)
|
||||
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)
|
||||
end
|
||||
|
||||
|
||||
-- ========= FUEL =========
|
||||
|
@ -1 +1,2 @@
|
||||
default
|
||||
technic
|
||||
|
@ -28,6 +28,7 @@ minetest.register_ore({
|
||||
height_min = -31000,
|
||||
height_max = 2,
|
||||
})
|
||||
if technic.config:getBool("enable_marble_generation") then
|
||||
minetest.register_ore({
|
||||
ore_type = "sheet",
|
||||
ore = "technic:marble",
|
||||
@ -40,6 +41,8 @@ minetest.register_ore({
|
||||
noise_threshhold = 0.4,
|
||||
noise_params = {offset=0, scale=15, spread={x=150, y=150, z=150}, seed=23, octaves=3, persist=0.70}
|
||||
})
|
||||
end
|
||||
if technic.config:getBool("enable_granite_generation") then
|
||||
minetest.register_ore({
|
||||
ore_type = "sheet",
|
||||
ore = "technic:granite",
|
||||
@ -52,4 +55,5 @@ minetest.register_ore({
|
||||
noise_threshhold = 0.4,
|
||||
noise_params = {offset=0, scale=15, spread={x=130, y=130, z=130}, seed=24, octaves=3, persist=0.70}
|
||||
})
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user