From 3f9faa75a9fbb83d527f42d68d5d9481edc1b2f0 Mon Sep 17 00:00:00 2001 From: AliasAlreadyTaken Date: Thu, 11 Jul 2024 00:12:38 +0200 Subject: [PATCH] Adds a couple of examples --- dev/example_item_chair.lua | 81 +++++++++++++++++++++++++++++++ dev/example_item_cobble.lua | 24 +++++++++ dev/example_item_melon.lua | 78 +++++++++++++++++++++++++++++ dev/example_item_remove.lua | 26 ++++++++++ dev/example_item_remove_twice.lua | 41 ++++++++++++++++ dev/example_item_sand.lua | 25 ++++++++++ dev/items.lua | 30 ++++++++++++ 7 files changed, 305 insertions(+) create mode 100644 dev/example_item_chair.lua create mode 100644 dev/example_item_cobble.lua create mode 100644 dev/example_item_melon.lua create mode 100644 dev/example_item_remove.lua create mode 100644 dev/example_item_remove_twice.lua create mode 100644 dev/example_item_sand.lua create mode 100644 dev/items.lua diff --git a/dev/example_item_chair.lua b/dev/example_item_chair.lua new file mode 100644 index 0000000..8745f9d --- /dev/null +++ b/dev/example_item_chair.lua @@ -0,0 +1,81 @@ +local stages = {} +local example = {} + +table.insert(stages, { + --stage related + stage_name = "example:chair_jam_1", + duration = 10, + next_stages = {{"example:chair_jam_2"},{"example:chair_jam_1"},{"example:chair_jam_1"}}, + --node definition + tiles = {"example_chair_jam_1.png"}, + description = "Awesome chair jam", + node_definition = example.get_node_definition() +}) + +table.insert(stages, { + --stage related + stage_name = "example:chair_jam_2", + duration = 10, + next_stages = {{"example:chair_jam_3",50},{"example:chair_jam_2",100}}, + --node definition + tiles = {"example_chair_jam_2.png"}, + description = "Awesome chair jam", + node_definition = example.get_node_definition() +}) + +table.insert(stages, { + --stage related + stage_name = "example:chair_jam_3", + duration = 10, + next_stages = "example:chair_jam_4", --same as next_stage = { {"example:melon_jam_2", 1} } + --node definition + tiles = {"example_chair_jam_3.png"}, + description = "Awesome chair jam", + node_definition = example.get_node_definition() +}) + +table.insert(stages, { + --stage related + stage_name = "example:chair_jam_4", + duration = 10, + next_stages = "example:chair_jam_5", --same as next_stage = { {"example:melon_jam_2", 1} } + --node definition + tiles = {"example_chair_jam_4.png"}, + description = "Awesome chair jam", + node_definition = example.get_node_definition() +}) + +table.insert(stages, { + --stage related + stage_name = "example:chair_jam_5", + duration = 10, + next_stages = "example:chair_jam_6", --same as next_stage = { {"example:melon_jam_2", 1} } + --node definition + tiles = {"example_chair_jam_5.png"}, + description = "Awesome chair jam", + node_definition = example.get_node_definition() +}) + +table.insert(stages, { + --stage related + stage_name = "example:chair_jam_6", + duration = 10, + next_stages = { + { "stairs:stair_pine_wood", 50, {},{param2=12}}, + { "example:chair_jam_1", 50} + }, + --node definition + tiles = {"example_chair_jam_6.png"}, + description = "Awesome chair jam", + node_definition = example.get_node_definition() +}) + +local success, good, bad, total, reasons = yl_api_nodestages.register_stages(stages) + +core.log("action","success = ".. dump(success)) +core.log("action","good = ".. dump(good)) +core.log("action","bad = ".. dump(bad)) +core.log("action","total = ".. dump(total)) +core.log("action","reasons = ".. dump(reasons)) + +assert(success) \ No newline at end of file diff --git a/dev/example_item_cobble.lua b/dev/example_item_cobble.lua new file mode 100644 index 0000000..19ad31d --- /dev/null +++ b/dev/example_item_cobble.lua @@ -0,0 +1,24 @@ + +yl_api_nodestages.add_stage({ + --stage related + stage_name = "default:cobble", + duration = 10, + next_stages = "default:stone", + restart = false + --node definition + --tiles = {"example_melon_jam_1.png"}, + --description = "Awesome melon jam", + --node_definition = example.get_node_definition() +}) + +yl_api_nodestages.add_stage({ + --stage related + stage_name = "default:stone", + duration = 10, + next_stages = "air", + restart = false + --node definition + --tiles = {"example_melon_jam_1.png"}, + --description = "Awesome melon jam", + --node_definition = example.get_node_definition() +}) \ No newline at end of file diff --git a/dev/example_item_melon.lua b/dev/example_item_melon.lua new file mode 100644 index 0000000..63f9612 --- /dev/null +++ b/dev/example_item_melon.lua @@ -0,0 +1,78 @@ +local stages = {} +local example = {} + +table.insert(stages, { + -- stage related + stage_name = "example:melon_jam_1", + duration = 10, + next_stages = "example:melon_jam_2", -- same as next_stage = { {"example:melon_jam_2", 1} } + -- node definition + tiles = {"example_melon_jam_1.png"}, + description = "Awesome melon jam", + node_definition = example.get_node_definition() +}) + +table.insert(stages, { + -- stage related + stage_name = "example:melon_jam_2", + --[[ + duration = {10, 20}, + duration = {20, 10}, + duration = {10}, + duration = {10, 10}, + ]] -- + duration = 10, + -- duration = "10", + next_stages = { + {"example:melon_jam_3", 50, {can_set = example.can_set}}, + {"example:melon_jam_4", 50}, + {"default:cobble", 50, {can_set = example.can_set}, {param2 = 12}} + }, + -- node definition + tiles = {"example_melon_jam_2.png"}, + description = "Awesome melon jam Stage 2", + node_definition = example.get_node_definition() +}) + +table.insert(stages, { + -- stage related + stage_name = "example:melon_jam_3", + -- duration = nil, + -- next_stages = nil, + -- node definition + tiles = {"example_melon_jam_3.png"}, + description = "Awesome melon jam Stage 3", + node_definition = example.get_node_definition() +}) + +--[[ +table.insert(stages, { + --stage related + stage_name = "example:melon_jam_4", + -- duration = {10, 20}, + -- duration = {20, 10}, + -- duration = {10}, + -- duration = {10, 10}, + duration = 10, + duration = "10", + next_stages = { + { "example:melon_jam_1", 50 }, + { "example:melon_jam_2", 50 } + }, + --node definition + tiles = {"example_melon_jam_2.png"}, + description = "Awesome melon jam Stage 4", + node_definition = example.get_node_definition() +}) +]] -- + +local success, good, bad, total, reasons = + yl_api_nodestages.register_stages(stages) + +core.log("action", "success = " .. dump(success)) +core.log("action", "good = " .. dump(good)) +core.log("action", "bad = " .. dump(bad)) +core.log("action", "total = " .. dump(total)) +core.log("action", "reasons = " .. dump(reasons)) + +assert(success) diff --git a/dev/example_item_remove.lua b/dev/example_item_remove.lua new file mode 100644 index 0000000..98fd5eb --- /dev/null +++ b/dev/example_item_remove.lua @@ -0,0 +1,26 @@ + +yl_api_nodestages.add_stage({ + --stage related + stage_name = "default:acacia_tree", + duration = 10, + next_stages = "default:gravel", + --node definition + --tiles = {"example_melon_jam_1.png"}, + --description = "Awesome melon jam", + --node_definition = example.get_node_definition() +}) + +yl_api_nodestages.overwrite_stage({ + --stage related + stage_name = "default:acacia_tree", + duration = 10, + next_stages = "default:dirt", + overwrite = true + --node definition + --tiles = {"example_melon_jam_1.png"}, + --description = "Awesome melon jam", + --node_definition = example.get_node_definition() +}) + +yl_api_nodestages.rollback_stage("default", "acacia_tree") + diff --git a/dev/example_item_remove_twice.lua b/dev/example_item_remove_twice.lua new file mode 100644 index 0000000..6757b56 --- /dev/null +++ b/dev/example_item_remove_twice.lua @@ -0,0 +1,41 @@ + +yl_api_nodestages.add_stage({ + --stage related + stage_name = "default:aspen_tree", + duration = 10, + next_stages = "default:gravel", + --node definition + --tiles = {"example_melon_jam_1.png"}, + --description = "Awesome melon jam", + --node_definition = example.get_node_definition() +}) + +yl_api_nodestages.overwrite_stage({ + --stage related + stage_name = "default:aspen_tree", + duration = 10, + next_stages = "default:dirt", + overwrite = true + --node definition + --tiles = {"example_melon_jam_1.png"}, + --description = "Awesome melon jam", + --node_definition = example.get_node_definition() +}) + +yl_api_nodestages.overwrite_stage({ + --stage related + stage_name = "default:aspen_tree", + duration = 10, + next_stages = "default:cobble", + overwrite = true + --node definition + --tiles = {"example_melon_jam_1.png"}, + --description = "Awesome melon jam", + --node_definition = example.get_node_definition() +}) + +yl_api_nodestages.rollback_stage("default", "aspen_tree") + +yl_api_nodestages.rollback_stage("default", "aspen_tree") + +yl_api_nodestages.delete_stage("default", "aspen_tree") \ No newline at end of file diff --git a/dev/example_item_sand.lua b/dev/example_item_sand.lua new file mode 100644 index 0000000..c280c03 --- /dev/null +++ b/dev/example_item_sand.lua @@ -0,0 +1,25 @@ + +yl_api_nodestages.add_stage({ + --stage related + stage_name = "default:sand", + duration = 10, + next_stages = "default:gravel", + restart = false + --node definition + --tiles = {"example_melon_jam_1.png"}, + --description = "Awesome melon jam", + --node_definition = example.get_node_definition() +}) + +yl_api_nodestages.overwrite_stage({ + --stage related + stage_name = "default:sand", + duration = 10, + next_stages = "default:dirt", + overwrite = true, + restart = false + --node definition + --tiles = {"example_melon_jam_1.png"}, + --description = "Awesome melon jam", + --node_definition = example.get_node_definition() +}) \ No newline at end of file diff --git a/dev/items.lua b/dev/items.lua new file mode 100644 index 0000000..c46d97f --- /dev/null +++ b/dev/items.lua @@ -0,0 +1,30 @@ + +local example = {} +example.modpath = minetest.get_modpath("example") .. DIR_DELIM + +function example.get_node_definition() + local t = { + drawtype = "plantlike", + paramtype = "light", + is_ground_content = false, + walkable = false, + selection_box = { + type = "fixed", + fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25} + }, + groups = { + attached_node = 1, + dig_immediate = 3, + canned_food = 1, + vessel = 1 + } + } + return t +end + +dofile(example.modpath .. "example_item_melon.lua") +dofile(example.modpath .. "example_item_chair.lua") +dofile(example.modpath .. "example_item_cobble.lua") +dofile(example.modpath .. "example_item_sand.lua") +dofile(example.modpath .. "example_item_remove.lua") +dofile(example.modpath .. "example_item_remove_remove.lua")