Community
    • Login

    Search and Replace Value on a Table (LUA)

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 860 Views 1 Watching
    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 Offline
      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 Offline
        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 Offline
          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 Offline
            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

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors