make compatability stuff less complicated
This commit is contained in:
parent
75969eb9d7
commit
9cc83ce5cc
|
@ -285,7 +285,14 @@ For the creation of crafting stations which can be used to transform nodes into
|
||||||
* `update_metadata = function(meta, inv)`
|
* `update_metadata = function(meta, inv)`
|
||||||
A function which updates the node's metadata (optional)
|
A function which updates the node's metadata (optional)
|
||||||
|
|
||||||
# legacy API
|
## Compat API
|
||||||
|
|
||||||
|
For compatability w/ other mods
|
||||||
|
|
||||||
|
* `function stairsplus.compat.override_stairs(name, node, overrides, meta)`
|
||||||
|
Override stairs registered w/ the `stairs` mod, and replace them w/ stairsplus-compatible nodes.
|
||||||
|
|
||||||
|
# Legacy API
|
||||||
|
|
||||||
Methods from the previous "moreblocks" version of stairsplus which are still provided so as not to break
|
Methods from the previous "moreblocks" version of stairsplus which are still provided so as not to break
|
||||||
compatability with older mods.
|
compatability with older mods.
|
||||||
|
@ -300,7 +307,25 @@ compatability with older mods.
|
||||||
sounds = moreblocks.node_sound_wood_defaults(),
|
sounds = moreblocks.node_sound_wood_defaults(),
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
* `stairsplus:register_micro(modname, subname, recipeitem, fields)`
|
||||||
|
* `stairsplus:register_panel(modname, subname, recipeitem, fields)`
|
||||||
|
* `stairsplus:register_slab(modname, subname, recipeitem, fields)`
|
||||||
|
* `stairsplus:register_slope(modname, subname, recipeitem, fields)`
|
||||||
|
* `stairsplus:register_stair(modname, subname, recipeitem, fields)`
|
||||||
|
* `stairsplus:register_custom_subset(subset, modname, subname, recipeitem, fields)`
|
||||||
|
|
||||||
* `stairsplus:register_alias_all(modname_old, subname_old, modname_new, subname_new)`
|
* `stairsplus:register_alias_all(modname_old, subname_old, modname_new, subname_new)`
|
||||||
|
* `stairsplus:register_alias_micro(modname_old, subname_old, modname_new, subname_new)`
|
||||||
|
* `stairsplus:register_alias_panel(modname_old, subname_old, modname_new, subname_new)`
|
||||||
|
* `stairsplus:register_alias_slab(modname_old, subname_old, modname_new, subname_new)`
|
||||||
|
* `stairsplus:register_alias_slope(modname_old, subname_old, modname_new, subname_new)`
|
||||||
|
* `stairsplus:register_alias_stair(modname_old, subname_old, modname_new, subname_new)`
|
||||||
|
* `stairsplus:register_custom_subset_alias(subset, modname_old, subname_old, modname_new, subname_new)`
|
||||||
|
|
||||||
* `stairsplus:register_alias_force_all(modname_old, subname_old, modname_new, subname_new)`
|
* `stairsplus:register_alias_force_all(modname_old, subname_old, modname_new, subname_new)`
|
||||||
|
* `stairsplus:register_alias_force_micro(modname_old, subname_old, modname_new, subname_new)`
|
||||||
|
* `stairsplus:register_alias_force_panel(modname_old, subname_old, modname_new, subname_new)`
|
||||||
|
* `stairsplus:register_alias_force_slab(modname_old, subname_old, modname_new, subname_new)`
|
||||||
|
* `stairsplus:register_alias_force_slope(modname_old, subname_old, modname_new, subname_new)`
|
||||||
|
* `stairsplus:register_alias_force_stair(modname_old, subname_old, modname_new, subname_new)`
|
||||||
|
* `stairsplus:register_custom_subset_alias(subset, modname_old, subname_old, modname_new, subname_new)`
|
||||||
|
|
|
@ -14,6 +14,7 @@ api.shapes_by_node = {}
|
||||||
api.node_by_shaped_node = {}
|
api.node_by_shaped_node = {}
|
||||||
api.shape_by_shaped_node = {}
|
api.shape_by_shaped_node = {}
|
||||||
|
|
||||||
|
api.registered_singles = {}
|
||||||
api.registered_on_register_singles = {}
|
api.registered_on_register_singles = {}
|
||||||
|
|
||||||
function api.register_on_register_single(func)
|
function api.register_on_register_single(func)
|
||||||
|
@ -227,6 +228,8 @@ function api.register_single(node, shape, overrides, meta)
|
||||||
shapes[shape] = true
|
shapes[shape] = true
|
||||||
api.shapes_by_node[node] = shapes
|
api.shapes_by_node[node] = shapes
|
||||||
|
|
||||||
|
table.insert(api.registered_singles, {node, shaped_name})
|
||||||
|
|
||||||
for _, func in ipairs(api.registered_on_register_singles) do
|
for _, func in ipairs(api.registered_on_register_singles) do
|
||||||
func(node, shaped_name)
|
func(node, shaped_name)
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@ i3.register_craft_type("stairsplus:craft_schema", {
|
||||||
icon = "stairsplus_saw_button.png",
|
icon = "stairsplus_saw_button.png",
|
||||||
})
|
})
|
||||||
|
|
||||||
i3.register_craft_type("stairsplus:craft_schema", {
|
i3.register_craft_type("stairsplus:circular_saw", {
|
||||||
description = "Stairs+ circular saw",
|
description = "Stairs+ circular saw",
|
||||||
icon = "stairsplus_saw_button.png",
|
icon = "stairsplus_saw_button.png",
|
||||||
})
|
})
|
||||||
|
@ -44,7 +44,7 @@ local function convert_schema_recipe_item(item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
api.register_on_register_craft_schema(function(schema)
|
local function on_register_craft_schema(schema)
|
||||||
local recipe = table.copy(schema)
|
local recipe = table.copy(schema)
|
||||||
|
|
||||||
recipe.output = convert_schema_recipe_item(recipe.output)
|
recipe.output = convert_schema_recipe_item(recipe.output)
|
||||||
|
@ -77,14 +77,27 @@ api.register_on_register_craft_schema(function(schema)
|
||||||
result = recipe.output,
|
result = recipe.output,
|
||||||
items = recipe.recipe,
|
items = recipe.recipe,
|
||||||
})
|
})
|
||||||
end)
|
end
|
||||||
|
|
||||||
api.register_on_register_single(function(node, shaped_name)
|
for _, schema in ipairs(api.registered_recipe_schemas) do
|
||||||
|
on_register_craft_schema(schema)
|
||||||
|
end
|
||||||
|
|
||||||
|
api.register_on_register_craft_schema(on_register_craft_schema)
|
||||||
|
|
||||||
|
local function on_register_single(node, shaped_name)
|
||||||
i3.register_craft({
|
i3.register_craft({
|
||||||
type = "stairsplus:circular_saw",
|
type = "stairsplus:circular_saw",
|
||||||
result = shaped_name,
|
result = shaped_name,
|
||||||
items = {node},
|
items = {node},
|
||||||
})
|
})
|
||||||
end)
|
end
|
||||||
|
|
||||||
|
for _, single in ipairs(api.registered_singles) do
|
||||||
|
local node, shaped_name = unpack(single)
|
||||||
|
on_register_single(node, shaped_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
api.register_on_register_single(on_register_single)
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,9 @@ stairsplus.compat = {
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
stairsplus.dofile("compat2", "stairs")
|
stairsplus.dofile("compat", "i3")
|
||||||
stairsplus.dofile("compat2", "old_moreblocks")
|
stairsplus.dofile("compat", "unified_inventory")
|
||||||
|
|
||||||
-- stairsplus.dofile("compat", "inventory_managers")
|
stairsplus.dofile("compat", "stairs")
|
||||||
-- unified_inventory, sfinv, i3
|
stairsplus.dofile("compat", "old_moreblocks")
|
||||||
|
|
|
@ -72,7 +72,7 @@ local function convert_schema_recipe_item(item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
api.register_on_register_craft_schema(function(schema)
|
local function on_register_craft_schema(schema)
|
||||||
local recipe = table.copy(schema)
|
local recipe = table.copy(schema)
|
||||||
|
|
||||||
recipe.output = convert_schema_recipe_item(recipe.output)
|
recipe.output = convert_schema_recipe_item(recipe.output)
|
||||||
|
@ -104,9 +104,15 @@ api.register_on_register_craft_schema(function(schema)
|
||||||
items = recipe.recipe,
|
items = recipe.recipe,
|
||||||
width = 3,
|
width = 3,
|
||||||
})
|
})
|
||||||
end)
|
end
|
||||||
|
|
||||||
api.register_on_register_single(function(node, shaped_name)
|
for _, schema in ipairs(api.registered_recipe_schemas) do
|
||||||
|
on_register_craft_schema(schema)
|
||||||
|
end
|
||||||
|
|
||||||
|
api.register_on_register_craft_schema(on_register_craft_schema)
|
||||||
|
|
||||||
|
local function on_register_single(node, shaped_name)
|
||||||
unified_inventory.register_craft({
|
unified_inventory.register_craft({
|
||||||
output = shaped_name,
|
output = shaped_name,
|
||||||
type = "stairsplus:circular_saw",
|
type = "stairsplus:circular_saw",
|
||||||
|
@ -116,6 +122,13 @@ api.register_on_register_single(function(node, shaped_name)
|
||||||
|
|
||||||
unified_inventory.add_category_item("stairsplus:cuttable", node)
|
unified_inventory.add_category_item("stairsplus:cuttable", node)
|
||||||
unified_inventory.add_category_item("stairsplus:cut_node", shaped_name)
|
unified_inventory.add_category_item("stairsplus:cut_node", shaped_name)
|
||||||
end)
|
end
|
||||||
|
|
||||||
|
for _, single in ipairs(api.registered_singles) do
|
||||||
|
local node, shaped_name = unpack(single)
|
||||||
|
on_register_single(node, shaped_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
api.register_on_register_single(on_register_single)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
-- compatability stuff for after the API is created, but before we start using it
|
|
||||||
|
|
||||||
stairsplus.dofile("compat1", "i3")
|
|
||||||
stairsplus.dofile("compat1", "unified_inventory")
|
|
||||||
|
|
|
@ -33,8 +33,6 @@ stairsplus.dofile("util")
|
||||||
|
|
||||||
stairsplus.dofile("api", "init")
|
stairsplus.dofile("api", "init")
|
||||||
|
|
||||||
stairsplus.dofile("compat1", "init")
|
|
||||||
|
|
||||||
stairsplus.dofile("shapes", "init")
|
stairsplus.dofile("shapes", "init")
|
||||||
stairsplus.dofile("groups", "init")
|
stairsplus.dofile("groups", "init")
|
||||||
stairsplus.dofile("craft_schemas", "init")
|
stairsplus.dofile("craft_schemas", "init")
|
||||||
|
@ -42,6 +40,6 @@ stairsplus.dofile("craft_schemas", "init")
|
||||||
stairsplus.dofile("resources", "init")
|
stairsplus.dofile("resources", "init")
|
||||||
stairsplus.dofile("circular_saw")
|
stairsplus.dofile("circular_saw")
|
||||||
|
|
||||||
stairsplus.dofile("compat2", "init")
|
stairsplus.dofile("compat", "init")
|
||||||
|
|
||||||
stairsplus.dofile("aliases")
|
stairsplus.dofile("aliases")
|
||||||
|
|
Loading…
Reference in New Issue