-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test nodes and unittest for override entity. Fix bugs.
- Loading branch information
Showing
19 changed files
with
354 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Test ABMs | ||
|
||
This mod contains a nodes and related ABM actions. | ||
By placing these nodes, you can test basic ABM behaviours. | ||
|
||
There are separate tests for ABM `chance`, `interval`, `min_y`, `max_y`, `neighbor` and `without_neighbor` fields. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
local S = minetest.get_translator("testabms") | ||
|
||
-- After ABM node | ||
minetest.register_node("testabms:after_abm", { | ||
description = S("After ABM processed node."), | ||
drawtype = "normal", | ||
tiles = { "testabms_after_node.png" }, | ||
|
||
groups = { dig_immediate = 3 }, | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
-- test ABMs with different chances | ||
|
||
local S = minetest.get_translator("testabms") | ||
|
||
-- ABM chance 5 node | ||
minetest.register_node("testabms:chance_5", { | ||
description = S("Node for test ABM chance_5"), | ||
drawtype = "normal", | ||
tiles = { "testabms_wait_node.png" }, | ||
|
||
groups = { dig_immediate = 3 }, | ||
|
||
on_construct = function (pos) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "Waiting for ABM testabms:chance_5") | ||
end, | ||
}) | ||
|
||
minetest.register_abm({ | ||
label = "testabms:chance_5", | ||
nodenames = "testabms:chance_5", | ||
interval = 10, | ||
chance = 5, | ||
action = function (pos) | ||
minetest.swap_node(pos, {name="testabms:after_abm"}) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "ABM testabsm:chance_5 changed this node.") | ||
end | ||
}) | ||
|
||
-- ABM chance 20 node | ||
minetest.register_node("testabms:chance_20", { | ||
description = S("Node for test ABM chance_20"), | ||
drawtype = "normal", | ||
tiles = { "testabms_wait_node.png" }, | ||
|
||
groups = { dig_immediate = 3 }, | ||
|
||
on_construct = function (pos) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "Waiting for ABM testabms:chance_20") | ||
end, | ||
}) | ||
|
||
minetest.register_abm({ | ||
label = "testabms:chance_20", | ||
nodenames = "testabms:chance_20", | ||
interval = 10, | ||
chance = 20, | ||
action = function (pos) | ||
minetest.swap_node(pos, {name="testabms:after_abm"}) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "ABM testabsm:chance_20 changed this node.") | ||
end | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
local path = minetest.get_modpath(minetest.get_current_modname()) | ||
|
||
dofile(path.."/after_node.lua") | ||
dofile(path.."/chances.lua") | ||
dofile(path.."/intervals.lua") | ||
dofile(path.."/min_max.lua") | ||
dofile(path.."/neighbors.lua") | ||
dofile(path.."/override.lua") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
-- test ABMs with different interval | ||
|
||
local S = minetest.get_translator("testabms") | ||
|
||
-- ABM inteval 1 node | ||
minetest.register_node("testabms:interval_1", { | ||
description = S("Node for test ABM interval_1"), | ||
drawtype = "normal", | ||
tiles = { "testabms_wait_node.png" }, | ||
|
||
groups = { dig_immediate = 3 }, | ||
|
||
on_construct = function (pos) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "Waiting for ABM testabms:interval_1") | ||
end, | ||
}) | ||
|
||
minetest.register_abm({ | ||
label = "testabms:interval_1", | ||
nodenames = "testabms:interval_1", | ||
interval = 1, | ||
chance = 1, | ||
action = function (pos) | ||
minetest.swap_node(pos, {name="testabms:after_abm"}) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "ABM testabsm:interval_1 changed this node.") | ||
end | ||
}) | ||
|
||
-- ABM interval 60 node | ||
minetest.register_node("testabms:interval_60", { | ||
description = S("Node for test ABM interval_60"), | ||
drawtype = "normal", | ||
tiles = { "testabms_wait_node.png" }, | ||
|
||
groups = { dig_immediate = 3 }, | ||
|
||
on_construct = function (pos) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "Waiting for ABM testabms:interval_60") | ||
end, | ||
}) | ||
|
||
minetest.register_abm({ | ||
label = "testabms:interval_60", | ||
nodenames = "testabms:interval_60", | ||
interval = 60, | ||
chance = 1, | ||
action = function (pos) | ||
minetest.swap_node(pos, {name="testabms:after_abm"}) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "ABM testabsm:interval_60 changed this node.") | ||
end | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
-- test ABMs with min_y and max_y | ||
|
||
local S = minetest.get_translator("testabms") | ||
|
||
-- ABM min_y node | ||
minetest.register_node("testabms:min_y", { | ||
description = S("Node for test ABM min_y."), | ||
drawtype = "normal", | ||
tiles = { "testabms_wait_node.png" }, | ||
|
||
groups = { dig_immediate = 3 }, | ||
|
||
on_construct = function (pos) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "Waiting for ABM testabms:min_y at y "..pos.y.." with min_y = 0") | ||
end, | ||
}) | ||
|
||
minetest.register_abm({ | ||
label = "testabms:min_y", | ||
nodenames = "testabms:min_y", | ||
interval = 10, | ||
chance = 1, | ||
min_y = 0, | ||
action = function (pos) | ||
minetest.swap_node(pos, {name="testabms:after_abm"}) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "ABM testabsm:min_y changed this node.") | ||
end | ||
}) | ||
|
||
-- ABM max_y node | ||
minetest.register_node("testabms:max_y", { | ||
description = S("Node for test ABM max_y."), | ||
drawtype = "normal", | ||
tiles = { "testabms_wait_node.png" }, | ||
|
||
groups = { dig_immediate = 3 }, | ||
|
||
on_construct = function (pos) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "Waiting for ABM testabms:max_y at y "..pos.y.." with max_y = 0") | ||
end, | ||
}) | ||
|
||
minetest.register_abm({ | ||
label = "testabms:max_y", | ||
nodenames = "testabms:max_y", | ||
interval = 10, | ||
chance = 1, | ||
max_y = 0, | ||
action = function (pos) | ||
minetest.swap_node(pos, {name="testabms:after_abm"}) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "ABM testabsm:max_y changed this node.") | ||
end | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
name = testabms | ||
description = Contains some nodes for test ABMs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
-- test ABMs with neighbor and without_neighbor | ||
|
||
local S = minetest.get_translator("testabms") | ||
|
||
-- ABM required neighboor | ||
minetest.register_node("testabms:required_neighbor", { | ||
description = S("Node for test ABM required_neighbor."), | ||
drawtype = "normal", | ||
tiles = { "testabms_wait_node.png" }, | ||
|
||
groups = { dig_immediate = 3 }, | ||
|
||
on_construct = function (pos) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "Waiting for ABM testabms:required_neighbor (normal drawtype testnode sensitive)") | ||
end, | ||
}) | ||
|
||
minetest.register_abm({ | ||
label = "testabms:required_neighbor", | ||
nodenames = "testabms:required_neighbor", | ||
neighbors = {"testnodes:normal"}, | ||
interval = 1, | ||
chance = 1, | ||
action = function (pos) | ||
minetest.swap_node(pos, {name="testabms:after_abm"}) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "ABM testabsm:required_neighbor changed this node.") | ||
end | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
-- test ABMs with override | ||
|
||
local S = minetest.get_translator("testabms") | ||
|
||
-- ABM override | ||
minetest.register_node("testabms:override", { | ||
description = S("Node for test ABM override"), | ||
drawtype = "normal", | ||
tiles = { "testabms_wait_node.png" }, | ||
|
||
groups = { dig_immediate = 3 }, | ||
|
||
on_construct = function (pos) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "Waiting for ABM testabms:overrid") | ||
end, | ||
}) | ||
|
||
minetest.register_abm({ | ||
label = "testabms:override", | ||
name = "testabms:override", | ||
nodenames = "testabms:override", | ||
interval = 1000, | ||
chance = 5000, | ||
action = function (pos) | ||
minetest.swap_node(pos, {name="testabms:after_abm"}) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "ABM testabms:override changed this node.") | ||
end | ||
}) | ||
|
||
minetest.override_abm("testabms:override", { | ||
interval = 1, | ||
chance = 1, | ||
action = function (pos) | ||
minetest.swap_node(pos, {name="testabms:after_abm"}) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "Override ABM testabms:override changed this node.") | ||
end | ||
}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Test LBMs | ||
|
||
This mod contains a nodes and related LBM actions. | ||
By placing these nodes, you can test basic LBM behaviours. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
local S = minetest.get_translator("testlbms") | ||
|
||
-- After LBM node | ||
minetest.register_node("testlbms:after_lbm", { | ||
description = S("After LBM processed node."), | ||
drawtype = "normal", | ||
tiles = { "testlbms_after_node.png" }, | ||
|
||
groups = { dig_immediate = 3 }, | ||
}) | ||
|
||
-- LBM onload change | ||
minetest.register_node("testlbms:onload_change", { | ||
description = S("Node for test LBM"), | ||
drawtype = "normal", | ||
tiles = { "testlbms_wait_node.png" }, | ||
|
||
groups = { dig_immediate = 3 }, | ||
|
||
on_construct = function (pos) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "Waiting for LBM testlbms:chance_5") | ||
end, | ||
}) | ||
|
||
minetest.register_lbm({ | ||
label = "testlbms:onload_change", | ||
name = "testlbms:onload_change", | ||
nodenames = "testlbms:onload_change", | ||
run_at_every_load = true, | ||
action = function (pos) | ||
minetest.swap_node(pos, {name="testlbms:after_lbm"}) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "LBM testlbms:onload_change changed this node.") | ||
end | ||
}) | ||
|
||
minetest.override_lbm("testlbms:onload_change", { | ||
action = function (pos) | ||
minetest.swap_node(pos, {name="testlbms:after_lbm"}) | ||
local meta = minetest.get_meta(pos) | ||
meta:set_string("infotext", "Override LBM testlbms:onload_change changed this node.") | ||
end, | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
name = testlbms | ||
description = Contains some nodes for test LBMs. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.