Community
    • Login

    Very new to notepad++

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    37 Posts 3 Posters 5.0k 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.
    • John RussellJ
      John Russell
      last edited by

      Ok so @PeterJones Ive had a look through it briefly and none of them mention multiplying by a certain number. So which one am I meant to be looking at? I see adding, rounding up and one more that I can’t remember. Also with this said python script that you can point me too like in NPP can you say for it only to times the ones selected or will it do it everything in the document?

      @Alan-Kilborn Ive tried your above and it’s working great thanks is there a way for it to look for decimal points? As it’s missing ones with them out and only doing whole numbers.

      PeterJonesP 2 Replies Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @John Russell
        last edited by PeterJones

        @john-russell said in Very new to notepad++:

        Ok so @PeterJones Ive had a look through it briefly and none of them mention multiplying by a certain number. So which one am I meant to be looking at? I see adding, rounding up and one more that I can’t remember.

        Sorry. I thought I had made it obviuos in the FAQ, but it was apparently not obvious to everyone. It was my intention that users would modify the mathematical formula in the addition example to compute whatever mathematical process they wanted.

        I also realized that not everyone would know which symbols were used in Python for which math operations: in your case, the * symbol is used by many such systems to signify multiplication, so you should change the example + to the needed *. And I will also say that you might have to edit the number to multiply by, if the existing number in the source code doesn’t happen to match your exact needs.

        Also with this said python script that you can point me too like in NPP can you say for it only to times the ones selected or will it do it everything in the document?

        It will multiply every number that matches the regular expression (regex) that you feed it in the “search” field.

        @Alan-Kilborn Ive tried your above and it’s working great thanks is there a way for it to look for decimal points? As it’s missing ones with them out and only doing whole numbers.

        Every one of your examples used integers, so he reasonably assumed you wanted integers. If you want to match floating point numbers, you can see a regex for matching #.###-style floating point in the rounding example in the FAQ

        1 Reply Last reply Reply Quote 1
        • PeterJonesP
          PeterJones @John Russell
          last edited by

          @john-russell ,

          I have updated the FAQ to make it more explicit that the example addition script can be easily modified to make it do other math, like multiplication, by changing the formula. There are details in the “customization” section, including the symbols used for each operation.

          John RussellJ 3 Replies Last reply Reply Quote 2
          • John RussellJ
            John Russell @PeterJones
            last edited by

            @peterjones said in Very new to notepad++:

            @john-russell ,

            I have updated the FAQ to make it more explicit that the example addition script can be easily modified to make it do other math, like multiplication, by changing the formula. There are details in the “customization” section, including the symbols used for each operation.

            I’ll take a look when I get home. Thanks

            1 Reply Last reply Reply Quote 0
            • John RussellJ
              John Russell @PeterJones
              last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • John RussellJ
                John Russell @PeterJones
                last edited by

                @peterjones said in Very new to notepad++:

                @john-russell ,

                I have updated the FAQ to make it more explicit that the example addition script can be easily modified to make it do other math, like multiplication, by changing the formula. There are details in the “customization” section, including the symbols used for each operation.

                <_templates Include="trucks">
                	<TruckTire>
                		<Mudtires _template="Heavy">
                			<WheelTracks _template="Offroad" />
                			<WheelSoftness _template="Average" />
                			<WheelFriction _template="Mudtires" />
                		</Mudtires>
                	</TruckTire>
                </_templates>
                <TruckWheels DamageCapacity="50" Radius="1" Width="0.67">
                	<TruckTires>
                		<TruckTire _template="Mudtires" Mesh="wheels/tire_scout_btr_1" Name="offroad_btr_1">
                			<WheelFriction _template="Mudtires" BodyFriction="3.0" SubstanceFriction="8.0" />
                			<GameData
                				Price="7200"
                				UnlockByExploration="false"
                				UnlockByRank="1"
                			>
                				<UiDesc UiDesc="UI_TIRE_OFFROAD_DESC" UiName="UI_TIRE_SCOUT_BTR_1_NAME" />
                			</GameData>
                		</TruckTire>
                	</TruckTires>
                	<TruckRims>
                		<TruckRim Mesh="wheels/rim_scout_btr_1" Name="rim_1">
                			<GameData>
                				<UiDesc UiDesc="UI_RIM_SCOUT_BTR_1_DESC" UiName="UI_RIM_SCOUT_BTR_1_NAME" />
                			</GameData>
                		</TruckRim>
                	</TruckRims>
                </TruckWheels>
                

                This what I’m working on modding a game… but I want to make it more challenging but in some instances I want to be able to multiply values but also sometimes divide values. This what I have so far

                # encoding=utf-8
                from Npp import editor
                
                def add_1(m):
                    return 'Y' + str(int(m.group(1)) * 2)
                
                # replace X followed by numbers by an incremented number
                # e.g.   X56 X39 X999
                #          becomes
                #        Y57 Y40 Y1000
                
                editor.rereplace('X([0-9]+)', add_1);
                

                but that does nothing. How come I set the Key shortcut to (Ctrl+ALT+LShift+S) and nothing happens when pressed or I manually press ‘Run Script’.

                What am I doing wrong?

                Alan KilbornA 1 Reply Last reply Reply Quote 0
                • Alan KilbornA
                  Alan Kilborn @John Russell
                  last edited by

                  @john-russell said in Very new to notepad++:

                  but in some instances I want to be able to multiply values but also sometimes divide values. This what I have so far: …

                  Well what you show doesn’t do any dividing, so… I don’t think any division is going to be happening.

                  How come I set the Key shortcut to (Ctrl+ALT+LShift+S) and nothing happens when pressed or I manually press ‘Run Script’.

                  What am I doing wrong?

                  You would have to provide more detail than that for anyone to be able to diagnose.

                  John RussellJ 1 Reply Last reply Reply Quote 0
                  • John RussellJ
                    John Russell @Alan Kilborn
                    last edited by

                    @alan-kilborn said in Very new to notepad++:

                    @john-russell said in Very new to notepad++:

                    but in some instances I want to be able to multiply values but also sometimes divide values. This what I have so far: …

                    Well what you show doesn’t do any dividing, so… I don’t think any division is going to be happening.

                    How come I set the Key shortcut to (Ctrl+ALT+LShift+S) and nothing happens when pressed or I manually press ‘Run Script’.

                    What am I doing wrong?

                    You would have to provide more detail than that for anyone to be able to diagnose.

                    Yeah in the example I only show the one that i tried to get it to ‘*’ but its not working

                    Alan KilbornA 1 Reply Last reply Reply Quote 0
                    • Alan KilbornA
                      Alan Kilborn @John Russell
                      last edited by Alan Kilborn

                      @john-russell

                      From what little you show and discuss, I’d have to ask you:

                      Is the data you are looking to replace in your file this?:

                      X56

                      …or X39? or X999?

                      …or X followed by some amount of digits?

                      Because that’s what the script you show is trying to find in your data. If the script appears to do nothing, it is very likely because this type of data is not found (so the script, as shown, WILL DO nothing).

                      John RussellJ 1 Reply Last reply Reply Quote 0
                      • John RussellJ
                        John Russell @Alan Kilborn
                        last edited by PeterJones

                        @alan-kilborn said in Very new to notepad++:

                        @john-russell

                        From what little you show and discuss, I’d have to ask you:

                        Is the data you are looking to replace in your file this?:

                        X56

                        …or X39? or X999?

                        …or X followed by some amount of digits?

                        Because that’s what the script you show is trying to find in your data. If the script appears to do nothing, it is very likely because this type of data is not found (so the script, as shown, WILL DO nothing).

                        Ok so in these documents I have multiple files similar to this

                        <_templates Include="trucks">
                        	<TruckTire>
                        		<Mudtires _template="Heavy">
                        			<WheelTracks _template="Offroad" />
                        			<WheelSoftness _template="Average" />
                        			<WheelFriction _template="Mudtires" />
                        		</Mudtires>
                        	</TruckTire>
                        </_templates>
                        <TruckWheels DamageCapacity="50" Radius="1" Width="0.67">
                        	<TruckTires>
                        		<TruckTire _template="Mudtires" Mesh="wheels/tire_scout_btr_1" Name="offroad_btr_1">
                        			<WheelFriction _template="Mudtires" BodyFriction="3.0" SubstanceFriction="8.0" />
                        			<GameData
                        				Price="7200"
                        				UnlockByExploration="false"
                        				UnlockByRank="1"
                        			>
                        				<UiDesc UiDesc="UI_TIRE_OFFROAD_DESC" UiName="UI_TIRE_SCOUT_BTR_1_NAME" />
                        			</GameData>
                        		</TruckTire>
                        	</TruckTires>
                        	<TruckRims>
                        		<TruckRim Mesh="wheels/rim_scout_btr_1" Name="rim_1">
                        			<GameData>
                        				<UiDesc UiDesc="UI_RIM_SCOUT_BTR_1_DESC" UiName="UI_RIM_SCOUT_BTR_1_NAME" />
                        			</GameData>
                        		</TruckRim>
                        	</TruckRims>
                        </TruckWheels>
                        

                        and like this

                        <_templates Include="trucks">
                        	<TruckTire>
                        		<Offroad _template="Medium">
                        			<WheelTracks _template="Offroad" />
                        			<WheelSoftness _template="Average" />
                        		</Offroad>
                        	</TruckTire>
                        </_templates>
                        <TruckWheels DamageCapacity="50" Radius="1" Width="0.65">
                        	<TruckTires>
                        		<TruckTire _template="Offroad" Mesh="wheels/tire_heavy_offroad_single_1" Name="allterrain_1">
                        			<WheelFriction _template="Allterrain" />
                        			<GameData
                        				Price="3400"
                        				UnlockByExploration="false"
                        				UnlockByRank="1"
                        			>
                        				<UiDesc UiDesc="UI_TIRE_ALLTERRAIN_DESC" UiName="UI_TIRE_YAR_87_ALLTERRAIN_NAME" />
                        			</GameData>
                        		</TruckTire>
                        		<TruckTire _template="Offroad" Mesh="wheels/tire_heavy_offroad_single_2" Name="offroad_1">
                        			<WheelFriction _template="Offroad" />
                        			<GameData
                        				Price="4700"
                        				UnlockByExploration="false"
                        				UnlockByRank="1"
                        			>
                        				<UiDesc UiDesc="UI_TIRE_OFFROAD_DESC" UiName="UI_TIRE_YAR_87_OFFROAD_NAME" />
                        			</GameData>
                        		</TruckTire>
                        		<TruckTire _template="Offroad" Mesh="wheels/tire_heavy_offroad_single_3" Name="mudtires_1">
                        			<WheelFriction _template="Mudtires" />
                        			<GameData
                        				Price="4900"
                        				UnlockByExploration="false"
                        				UnlockByRank="12"
                        			>
                        				<UiDesc UiDesc="UI_TIRE_MUDTIRES_DESC" UiName="UI_TIRE_YAR_87_MUDTIRES_NAME" />
                        			</GameData>
                        		</TruckTire>
                        		<TruckTire _template="Offroad" Mesh="wheels/tire_heavy_chains_single_1" Name="chains_1">
                        			<WheelFriction _template="Chains" />
                        			<GameData
                        				Price="6000"
                        				UnlockByExploration="false"
                        				UnlockByRank="12"
                        			>
                        				<UiDesc UiDesc="UI_TIRE_CHAINS_DESC" UiName="UI_TIRE_YAR_87_CHAINS_NAME" />
                        			</GameData>
                        		</TruckTire>
                        	</TruckTires>
                        	<TruckRims>
                        		<TruckRim Mesh="wheels/rim_heavy_offroad_single_1" Name="rim_1" >
                        			<GameData>
                        				<UiDesc UiDesc="UI_RIM_YAR_87_1_DESC" UiName="UI_RIM_YAR_87_1_NAME" />
                        			</GameData>
                        		</TruckRim>
                        		<TruckRim Mesh="wheels/rim_heavy_offroad_single_2" Name="rim_2" >
                        			<GameData>
                        				<UiDesc UiDesc="UI_RIM_YAR_87_2_DESC" UiName="UI_RIM_YAR_87_2_NAME" />
                        			</GameData>
                        		</TruckRim>
                        	</TruckRims>
                        </TruckWheels>
                        

                        Etc etc but across all files they are certain values/phrase that are worded the exact same in all files but just with different numerical values for eg.

                        DamageCapacity="50"
                        
                        Price="3400"
                        
                        UnlockByRank="12"
                        
                        Torque="30000"
                        
                        FuelConsumption="0.6"
                        
                        EngineResponsiveness="0.04"
                        

                        There’s more that a similar but these are just a few examples to get you to build a picture.

                        So to make things more of a challenge in game I was thinking of dividing all Torque="30000" by say ‘1.05’ across all entries torque relates to the vehicles power in game so making this less by dividing will make the game more of a challenge because the vehicles will struggle to get through mud or up hills or pulling heavier loads etc

                        Same goes for maybe ‘X’ by ‘2.5’ for all Price="1500" values to make them hard to buy etc

                        Hope this explains it in better detail of what I’m wanting to achieve but I need it so it only does it for what is selected not for every single value in the all open files

                        Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote 0
                        • Alan KilbornA
                          Alan Kilborn @John Russell
                          last edited by

                          @john-russell said in Very new to notepad++:

                          There’s more that a similar but these are just a few examples to get you to build a picture.

                          Oh, we know what you want, but you are the one that has to take what you’ve been given and extrapolate that to your situation(s).

                          but I need it so it only does it for what is selected

                          This is a new requirement. So, you might have this:

                          b89b1fd4-5a00-4b14-a30c-bc98467de53b-image.png

                          and because you only have a limited selection, when running the script you’d only want the selected values to be changed, maybe to result in:

                          e2643d00-0c6c-4008-ac12-a658e17fcaa2-image.png

                          For that to happen, the rereplace line in the script would have to be expanded, somewhat like this:

                          editor.rereplace(___, ___, 0, editor.getSelectionStart(), editor.getSelectionEnd())

                          where the ___ is your find and replace expressions.

                          The key new part of this is specifying the range over which the replacement is to take place.

                          not for every single value in the all open files

                          Well the scripting that has been provided will not work over all open files anyway, only the file that is currently being edited.

                          John RussellJ 2 Replies Last reply Reply Quote 2
                          • John RussellJ
                            John Russell @Alan Kilborn
                            last edited by

                            This post is deleted!
                            1 Reply Last reply Reply Quote 0
                            • John RussellJ
                              John Russell @Alan Kilborn
                              last edited by

                              @alan-kilborn said in Very new to notepad++:

                              @john-russell said in Very new to notepad++:

                              There’s more that a similar but these are just a few examples to get you to build a picture.

                              Oh, we know what you want, but you are the one that has to take what you’ve been given and extrapolate that to your situation(s).

                              but I need it so it only does it for what is selected

                              This is a new requirement. So, you might have this:

                              b89b1fd4-5a00-4b14-a30c-bc98467de53b-image.png

                              and because you only have a limited selection, when running the script you’d only want the selected values to be changed, maybe to result in:

                              e2643d00-0c6c-4008-ac12-a658e17fcaa2-image.png

                              For that to happen, the rereplace line in the script would have to be expanded, somewhat like this:

                              editor.rereplace(___, ___, 0, editor.getSelectionStart(), editor.getSelectionEnd())

                              where the ___ is your find and replace expressions.

                              The key new part of this is specifying the range over which the replacement is to take place.

                              not for every single value in the all open files

                              Well the scripting that has been provided will not work over all open files anyway, only the file that is currently being edited.

                              Ok so with this I have one of the pages/files I want to edit

                              	<Winch
                              		Name="w_any_default"
                              		Length="14"
                              		StrengthMult="1"
                              		IsEngineIgnitionRequired="true"
                              	>
                              		<GameData
                              			Price="0"
                              			UnlockByExploration="false"
                              			UnlockByRank="1"
                              		>
                              			<WinchParams
                              			/>
                              			<UiDesc
                              				UiDesc="UI_WINCH_UPGRADE_DEFAULT_DESC"
                              				UiIcon30x30=""
                              				UiIcon40x40=""
                              				UiName="UI_WINCH_UPGRADE_DEFAULT_NAME"
                              			/>
                              		</GameData>
                              	</Winch>
                              

                              Inbetween the <Winch and the </Winch> I highlight everything and press my hotkey/keyboard shortcut and then the magic happens it times or divides by said number but that is not happening

                              where the `___` is your find and replace expressions. I don’t want too or have too type stuff in there I want to literally just highlight the text I need and for it to work press the relevant hotkey to either times the number by ‘X’ amount or to divided the number by ‘X’ amount.

                              Does this better explain it or is this simply not possible?

                              Alan KilbornA 1 Reply Last reply Reply Quote 0
                              • PeterJonesP
                                PeterJones @John Russell
                                last edited by PeterJones

                                @john-russell ,

                                You are expected to modify what the script searches for, and what the script replaces, so that it will give you the results necessary. We are not a free custom data manipulation outsource facility.

                                The example script shown in the FAQ is only an example, not a customized script for your specific situation. The intention is that users will modify the script in the FAQ to search for the text they want to match, and to output the text they want to replace it with.

                                For your level of skill, I would suggest doing things in multiple passes, one for each attribute that you want to change. I will show you an example of how to manipulate it for one – your DamageCapacity="50" and similar (ie, any that are attribute of DamageCapacity with an arbitrary number inside the quotes). The process that you need to go through:

                                1. Ask yourself, “what am I searching for?”:
                                  • ANSWER = “I want DamageCapacity followed by equals sign, with a number in quotes”.
                                2. Ask yourself, “how do I translate that into a regular expression?”
                                  • ANSWER = DamageCapacity="(\d*\.?\d+)"
                                  • Note: I used the floating point definition of a number, as derived from the other example I pointed you to earlier, so that way you can use nearly the same answer for all your future versions that you will have to do on your own
                                3. Put this in the editor.rereplace line in the script, remembering that I specifically said that if you have backslashes in the expression, you need to use r'...' instead of just '...':
                                  • ANSWER = editor.rereplace(r'DamageCapacity="(\d*\.?\d+)"', add_1)
                                4. Ask yourself, “what mathy replacement do I want to replace the match with?”
                                  • ANSWER = “I want to multiply all the damage capacity values by 2”
                                5. As per the FAQ, rename your sub if you aren’t actually going to be adding 1:
                                  • a good name for multiplying by two would be multiply_by_2
                                  • You need to change every place in the script where it used to say add_1 to now say the new name
                                  • CHANGE1: change def add_1(m): to def multiply_by_2(m):
                                  • CHANGE2: change editor.rereplace(r'DamageCapacity="(\d*\.?\d+)"', add_1) to editor.rereplace(r'DamageCapacity="(\d*\.?\d+)"', multiply_by_2)
                                6. Ask yourself “what string do I want instead of DamageCapacity="xxx"?”
                                  • ANSWER = "I want DamageCapacity="yyy" where yyy is 2*xxx
                                7. Per the FAQ, you need to build that into the return expression.
                                  • You currently have return 'Y' + str(int(m.group(1)) * 2) – this will return the letter Y followed by 2 times the value. This is obviously not what you want.
                                  • Change that return line to the following, so that it will be DamageCapacity=" followed by the number followed by " – so it should be
                                      return 'DamageCapacity="' + str(int(m.group(1)) * 2) + '"'
                                  
                                8. Save your changes to the script.
                                9. Read over your script. Make sure it makes sense for what you are trying to do
                                  # encoding=utf-8
                                  from Npp import editor
                                  
                                  def multiply_by_2(m):
                                      return 'DamageCapacity="' + str(int(m.group(1)) * 2) + '"'
                                  
                                  editor.rereplace(r'DamageCapacity="(\d*\.?\d+)"', multiply_by_2)
                                  
                                  • Looks good to me
                                10. Open the file you want to change the DamageCapacity on. Run this script on that file, then save that file.
                                11. If there are more files where you want to double the DamageCapacity, do all of those.

                                Now, repeat that 11-step process for doubling the Price="xxxx" type lines (or, if you want to do 2.5, then use 2.5 in the appropriate location). Then repeat for the UnlockByRank math. Then repeat for the division of Torque values by 1.05. Then repeat for …

                                You have to customize the script each time to pick the right phrase from the file and to perform the right multiplication or division.

                                BTW: before you whine that doing those 11 steps separately for each individual parameter is a lot of work, remember: you would have to do a similar process in any text-editor-with-scripting you chose, not just Notepad++. You have asked for a complicated task. What you have really described is a brand new application which finds all the different attributes in a family of files, and applies the same scaling to each instance of that attribute across all the files – that’s a rather custom application, and writing a custom application to meet all your goals could take a professional software contractor a week or two to write it in a nice GUI would cost you an arm and a leg, and is not worth the prices since you’re just customizing game files of some sort. So the fact that you’ve been given this workaround for free, even though it requires thought and effort and repetition on your part, is still an awesome deal.

                                ----

                                Addendum: this reply was done before Alan had highlighed that you also want to do this only within a certain range of selected text in the file. Wow, you are making this hard on everybody. Follow his instructions on that part. And remember, Notepad++ is a text editor; even Notepad++ together with PythonScript plugin isn’t a custom game-parameter-editing-suite, with all the builtin tools to make it simple to scale specific parameters in very narrow regions of a plethora of files. And good luck

                                John RussellJ 1 Reply Last reply Reply Quote 3
                                • Alan KilbornA
                                  Alan Kilborn @John Russell
                                  last edited by Alan Kilborn

                                  @john-russell said in Very new to notepad++:

                                  Inbetween the <Winch and the </Winch> I highlight everything

                                  I don’t want too or have too type stuff in there I want to literally just highlight the text I need and for it to work

                                  First, by “highlight” you mean “select” the text.

                                  Second, you can’t have it both ways, as there is only one possible selection when the script is run, you either have the text range you want to operate over selected OR you have a keyword (e.g. Torque) to operate on selected.

                                  press the relevant hotkey to either times the number by ‘X’ amount or to divided the number by ‘X’ amount

                                  How is it supposed to know which (multiply / divide) you want?
                                  I guess in this instance you get somewhat lucky because you can always multiply – and if you want divide you can just multiply by 1 over your number.

                                  And how is it supposed to know if you want to multiply by 2 or by 7 or whatever?

                                  You seem to want a lot (which is OK), but you want it to happen almost automagically (which is OK to want, but…).

                                  You probably need to invest some time in learning programming, then script programming specifically for Notepad++, if you want these types of solutions.

                                  1 Reply Last reply Reply Quote 1
                                  • John RussellJ
                                    John Russell @PeterJones
                                    last edited by

                                    @peterjones said in Very new to notepad++:

                                    @john-russell ,

                                    You are expected to modify what the script searches for, and what the script replaces, so that it will give you the results necessary. We are not a free custom data manipulation outsource facility.

                                    The example script shown in the FAQ is only an example, not a customized script for your specific situation. The intention is that users will modify the script in the FAQ to search for the text they want to match, and to output the text they want to replace it with.

                                    For your level of skill, I would suggest doing things in multiple passes, one for each attribute that you want to change. I will show you an example of how to manipulate it for one – your DamageCapacity="50" and similar (ie, any that are attribute of DamageCapacity with an arbitrary number inside the quotes). The process that you need to go through:

                                    1. Ask yourself, “what am I searching for?”:
                                      • ANSWER = “I want DamageCapacity followed by equals sign, with a number in quotes”.
                                    2. Ask yourself, “how do I translate that into a regular expression?”
                                      • ANSWER = DamageCapacity="(\d*\.?\d+)"
                                      • Note: I used the floating point definition of a number, as derived from the other example I pointed you to earlier, so that way you can use nearly the same answer for all your future versions that you will have to do on your own
                                    3. Put this in the editor.rereplace line in the script, remembering that I specifically said that if you have backslashes in the expression, you need to use r'...' instead of just '...':
                                      • ANSWER = editor.rereplace(r'DamageCapacity="(\d*\.?\d+)"', add_1)
                                    4. Ask yourself, “what mathy replacement do I want to replace the match with?”
                                      • ANSWER = “I want to multiply all the damage capacity values by 2”
                                    5. As per the FAQ, rename your sub if you aren’t actually going to be adding 1:
                                      • a good name for multiplying by two would be multiply_by_2
                                      • You need to change every place in the script where it used to say add_1 to now say the new name
                                      • CHANGE1: change def add_1(m): to def multiply_by_2(m):
                                      • CHANGE2: change editor.rereplace(r'DamageCapacity="(\d*\.?\d+)"', add_1) to editor.rereplace(r'DamageCapacity="(\d*\.?\d+)"', multiply_by_2)
                                    6. Ask yourself “what string do I want instead of DamageCapacity="xxx"?”
                                      • ANSWER = "I want DamageCapacity="yyy" where yyy is 2*xxx
                                    7. Per the FAQ, you need to build that into the return expression.
                                      • You currently have return 'Y' + str(int(m.group(1)) * 2) – this will return the letter Y followed by 2 times the value. This is obviously not what you want.
                                      • Change that return line to the following, so that it will be DamageCapacity=" followed by the number followed by " – so it should be return 'DamageCapacity="' + str(int(m.group(1)) * 2) + '"'
                                    8. Save your changes to the script.
                                    9. Read over your script. Make sure it makes sense for what you are trying to do
                                      # encoding=utf-8
                                      from Npp import editor
                                      
                                      def multiply_by_2(m):
                                          return 'DamageCapacity="' + str(int(m.group(1)) * 2) + '"'
                                      
                                      editor.rereplace(r'DamageCapacity="(\d*\.?\d+)"', multiply_by_2)
                                      
                                      • Looks good to me
                                    10. Open the file you want to change the DamageCapacity on. Run this script on that file, then save that file.
                                    11. If there are more files where you want to double the DamageCapacity, do all of those.

                                    Now, repeat that 11-step process for doubling the Price="xxxx" type lines (or, if you want to do 2.5, then use 2.5 in the appropriate location). Then repeat for the UnlockByRank math. Then repeat for the division of Torque values by 1.05. Then repeat for …

                                    You have to customize the script each time to pick the right phrase from the file and to perform the right multiplication or division.

                                    BTW: before you whine that doing those 11 steps separately for each individual parameter is a lot of work, remember: you would have to do a similar process in any text-editor-with-scripting you chose, not just Notepad++. You have asked for a complicated task. What you have really described is a brand new application which finds all the different attributes in a family of files, and applies the same scaling to each instance of that attribute across all the files – that’s a rather custom application, and writing a custom application to meet all your goals could take a professional software contractor a week or two to write it in a nice GUI would cost you an arm and a leg, and is not worth the prices since you’re just customizing game files of some sort. So the fact that you’ve been given this workaround for free, even though it requires thought and effort and repetition on your part, is still an awesome deal.

                                    ----

                                    Addendum: this reply was done before Alan had highlighed that you also want to do this only within a certain range of selected text in the file. Wow, you are making this hard on everybody. Follow his instructions on that part. And remember, Notepad++ is a text editor; even Notepad++ together with PythonScript plugin isn’t a custom game-parameter-editing-suite, with all the builtin tools to make it simple to scale specific parameters in very narrow regions of a plethora of files. And good luck

                                    I seen someone manually modding all these values for the game in choice (Snowrunner) on YouTube on Friday and decided to find the program he used which was Notepad++ and Cheat engine 7.2 i decided instantly cheat engine wasn’t what I was looking for so looked at downloading Notepad++.
                                    But as everyone when they first start we are complete newbies. So when I see like "(\d*\.?\d+)"' I’m like erm “English please” I don’t understand what this does.
                                    But thanks for your help and I complete understand that you could charge for stuff like you can with anything that invest time

                                    Anyway that made me think is there a way to do this easier than having to go through all files individually 9000+ with between 350 - 6800 letters in each of them and that’s when I remembered seeing him talk about Python and how it makes it easier in terms of memory hacking so I decided to ask here if it what i wanted to achieve was possible and got told about Python plugin

                                    Thanks again I don’t mean to come across ungrateful or anything I just don’t have any idea of how to start. I appreciate your efforts and that goes for everyone that has replied

                                    Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote 1
                                    • Alan KilbornA
                                      Alan Kilborn @John Russell
                                      last edited by

                                      @john-russell said in Very new to notepad++:

                                      So when I see like “(\d*.?\d+)”’ I’m like erm “English please” I don’t understand what this does.

                                      This is why I linked you to the regular expression documentation in my first reply in this thread.

                                      Maybe now with ALL the background provided, there’s a good starting point for putting together a bit more of a demo – I’ll try to do this, and perhaps it will give you a better start.

                                      Alan KilbornA 1 Reply Last reply Reply Quote 1
                                      • PeterJonesP
                                        PeterJones @John Russell
                                        last edited by

                                        @john-russell ,

                                        Is what you want possible in Notepad++ & PythonScript plugin together? Yes

                                        By @John-Russell? At this moment in time? No. After a day or two of asking us questions here? Not likely. After a few weeks or months of learning regular expressions (so that you understand (\d*\.?\d+)) and Python (so that you can figure out how to customize the simple example scripts to do something really complicated): maybe; I don’t know how quickly you learn.

                                        And honestly, what I think you’re trying to do would be faster with just writing a command-line program for Python – for which you would still have to learn Python, because this isn’t the forum for asking generic Python questions or for having us write you custom Python applications for free – or in some other language if you already know a programming language (I would personally write it in Perl if I were doing it for myself).

                                        Since you’ve got 9000+ files that you want to edit, that’s not really the kind of thing that you want to invoke a text editor to do: text editors are made for editing one file at a time, or a few files at a time. If you’ve got a change that goes across hundreds or thousands of files, text editor isn’t the right choice. You could do it in PythonScript plugin in Notepad++, and the plugin would loop through the files, individually opening them, performing the changes, and then exiting – assuming that you don’t really need to highlight text in each file before doing the replacement.

                                        But the situation I think you really have:

                                        1. You have a list of parameters you would like to change: DamageCapacity, Price, UnlockByRank, Torque, FuelConsumption, EngineResponsiveness, and so on.
                                        2. You have a mental list of scaling factors (2x, divide-by-1.05, 2.5x, etc) that you have a mental map of that scaling factor to the parameter
                                        3. You have a list of 9000+ files (hopefully all in the same directory or hierarchy, and hopefully all with a common file extension) that you want to perform the edits on
                                        4. You have unclear-to-me-requirements: on how many changes in each file:
                                          • Maybe you want to scale every instance of DamageCapacity in every file it’s listed in by the same amount. If so, that’s actually relatively easy.
                                          • Maybe there are multiple of each parameter in each file, but you only want to do the math in a certain section, and that section is the same in every file. For example, maybe only in <Winch> in every file, so you change any DamageCapacity and Torque and … in every <Winch>, but not in any other <PowerDrill> or <SuperTank> objects. If so, that’s a little more complicated, but still doable.
                                          • If it’s any more complicated than that, you need to find an already purpose-built application to handle the complicated logic.

                                        But we’ve given you a start in Notepad++ & PythonScript, and shown you how to do it on individual chunks to get started. If you want to make a more general-purpose solution, you are going to have to start putting in the effort to learn regular expressions and a programming language like Python. This Forum is not the place for learning either of those. (We help with quick regex in Notepad++, but we cannot handhold you through the entire process. And we will help with the Notepad+±related portions of PythonScript – how the PythonScript plugin interacts with the Notepad++ editor – but generic Python questsions don’t belong here.)

                                        John RussellJ 1 Reply Last reply Reply Quote 1
                                        • John RussellJ
                                          John Russell @PeterJones
                                          last edited by

                                          Ok so @Alan-Kilborn @PeterJones when I run the script for this

                                          def multiply_by_2(m):
                                              return 'Torque="' + str(int(m.group(1)) * 2) + '"'
                                          
                                          editor.rereplace(r'Torque="(\d*\.?\d*.\d+)"', multiply_by_2)
                                          

                                          and say the Torque Value=70000 I press my hot key and everything is good value then turns to Torque Value=140000 I then come to the next segment in the file which for example is EngineResponsiveness=0.35 I press my hot key and nothing happens??

                                          Yesterday when I got help for howManyblueitems=\d+ I found that it did the same it worked for everything unless the value had a decimal point. So with a bit of tinkering well basically - I just randomly added .\d+ so the code looked like this howManyblueitems=\d+.\d+ and it worked and replaced the ones with decimals as well.

                                          So I’ve tried the same logic with editor.rereplace(r'Torque="(\d*\.?\d+.\d+)"', multiply_by_2) but it doesn’t work.

                                          How come?

                                          Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote 0
                                          • Alan KilbornA
                                            Alan Kilborn @John Russell
                                            last edited by

                                            @john-russell

                                            Are you seriously expecting a search term containing Torque= to match something containing EngineResponsiveness= ?

                                            We are willing to go the extra mile in assisting, but we expect more thinking on the asking end.

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