aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation/pcnaming.lua
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains_luaautomation/pcnaming.lua')
-rw-r--r--advtrains_luaautomation/pcnaming.lua15
1 files changed, 11 insertions, 4 deletions
diff --git a/advtrains_luaautomation/pcnaming.lua b/advtrains_luaautomation/pcnaming.lua
index ebb769f..60983a6 100644
--- a/advtrains_luaautomation/pcnaming.lua
+++ b/advtrains_luaautomation/pcnaming.lua
@@ -2,6 +2,8 @@
--a.k.a Passive component naming
--Allows to assign names to passive components, so they can be called like:
--setstate("iamasignal", "green")
+local S = atltrans
+
atlatc.pcnaming={name_map={}}
function atlatc.pcnaming.load(stuff)
if type(stuff)=="table" then
@@ -23,7 +25,7 @@ function atlatc.pcnaming.resolve_pos(pos, func_name)
end
minetest.register_craftitem("advtrains_luaautomation:pcnaming",{
- description = attrans("Passive Component Naming Tool\n\nRight-click to name a passive component."),
+ description = S("Passive Component Naming Tool\n\nRight-click to name a passive component."),
groups = {cracky=1}, -- key=name, value=rating; rating=1..3.
inventory_image = "atlatc_pcnaming.png",
wield_image = "atlatc_pcnaming.png",
@@ -34,7 +36,7 @@ minetest.register_craftitem("advtrains_luaautomation:pcnaming",{
return
end
if not minetest.check_player_privs(pname, {atlatc=true}) then
- minetest.chat_send_player(pname, "Missing privilege: atlatc")
+ minetest.chat_send_player(pname, S("You are not allowed to name LuaATC passive components without the @1 privilege.", "atlatc"))
return
end
if pointed_thing.type=="node" then
@@ -44,7 +46,12 @@ minetest.register_craftitem("advtrains_luaautomation:pcnaming",{
return
end
local node = advtrains.ndb.get_node(pos)
- if node.name and (minetest.get_item_group(node.name, "advtrains_signal")>0 or advtrains.is_passive(pos)) then
+ local ndef = minetest.registered_nodes[node.name]
+ if node.name and (
+ minetest.get_item_group(node.name, "advtrains_signal")>0 --is IL signal
+ or advtrains.is_passive(pos) -- is passive component
+ or (ndef and ndef.luaautomation) -- is active component
+ ) then
--look if this one already has a name
local pn=""
for name, npos in pairs(atlatc.pcnaming.name_map) do
@@ -52,7 +59,7 @@ minetest.register_craftitem("advtrains_luaautomation:pcnaming",{
pn=name
end
end
- minetest.show_formspec(pname, "atlatc_naming_"..minetest.pos_to_string(pos), "field[pn;Set name of component (empty to clear);"..minetest.formspec_escape(pn).."]")
+ minetest.show_formspec(pname, "atlatc_naming_"..minetest.pos_to_string(pos), "field[pn;"..S("Set name of component (empty to clear)")..";"..minetest.formspec_escape(pn).."]")
end
end
end,