generated from your-land/yl_template
Adds a couple of examples
This commit is contained in:
parent
e4832e0260
commit
3f9faa75a9
81
dev/example_item_chair.lua
Normal file
81
dev/example_item_chair.lua
Normal file
@ -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)
|
24
dev/example_item_cobble.lua
Normal file
24
dev/example_item_cobble.lua
Normal file
@ -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()
|
||||
})
|
78
dev/example_item_melon.lua
Normal file
78
dev/example_item_melon.lua
Normal file
@ -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)
|
26
dev/example_item_remove.lua
Normal file
26
dev/example_item_remove.lua
Normal file
@ -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")
|
||||
|
41
dev/example_item_remove_twice.lua
Normal file
41
dev/example_item_remove_twice.lua
Normal file
@ -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")
|
25
dev/example_item_sand.lua
Normal file
25
dev/example_item_sand.lua
Normal file
@ -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()
|
||||
})
|
30
dev/items.lua
Normal file
30
dev/items.lua
Normal file
@ -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")
|
Loading…
Reference in New Issue
Block a user