-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.lua
114 lines (90 loc) · 3.05 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
cg = {
PAGE_WIDTH = 8,
PAGE_ITEMS = 32,
items_all = {},
player_data = {},
crafts = {},
craft_methods = {},
group_stereotypes = {},
}
local settings = minetest.settings
cg.AUTOCRAFTING = settings:get_bool("cg_plus_autocrafting", true)
cg.GROUP_SEARCH = settings:get_bool("cg_plus_group_search", true)
cg.GROUP_SEARCH_MAX = tonumber(settings:get("cg_plus_group_search_max")) or 5
cg.S = minetest.get_translator("cg_plus")
local F = minetest.formspec_escape
local path = minetest.get_modpath("cg_plus")
dofile(path .. "/api.lua")
if cg.AUTOCRAFTING then
dofile(path .. "/autocrafting.lua")
end
dofile(path .. "/inventory.lua")
cg.register_crafting_method("normal", {
description = cg.S("Crafting"),
uses_crafting_grid = true,
get_grid_size = function(craft)
local width = math.max(craft.width, 1)
local height = math.ceil(table.maxn(craft.items) / width)
local sideLen = math.max(width, height)
if sideLen < 3 then
return {x = 3, y = 3}
else
return {x = sideLen, y = sideLen}
end
end
})
cg.register_crafting_method("shapeless", {
description = cg.S("Mixing"),
uses_crafting_grid = true,
get_grid_size = function(craft)
local numItems = table.maxn(craft.items)
if table.maxn(craft.items) <= 9 then
return {x = 3, y = 3}
else
local sideLen = math.ceil(math.sqrt(numItems))
return {x = sideLen, y = sideLen}
end
end
})
cg.register_crafting_method("cooking", {
description = cg.S("Cooking"),
arrow_icon = "cg_plus_arrow_bottom.png^cg_plus_icon_cooking.png",
get_grid_size = function(craft)
return {x = 1, y = 1}
end,
get_infotext = function(craft)
return minetest.colorize("#FFFF00", cg.S("Time: @1 s", craft.width or 0))
end
})
cg.register_crafting_method("fuel", {
description = cg.S("Fuel"),
arrow_icon = "cg_plus_arrow_bottom.png^cg_plus_icon_fuel.png",
get_grid_size = function(craft)
return {x = 1, y = 1}
end,
get_infotext = function(craft)
return minetest.colorize("#FFFF00", cg.S("Time: @1 s", craft.time or 0))
end
})
cg.register_crafting_method("digging", {
description = cg.S("Digging"),
arrow_icon = "cg_plus_arrow_bottom.png^cg_plus_icon_digging.png",
get_grid_size = function(craft)
return {x = 1, y = 1}
end
})
cg.register_crafting_method("digging_chance", {
description = cg.S("Digging@n(by chance)"),
arrow_icon = "cg_plus_arrow_bottom.png^cg_plus_icon_digging.png",
get_grid_size = function(craft)
return {x = 1, y = 1}
end
})
cg.register_group_stereotype("mesecon_conductor_craftable", "mesecons:wire_00000000_off")
if minetest.get_modpath("default") then
cg.register_group_stereotype("stone", "default:stone")
cg.register_group_stereotype("wood", "default:wood")
cg.register_group_stereotype("sand", "default:sand")
cg.register_group_stereotype("leaves", "default:leaves")
cg.register_group_stereotype("tree", "default:tree")
end