2024-09-26 17:32:55 +02:00
|
|
|
-- test ABMs with different chances
|
|
|
|
|
2024-10-28 15:57:54 +01:00
|
|
|
local S = core.get_translator("testnodes")
|
2024-09-26 17:32:55 +02:00
|
|
|
|
|
|
|
-- ABM chance 5 node
|
2024-10-28 15:57:54 +01:00
|
|
|
core.register_node("testabms:chance_5", {
|
2024-09-26 17:32:55 +02:00
|
|
|
description = S("Node for test ABM chance_5"),
|
|
|
|
drawtype = "normal",
|
|
|
|
tiles = { "testabms_wait_node.png" },
|
|
|
|
|
|
|
|
groups = { dig_immediate = 3 },
|
|
|
|
|
|
|
|
on_construct = function (pos)
|
2024-10-28 15:57:54 +01:00
|
|
|
local meta = core.get_meta(pos)
|
2024-09-26 17:32:55 +02:00
|
|
|
meta:set_string("infotext", "Waiting for ABM testabms:chance_5")
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
2024-10-28 15:57:54 +01:00
|
|
|
core.register_abm({
|
2024-09-26 17:32:55 +02:00
|
|
|
label = "testabms:chance_5",
|
|
|
|
nodenames = "testabms:chance_5",
|
|
|
|
interval = 10,
|
|
|
|
chance = 5,
|
|
|
|
action = function (pos)
|
2024-10-28 15:57:54 +01:00
|
|
|
core.swap_node(pos, {name="testabms:after_abm"})
|
|
|
|
local meta = core.get_meta(pos)
|
2024-09-26 17:32:55 +02:00
|
|
|
meta:set_string("infotext", "ABM testabsm:chance_5 changed this node.")
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
-- ABM chance 20 node
|
2024-10-28 15:57:54 +01:00
|
|
|
core.register_node("testabms:chance_20", {
|
2024-09-26 17:32:55 +02:00
|
|
|
description = S("Node for test ABM chance_20"),
|
|
|
|
drawtype = "normal",
|
|
|
|
tiles = { "testabms_wait_node.png" },
|
|
|
|
|
|
|
|
groups = { dig_immediate = 3 },
|
|
|
|
|
|
|
|
on_construct = function (pos)
|
2024-10-28 15:57:54 +01:00
|
|
|
local meta = core.get_meta(pos)
|
2024-09-26 17:32:55 +02:00
|
|
|
meta:set_string("infotext", "Waiting for ABM testabms:chance_20")
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
2024-10-28 15:57:54 +01:00
|
|
|
core.register_abm({
|
2024-09-26 17:32:55 +02:00
|
|
|
label = "testabms:chance_20",
|
|
|
|
nodenames = "testabms:chance_20",
|
|
|
|
interval = 10,
|
|
|
|
chance = 20,
|
|
|
|
action = function (pos)
|
2024-10-28 15:57:54 +01:00
|
|
|
core.swap_node(pos, {name="testabms:after_abm"})
|
|
|
|
local meta = core.get_meta(pos)
|
2024-09-26 17:32:55 +02:00
|
|
|
meta:set_string("infotext", "ABM testabsm:chance_20 changed this node.")
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|