Community
    • Login

    Search and Replace Value on a Table (LUA)

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 539 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Mark LozadaM
      Mark Lozada
      last edited by

      Please help me on this task. I have this table in .LUA extension

      tbl = {
      	[500] = {
      		unidentifiedDisplayName = "Choco Gangjeong",
      		unidentifiedResourceName = "금광석",
      		unidentifiedDescriptionName = { "" },
      		identifiedDisplayName = "Choco Gangjeong",
      		identifiedResourceName = "금광석",
      		identifiedDescriptionName = {
      			"A snack of a piece of walnut mixed with chocolate and rounded together.",
      			"I don't know why walnut carries it.",
      			"________________________",
      			"Heals 10% HP and 10% SP.",
      			"________________________",
      			"^ff0000(The item is deleted after the event ends.)^000000",
      			"________________________",
      			"^0000CCWeight:^000000 1"
      		},
      		slotCount = 0,
      		ClassNum = 0
      	},	
      	[5453] = {
      		unidentifiedDisplayName = "Unidentified Helmet",
      		unidentifiedResourceName = "헬름",
      		unidentifiedDescriptionName = { "Can be identified by using a ^990099Magnifier^000000." },
      		identifiedDisplayName = "Copper Dragon Helm",
      		identifiedResourceName = "용투구_동",
      		identifiedDescriptionName = {
      			"A legendary helm, inspired by god of Dragon.",
      			"________________________",
      			"Decreases damage taken from ^FF0000Demi-Human^000000 race monsters by 5%.",
      			"________________________",
      			"Increases Physical Damage against ^FF0000Demi-Human^000000 race monsters by 1%.",
      			"________________________",
      			"^0000CCType:^000000 Headgear",
      			"^0000CCDefense:^000000 5",
      			"^0000CCPosition:^000000 Upper",
      			"^0000CCWeight:^000000 150",
      			"^0000CCArmor Level:^000000 1",
      			"^0000CCRefineable:^000000 No",
      			"________________________",
      			"^0000CCRequirement:^000000 None"
      		},
      		slotCount = 1,
      		ClassNum = 454
      	},	
      	[1230000] = {
      		unidentifiedDisplayName = "IDTest Ammo",
      		unidentifiedResourceName = "자르곤",
      		unidentifiedDescriptionName = { "" },
      		identifiedDisplayName = "IDTest ammo",
      		identifiedResourceName = "자르곤",
      		identifiedDescriptionName = {
      			"When equipped with ^990099IDTest Gun^000000:",
      			"DEX +1",
      			"________________________",
      			"^0000CCType:^000000 Ammo",
      			"^0000CCAttack:^000000 10",
      			"^0000CCWeight:^000000 1",
      			"^0000CCElement:^777777 Neutral"
      		},
      		slotCount = 0,
      		ClassNum = 0
      	},
      }
      

      What I need to do is search for this 2 value in a table ():
      Armor Level
      slotCount

      If the table {} has “Armor Level” then replace “slotCount = 2”
      slotCount in the table has a value varying from to 0-4

      Thank you…

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Mark Lozada
        last edited by

        @Mark-Lozada

        I presume that you want to do this within the [digits] = { … } groupings?

        1 Reply Last reply Reply Quote 0
        • guy038G
          guy038
          last edited by guy038

          Hello, @mark-lozada, @alan-kilborn and All,

          A basic regex solution could be :

          SEARCH (?s-i)(Armor Level.*?\},\s+slotCount =) [0-4]

          REPLACE \1 2

          As usual, tick the Wrap around option and select the Regular expression search mode

          Note : If this syntax is not restrictive enough, try that one :

          SEARCH (?s-i)(\^0000CCArmor Level.*?\},\s+slotCount =) [0-4]

          REPLACE \1 2

          Best Regards,

          guy038

          Mark LozadaM 1 Reply Last reply Reply Quote 1
          • Mark LozadaM
            Mark Lozada @guy038
            last edited by

            @guy038

            Thank you very much! It worked wonderful
            Thank you for your time!

            1 Reply Last reply Reply Quote 1
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors