From eb0c5b78627505bcba409dc5f52dbb05891954c5 Mon Sep 17 00:00:00 2001 From: "Y. Wang" Date: Wed, 4 Oct 2023 22:14:18 +0200 Subject: Various translation improvements --- advtrains/trackplacer.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'advtrains/trackplacer.lua') diff --git a/advtrains/trackplacer.lua b/advtrains/trackplacer.lua index fe76290..9f97171 100644 --- a/advtrains/trackplacer.lua +++ b/advtrains/trackplacer.lua @@ -310,7 +310,7 @@ end minetest.register_craftitem("advtrains:trackworker",{ - description = attrans("Track Worker Tool\n\nLeft-click: change rail type (straight/curve/switch)\nRight-click: rotate rail/bumper/signal/etc."), + description = attrans("Track Worker Tool\n\nLeft-click: change rail type (straight/curve/switch)\nRight-click: rotate object"), groups = {cracky=1}, -- key=name, value=rating; rating=1..3. inventory_image = "advtrains_trackworker.png", wield_image = "advtrains_trackworker.png", @@ -337,7 +337,7 @@ minetest.register_craftitem("advtrains:trackworker",{ nnprefix, suffix=string.match(node.name, "^(.+)_([^_]+)$") rotation = "" if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twrotate[suffix] then - minetest.chat_send_player(placer:get_player_name(), attrans("This node can't be rotated using the trackworker!")) + minetest.chat_send_player(placer:get_player_name(), attrans("This node can't be rotated using the trackworker.")) return end end @@ -347,7 +347,7 @@ minetest.register_craftitem("advtrains:trackworker",{ -- is a track, we can query local can_modify, reason = advtrains.can_dig_or_modify_track(pos) if not can_modify then - local str = attrans("This track can not be rotated!") + local str = attrans("This track can not be rotated.") if reason then str = str .. " " .. reason end @@ -374,7 +374,7 @@ minetest.register_craftitem("advtrains:trackworker",{ if v==rotation then modpos=k end end if not modpos then - minetest.chat_send_player(placer:get_player_name(), attrans("This node can't be rotated using the trackworker!")) + minetest.chat_send_player(placer:get_player_name(), attrans("This node can't be rotated using the trackworker.")) return end advtrains.ndb.swap_node(pos, {name=nnprefix.."_"..suffix..modext[modpos+1], param2=node.param2}) @@ -401,7 +401,7 @@ minetest.register_craftitem("advtrains:trackworker",{ nnprefix, suffix=string.match(node.name, "^(.+)_([^_]+)$") rotation = "" if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twcycle[suffix] then - minetest.chat_send_player(user:get_player_name(), attrans("This node can't be changed using the trackworker!")) + minetest.chat_send_player(user:get_player_name(), attrans("This node can't be changed using the trackworker.")) return end end @@ -411,7 +411,7 @@ minetest.register_craftitem("advtrains:trackworker",{ -- is a track, we can query local can_modify, reason = advtrains.can_dig_or_modify_track(pos) if not can_modify then - local str = attrans("This track can not be changed!") + local str = attrans("This track can not be changed.") if reason then str = str .. " " .. reason end -- cgit v1.2.3 From 671cb16e9599f9989cf5b12f76f1eb0a21252172 Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Sun, 8 Sep 2024 08:57:32 +0800 Subject: Allow operate on_rightclick nodes with track placers and wagon placers Press sneak to force default behavior. --- advtrains/trackplacer.lua | 21 +++++++++++++++++---- advtrains/wagons.lua | 22 ++++++++++++++++------ 2 files changed, 33 insertions(+), 10 deletions(-) (limited to 'advtrains/trackplacer.lua') diff --git a/advtrains/trackplacer.lua b/advtrains/trackplacer.lua index 9f97171..2588088 100644 --- a/advtrains/trackplacer.lua +++ b/advtrains/trackplacer.lua @@ -275,11 +275,24 @@ function tp.register_track_placer(nnprefix, imgprefix, dispname, def) groups={advtrains_trackplacer=1, digtron_on_place=1}, liquids_pointable = def.liquids_pointable, on_place = function(itemstack, placer, pointed_thing) - local name = placer:get_player_name() - if not name then - return itemstack, false - end if pointed_thing.type=="node" then + do + local pointed_pos = pointed_thing.under + local pointed_node = minetest.get_node(pointed_pos) + local pointed_def = minetest.registered_nodes[pointed_node.name] + if pointed_def and pointed_def.on_rightclick then + local controls = placer:get_player_control() + if not controls.sneak then + return pointed_def.on_rightclick(pointed_pos, pointed_node, placer, itemstack, pointed_thing) + end + end + end + + local name = placer:get_player_name() + if not name then + return itemstack, false + end + local pos=pointed_thing.above local upos=vector.subtract(pointed_thing.above, {x=0, y=1, z=0}) if not advtrains.check_track_protection(pos, name) then diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua index ddff2f5..50ce4ab 100644 --- a/advtrains/wagons.lua +++ b/advtrains/wagons.lua @@ -1393,13 +1393,23 @@ function advtrains.register_wagon(sysname_p, prototype, desc, inv_img, nincreati groups = wagon_groups, on_place = function(itemstack, placer, pointed_thing) - if not pointed_thing.type == "node" then + if pointed_thing.type ~= "node" then return end + + local pos = pointed_thing.under + local node = minetest.get_node(pos) + local pointed_def = minetest.registered_nodes[node.name] + if pointed_def and pointed_def.on_rightclick then + local controls = placer:get_player_control() + if not controls.sneak then + return pointed_def.on_rightclick(pos, node, placer, itemstack, pointed_thing) + end + end + local pname = placer:get_player_name() - local node=minetest.get_node_or_nil(pointed_thing.under) - if not node then atprint("[advtrains]Ignore at placer position") return itemstack end + if node.name == "ignore" then atprint("[advtrains]Ignore at placer position") return itemstack end local nodename=node.name if(not advtrains.is_track_and_drives_on(nodename, prototype.drives_on)) then atprint("no track here, not placing.") @@ -1409,14 +1419,14 @@ function advtrains.register_wagon(sysname_p, prototype, desc, inv_img, nincreati minetest.chat_send_player(pname, "You don't have the train_operator privilege.") return itemstack end - if not minetest.check_player_privs(placer, {train_admin = true }) and minetest.is_protected(pointed_thing.under, placer:get_player_name()) then + if not minetest.check_player_privs(placer, {train_admin = true }) and minetest.is_protected(pos, placer:get_player_name()) then return itemstack end local tconns=advtrains.get_track_connections(node.name, node.param2) local yaw = placer:get_look_horizontal() local plconnid = advtrains.yawToClosestConn(yaw, tconns) - local prevpos = advtrains.get_adjacent_rail(pointed_thing.under, tconns, plconnid, prototype.drives_on) + local prevpos = advtrains.get_adjacent_rail(pos, tconns, plconnid, prototype.drives_on) if not prevpos then minetest.chat_send_player(pname, "The track you are trying to place the wagon on is not long enough!") return @@ -1424,7 +1434,7 @@ function advtrains.register_wagon(sysname_p, prototype, desc, inv_img, nincreati local wid = advtrains.create_wagon(sysname, pname) - local id=advtrains.create_new_train_at(pointed_thing.under, plconnid, 0, {wid}) + local id=advtrains.create_new_train_at(pos, plconnid, 0, {wid}) if not advtrains.is_creative(pname) then itemstack:take_item() -- cgit v1.2.3