Added this mod to github
162
core.lua
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
input={}
|
||||||
|
out1 = {}
|
||||||
|
out2 = {}
|
||||||
|
out3 = {}
|
||||||
|
out4 = {}
|
||||||
|
out5 = {}
|
||||||
|
out6 = {}
|
||||||
|
out7 = {}
|
||||||
|
out8 = {}
|
||||||
|
out9 = {}
|
||||||
|
count=0
|
||||||
|
minetest.register_craftitem("chemistry:reactor",
|
||||||
|
{
|
||||||
|
description = "Chemical reactor",
|
||||||
|
inventory_image = "reactor.png",
|
||||||
|
})
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "chemistry:reactor",
|
||||||
|
recipe = {
|
||||||
|
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||||
|
{"default:steel_ingot", "default:chest", "default:steel_ingot"},
|
||||||
|
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
function register_chemical_recepie(from,to1,to2,to3,to4,to5,to6,to7,to8,to9)
|
||||||
|
table.insert(input, from)
|
||||||
|
table.insert(out1, to1)
|
||||||
|
table.insert(out2, to2)
|
||||||
|
table.insert(out3, to3)
|
||||||
|
table.insert(out4, to4)
|
||||||
|
table.insert(out5, to5)
|
||||||
|
table.insert(out6, to6)
|
||||||
|
table.insert(out7, to7)
|
||||||
|
table.insert(out8, to8)
|
||||||
|
table.insert(out9, to9)
|
||||||
|
count=count+1
|
||||||
|
end
|
||||||
|
for index = 1, #input do
|
||||||
|
minetest.register_craft({
|
||||||
|
output = input[index],
|
||||||
|
recipe = {
|
||||||
|
{out1[index], out2[index], out3[index]},
|
||||||
|
{out4[index], out5[index], out6[index]},
|
||||||
|
{out7[index], out8[index], out9[index]}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
formspec= "size[10,10]"..
|
||||||
|
"list[current_name;from;4,0;1,1;]"..
|
||||||
|
"list[current_name;result;3,2;3,3;]"..
|
||||||
|
"listring[current_name;result]"..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
"listring[current_name;from]"..
|
||||||
|
"list[current_player;main;1,6;8,4;]"
|
||||||
|
function where(it,arr)
|
||||||
|
for index=1,count do
|
||||||
|
if arr[index]==it then
|
||||||
|
return index
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function react(pos, listname)
|
||||||
|
if listname=="from" then
|
||||||
|
local meta=minetest.get_meta(pos)
|
||||||
|
local inv = minetest.get_inventory({type="node", pos=pos})
|
||||||
|
if inv:is_empty("result") then
|
||||||
|
if not inv:is_empty("from") then
|
||||||
|
local from = inv:get_stack("from", 1)
|
||||||
|
if from:get_count()>0 and from:get_count()<100 then
|
||||||
|
numx = from:get_count()
|
||||||
|
local name=from:get_name()
|
||||||
|
local num=where(name,input)
|
||||||
|
if num ~=nil then
|
||||||
|
local to1 = inv:get_stack("result", 1)
|
||||||
|
local to2 = inv:get_stack("result", 2)
|
||||||
|
local to3 = inv:get_stack("result", 3)
|
||||||
|
local to4 = inv:get_stack("result", 4)
|
||||||
|
local to5 = inv:get_stack("result", 5)
|
||||||
|
local to6 = inv:get_stack("result", 6)
|
||||||
|
local to7 = inv:get_stack("result", 7)
|
||||||
|
local to8 = inv:get_stack("result", 8)
|
||||||
|
local to9 = inv:get_stack("result", 9)
|
||||||
|
local item1=out1[num]
|
||||||
|
local item2=out2[num]
|
||||||
|
local item3=out3[num]
|
||||||
|
local item4=out4[num]
|
||||||
|
local item5=out5[num]
|
||||||
|
local item6=out6[num]
|
||||||
|
local item7=out7[num]
|
||||||
|
local item8=out8[num]
|
||||||
|
local item9=out9[num]
|
||||||
|
stack1={name=item1,count=numx}
|
||||||
|
stack2={name=item2,count=numx}
|
||||||
|
stack3={name=item3,count=numx}
|
||||||
|
stack4={name=item4,count=numx}
|
||||||
|
stack5={name=item5,count=numx}
|
||||||
|
stack6={name=item6,count=numx}
|
||||||
|
stack7={name=item7,count=numx}
|
||||||
|
stack8={name=item8,count=numx}
|
||||||
|
stack9={name=item9,count=numx}
|
||||||
|
inv:set_stack("result", 1, stack1)
|
||||||
|
inv:set_stack("result", 2, stack2)
|
||||||
|
inv:set_stack("result", 3, stack3)
|
||||||
|
inv:set_stack("result", 4, stack4)
|
||||||
|
inv:set_stack("result", 5, stack5)
|
||||||
|
inv:set_stack("result", 6, stack6)
|
||||||
|
inv:set_stack("result", 7, stack7)
|
||||||
|
inv:set_stack("result", 8, stack8)
|
||||||
|
inv:set_stack("result", 9, stack9)
|
||||||
|
inv:set_stack("from", 1, {})
|
||||||
|
minetest.log("action","pass")
|
||||||
|
end
|
||||||
|
minetest.log("action","pass")
|
||||||
|
end
|
||||||
|
minetest.log("action","pass")
|
||||||
|
end
|
||||||
|
minetest.log("action","pass")
|
||||||
|
end
|
||||||
|
minetest.log("action","pass")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function retry(pos, listname)
|
||||||
|
if listname=="result" then
|
||||||
|
react(pos, "from")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function testit(pos)
|
||||||
|
local inv = minetest.get_inventory({type="node", pos=pos})
|
||||||
|
if inv:is_empty("result") and inv:is_empty("from") then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
minetest.register_node("chemistry:reactor",
|
||||||
|
{
|
||||||
|
description = "Chemical reactor",
|
||||||
|
tiles = {"reactor.png"},
|
||||||
|
on_metadata_inventory_put = react,
|
||||||
|
on_metadata_inventory_take = retry,
|
||||||
|
groups = {cracky=2},
|
||||||
|
can_dig = testit,
|
||||||
|
})
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"chemistry:reactor"},
|
||||||
|
interval = 1,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
local meta=minetest.get_meta(pos)
|
||||||
|
local inv = minetest.get_inventory({type="node", pos=pos})
|
||||||
|
meta:set_string("formspec",formspec)
|
||||||
|
if inv~=nil then
|
||||||
|
inv:set_size("from", 1)
|
||||||
|
inv:set_size("result", 9)
|
||||||
|
react(pos,"from")
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
hopper:add_container({
|
||||||
|
{"top", "chemistry:reactor", "result"}, -- take cooked items from above into hopper below
|
||||||
|
{"bottom", "chemistry:reactor", "from"}, -- insert items below to be cooked from hopper above
|
||||||
|
})
|
||||||
|
minetest.log("action","Chemistry!")
|
8
elements.lua
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
prvky={"H","He","Li","Be","B","C","N","O","F","Ne","Na","Mg","Al","Si","P","S","Cl","Ar","K","Ca","Sc","Ti","V","Cr","Mn","Fe","Co","Ni","Cu","Zn","Ga","Ge","As","Se","Br","Kr","Rb","Sr","Y","Zr","Nb","Mo","Tc","Ru","Rh","Pd","Ag","Cd","In","Sn","Sb","Te","I","Xe","Cs","Ba","La","Ce","Pr","Nd","Pm","Sm","Eu","Gd","Tb","Dy","Ho","Er","Tm","Yb","Lu","Hf","Ta","W","Re","Os","Ir","Pt","Au","Hg","Tl","Pb","Bi","Po","At","Rn","Fr","Ra","Ac","Th","Pa","U","Np","Pu","Am","Cm","Bk","Cf","Es","Fm","Md","No","Lr","Rf","Db","Sg","Bh","Hs","Mt","Ds","Rg","Cn","Nh","Fl","Mc","Lv","Ts","Og"}
|
||||||
|
nazvy={"Hydrogen","Helium","Lithium","Beryllium","Boron","Carbon","Nitrogen","Oxygen","Fluorine","Neon","Sodium","Magnesium","Aluminum","Silicon","Phosphorus","Sulfur","Chlorine","Argon","Potassium","Calcium","Scandium","Titanium","Vanadium","Chromium","Manganese","Iron","Cobalt","Nickel","Copper","Zinc","Gallium","Germanium","Arsenic","Selenium","Bromine","Krypton","Rubidium","Strontium","Yttrium","Zirconium","Niobium","Molybdenum","Technetium","Ruthenium","Rhodium","Palladium","Silver","Cadmium","Indium","Tin","Antimony","Tellurium","Iodine","Xenon","Cesium","Barium","Lanthanum","Cerium","Praseodymium","Neodymium","Promethium","Samarium","Europium","Gadolinium","Terbium","Dysprosium","Holmium","Erbium","Thulium","Ytterbium","Lutetium","Hafnium","Tantalum","Tungsten","Rhenium","Osmium","Iridium","Platinum","Gold","Mercury","Thallium","Lead","Bismuth","Polonium","Astatine","Radon","Francium","Radium","Actinium","Thorium","Protactinium","Uranium","Neptunium","Plutonium","Americium","Curium","Berkelium","Californium","Einsteinium","Fermium","Mendelevium","Nobelium","Lawrencium","Rutherfordium","Dubnium","Seaborgium","Bohrium","Hassium","Meitnerium","Darmstadtium","Roentgenium","Copernicium","Nihonium","Flerovium","Moscovium","Livermorium","Tennessine","Oganesson"}
|
||||||
|
for i, elem in ipairs(prvky) do
|
||||||
|
minetest.register_craftitem('chemistry:'..elem..'', {
|
||||||
|
description = nazvy[i],
|
||||||
|
inventory_image = elem..'.png',
|
||||||
|
})
|
||||||
|
end
|
3
init.lua
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
dofile(minetest.get_modpath("chemistry").."/elements.lua")
|
||||||
|
dofile(minetest.get_modpath("chemistry").."/core.lua")
|
||||||
|
dofile(minetest.get_modpath("chemistry").."/recepies.lua")
|
3
mod.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = chemistry
|
||||||
|
depends = default, hopper
|
||||||
|
description = Adds a way to turn one item into another.
|
2
recepies.lua
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
register_chemical_recepie("default:dirt","chemistry:Si","chemistry:Ar","chemistry:Si","chemistry:Ar","chemistry:Si","chemistry:Ar","chemistry:Si","chemistry:Ar","chemistry:Si")
|
||||||
|
register_chemical_recepie("default:sand","chemistry:Ar","chemistry:Si","chemistry:Ar","chemistry:Si","chemistry:Ar","chemistry:Si","chemistry:Ar","chemistry:Si","chemistry:Ar")
|
BIN
textures/Ac.png
Normal file
After Width: | Height: | Size: 780 B |
BIN
textures/Ag.png
Normal file
After Width: | Height: | Size: 848 B |
BIN
textures/Al.png
Normal file
After Width: | Height: | Size: 648 B |
BIN
textures/Am.png
Normal file
After Width: | Height: | Size: 736 B |
BIN
textures/Ar.png
Normal file
After Width: | Height: | Size: 695 B |
BIN
textures/As.png
Normal file
After Width: | Height: | Size: 812 B |
BIN
textures/At.png
Normal file
After Width: | Height: | Size: 689 B |
BIN
textures/Au.png
Normal file
After Width: | Height: | Size: 705 B |
BIN
textures/B.png
Normal file
After Width: | Height: | Size: 596 B |
BIN
textures/Ba.png
Normal file
After Width: | Height: | Size: 778 B |
BIN
textures/Be.png
Normal file
After Width: | Height: | Size: 762 B |
BIN
textures/Bh.png
Normal file
After Width: | Height: | Size: 672 B |
BIN
textures/Bi.png
Normal file
After Width: | Height: | Size: 613 B |
BIN
textures/Bk.png
Normal file
After Width: | Height: | Size: 718 B |
BIN
textures/Br.png
Normal file
After Width: | Height: | Size: 638 B |
BIN
textures/C.png
Normal file
After Width: | Height: | Size: 686 B |
BIN
textures/Ca.png
Normal file
After Width: | Height: | Size: 834 B |
BIN
textures/Cd.png
Normal file
After Width: | Height: | Size: 809 B |
BIN
textures/Ce.png
Normal file
After Width: | Height: | Size: 826 B |
BIN
textures/Cf.png
Normal file
After Width: | Height: | Size: 723 B |
BIN
textures/Cl.png
Normal file
After Width: | Height: | Size: 695 B |
BIN
textures/Cm.png
Normal file
After Width: | Height: | Size: 797 B |
BIN
textures/Cn.png
Normal file
After Width: | Height: | Size: 759 B |
BIN
textures/Co.png
Normal file
After Width: | Height: | Size: 816 B |
BIN
textures/Cr.png
Normal file
After Width: | Height: | Size: 740 B |
BIN
textures/Cs.png
Normal file
After Width: | Height: | Size: 846 B |
BIN
textures/Cu.png
Normal file
After Width: | Height: | Size: 737 B |
BIN
textures/Db.png
Normal file
After Width: | Height: | Size: 750 B |
BIN
textures/Ds.png
Normal file
After Width: | Height: | Size: 772 B |
BIN
textures/Dy.png
Normal file
After Width: | Height: | Size: 755 B |
BIN
textures/Er.png
Normal file
After Width: | Height: | Size: 517 B |
BIN
textures/Es.png
Normal file
After Width: | Height: | Size: 685 B |
BIN
textures/Eu.png
Normal file
After Width: | Height: | Size: 539 B |
BIN
textures/F.png
Normal file
After Width: | Height: | Size: 427 B |
BIN
textures/Fe.png
Normal file
After Width: | Height: | Size: 665 B |
BIN
textures/Fl.png
Normal file
After Width: | Height: | Size: 434 B |
BIN
textures/Fm.png
Normal file
After Width: | Height: | Size: 544 B |
BIN
textures/Fr.png
Normal file
After Width: | Height: | Size: 505 B |
BIN
textures/Ga.png
Normal file
After Width: | Height: | Size: 865 B |
BIN
textures/Gd.png
Normal file
After Width: | Height: | Size: 838 B |
BIN
textures/Ge.png
Normal file
After Width: | Height: | Size: 853 B |
BIN
textures/H.png
Normal file
After Width: | Height: | Size: 431 B |
BIN
textures/He.png
Normal file
After Width: | Height: | Size: 668 B |
BIN
textures/Hf.png
Normal file
After Width: | Height: | Size: 489 B |
BIN
textures/Hg.png
Normal file
After Width: | Height: | Size: 719 B |
BIN
textures/Ho.png
Normal file
After Width: | Height: | Size: 647 B |
BIN
textures/Hs.png
Normal file
After Width: | Height: | Size: 678 B |
BIN
textures/I.png
Normal file
After Width: | Height: | Size: 402 B |
BIN
textures/In.png
Normal file
After Width: | Height: | Size: 507 B |
BIN
textures/Ir.png
Normal file
After Width: | Height: | Size: 487 B |
BIN
textures/K.png
Normal file
After Width: | Height: | Size: 636 B |
BIN
textures/Kr.png
Normal file
After Width: | Height: | Size: 669 B |
BIN
textures/La.png
Normal file
After Width: | Height: | Size: 661 B |
BIN
textures/Li.png
Normal file
After Width: | Height: | Size: 438 B |
BIN
textures/Lr.png
Normal file
After Width: | Height: | Size: 506 B |
BIN
textures/Lu.png
Normal file
After Width: | Height: | Size: 514 B |
BIN
textures/Lv.png
Normal file
After Width: | Height: | Size: 598 B |
BIN
textures/Mc.png
Normal file
After Width: | Height: | Size: 773 B |
BIN
textures/Md.png
Normal file
After Width: | Height: | Size: 764 B |
BIN
textures/Mg.png
Normal file
After Width: | Height: | Size: 845 B |
BIN
textures/Mn.png
Normal file
After Width: | Height: | Size: 690 B |
BIN
textures/Mo.png
Normal file
After Width: | Height: | Size: 776 B |
BIN
textures/Mt.png
Normal file
After Width: | Height: | Size: 668 B |
BIN
textures/N.png
Normal file
After Width: | Height: | Size: 569 B |
BIN
textures/Na.png
Normal file
After Width: | Height: | Size: 767 B |
BIN
textures/Nb.png
Normal file
After Width: | Height: | Size: 746 B |
BIN
textures/Nd.png
Normal file
After Width: | Height: | Size: 736 B |
BIN
textures/Ne.png
Normal file
After Width: | Height: | Size: 759 B |
BIN
textures/Nh.png
Normal file
After Width: | Height: | Size: 661 B |
BIN
textures/Ni.png
Normal file
After Width: | Height: | Size: 594 B |
BIN
textures/No.png
Normal file
After Width: | Height: | Size: 749 B |
BIN
textures/Np.png
Normal file
After Width: | Height: | Size: 744 B |
BIN
textures/O.png
Normal file
After Width: | Height: | Size: 721 B |
BIN
textures/Og.png
Normal file
After Width: | Height: | Size: 922 B |
BIN
textures/Os.png
Normal file
After Width: | Height: | Size: 872 B |
BIN
textures/P.png
Normal file
After Width: | Height: | Size: 539 B |
BIN
textures/Pa.png
Normal file
After Width: | Height: | Size: 748 B |
BIN
textures/Pb.png
Normal file
After Width: | Height: | Size: 722 B |
BIN
textures/Pd.png
Normal file
After Width: | Height: | Size: 719 B |
BIN
textures/Pm.png
Normal file
After Width: | Height: | Size: 630 B |
BIN
textures/Po.png
Normal file
After Width: | Height: | Size: 716 B |
BIN
textures/Pr.png
Normal file
After Width: | Height: | Size: 585 B |
BIN
textures/Pt.png
Normal file
After Width: | Height: | Size: 601 B |
BIN
textures/Pu.png
Normal file
After Width: | Height: | Size: 640 B |
BIN
textures/Ra.png
Normal file
After Width: | Height: | Size: 755 B |
BIN
textures/Rb.png
Normal file
After Width: | Height: | Size: 735 B |
BIN
textures/Re.png
Normal file
After Width: | Height: | Size: 737 B |
BIN
textures/Rf.png
Normal file
After Width: | Height: | Size: 614 B |
BIN
textures/Rg.png
Normal file
After Width: | Height: | Size: 794 B |
BIN
textures/Rh.png
Normal file
After Width: | Height: | Size: 633 B |
BIN
textures/Rn.png
Normal file
After Width: | Height: | Size: 631 B |
BIN
textures/Ru.png
Normal file
After Width: | Height: | Size: 650 B |
BIN
textures/S.png
Normal file
After Width: | Height: | Size: 739 B |
BIN
textures/Sb.png
Normal file
After Width: | Height: | Size: 860 B |
BIN
textures/Sc.png
Normal file
After Width: | Height: | Size: 861 B |