Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    function list not working for lua script

    Help wanted · · · – – – · · ·
    3
    4
    219
    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.
    • Kesler Sullyvan
      Kesler Sullyvan last edited by

      I’ve already tried adding new code into the function .xml file, but it doesn’t seem to be working, this code btw. Even basic functions don’t show up on the list:

      function max(num1, num2)
      
         if (num1 > num2) then
            result = num1;
         else
            result = num2;
         end
      
         return result; 
      end
      
      -- calling a function
      print("The maximum of the two numbers is ",max(10,4))
      print("The maximum of the two numbers is ",max(5,6))
      

      I also already tried updating, and using portable versions, but nothing. Am I doing something wrong here?

      PeterJones 1 Reply Last reply Reply Quote 0
      • PeterJones
        PeterJones @Kesler Sullyvan last edited by

        @Kesler-Sullyvan said in function list not working for lua script:

        I also already tried updating, and using portable versions, but nothing.

        That’s because the instructions at that site were written for v7.9.0 and earlier; v7.9.1 and newer separate out each functionList configuration into a separate file.

        In your installed Notepad++, go to %AppData%\Notepad++\functionList\ folder 🛈, and copy one of the other language XML files to lua.xml. Replace the <parser ...> section with the <parser ...> from that other site: it will look like:

        <?xml version="1.0" encoding="UTF-8" ?>
        <!-- ==========================================================================\
        |
        |   To learn how to make your own language parser, please check the following
        |   link:
        |       https://npp-user-manual.org/docs/function-list/
        |
        \=========================================================================== -->
        <NotepadPlus>
            <functionList>
                <parser displayName="Lua" id="lua_function" commentExpr="--.*?$" >
                    <!-- Basic lua table view, nested lua table not supported -->
                    <classRange
                        mainExpr="[.\w]+[\s]*=[\s]*\{"
                        openSymbole="\{"
                        closeSymbole="\}"
                        displayMode="node">
                        <className>
                            <nameExpr expr="[.\w]+"/>
                        </className>
                        <function
                            mainExpr="[.\w]+[\s]*=[\s]*['&quot;]?[\w]+['&quot;]?">
                            <functionName>
                                <funcNameExpr expr=".*"/>
                            </functionName>
                        </function>
                    </classRange>
                    <!-- Basic lua functions support -->
                    <function 
                        mainExpr="(function[\s]+[.\w]+(:[\w]+)?)|([.\w]+[\s]*=[\s]*function)"
                        displayMode="$className->$functionName">
                        <functionName>
                            <nameExpr expr="((?<=function)[\s]+[.:\w]+)|(([.\w]+)(?=([\s]*=[\s]*function)))"/>
                        </functionName>
                        <className>
                            <nameExpr expr="[.\w]+(?=:)"/>
                        </className>
                    </function>
                </parser>
            </functionList>
        </NotepadPlus>
        

        Unlike the site says, you don’t need to check or change an <association> tag or edit the new overrideMap.xml, because Lua defaults to lua.xml.
        Exit Notepad++ and restart. The source code you showed will then show functions

        c290bd87-700b-4040-a04d-aa34e5ee64a4-image.png

        N 1 Reply Last reply Reply Quote 3
        • Kesler Sullyvan
          Kesler Sullyvan last edited by

          Oh wow! Thanks so much! I still don’t know what worked, but as soon as I dropped your code into the functionlist folder, it clicked. Honestly, I don’t really code at all. I messed around with bots a while ago, but nowadays I just really enjoying organizing my texts using Lua on N++. I’m glad I posted, you made my day :)

          1 Reply Last reply Reply Quote 0
          • N
            Nick M @PeterJones last edited by

            @PeterJones Your code helped me too.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Copyright © 2014 NodeBB Forums | Contributors