Compare commits

...

5 Commits

Author SHA1 Message Date
ademant 8d81c1b1d4 change lapislazuli 2020-06-19 16:43:36 +02:00
ademant 4fc8b73485 bool definition as bool not string 2020-06-19 16:42:38 +02:00
ademant b80bc136a1 recipe with json 2019-07-22 10:21:15 +02:00
ademant c1682fd6dc add cryolite 2019-07-22 06:22:43 +02:00
ademant 1d1ba3bc8c craft json 2019-07-22 05:12:15 +02:00
9 changed files with 159 additions and 26 deletions

View File

@ -208,6 +208,11 @@ minerdream.register_ore=function(i,tdef)
minerdream.register_crafts(tdef,tdef.crafts)
end
-- register additional crafts if given in json file
if tdef.craftitems ~= nil then
minerdream.register_craftitems(tdef,tdef.craftitems)
end
-- save definition to minerdream.items
minerdream.items[ore_name]=tdef
@ -233,7 +238,7 @@ minerdream.register_node_lump=function(tdef,ldef)
end
if ldef.is_lump_gemstone ~= nil then
lump_def.paramtype="light"
lump_def.walkable = "true"
lump_def.walkable = true
lump_def.tiles = {lump_def.inventory_image}
lump_def.is_ground_content = true
lump_def.groups={snappy=3,dig_immidiate=3}
@ -298,7 +303,7 @@ minerdream.register_node_ore=function(tdef,odef,ltype)
ore_def.paramtype="light"
ore_def.drawtype = "mesh"
ore_def.mesh = "gemstone_cubic_pillars.obj"
ore_def.walkable = "true"
ore_def.walkable = true
ore_def.tiles = {"minerdream_"..tdef.ore_name.."_rock.png"}
ore_def.selection_box = {type = "fixed",
fixed = {{-0.4, -0.5, -0.4, 0.4, 0.0, 0.4},},}
@ -317,40 +322,101 @@ minerdream.register_node_ore=function(tdef,odef,ltype)
oredef.name=minerdream.modname..":"..wi.."_with_"..odef.ore_name
oredef.tiles={"default_"..wi..".png^"..odef.inventory_image}
odef.node_name[wi]=oredef.name
-- print(oredef.name)
-- print(dump2(oredef))
-- print(dump(oredef))
minetest.register_node(oredef.name,oredef)
end
end
minerdream.register_craftitems=function(tdef,cdef)
if cdef ~= nil then
for item_name,item_def in pairs(cdef) do
local idef=cdef[item_name]
if idef.name == nil then idef.name = item_name end
if idef.inventory_image == nil then
idef.inventory_image=minerdream.modname.."_"..item_name..".png"
end
if idef.description == nil then
idef.description=S(item_name:gsub("_"," "))
else
idef.description=S(idef.description)
end
local iname=tdef.ore_modname..":"..item_name or minerdream.modname..":"..item_name
minetest.register_craftitem(iname,idef)
end
end
end
local parse_recipe_element=function(tdef,recipe_item)
local out=nil
local found=true
if recipe_item ~= nil then
if recipe_item ~= "" then
if tdef[recipe_item] ~= nil then
out = tdef[recipe_item].node_name or tdef[recipe_item].item_name
end
if string.match(recipe_item,"@") then
local sw=string.split(recipe_item,"@")
if minerdream.items[sw[1]] ~= nil then
local ti=minerdream.items[sw[1]]
if ti[sw[2]] ~= nil then
out=ti[sw[2]].node_name or ti[sw[2]].item_name
end
if out == nil then
found = false
end
end
end
end
end
return out,found
end
minerdream.register_crafts=function(tdef,cdef)
if cdef ~= nil then
print(dump(cdef))
for _,ccdef in pairs(cdef) do
if ccdef.output ~= nil and ccdef.recipe ~= nil then
local bcraft=true
-- analyse, if recipe refers to items in definition
for k,v in pairs(ccdef.recipe) do
if type(v) == "table" then
for l,w in pairs(v) do
if tdef[w] ~= nil then
if tdef[w].node_name ~= nil then
ccdef.recipe[k][l]=tdef[w].node_name
if type(ccdef.recipe)=="table" then
for k,v in pairs(ccdef.recipe) do
if type(v) == "table" then
for l,w in pairs(v) do
local pre,pref=parse_recipe_element(tdef,w)
if pref then
if pre~=nil then
ccdef.recipe[k][l]=pre
end
else
bcraft = false
end
end
if string.match(w,"@") then
local sw=string.split(w,"@")
if minerdream.items[sw[1]] ~= nil then
local ti=minerdream.items[sw[1]]
if ti[sw[2]] ~= nil then
local ni=ti[sw[2]].node_name or ti[sw[2]].item_name
if ni ~= nil then
ccdef.recipe[k][l]=ni
end
end
else
bcraft = false
table.insert(minerdream.delayed_crafts,cdef)
end
if type(v) == "string" then
local pre,pref=parse_recipe_element(tdef,v)
if pref then
if pre~=nil then
ccdef.recipe[k]=pre
end
end end end end
else
bcraft = false
end
end
end
end
if type(ccdef.recipe)=="string" then
local pre,pref=parse_recipe_element(tdef,ccdef.recipe)
if pref then
if pre ~= nil then
ccdef.recipe={pre}
end
else bcraft=false end
end
local pre,pref=parse_recipe_element(tdef,ccdef.output)
if pref then
if pre ~= nil then ccdef.output=pre end
else bcraft = false end
if bcraft then
minetest.register_craft(ccdef)
else
@ -395,7 +461,7 @@ minerdream.register_ore_lump=function(ore_name,tdef)
ore_def.paramtype="light"
ore_def.drawtype = "mesh"
ore_def.mesh = "gemstone_cubic_pillars.obj"
ore_def.walkable = "true"
ore_def.walkable = true
ore_def.inventory_image = "minerdream_"..ore_name.."_gem.png"
ore_def.tiles = {"minerdream_"..ore_name.."_rock.png"}
ore_def.selection_box = {type = "fixed",
@ -413,7 +479,7 @@ minerdream.register_ore_lump=function(ore_name,tdef)
if tdef.groups.is_lump_gemstone ~= nil then
lump_def.drawtype="mesh"
lump_def.mesh = ore_name..".obj"
lump_def.walkable = "true"
lump_def.walkable = true
lump_def.inventory_image = "minerdream_"..ore_name.."_gem.png"
lump_def.tiles = {"minerdream_"..ore_name..".png"}
lump_def.paramtype = "light"

View File

@ -0,0 +1,67 @@
{"color":"87A9AFD0",
"groups":{"drop_as_lump":1,
"in_desert":1,
"is_mineral":1},
"name":"cryolite",
"ore_modname":"minerdream",
"tier":1,
"ore":{
"wherein":["stone"],
"crack":2,
"inventory_image":"minerdream_cryolite_ore.png",
"clust_size":3,
"num_ores":5,
"scarcity":13,
"y_max":120,
"y_min":-31000
},
"poorore":{
"wherein":["stone"],
"crack":2,
"inventory_image":"minerdream_cryolite_poorore.png",
"clust_size":2,
"num_ores":5,
"scarcity":12,
"y_max":200,
"y_min":-31000
},
"lump":{
"crack":2,
"inventory_image":"minerdream_cryolite_lump.png",
"stack_max":99,
"cooking_time":2
},
"dust":{
"cracky":1,
"grind_time":1,
"cooking_time":1,
"inventory_image":"minerdream_cryolite_dust.png"
},
"nugget":{
"inventory_image":"minerdream_cryolite_poorore.png",
"cracky":1,
"clust_size":2,
"num_ores":5,
"scarcity":12,
"y_max":420
},
"crafts":{
"dust16":{
"output":"minerdream:cryolith_dust_part9 9",
"recipe":[["dust"]]
},
"dust162d":{
"output":"dust",
"recipe":[["minerdream:cryolith_dust_part9","minerdream:cryolith_dust_part9","minerdream:cryolith_dust_part9"],
["minerdream:cryolith_dust_part9","minerdream:cryolith_dust_part9","minerdream:cryolith_dust_part9"],
["minerdream:cryolith_dust_part9","minerdream:cryolith_dust_part9","minerdream:cryolith_dust_part9"]]
}
},
"craftitems":{
"cryolith_dust_part9":{
"stackmax":200,
"description":"9th part dust of cryolite",
"inventory_image":"minerdream_cryolite_dust_part16.png"
}
}
}

View File

@ -8,7 +8,7 @@
"stackmax":"200",
"tier":2,
"ore":{
"wherein":["stone","desert_stone"],
"wherein":["stone"],
"crack":3,
"inventory_image":"minerdream_lapislazuli_ore.png",
"clust_size":1,

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B