updated
parent
9b56c0ac56
commit
1d26ea1990
155
config.lua
155
config.lua
|
@ -23,83 +23,118 @@ local int_pri={}
|
|||
for i,v in pairs(price_def) do
|
||||
v.groups=nil
|
||||
kiosk.add_inv(i,v)
|
||||
local reci=minetest.get_all_craft_recipes(i)
|
||||
-- print(dump2(reci))
|
||||
if reci ~= nil then
|
||||
for j,w in pairs(reci) do
|
||||
local count = w.output:split(" ")[2]
|
||||
if count == nil then count = 1 end
|
||||
if #w.items==1 then
|
||||
local nit=w.items[1]
|
||||
if int_pri[nit] == nil then
|
||||
int_pri[nit]={v.buy*count/0.9}
|
||||
else
|
||||
table.insert(int_pri[nit],v.buy*count/0.9)
|
||||
end
|
||||
else
|
||||
local in_it={}
|
||||
local vb=v.buy*count/(0.9*#w.items)
|
||||
for n=1,#w.items do
|
||||
if in_it[w.items[n]]==nil then
|
||||
in_it[w.items[n]]=1
|
||||
else
|
||||
in_it[w.items[n]]=1+in_it[w.items[n]]
|
||||
end
|
||||
end
|
||||
for n,c in pairs(in_it) do
|
||||
if int_pri[n] == nil then
|
||||
int_pri[n]={vb*c}
|
||||
else
|
||||
table.insert(int_pri[n],vb*c)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local reci=minetest.get_craft_result({method="cooking",items={i}})
|
||||
if reci.time > 0 then
|
||||
local output=reci.item:get_name()
|
||||
local count = output:split(" ")[2]
|
||||
if count == nil then count = 1 end
|
||||
if int_pri[output] == nil then
|
||||
int_pri[output]={v.buy+reci.time/20}
|
||||
else
|
||||
table.insert(int_pri[output],v.buy+reci.time/20)
|
||||
end
|
||||
end
|
||||
print(dump2(minetest.registered_items[i]))
|
||||
end
|
||||
|
||||
local new_inv={}
|
||||
|
||||
for i,v in pairs(minetest.registered_nodes) do
|
||||
local node_price=0
|
||||
if v.groups then
|
||||
for j,w in pairs({[10]="cracky",[8]="choppy",[5]="snappy",[3]="crumbly",[1]="fleshy"}) do
|
||||
if v.groups[w]~=nil then node_price=j*v.groups[w] end
|
||||
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
|
||||
-- print(dump2(v))
|
||||
if v.drop ~= nil and node_price > 0 then
|
||||
if type(v.drop)=="string" then
|
||||
if not kiosk.is_inventar(v.drop) then
|
||||
print(dump2(v.drop))
|
||||
if new_inv[v.drop]==nil then
|
||||
new_inv[v.drop]={node_price/10}
|
||||
else
|
||||
table.insert(new_inv[v.drop],node_price/10)
|
||||
if v.drop and node_price > 0 then
|
||||
-- print(i,node_price)
|
||||
-- print(type(v.drop))
|
||||
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 new_inv[dn]==nil then
|
||||
new_inv[dn] = {node_price/(dcount*10)}
|
||||
else
|
||||
table.insert(new_inv[dn],node_price/(dcount*10))
|
||||
end
|
||||
elseif type(v.drop)=="table" then
|
||||
-- print(dump2(v.drop))
|
||||
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 new_inv[dn]==nil then
|
||||
new_inv[dn] = {node_price/(dcount*10)}
|
||||
else
|
||||
table.insert(new_inv[dn],node_price/(dcount*10))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for i,v in pairs(new_inv) do
|
||||
print(i,#v)
|
||||
if not kiosk.is_inventar(i) then
|
||||
local np=math.huge
|
||||
for _,j in ipairs(v) do
|
||||
np=math.min(np,j)
|
||||
end
|
||||
kiosk.add_inventar(i,np)
|
||||
end
|
||||
end
|
||||
--print(dump2(new_inv))
|
||||
--print(dump2(int_pri))
|
||||
--print(dump2(kiosk.inventar))
|
||||
|
||||
for i,v in pairs(kiosk.inventar) do
|
||||
local reci=minetest.get_craft_result({method="cooking",items={ItemStack(i)}})
|
||||
if reci.time>0 then
|
||||
local lpr=math.ceil((v.buy*1.1+reci.time*0.25/40)*100)/100
|
||||
local ni=reci.item:get_name()
|
||||
local count=reci.item:get_count()
|
||||
local lpr=math.ceil((v.buy*1.1+reci.time*0.25/40)*100)/(count*100)
|
||||
if not kiosk.is_inventar(ni) then
|
||||
kiosk.add_inventar(ni,lpr)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local missing_item={}
|
||||
local missing_sources={}
|
||||
local missing_group={}
|
||||
for i,v in pairs(minetest.registered_items) do
|
||||
if not kiosk.is_inventar(i) then
|
||||
missing_item[i]=1
|
||||
|
||||
local reci=minetest.get_all_craft_recipes(i)
|
||||
if reci then
|
||||
for j,w in pairs(reci) do
|
||||
if w.items then
|
||||
local rprice=0
|
||||
local fullcalc=1
|
||||
for _,n in pairs(w.items) do
|
||||
if kiosk.is_inventar(n) then
|
||||
rprice=rprice+kiosk.get_buy(n)
|
||||
else
|
||||
fullcalc=0
|
||||
if n:split(":")[1]=="group" then
|
||||
local ng=n:split(":")[2]
|
||||
for k,x in ipairs(ng:split(",")) do
|
||||
missing_group[x]=1
|
||||
end
|
||||
else
|
||||
missing_sources[n]=1
|
||||
end
|
||||
end
|
||||
end
|
||||
if fullcalc==1 and rprice>0 then
|
||||
rprice=math.ceil(rprice*110)/100
|
||||
kiosk.add_inventar(i,rprice)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
print(dump2(missing_item))
|
||||
print(dump2(missing_sources))
|
||||
print(dump2(missing_group))
|
||||
|
||||
|
||||
print(dump2(minetest.registered_items["default:coal_lump"]))
|
||||
--print(dump2(minetest.registered_items["default:coal_lump"]))
|
||||
-- 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}
|
||||
|
||||
|
|
|
@ -10,3 +10,4 @@ default:silver_sand,0.05,0.045
|
|||
default:ice,0.05,0.045
|
||||
default:desert_sand,0.05,0.045
|
||||
default:iron_lump,0.5,0.45
|
||||
default:coal_lump,0.25,0.2
|
||||
|
|
Loading…
Reference in New Issue