123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- kiosk.sell_factor=tonumber(minetest.settings:get("kiosk.sell_factor")) or 0.95
- kiosk.prefix=minetest.settings:get("kiosk.prefix") or "kiosk"
- kiosk.account=minetest.settings:get("kiosk.account") or "kiosk_balance"
- kiosk.map_partition=128
- kiosk.map_chunks=math.floor(30926/kiosk.map_partition)
- kiosk.player={}
- kiosk.inventar={}
- for i,mg in ipairs({"currency:minegeld","currency:minegeld_5","currency:minegeld_10","currency:minegeld_50"}) do
- local value=tonumber(mg:split("_")[2])
- if value == nil then value = 1 end
- if minetest.registered_items[mg] ~= nil then
- kiosk.add_inventar(mg,value,value,0,1)
- end
- end
- local has_value = basic_functions.has_value
- local price_cols={
- col_num={"buy_value","sell_value"},}
- local price_def = basic_functions.import_csv(kiosk.path.."/initial_prices.txt",price_cols)
- local int_pri={}
- for i,v in pairs(price_def) do
- v.groups=nil
- kiosk.add_inv(i,v)
- end
- -- build tree of nodes
- for i,v in pairs(minetest.registered_nodes) do
- local node_price=0
- -- first guess of value by dig mode
- if v.groups then
- for j,w in pairs({[10]="cracky",[8]="choppy",[6]="snappy",[4]="crumbly",[2]="fleshy"}) do
- if v.groups[w] then
- node_price=math.max(node_price,j,v.groups[w])
- end
- end
- end
- if v.drop and node_price > 0 then
- if type(v.drop)=="string" and v.drop ~= "" then
- local dn=v.drop:split(" ")[1]
- local dcount=v.drop:split(" ")[2]
- if dcount==nil then dcount=1 end
-
- if not kiosk.is_inventar(dn) then
- kiosk.add_inv(dn,{buy_value=node_price/(dcount*10)})
- end
- kiosk.is_drop_item(dn)
- elseif type(v.drop)=="table" then
- if v.drop.items then
- for j,w in pairs(v.drop.items) do
- local dn=w.items[1]:split(" ")[1]
- local dcount=w.items[1]:split(" ")[2]
- if dcount==nil then dcount=1 end
- if w.rarity then
- dcount=dcount/w.rarity
- end
- if not kiosk.is_inventar(dn) then
- kiosk.add_inv(dn,{buy_value=node_price/(dcount*10)})
- end
- if w.rarity then
- if w.rarity == 1 then
- kiosk.is_drop_item(dn)
- end
- else
- kiosk.is_drop_item(dn)
- end
- end
- end
- end
- end
- end
- for i,v in pairs(minetest.registered_items) do
- if not kiosk.is_inventar(i) then
- kiosk.add_inv(i,{})
- end
- local recipes=minetest.get_all_craft_recipes(i)
- if recipes ~= nil then
- for j,w in pairs(recipes) do
- for k,x in pairs(w.items) do
- kiosk.register_craft_relation(x,i)
- end
- end
- end
- end
- for i,v in pairs(kiosk.inventar) do
- if v.source ~= nil and v.dest ~= nil and v.is_drop ~= nil then
- local ts=table.copy(v.source)
- local ns={}
- for j,w in ipairs(ts) do
- if not has_value(v.dest,w) then
- table.insert(ns,w)
- end
- end
- v.source=ns
- if #ns == 0 then
- print(dump2(v))
- end
- end
- end
- local end_dest={}
- for i,v in pairs(kiosk.inventar) do
- if v.dest==nil and v.source ~= nil then
- table.insert(end_dest,i)
- end
- end
- --print(dump2(end_dest))
- -- initialise map_extend with values, which are corrected in first run
- kiosk.map_extend={emin={x=31000,y=31000,z=31000},emax={x=(-31000),y=(-31000),z=(-31000)},volume=0}
|