Read an external configuration file, if it exists

master
Ben Deutsch 2015-06-30 06:49:40 +02:00
parent 0afc4e055e
commit 41d2390495
2 changed files with 94 additions and 1 deletions

View File

@ -77,4 +77,16 @@ thirsty.config = {
}
-- TODO: read more configuration from thirsty.conf or similar
-- read more configuration from thirsty.conf
local filename = minetest.get_modpath('thirsty') .. "/thirsty.conf"
local file, err = io.open(filename, 'r')
if file then
file:close() -- was just for checking existance
local confcode, err = loadfile(filename)
if confcode then
confcode()
else
minetest.log("error", "Could not load thirsty.conf: " .. err)
end
end

81
thirsty.conf.example Normal file
View File

@ -0,0 +1,81 @@
--[[
Configuration file for Thirsty.
Copy this file to "thirsty.conf" and place it in the mod's directory.
Modify to suit your needs; it will not get overwritten if you update
Thirsty.
The following values are the default values; you can safely remove
or comment out any line you're not interested in. Commented lines
start with '--'
]]
-- Main loop tick time, in seconds
-- Increasing this value will make Thirsty less accurate, but will
-- generally behave the same.
thirsty.config.tick_time = 0.5
-- Thirst per second (full hydration is 20 hydro points)
thirsty.config.thirst_per_second = 1.0 / 20.0
-- Damage per second if completely thirsty / out of hydration
thirsty.config.damage_per_second = 1.0 / 10.0
-- How long in seconds you have to remain still to drink from standing
-- in water
thirsty.config.stand_still_for_drink = 1.0,
-- How long in seconds of not moving before a player is deemed AFK
-- (away from keyboard), such players no longer get thirsty or damaged
thirsty.config.stand_still_for_afk = 120.0, -- 2 Minutes
-- regen_from_node is a table defining, for each node type, the
-- amount of hydro per second a player drinks by standing in it.
-- Assign 'nil' to stop a player from drinking from this node type.
thirsty.config.regen_from_node['default:water_source'] = 0.5
thirsty.config.regen_from_node['default:water_flowing'] = 0.5
-- node_drinkable: which nodes can we drink from, given a
-- container (a cup, a bowl etc.)
thirsty.config.node_drinkable['default:water_source'] = true
thirsty.config.node_drinkable['default:water_flowing'] = true
thirsty.config.node_drinkable['thirsty:drinking_fountain'] = true
-- drink_from_container: the hydration you drink to when
-- using each container. Remember that "full hydration" is
-- 20 points; these should be more to reward using them.
thirsty.config.drink_from_container['thirsty:wooden_bowl'] = 25
thirsty.config.drink_from_container['thirsty:steel_canteen'] = 25
thirsty.config.drink_from_container['thirsty:bronze_canteen'] = 25
-- container_capacity: how much hydration each container (canteens)
-- can hold. Remember that "full hydration" is 20 points
thirsty.config.container_capacity['thirsty:steel_canteen'] = 40
thirsty.config.container_capacity['thirsty:bronze_canteen'] = 60
-- drink_from_node: if you use one of these nodes (i.e. fountains),
-- even without cups or bowls, how full will you get?
thirsty.config.drink_from_node['thirsty:drinking_fountain'] = 30
-- fountain_type: when scanning the surroundings of fountains,
-- which nodes are "fountains" and which are "water"? You need
-- at least one "fountain" and one "water" per fountain level.
thirsty.config.fountain_type['thirsty:water_fountain'] = 'f'
thirsty.config.fountain_type['thirsty:water_extender'] = 'f'
thirsty.config.fountain_type['default:water_source'] = 'w'
thirsty.config.fountain_type['default:water_flowing'] = 'w'
-- Regeneration from being within a fountain's radius; see also
-- regen_from_node (it's as if you're standing in water)
thirsty.config.regen_from_fountain = 0.5
-- How far should the fountain scanning pyramid go?
thirsty.config.fountain_height = 4
-- The max level of a fountain
thirsty.config.fountain_max_level = 20
-- How many nodes away can you still benefit from a fountain,
-- per fountain level
thirsty.config.fountain_distance_per_level = 5
-- How much hydration does a given item *extract* (pull out of the air)
thirsty.config.extraction_for_item['thirsty:extractor'] = 0.6
-- How much hydration does a given item *inject* (fill you up with)
thirsty.config.injection_for_item['thirsty:injector'] = 0.5