config.lua 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. kiosk.sell_factor=tonumber(minetest.settings:get("kiosk.sell_factor")) or 0.95
  2. kiosk.prefix=minetest.settings:get("kiosk.prefix") or "kiosk"
  3. kiosk.account=minetest.settings:get("kiosk.account") or "kiosk_balance"
  4. kiosk.map_partition=128
  5. kiosk.map_chunks=math.floor(30926/kiosk.map_partition)
  6. kiosk.player={}
  7. kiosk.inventar={}
  8. for i,mg in ipairs({"currency:minegeld","currency:minegeld_5","currency:minegeld_10","currency:minegeld_50"}) do
  9. local value=tonumber(mg:split("_")[2])
  10. if value == nil then value = 1 end
  11. if minetest.registered_items[mg] ~= nil then
  12. kiosk.add_inventar(mg,value,value,0,1)
  13. end
  14. end
  15. local has_value = basic_functions.has_value
  16. local price_cols={
  17. col_num={"buy_value","sell_value"},}
  18. local price_def = basic_functions.import_csv(kiosk.path.."/initial_prices.txt",price_cols)
  19. local int_pri={}
  20. for i,v in pairs(price_def) do
  21. v.groups=nil
  22. kiosk.add_inv(i,v)
  23. end
  24. -- build tree of nodes
  25. for i,v in pairs(minetest.registered_nodes) do
  26. local node_price=0
  27. -- first guess of value by dig mode
  28. if v.groups then
  29. for j,w in pairs({[10]="cracky",[8]="choppy",[6]="snappy",[4]="crumbly",[2]="fleshy"}) do
  30. if v.groups[w] then
  31. node_price=math.max(node_price,j,v.groups[w])
  32. end
  33. end
  34. end
  35. if v.drop and node_price > 0 then
  36. if type(v.drop)=="string" and v.drop ~= "" then
  37. local dn=v.drop:split(" ")[1]
  38. local dcount=v.drop:split(" ")[2]
  39. if dcount==nil then dcount=1 end
  40. if not kiosk.is_inventar(dn) then
  41. kiosk.add_inv(dn,{buy_value=node_price/(dcount*10)})
  42. end
  43. kiosk.is_drop_item(dn)
  44. elseif type(v.drop)=="table" then
  45. if v.drop.items then
  46. for j,w in pairs(v.drop.items) do
  47. local dn=w.items[1]:split(" ")[1]
  48. local dcount=w.items[1]:split(" ")[2]
  49. if dcount==nil then dcount=1 end
  50. if w.rarity then
  51. dcount=dcount/w.rarity
  52. end
  53. if not kiosk.is_inventar(dn) then
  54. kiosk.add_inv(dn,{buy_value=node_price/(dcount*10)})
  55. end
  56. if w.rarity then
  57. if w.rarity == 1 then
  58. kiosk.is_drop_item(dn)
  59. end
  60. else
  61. kiosk.is_drop_item(dn)
  62. end
  63. end
  64. end
  65. end
  66. end
  67. end
  68. for i,v in pairs(minetest.registered_items) do
  69. if not kiosk.is_inventar(i) then
  70. kiosk.add_inv(i,{})
  71. end
  72. local recipes=minetest.get_all_craft_recipes(i)
  73. if recipes ~= nil then
  74. for j,w in pairs(recipes) do
  75. for k,x in pairs(w.items) do
  76. kiosk.register_craft_relation(x,i)
  77. end
  78. end
  79. end
  80. end
  81. for i,v in pairs(kiosk.inventar) do
  82. if v.source ~= nil and v.dest ~= nil and v.is_drop ~= nil then
  83. local ts=table.copy(v.source)
  84. local ns={}
  85. for j,w in ipairs(ts) do
  86. if not has_value(v.dest,w) then
  87. table.insert(ns,w)
  88. end
  89. end
  90. v.source=ns
  91. if #ns == 0 then
  92. print(dump2(v))
  93. end
  94. end
  95. end
  96. local end_dest={}
  97. for i,v in pairs(kiosk.inventar) do
  98. if v.dest==nil and v.source ~= nil then
  99. table.insert(end_dest,i)
  100. end
  101. end
  102. --print(dump2(end_dest))
  103. -- initialise map_extend with values, which are corrected in first run
  104. kiosk.map_extend={emin={x=31000,y=31000,z=31000},emax={x=(-31000),y=(-31000),z=(-31000)},volume=0}