You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

config.lua 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. --
  2. -- money3
  3. --
  4. -- Copyright © 2012 Bad_Command
  5. -- Copyright © 2012 kotolegokot
  6. -- Copyright © 2019 by luk3yx
  7. --
  8. -- This library is free software; you can redistribute it and/or
  9. -- modify it under the terms of the GNU Lesser General Public
  10. -- License as published by the Free Software Foundation; either
  11. -- version 2.1 of the License, or (at your option) any later version.
  12. --
  13. -- This program is distributed in the hope that it will be useful,
  14. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. -- GNU General Public License for more details.
  17. --
  18. -- You should have received a copy of the GNU Lesser General Public
  19. -- License along with this library; if not, write to the Free Software
  20. -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. --
  22. local function setting(name, default)
  23. name = name
  24. local value
  25. if minetest.settings then
  26. value = minetest.settings:get("money3." .. name)
  27. else
  28. setting = minetest.setting_get("money3." .. name)
  29. end
  30. if value and type(default) == "number" then
  31. value = tonumber(value)
  32. if value ~= value then value = false end
  33. end
  34. if value and value ~= "" then
  35. money3[name] = value
  36. else
  37. money3[name] = default
  38. end
  39. end
  40. local function setting_bool(name, default)
  41. local value
  42. if minetest.settings then
  43. value = minetest.settings:get_bool("money3" .. name)
  44. else
  45. value = minetest.setting_getbool("money3" .. name)
  46. end
  47. if value == nil then
  48. money3[name] = default
  49. else
  50. money3[name] = value
  51. end
  52. end
  53. setting("initial_amount", 0)
  54. setting("currency_name", "cr")
  55. setting("income_amount", 10)
  56. setting("convert_items", {
  57. gold = { item = "default:gold_ingot", dig_block="default:stone_with_gold", desc='Gold', amount=75, minval=25 },
  58. silver = { item = "moreores:silver_ingot", dig_block="moreores:mineral_silver", desc='Silver', amount = 27, minval=7}
  59. })
  60. setting_bool("enable_income", true)
  61. if money3.enable_income and minetest.settings and
  62. minetest.settings:get_bool("creative_mode") then
  63. minetest.log("action", "[money3] Creative mode is enabled, force-disabling"
  64. .. " income.")
  65. money3.enable_income = false
  66. end
  67. -- Read the convert_items setting
  68. if type(money3.convert_items) == "string" then
  69. local good, msg = pcall(minetest.deserialize, "return " ..
  70. money3.convert_items)
  71. if good and type(msg) == "table" then
  72. money3.convert_items = msg
  73. else
  74. money3.convert_items = {}
  75. end
  76. end