From 5b4f5491d26ae42419ecb036f79fa0040ce45975 Mon Sep 17 00:00:00 2001 From: Blockhead Date: Mon, 22 Mar 2021 11:00:37 +0100 Subject: Do not return early after setting station info on stop rail Solves Hemiptera#171 --- advtrains_line_automation/stoprail.lua | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'advtrains_line_automation') diff --git a/advtrains_line_automation/stoprail.lua b/advtrains_line_automation/stoprail.lua index 9c1470a..0a66eee 100644 --- a/advtrains_line_automation/stoprail.lua +++ b/advtrains_line_automation/stoprail.lua @@ -89,23 +89,20 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) tmp_checkboxes[pe].reverse = (fields.reverse == "true") end if fields.save then - if fields.stn and stdata.stn ~= fields.stn then - if fields.stn ~= "" then - local stn = advtrains.lines.stations[fields.stn] - if stn then - if (stn.owner == pname or minetest.check_player_privs(pname, "train_admin")) then - stdata.stn = fields.stn - else - minetest.chat_send_player(pname, "Station code '"..fields.stn.."' does already exist and is owned by "..stn.owner) - end - else - advtrains.lines.stations[fields.stn] = {name = fields.stnname, owner = pname} + if fields.stn and stdata.stn ~= fields.stn and fields.stn ~= "" then + local stn = advtrains.lines.stations[fields.stn] + if stn then + if (stn.owner == pname or minetest.check_player_privs(pname, "train_admin")) then stdata.stn = fields.stn + else + minetest.chat_send_player(pname, "Station code '"..fields.stn.."' does already exist and is owned by "..stn.owner) + show_stoprailform(pos,player) + return end + else + advtrains.lines.stations[fields.stn] = {name = fields.stnname, owner = pname} + stdata.stn = fields.stn end - updatemeta(pos) - show_stoprailform(pos, player) - return end local stn = advtrains.lines.stations[stdata.stn] if stn and fields.stnname and fields.stnname ~= stn.name then -- cgit v1.2.3