diff --git a/api.lua b/api.lua index 8232e8f..47afef7 100644 --- a/api.lua +++ b/api.lua @@ -39,6 +39,17 @@ function microexpansion.register_recipe(output, recipe) else return microexpansion.log("invalid recipe for definition "..output..". "..dump(recipe[2])) end end +-- [local function] Choose description colour +local function desc_colour(status, desc) + if status == "unstable" then + return minetest.colorize("orange", desc) + elseif status == "no" then + return minetest.colorize("red", desc) + else + return minetest.colorize("white", desc) + end +end + -- [function] Register Item function microexpansion.register_item(itemstring, def) -- Set usedfor @@ -51,6 +62,8 @@ function microexpansion.register_item(itemstring, def) else def.inventory_image = BASENAME.."_"..itemstring..".png" end + -- Colour description + def.description = desc_colour(def.status, def.description) -- Register craftitem minetest.register_craftitem(BASENAME..":"..itemstring, def) @@ -73,6 +86,8 @@ function microexpansion.register_node(itemstring, def) def.tiles[_] = BASENAME.."_"..i..".png" end end + -- Colour description + def.description = desc_colour(def.status, def.description) -- register craftitem minetest.register_node(BASENAME..":"..itemstring, def) diff --git a/doc/api.md b/doc/api.md index 20a309d..1ee5b20 100644 --- a/doc/api.md +++ b/doc/api.md @@ -41,9 +41,9 @@ The above registers multiple recipes for the item specified. The `1` specifies t #### `register_item(itemstring, def)` __Usage:__ `microexpansion.register_item(, ` -This API function accepts the same parameters in the definition table as does `minetest.register_craftitem`, however, it makes several modifications to the parameters before passing them on. A new parameter, `usedfor`, is introduced, which if provided is appened on a new line in grey to the item description, a good way to specify what the item does or include more information about it. The `inventory_image` parameter is modified to enforce the naming style adding `microexpansion_` to the beginning of the specified path, and `.png` to the end. If not `inventory_image` is provided, the itemstring is used and then undergoes the above modification. This allows shortening and even removing the `inventory_image` code, while passing everything else (aside from `usedfor`) on to `minetest.register_craftitem`. +This API function accepts the same parameters in the definition table as does `minetest.register_craftitem`, however, it makes several modifications to the parameters before passing them on. A new parameter, `usedfor`, is introduced, which if provided is appened on a new line in grey to the item description, a good way to specify what the item does or include more information about it. The `inventory_image` parameter is modified to enforce the naming style adding `microexpansion_` to the beginning of the specified path, and `.png` to the end. If not `inventory_image` is provided, the itemstring is used and then undergoes the above modification. This allows shortening and even removing the `inventory_image` code, while passing everything else (aside from `usedfor`) on to `minetest.register_craftitem`. One final extra parameter is `status`, which if set to `no` the description is red, if set to `unstable` the description is `orange`, and if anything else the description is red. #### `register_node(itemstring, def)` __Usage:__ `microexpansion.register_node(, ` -This API function accepts the same parameters in the definition table as does `minetest.register_craftitem`, however, it makes several modifications to the parameters before passing them on. A new parameter, `usedfor`, is introduced, which if provided is appened on a new line in grey to the item description, a good way to specify what the item does or include more information about it. The `tiles` table is modified so as to simplify the definition when registering the node. Each texture in the `tiles` table has `microexpansion_` added to the beginning and `.png` to the end. This means that rather than specifying something like `microexpansion_chest_top.png`, only `chest_top` is required. __Note:__ the texture path "autocomplete" functionality can be disabled by settings `auto_complete` to `false` in the definition (useful if using textures from another mod). \ No newline at end of file +This API function accepts the same parameters in the definition table as does `minetest.register_craftitem`, however, it makes several modifications to the parameters before passing them on. A new parameter, `usedfor`, is introduced, which if provided is appened on a new line in grey to the item description, a good way to specify what the item does or include more information about it. The `tiles` table is modified so as to simplify the definition when registering the node. Each texture in the `tiles` table has `microexpansion_` added to the beginning and `.png` to the end. This means that rather than specifying something like `microexpansion_chest_top.png`, only `chest_top` is required. __Note:__ the texture path "autocomplete" functionality can be disabled by settings `auto_complete` to `false` in the definition (useful if using textures from another mod). One final extra parameter is `status`, which if set to `no` the description is red, if set to `unstable` the description is `orange`, and if anything else the description is red. \ No newline at end of file diff --git a/modules/power/gen.lua b/modules/power/gen.lua index e8f069b..7ebaf3b 100644 --- a/modules/power/gen.lua +++ b/modules/power/gen.lua @@ -23,6 +23,7 @@ me.register_node("fuel_fired_generator", { }, groups = { cracky = 1 }, paramtype2 = "facedir", + status = "no", }) -- [register node] Super Smelter @@ -46,4 +47,5 @@ me.register_node("super_smelter", { }, groups = { cracky = 1 }, paramtype2 = "facedir", + status = "no", })