Community
    • Login

    Mass Replace while dividing the value

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    23 Posts 3 Posters 2.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.
    • Terry RT
      Terry R @Caddy D
      last edited by

      @Caddy-D said in Mass Replace while dividing the value:

      I would like to divide all the numbers found in between <max_hp> </max_hp> in my XML file by 2
      how can I do that? thank you

      This question was asked recently, within the last 6 months I think. The solution was to use a “transform” plugin, it might be related to XML as well. Unfortunately I can’t seem to find that post currently. You could try to search yourself, you might get lucky. Regular expressions won’t help so it’s either a plugin or another (external) tool you’ll need to look for.

      Terry

      Terry RT 1 Reply Last reply Reply Quote 0
      • Terry RT
        Terry R @Terry R
        last edited by

        @Terry-R said in Mass Replace while dividing the value:

        This question was asked recently, within the last 6 months I think.

        The only relevant post I’ve found so far is in our FAQ section here.

        Terry

        1 Reply Last reply Reply Quote 0
        • Caddy DC
          Caddy D
          last edited by

          I was looking at this: example
          similar issue just a different format. My regex skills are a beginner at best, maybe someone can shed light on this for me

          EkopalypseE 1 Reply Last reply Reply Quote 0
          • EkopalypseE
            Ekopalypse @Caddy D
            last edited by Ekopalypse

            @Caddy-D

            the post you linked to uses the xml module, isn’t this an option?

            import xml.etree.ElementTree as ET
            
            root = ET.XML(editor.getText())
            
            for max_hp in root.findall(".//max_hp"):
                if max_hp is not None:
                    value = float(max_hp.text.strip()) * 0.5
                    max_hp.text = "{:.1f}".format(value)
            
            editor.setText(ET.tostring(root))
            

            Concerning your regular expression, you seem to look for <max_hp>"WHATEVER_NUMBER" whereas your example shows <max_hp>158</max_hp> (no quotes)

            Caddy DC 2 Replies Last reply Reply Quote 0
            • Caddy DC
              Caddy D @Ekopalypse
              last edited by

              @Ekopalypse ty for your answer, there are different values for <max_hp> in that file. That’s why I look for “Whatever_number”.

              1 Reply Last reply Reply Quote 0
              • Caddy DC
                Caddy D @Ekopalypse
                last edited by

                @Ekopalypse running your script gives me this error in the Python Console:

                Traceback (most recent call last):
                  File "C:\Program Files\Notepad++\plugins\PythonScript\scripts\calculate3.py", line 4, in <module>
                    root = ET.XML(editor.getText())
                  File "C:\Program Files\Notepad++\plugins\PythonScript\lib\xml\etree\ElementTree.py", line 1310, in XML
                    parser = XMLParser(target=TreeBuilder())
                  File "C:\Program Files\Notepad++\plugins\PythonScript\lib\xml\etree\ElementTree.py", line 1482, in __init__
                    "No module named expat; use SimpleXMLTreeBuilder instead"
                ImportError: No module named expat; use SimpleXMLTreeBuilder instead
                

                I have PythonScript 2.0.0.0 and XML Tools 3.1.1.13 installed
                Any ideas?
                Ty

                EkopalypseE 2 Replies Last reply Reply Quote 0
                • EkopalypseE
                  Ekopalypse @Caddy D
                  last edited by

                  @Caddy-D

                  how did you install the python script plugin?
                  Via plugin admin?

                  Caddy DC 1 Reply Last reply Reply Quote 0
                  • EkopalypseE
                    Ekopalypse @Caddy D
                    last edited by

                    @Caddy-D

                    The error points to a missing expat library, which afaik is part of Python’s standard library.

                    I just tried it with a fresh portable and PS2.0.0, seems to work.

                    aac7f037-94c2-467a-9918-5fd425155ce7-image.png

                    1 Reply Last reply Reply Quote 0
                    • Caddy DC
                      Caddy D @Ekopalypse
                      last edited by

                      @Ekopalypse I download it from here: https://github.com/bruderstein/PythonScript/releases “PythonScript_2.0.0.0_x64.msi”
                      I will try to remove it and install it from the plugin admin

                      1 Reply Last reply Reply Quote 1
                      • Caddy DC
                        Caddy D
                        last edited by

                        how can I remove the .0 after the value? thank you

                        EkopalypseE 1 Reply Last reply Reply Quote 0
                        • EkopalypseE
                          Ekopalypse @Caddy D
                          last edited by

                          @Caddy-D

                          replace max_hp.text = "{:.1f}".format(value) with max_hp.text = "{}".format(int(value))

                          Caddy DC 1 Reply Last reply Reply Quote 0
                          • Caddy DC
                            Caddy D @Ekopalypse
                            last edited by

                            @Ekopalypse ty, I reinstalled the Python Module by using Notepad++ Plugin Admin, and now I get this new error:

                            Traceback (most recent call last):
                              File "C:\Program Files\Notepad++\plugins\PythonScript\scripts\Tests\calculate3.py", line 4, in <module>
                                root = ET.XML(editor.getText())
                              File "C:\Program Files\Notepad++\plugins\PythonScript\lib\xml\etree\ElementTree.py", line 1311, in XML
                                parser.feed(text)
                              File "C:\Program Files\Notepad++\plugins\PythonScript\lib\xml\etree\ElementTree.py", line 1659, in feed
                                self._raiseerror(v)
                              File "C:\Program Files\Notepad++\plugins\PythonScript\lib\xml\etree\ElementTree.py", line 1523, in _raiseerror
                                raise err
                            xml.etree.ElementTree.ParseError: encoding specified in XML declaration is incorrect: line 1, column 30
                            
                            EkopalypseE 1 Reply Last reply Reply Quote 0
                            • EkopalypseE
                              Ekopalypse @Caddy D
                              last edited by

                              @Caddy-D

                              looks like your xml encoding data is incorrect. Can you post the xml data? If not, only the first few lines?

                              Caddy DC 1 Reply Last reply Reply Quote 0
                              • Caddy DC
                                Caddy D @Ekopalypse
                                last edited by

                                @Ekopalypse it’s a huge file of 154 MB, I will post a bit of it

                                <?xml version="1.0" encoding="UTF-16" ?>
                                <!DOCTYPE strings [
                                	<!ENTITY quot "quot">
                                	<!ENTITY amp "amp">
                                	<!ENTITY apos "apos">
                                	<!ENTITY lt "lt">
                                	<!ENTITY gt "gt">
                                	<!ENTITY nbsp "nbsp">
                                	<!ENTITY iexcl "iexcl">
                                	<!ENTITY cent "cent">
                                	<!ENTITY pound "pound">
                                	<!ENTITY curren "curren">
                                	<!ENTITY yen "yen">
                                	<!ENTITY brvbar "brvbar">
                                	<!ENTITY sect "sect">
                                	<!ENTITY uml "uml">
                                	<!ENTITY copy "copy">
                                	<!ENTITY ordf "ordf">
                                	<!ENTITY laquo "laquo">
                                	<!ENTITY not "not">
                                	<!ENTITY shy "shy">
                                	<!ENTITY reg "reg">
                                	<!ENTITY macr "macr">
                                	<!ENTITY deg "deg">
                                	<!ENTITY plusmn "plusmn">
                                	<!ENTITY sup2 "sup2">
                                	<!ENTITY sup3 "sup3">
                                	<!ENTITY acute "acute">
                                	<!ENTITY micro "micro">
                                	<!ENTITY para "para">
                                	<!ENTITY middot "middot">
                                	<!ENTITY cedil "cedil">
                                	<!ENTITY sup1 "sup1">
                                	<!ENTITY ordm "ordm">
                                	<!ENTITY raquo "raquo">
                                	<!ENTITY frac14 "frac14">
                                	<!ENTITY frac12 "frac12">
                                	<!ENTITY frac34 "frac34">
                                	<!ENTITY iquest "iquest">
                                	<!ENTITY Agrave "Agrave">
                                	<!ENTITY Aacute "Aacute">
                                	<!ENTITY Acirc "Acirc">
                                	<!ENTITY Atilde "Atilde">
                                	<!ENTITY Auml "Auml">
                                	<!ENTITY Aring "Aring">
                                	<!ENTITY AElig "AElig">
                                	<!ENTITY Ccedil "Ccedil">
                                	<!ENTITY Egrave "Egrave">
                                	<!ENTITY Eacute "Eacute">
                                	<!ENTITY Ecirc "Ecirc">
                                	<!ENTITY Euml "Euml">
                                	<!ENTITY Igrave "Igrave">
                                	<!ENTITY Iacute "Iacute">
                                	<!ENTITY Icirc "Icirc">
                                	<!ENTITY Iuml "Iuml">
                                	<!ENTITY ETH "ETH">
                                	<!ENTITY Ntilde "Ntilde">
                                	<!ENTITY Ograve "Ograve">
                                	<!ENTITY Oacute "Oacute">
                                	<!ENTITY Ocirc "Ocirc">
                                	<!ENTITY Otilde "Otilde">
                                	<!ENTITY Ouml "Ouml">
                                	<!ENTITY times "times">
                                	<!ENTITY Oslash "Oslash">
                                	<!ENTITY Ugrave "Ugrave">
                                	<!ENTITY Uacute "Uacute">
                                	<!ENTITY Ucirc "Ucirc">
                                	<!ENTITY Uuml "Uuml">
                                	<!ENTITY Yacute "Yacute">
                                	<!ENTITY THORN "THORN">
                                	<!ENTITY szlig "szlig">
                                	<!ENTITY agrave "agrave">
                                	<!ENTITY aacute "aacute">
                                	<!ENTITY acirc "acirc">
                                	<!ENTITY atilde "atilde">
                                	<!ENTITY auml "auml">
                                	<!ENTITY aring "aring">
                                	<!ENTITY aelig "aelig">
                                	<!ENTITY ccedil "ccedil">
                                	<!ENTITY egrave "egrave">
                                	<!ENTITY eacute "eacute">
                                	<!ENTITY ecirc "ecirc">
                                	<!ENTITY euml "euml">
                                	<!ENTITY igrave "igrave">
                                	<!ENTITY iacute "iacute">
                                	<!ENTITY icirc "icirc">
                                	<!ENTITY iuml "iuml">
                                	<!ENTITY eth "eth">
                                	<!ENTITY ntilde "ntilde">
                                	<!ENTITY ograve "ograve">
                                	<!ENTITY oacute "oacute">
                                	<!ENTITY ocirc "ocirc">
                                	<!ENTITY otilde "otilde">
                                	<!ENTITY ouml "ouml">
                                	<!ENTITY divide "divide">
                                	<!ENTITY oslash "oslash">
                                	<!ENTITY ugrave "ugrave">
                                	<!ENTITY uacute "uacute">
                                	<!ENTITY ucirc "ucirc">
                                	<!ENTITY uuml "uuml">
                                	<!ENTITY yacute "yacute">
                                	<!ENTITY thorn "thorn">
                                	<!ENTITY yuml "yuml">
                                	<!ENTITY OElig "OElig">
                                	<!ENTITY oelig "oelig">
                                	<!ENTITY Scaron "Scaron">
                                	<!ENTITY scaron "scaron">
                                	<!ENTITY Yuml "Yuml">
                                	<!ENTITY fnof "fnof">
                                	<!ENTITY circ "circ">
                                	<!ENTITY tilde "tilde">
                                	<!ENTITY Alpha "Alpha">
                                	<!ENTITY Beta "Beta">
                                	<!ENTITY Gamma "Gamma">
                                	<!ENTITY Delta "Delta">
                                	<!ENTITY Epsilon "Epsilon">
                                	<!ENTITY Zeta "Zeta">
                                	<!ENTITY Eta "Eta">
                                	<!ENTITY Theta "Theta">
                                	<!ENTITY Iota "Iota">
                                	<!ENTITY Kappa "Kappa">
                                	<!ENTITY Lambda "Lambda">
                                	<!ENTITY Mu "Mu">
                                	<!ENTITY Nu "Nu">
                                	<!ENTITY Xi "Xi">
                                	<!ENTITY Omicron "Omicron">
                                	<!ENTITY Pi "Pi">
                                	<!ENTITY Rho "Rho">
                                	<!ENTITY Sigma "Sigma">
                                	<!ENTITY Tau "Tau">
                                	<!ENTITY Upsilon "Upsilon">
                                	<!ENTITY Phi "Phi">
                                	<!ENTITY Chi "Chi">
                                	<!ENTITY Psi "Psi">
                                	<!ENTITY Omega "Omega">
                                	<!ENTITY alpha "alpha">
                                	<!ENTITY beta "beta">
                                	<!ENTITY gamma "gamma">
                                	<!ENTITY delta "delta">
                                	<!ENTITY epsilon "epsilon">
                                	<!ENTITY zeta "zeta">
                                	<!ENTITY eta "eta">
                                	<!ENTITY theta "theta">
                                	<!ENTITY iota "iota">
                                	<!ENTITY kappa "kappa">
                                	<!ENTITY lambda "lambda">
                                	<!ENTITY mu "mu">
                                	<!ENTITY nu "nu">
                                	<!ENTITY xi "xi">
                                	<!ENTITY omicron "omicron">
                                	<!ENTITY pi "pi">
                                	<!ENTITY rho "rho">
                                	<!ENTITY sigmaf "sigmaf">
                                	<!ENTITY sigma "sigma">
                                	<!ENTITY tau "tau">
                                	<!ENTITY upsilon "upsilon">
                                	<!ENTITY phi "phi">
                                	<!ENTITY chi "chi">
                                	<!ENTITY psi "psi">
                                	<!ENTITY omega "omega">
                                	<!ENTITY thetasym "thetasym">
                                	<!ENTITY upsih "upsih">
                                	<!ENTITY piv "piv">
                                	<!ENTITY ensp "ensp">
                                	<!ENTITY emsp "emsp">
                                	<!ENTITY thinsp "thinsp">
                                	<!ENTITY zwnj "zwnj">
                                	<!ENTITY zwj "zwj">
                                	<!ENTITY lrm "lrm">
                                	<!ENTITY rlm "rlm">
                                	<!ENTITY ndash "ndash">
                                	<!ENTITY mdash "mdash">
                                	<!ENTITY lsquo "lsquo">
                                	<!ENTITY rsquo "rsquo">
                                	<!ENTITY sbquo "sbquo">
                                	<!ENTITY ldquo "ldquo">
                                	<!ENTITY rdquo "rdquo">
                                	<!ENTITY bdquo "bdquo">
                                	<!ENTITY dagger "dagger">
                                	<!ENTITY Dagger "Dagger">
                                	<!ENTITY bull "bull">
                                	<!ENTITY hellip "hellip">
                                	<!ENTITY permil "permil">
                                	<!ENTITY prime "prime">
                                	<!ENTITY Prime "Prime">
                                	<!ENTITY lsaquo "lsaquo">
                                	<!ENTITY rsaquo "rsaquo">
                                	<!ENTITY oline "oline">
                                	<!ENTITY frasl "frasl">
                                	<!ENTITY euro "euro">
                                	<!ENTITY image "image">
                                	<!ENTITY weierp "weierp">
                                	<!ENTITY real "real">
                                	<!ENTITY trade "trade">
                                	<!ENTITY alefsym "alefsym">
                                	<!ENTITY larr "larr">
                                	<!ENTITY uarr "uarr">
                                	<!ENTITY rarr "rarr">
                                	<!ENTITY darr "darr">
                                	<!ENTITY harr "harr">
                                	<!ENTITY crarr "crarr">
                                	<!ENTITY lArr "lArr">
                                	<!ENTITY uArr "uArr">
                                	<!ENTITY rArr "rArr">
                                	<!ENTITY dArr "dArr">
                                	<!ENTITY hArr "hArr">
                                	<!ENTITY forall "forall">
                                	<!ENTITY part "part">
                                	<!ENTITY exist "exist">
                                	<!ENTITY empty "empty">
                                	<!ENTITY nabla "nabla">
                                	<!ENTITY isin "isin">
                                	<!ENTITY notin "notin">
                                	<!ENTITY ni "ni">
                                	<!ENTITY prod "prod">
                                	<!ENTITY sum "sum">
                                	<!ENTITY minus "minus">
                                	<!ENTITY lowast "lowast">
                                	<!ENTITY radic "radic">
                                	<!ENTITY prop "prop">
                                	<!ENTITY infin "infin">
                                	<!ENTITY ang "ang">
                                	<!ENTITY and "and">
                                	<!ENTITY or "or">
                                	<!ENTITY cap "cap">
                                	<!ENTITY cup "cup">
                                	<!ENTITY int "int">
                                	<!ENTITY there4 "there4">
                                	<!ENTITY sim "sim">
                                	<!ENTITY cong "cong">
                                	<!ENTITY asymp "asymp">
                                	<!ENTITY ne "ne">
                                	<!ENTITY equiv "equiv">
                                	<!ENTITY le "le">
                                	<!ENTITY ge "ge">
                                	<!ENTITY sub "sub">
                                	<!ENTITY sup "sup">
                                	<!ENTITY nsub "nsub">
                                	<!ENTITY sube "sube">
                                	<!ENTITY supe "supe">
                                	<!ENTITY oplus "oplus">
                                	<!ENTITY otimes "otimes">
                                	<!ENTITY perp "perp">
                                	<!ENTITY sdot "sdot">
                                	<!ENTITY lceil "lceil">
                                	<!ENTITY rceil "rceil">
                                	<!ENTITY lfloor "lfloor">
                                	<!ENTITY rfloor "rfloor">
                                	<!ENTITY lang "lang">
                                	<!ENTITY rang "rang">
                                	<!ENTITY loz "loz">
                                	<!ENTITY spades "spades">
                                	<!ENTITY clubs "clubs">
                                	<!ENTITY hearts "hearts">
                                	<!ENTITY diams "diams">
                                ]>
                                <npcs generated_time="2014/05/21 19:07:59">
                                	<npc>
                                		<id>250001</id>
                                		<name>AbProto_Ab1_Artifact_light_0</name>
                                		<desc>STR_AbProto_Ab1_Artifact_light_0</desc>
                                		<__spawn_zonename__>AbProto</__spawn_zonename__>
                                		<dir>NPC/NPC/Level_Object/artifact</dir>
                                		<mesh>artifact_light</mesh>
                                		<no_check_animation>1</no_check_animation>
                                		<bound_radius>
                                			<front>0.500000</front>
                                			<side>0.700000</side>
                                			<upper>2.000000</upper>
                                		</bound_radius>
                                		<scale>100</scale>
                                		<weapon_scale>100</weapon_scale>
                                		<altitude>0.000000</altitude>
                                		<move_speed_normal_walk>0.000000</move_speed_normal_walk>
                                		<move_speed_normal_run>0.000000</move_speed_normal_run>
                                		<move_speed_combat_run>0.000000</move_speed_combat_run>
                                		<pushed_range>0.000000</pushed_range>
                                		<dual>0</dual>
                                		<level>1</level>
                                		<exp>105</exp>
                                		<dp>100</dp>
                                		<max_hp>158</max_hp>
                                		<hpgauge_level>3</hpgauge_level>
                                		<hp_regen>79</hp_regen>
                                		<physical_attack>24</physical_attack>
                                		<physical_defend>103</physical_defend>
                                		<magical_attack>14</magical_attack>
                                		<magical_defend>0</magical_defend>
                                		<magical_resist>96</magical_resist>
                                		<min_damage>19</min_damage>
                                		<max_damage>29</max_damage>
                                		<magical_skill_boost>0</magical_skill_boost>
                                		<magical_skill_boost_resist>0</magical_skill_boost_resist>
                                		<hit_count>1</hit_count>
                                		<attack_delay>2100</attack_delay>
                                		<hit_accuracy>207</hit_accuracy>
                                		<magical_hit_accuracy>46</magical_hit_accuracy>
                                		<critical>5</critical>
                                		<magical_critical>5</magical_critical>
                                		<concentration>0</concentration>
                                		<dodge>123</dodge>
                                		<parry>0</parry>
                                		<block>0</block>
                                		<dp_reduce>0</dp_reduce>
                                		<abyss_point>14</abyss_point>
                                		<abyss_rank>1</abyss_rank>
                                		<cancel_level>100</cancel_level>
                                		<first_level_attr>
                                			<elemental_defend_light>0</elemental_defend_light>
                                			<elemental_defend_dark>0</elemental_defend_dark>
                                			<elemental_defend_earth>0</elemental_defend_earth>
                                			<elemental_defend_air>0</elemental_defend_air>
                                			<elemental_defend_water>0</elemental_defend_water>
                                			<elemental_defend_fire>0</elemental_defend_fire>
                                		</first_level_attr>
                                		<abnormal_penetrations>
                                			<data>
                                				<abnormal_penetration_value>0</abnormal_penetration_value>
                                			</data>
                                			<data>
                                				<abnormal_penetration_value>0</abnormal_penetration_value>
                                			</data>
                                			<data>
                                				<abnormal_penetration_value>0</abnormal_penetration_value>
                                			</data>
                                		</abnormal_penetrations>
                                		<first_attack_split_rate>Split_Default</first_attack_split_rate>
                                		<ai_name>NPC</ai_name>
                                		<idle_name>NoMove</idle_name>
                                		<tribe>General</tribe>
                                		<race_type>pc_light</race_type>
                                		<pet_ai_name>Pet</pet_ai_name>
                                		<max_enemy_count>10</max_enemy_count>
                                		<sensory_range>8.000000</sensory_range>
                                		<sensory_angle>360</sensory_angle>
                                		<chase_flying>1</chase_flying>
                                		<react_to_pathfind_fail>return_to_sp</react_to_pathfind_fail>
                                		<can_see_invisible>0</can_see_invisible>
                                		<can_see_polymorph>true</can_see_polymorph>
                                		<npc_type>General</npc_type>
                                		<no_penalty>1</no_penalty>
                                		<unattackable>1</unattackable>
                                		<talking_distance>5.000000</talking_distance>
                                		<abyss_npc_type>artifact</abyss_npc_type>
                                		<artifact_id>5</artifact_id>
                                		<user_animation>quest_energyblow</user_animation>
                                	</npc>
                                	<npc>
                                		<id>250002</id>
                                		<name>AbProto_Ab1_Artifact_dark_0</name>
                                		<desc>STR_AbProto_Ab1_Artifact_dark_0</desc>
                                		<__spawn_zonename__>AbProto</__spawn_zonename__>
                                		<dir>NPC/NPC/Level_Object/artifact</dir>
                                		<mesh>artifact_dark</mesh>
                                		<no_check_animation>1</no_check_animation>
                                		<bound_radius>
                                			<front>0.500000</front>
                                			<side>0.700000</side>
                                			<upper>2.000000</upper>
                                		</bound_radius>
                                		<scale>100</scale>
                                		<weapon_scale>100</weapon_scale>
                                		<altitude>0.000000</altitude>
                                		<move_speed_normal_walk>0.000000</move_speed_normal_walk>
                                		<move_speed_normal_run>0.000000</move_speed_normal_run>
                                		<move_speed_combat_run>0.000000</move_speed_combat_run>
                                		<pushed_range>0.000000</pushed_range>
                                		<dual>0</dual>
                                		<level>1</level>
                                		<exp>105</exp>
                                		<dp>100</dp>
                                		<max_hp>158</max_hp>
                                		<hpgauge_level>3</hpgauge_level>
                                		<hp_regen>79</hp_regen>
                                		<physical_attack>24</physical_attack>
                                		<physical_defend>103</physical_defend>
                                		<magical_attack>14</magical_attack>
                                		<magical_defend>0</magical_defend>
                                		<magical_resist>96</magical_resist>
                                		<min_damage>19</min_damage>
                                		<max_damage>29</max_damage>
                                		<magical_skill_boost>0</magical_skill_boost>
                                		<magical_skill_boost_resist>0</magical_skill_boost_resist>
                                		<hit_count>1</hit_count>
                                		<attack_delay>2100</attack_delay>
                                		<hit_accuracy>207</hit_accuracy>
                                		<magical_hit_accuracy>46</magical_hit_accuracy>
                                		<critical>5</critical>
                                		<magical_critical>5</magical_critical>
                                		<concentration>0</concentration>
                                		<dodge>123</dodge>
                                		<parry>0</parry>
                                		<block>0</block>
                                		<dp_reduce>0</dp_reduce>
                                		<abyss_point>14</abyss_point>
                                		<abyss_rank>1</abyss_rank>
                                		<cancel_level>100</cancel_level>
                                		<first_level_attr>
                                			<elemental_defend_light>0</elemental_defend_light>
                                			<elemental_defend_dark>0</elemental_defend_dark>
                                			<elemental_defend_earth>0</elemental_defend_earth>
                                			<elemental_defend_air>0</elemental_defend_air>
                                			<elemental_defend_water>0</elemental_defend_water>
                                			<elemental_defend_fire>0</elemental_defend_fire>
                                		</first_level_attr>
                                		<abnormal_penetrations>
                                			<data>
                                				<abnormal_penetration_value>0</abnormal_penetration_value>
                                			</data>
                                			<data>
                                				<abnormal_penetration_value>0</abnormal_penetration_value>
                                			</data>
                                			<data>
                                				<abnormal_penetration_value>0</abnormal_penetration_value>
                                			</data>
                                		</abnormal_penetrations>
                                		<first_attack_split_rate>Split_Default</first_attack_split_rate>
                                		<ai_name>NPC</ai_name>
                                		<idle_name>NoMove</idle_name>
                                		<tribe>General_Dark</tribe>
                                		<race_type>pc_dark</race_type>
                                		<pet_ai_name>Pet</pet_ai_name>
                                		<max_enemy_count>10</max_enemy_count>
                                		<sensory_range>8.000000</sensory_range>
                                		<sensory_angle>360</sensory_angle>
                                		<chase_flying>1</chase_flying>
                                		<react_to_pathfind_fail>return_to_sp</react_to_pathfind_fail>
                                		<can_see_invisible>0</can_see_invisible>
                                		<can_see_polymorph>true</can_see_polymorph>
                                		<npc_type>General</npc_type>
                                		<no_penalty>1</no_penalty>
                                		<unattackable>1</unattackable>
                                		<talking_distance>5.000000</talking_distance>
                                		<abyss_npc_type>artifact</abyss_npc_type>
                                		<artifact_id>5</artifact_id>
                                		<user_animation>quest_energyblow</user_animation>
                                	</npc>
                                
                                EkopalypseE 2 Replies Last reply Reply Quote 0
                                • EkopalypseE
                                  Ekopalypse @Caddy D
                                  last edited by

                                  @Caddy-D

                                  hmm, looks ok, can you use xml tools to verify if it really is correct?

                                  EkopalypseE 1 Reply Last reply Reply Quote 0
                                  • EkopalypseE
                                    Ekopalypse @Ekopalypse
                                    last edited by

                                    @Ekopalypse

                                    ooopppsss - PS is indeed complaining

                                    Caddy DC 1 Reply Last reply Reply Quote 0
                                    • EkopalypseE
                                      Ekopalypse @Caddy D
                                      last edited by

                                      @Caddy-D

                                      ahh - not supported by PS2 and it removes the header
                                      No, sorry, using xml module does not work in this case
                                      Back to your regex solution. Gimme a sec.

                                      1 Reply Last reply Reply Quote 0
                                      • Caddy DC
                                        Caddy D @Ekopalypse
                                        last edited by

                                        @Ekopalypse I removed the DT stuff on top of the file and still get those errors

                                        Traceback (most recent call last):
                                          File "C:\Program Files\Notepad++\plugins\PythonScript\scripts\Tests\calculate4.py", line 4, in <module>
                                            root = ET.XML(editor.getText())
                                          File "C:\Program Files\Notepad++\plugins\PythonScript\lib\xml\etree\ElementTree.py", line 1311, in XML
                                            parser.feed(text)
                                          File "C:\Program Files\Notepad++\plugins\PythonScript\lib\xml\etree\ElementTree.py", line 1659, in feed
                                            self._raiseerror(v)
                                          File "C:\Program Files\Notepad++\plugins\PythonScript\lib\xml\etree\ElementTree.py", line 1523, in _raiseerror
                                            raise err
                                        xml.etree.ElementTree.ParseError: encoding specified in XML declaration is incorrect: line 1, column 30
                                        
                                        EkopalypseE 1 Reply Last reply Reply Quote 0
                                        • EkopalypseE
                                          Ekopalypse @Caddy D
                                          last edited by Ekopalypse

                                          @Caddy-D

                                          def regexmath(m):
                                              return "{}".format(int(float(m.group())*0.5))
                                          
                                          editor.rereplace('(?<=<max_hp>)\d+\.*\d*(?=</max_hp>)', regexmath)
                                          

                                          will replace the ones without surrounded by quotes.

                                          editor.rereplace('(?<=<max_hp>")\d+\.*\d*(?="</max_hp>)', regexmath)
                                          

                                          will replace if surrounded by quotes.

                                          Caddy DC 1 Reply Last reply Reply Quote 1
                                          • Caddy DC
                                            Caddy D @Ekopalypse
                                            last edited by

                                            @Ekopalypse thank you very much kind sir, it works, have a great and amazing day

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