r/lua 48m ago

Help Can someone teach me to code stuff for PVZ Undead Adventures?

Thumbnail
Upvotes

r/lua 1h ago

Project LuaJIT Playground

Upvotes

There's websites for running Lua, but I couldn't find any that let's you run LuaJIT!!

I made this website (me, not AI) so if you haven't tried LuaJIT before, or you don't have access to your dev environment, or you just want to quickly experiment...now you can run it online, and share the script + output with others as either a link or markdown.

Pre-compiled binaries for Windows/Linux are also provided. The static library, dynamic library, and executable, are all bundled in a single convenient .zip file for each platform. I'm hoping to automate this process at some point, but for now I just publish them whenever I see there's been new commits...

https://luajit.dev

The backported extensions for LuaJIT 3.0 are available now, by the way.

  • Bit Operators: unary ~, binary & | ~ << >> ~>>
  • Customary Operators: ! && || !=
  • Ternary ?: conditional operator
  • Safe Navigation Operator ?.
  • nil-Coalescing Operator ??
  • Compound Assignment Operators: += -= *= /= %= &= |= ~= <<= = ~= ..=
  • continue Statement
  • const Declaration
  • Short Function Expression
  • Underscores in Number Literals

r/lua 2h ago

Help Trouble parsing through .txt file to find lines with specific string

0 Upvotes

I'm trying to make a program to look through a .txt file and look for any line with the word MODULE in it. So far I am not having any luck.

The file is quite large, about 7.5 million lines. And I am just dipping my toes into Lua. I was able to access the file and make a line by line copy after getting random character puke by reading and writing as binary.

I stuck a print statement immediately after the for loop and that would print ok.

But when I try and get anything to occur in the IF portion it seems to do nothing.

local path = 'C:\\filepathgoeshere'    
--create file path


local file = io.open(path, "rb")--open file in path


if file then                    --if the file is found, read and create PID file
    local outputfile = io.open('CHA_PID.txt', 'w+b')
    if not outputfile then      --if the output file cannot be created, close input and return
        file:close()
        print("Error: Could not create output file CHA_PID.txt")
        return
        
    else
        for line in file:lines() do
            if string.find(line, 'MODULE') then
                --outputfile:write(line .. "\n")
                print('FOUND ONE!\n')
                --outputfile:write('FOUND ONE!\n')
                return
            end
        end
    end


    outputfile:close()
    file:close()
    return


else                         --if file not found, print error message and return
    print('Error: Could not open file at path: ' .. path)
    return


end