/
init.lua
97 lines (86 loc) · 2.59 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
modpath=minetest.get_modpath("itest")
itest = {}
itest.registered_ores = {}
function itest.register_ore(name,value)
itest.registered_ores[name]=value
end
function hacky_swap_node(pos,name)
local node = minetest.env:get_node(pos)
local meta = minetest.env:get_meta(pos)
local meta0 = meta:to_table()
if node.name == name then
return
end
node.name = name
local meta0 = meta:to_table()
minetest.env:set_node(pos,node)
meta = minetest.env:get_meta(pos)
meta:from_table(meta0)
end
function addVect(pos1,pos2)
return {x=pos1.x+pos2.x,y=pos1.y+pos2.y,z=pos1.z+pos2.z}
end
function param22dir(param2)
if param2==0 then
return {x=1,y=0,z=0}
elseif param2==1 then
return {x=0,y=0,z=-1}
elseif param2==2 then
return {x=-1,y=0,z=0}
else
return {x=0,y=0,z=1}
end
end
function get_node_field(name,meta,key,pos)
if meta == nil then meta = minetest.env:get_meta(pos) end
if name == nil then name = minetest.env:get_node(pos).name end
if meta:get_string(key) ~= "" then return meta:get_int(key) end
if minetest.registered_nodes[name] and
minetest.registered_nodes[name].itest and
minetest.registered_nodes[name].itest[key] then
return minetest.registered_nodes[name].itest[key]
end
return minetest.get_item_group(name,key)
end
function get_node_field_float(name,meta,key,pos)
if meta == nil then meta = minetest.env:get_meta(pos) end
if name == nil then name = minetest.env:get_node(pos).name end
if meta:get_string(key) ~= "" then return meta:get_float(key) end
if minetest.registered_nodes[name] and
minetest.registered_nodes[name].itest and
minetest.registered_nodes[name].itest[key] then
return minetest.registered_nodes[name].itest[key]
end
return 0
end
function get_item_field(name,key)
if minetest.registered_items[name] and
minetest.registered_items[name].itest and
minetest.registered_items[name].itest[key] then
return minetest.registered_items[name].itest[key]
end
return minetest.get_item_group(name,key)
end
function is_fuel_no_lava(stack)
return (minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0)
and (string.find(stack:get_name(),"lava")==nil)
end
function clone_node(name)
node2={}
node=minetest.registered_nodes[name]
for k,v in pairs(node) do
node2[k]=v
end
return node2
end
dofile(modpath.."/builtin.lua")
dofile(modpath.."/mapgen.lua")
dofile(modpath.."/iron_furnace.lua")
dofile(modpath.."/energy_transport.lua")
dofile(modpath.."/cables.lua")
dofile(modpath.."/charge.lua")
dofile(modpath.."/generators.lua")
dofile(modpath.."/storage.lua")
dofile(modpath.."/consumers.lua")
dofile(modpath.."/upgrades.lua")
dofile(modpath.."/craft.lua")