config.lua 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. -- check, which submodule should be enabled
  2. for i,attr in ipairs({"exhaustion","saturation","thirst","sunburn","nyctophoby"}) do
  3. physio_stress.attributes[attr]=(minetest.settings:get(physio_stress.intprefix.."."..attr)=="true") or false
  4. local is_status=" is enabled"
  5. if physio_stress.attributes[attr] == false then
  6. is_status = " is disabled"
  7. end
  8. print(attr..is_status)
  9. end
  10. -- no sunburn if 3d armor is not available
  11. if armor == nil then
  12. physio_stress.attributes.sunburn = false
  13. end
  14. physio_stress.dtime=tonumber(minetest.settings:get(physio_stress.intprefix..".dtime")) or 1
  15. physio_stress.dtime_heal=tonumber(minetest.settings:get(physio_stress.intprefix..".dtime_heal")) or 1
  16. physio_stress.dt=0
  17. physio_stress.dt_heal=0
  18. physio_stress.saturationmax=tonumber(minetest.settings:get(physio_stress.intprefix..".saturation_max")) or 20
  19. physio_stress.saturation_minhealing=tonumber(minetest.settings:get(physio_stress.intprefix..".saturation_minhealing")) or 3
  20. physio_stress.thirstmax=tonumber(minetest.settings:get(physio_stress.intprefix..".thirst_max")) or 20
  21. physio_stress.saturation_recreation=tonumber(minetest.settings:get(physio_stress.intprefix..".saturation_recreation")) or 0.5
  22. physio_stress.ingestion_rejoin=tonumber(minetest.settings:get(physio_stress.intprefix..".ingestion_rejoin")) or 3
  23. physio_stress.player={}
  24. physio_stress.exhausted_build={}
  25. physio_stress.exhausted_dig={}
  26. physio_stress.st_coeff_names={"walked","swam","dug","build","playtime","craft"}
  27. physio_stress.action_names={"walked","swam","dug","build","craft"}
  28. physio_stress.dig_groups={"cracky","crumbly","snappy","choppy"}
  29. physio_stress.player_fields={"sunburn_armor_dmaxlight","sunburn_maxlight","sunburn_delay","sunburn_diff","nyctophoby_diff","sunburn_hp","nyctophoby_delay","nyctophoby_hp","sunburn_armor","nyctophoby_armor","nyctophoby_minlight"}
  30. -- check, which phobies are enabled and initialize xpfw attribute
  31. physio_stress.phobies={}
  32. for i,attr in ipairs({"sunburn","nyctophoby"}) do
  33. if physio_stress.attributes[attr]~=nil then
  34. if physio_stress.attributes[attr] == true then
  35. table.insert(physio_stress.phobies,attr)
  36. xpfw.register_attribute(attr,{min=0,max=20,default=0,hud=1})
  37. end
  38. end
  39. end
  40. --check which ingestions are enabled and enable xpfw attribute
  41. physio_stress.ingestion={}
  42. for i,attr in ipairs({"saturation","thirst"}) do
  43. if physio_stress.attributes[attr]~=nil then
  44. if physio_stress.attributes[attr] == true then
  45. table.insert(physio_stress.ingestion,attr)
  46. local att_max=tonumber(minetest.settings:get(physio_stress.intprefix.."."..attr.."_max")) or 20
  47. xpfw.register_attribute(attr,{min=0,max=att_max,default=att_max,
  48. hud=1,})
  49. end
  50. end
  51. end
  52. -- check for global variables, stored in mod_storage
  53. for i,attr in ipairs({"playerlist"}) do
  54. physio_stress[attr]=physio_stress.mod_storage:get_string(attr)
  55. end
  56. -- get default values for new players
  57. physio_stress.default_player={}
  58. for i,attr in ipairs(physio_stress.player_fields) do
  59. physio_stress.default_player[attr]=tonumber(minetest.settings:get(physio_stress.intprefix.."."..attr)) or 1
  60. end
  61. for j,st in ipairs(physio_stress.ingestion) do
  62. local coeff_names=table.copy(physio_stress.st_coeff_names)
  63. table.insert(coeff_names,"exhaustion")
  64. for i,attr in ipairs(coeff_names) do
  65. local sat_coeff = tonumber(minetest.settings:get(physio_stress.intprefix.."."..st.."_"..attr)) or 100
  66. if sat_coeff > 0 then
  67. physio_stress.default_player[st.."_"..attr] = sat_coeff
  68. end
  69. end
  70. end
  71. -- first protect against sunburn/nyctophoby
  72. for i,attr in ipairs({"sunburn_protect","nyctophoby_protect"}) do
  73. physio_stress.default_player[attr]=true
  74. end
  75. -- restore player settings, if stored in mod_storage
  76. if physio_stress.playerlist ~= "" then
  77. local players=physio_stress.playerlist:split(",",true)
  78. for i,pl in ipairs(players) do
  79. physio_stress.player[pl]=table.copy(physio_stress.default_player)
  80. for j,attr in pairs(physio_stress.player[pl]) do
  81. local modval=physio_stress.mod_storage:get(pl.."_"..j)
  82. if modval ~= nil then
  83. physio_stress.player[pl][attr]=tonumber(modval)
  84. end
  85. end
  86. end
  87. end
  88. -- dig correction values for saturation
  89. physio_stress.dig_correction={}
  90. for i,attr in ipairs(physio_stress.dig_groups) do
  91. physio_stress.dig_correction[attr]=tonumber(minetest.settings:get(physio_stress.intprefix..".dig_"..attr)) or 1
  92. end
  93. -- initialize exhaustion
  94. if physio_stress.attributes["exhaustion"] then
  95. local attr_def={min=0,max=20,default=0,hud=1,
  96. moving_average_factor=tonumber(minetest.settings:get(physio_stress.intprefix..".exhaustion_mean_weight")) or 50,
  97. recreation_factor=tonumber(minetest.settings:get(physio_stress.intprefix..".exhaustion_recreation")) or 10,
  98. }
  99. xpfw.register_attribute("exhaustion",attr_def)
  100. end