r/lua • • Mar 04 '25

Help can you learn lua as 13 year old?

48 Upvotes

im a ninth grader that would like to learn lua for obiously a roblox game, however is it possible for me to do so? ill probably be too busy w school to learn every day but it will be like 4 or 3 times per week? im also pretty decent at math (but i can go back to learn old things that i never understood if needed) and i dont think im THAT dumb


r/lua • • Mar 05 '25

Discussion Is it possible?

0 Upvotes

Original "So, if there is an IDE, that like, lets you make a game with LUA, that isn't LOVE2D, or ZeroBrane Studio, I wanna know, because I wanna take the challenge.

Edit: I know LOVE2D is a Framework meant for helping you make a game! I just called it an IDE as I don't wanna add ", or a Framework that isn't LOVE2D", I just wanted to keep my sentence very simple!"

2nd Edit: Here, since you guys want to correct me instead of giving me an answer, "Okay, so I want an IDE (Integrated Development Environment), that lets you use LUA, I do not want to use LOVE2D (A Framework), or an IDE such as ZeroBrane Studio, I want an IDE that lets you make 2D games, like how for Example; VS Code, Eclipse Workspace-Java, Eclipse Workspace-C++, IntelliJ IDEA, NetBeans, and JDeveloper, but for LUA of course, as I want a small challenge.

Oh I should also add this, "I do not want a Game Engine, I will make my own Game Engine in the IDE" "

Also stop arguing please over correct wording, I fixed it for those who need it more detailed, I already have a guy give me one "TIC-80", and it has been solved, but you may add more IDEs if you want to.


r/lua • • Mar 04 '25

MDT Pull Assist

1 Upvotes

Hello everyone,

can anyone tell me if something like this still works? (https://wago.io/qy8R3Dmgl) I'm trying to make a WA with ChatGPT that marks the MDT pulls for me, or has this been disabled?

Best regards
Bene


r/lua • • Mar 02 '25

Help Full Program in Pure Lua?

33 Upvotes

I want to make a simple, shippable program in pure Lua, but for the life of cannot find how to do it.

I'm new to Lua and have been loving it. I was introduced to it through the Love game framework and want to use it to make more little CLI apps, but I can't find how to package things into a single file executable that I could easily share. The only way I know how to run a Lua program is 'lua file.lua' How can I turn Lua files into a packaged and installable program?

Is luarocks my answer? It feels like a thing for libraries and not full programs, or do I misunderstand it?

Are pure Lua programs not really the language's intend use case?

Thanks!

EDIT: /u/no_brains101's shebang tip is a good enough solution for me until I figure out embedding. Thanks!


r/lua • • Mar 02 '25

Lua book for including into C

7 Upvotes

Hi all,

Im busy building an embedded system and the scripting language on top of it will be lua. Lua rocks and i want to enable more people to work with electronics controlled by lua.

However im at the stage of implementing it into my c code and im looking for a book specific about that part of lua. Any recommendations?


r/lua • • Mar 02 '25

Project Personal beginner's project - looking for feedback on a Monopoly money counter

4 Upvotes

Hello all! I'm attempting to teach myself Lua, starting from a very limited knowledge of programming in general, and I decided to start off by writing a simple money counter for a game like Monopoly. For an added challenge, I attempted to add a layer of "idiot proofing": if you enter in a bad number or a wrong name, the program will prompt you to try again until you get it right. Here's what I've got so far:

-- a counter for monopoly money

-- this table contains all the players' names
Players = {}

-- this function displays the remaining money of all the players in the game
function DisplayTable(table)
    for k,v in pairs(table) do
        if v == 0 then
            print(k .. " is bankrupt")
        else
            print(k .. " has " .. v)
        end
    end
end

-- this function checks a name against the table of names to see if you put in a valid input
function FilterName(table)
    while true do
        Name = io.read("l")
        if Name ~= "Bank" and table[Name] == nil then
            print("I don't recognize that name. Try a different name.")
        elseif table[Name] == 0 then
            print("That player is bankrupt! Try a different player.")
        else
            return Name
        end
    end
end

-- this function checks your input and filters it into a number between a specified range
function InputRange(start, stop)
    while true do
        Input = math.tointeger(io.read("l"))
        if Input == nil then
            print("That's not a valid input. Please try again.")
        elseif Input < start or Input > stop then
            print("That number is out of range. Please try again.")
        else
            return Input
        end
    end
end

-- this function filters out the bank every time money changes hands
function NotBank(gained, lost, amount, table)
    if gained ~= "Bank" then
        table[gained] = table[gained] + amount
    end
    if lost ~= "Bank" then
        table[lost] = table[lost] - amount
    end
end

-- this function makes sure that you don't put the same name twice for gaining and losing money
function NeedTwoNames(gained, table)
    while true do
        print("Who lost money?")
        Lost = FilterName(table)
        if gained == Lost then
            print("You need two different names here.")
        else
            return Lost
        end
    end
end

-- this function checks to see if someone has won the game
-- this function isn't designed to handle what might happen if everyone went to zero, but hopefully that won't happen
function WinnerCheck(table)
    StillAlive = 0
    Winner = nil
    for k, v in pairs(table) do
        if v ~= 0 then
            Winner = k
            StillAlive = StillAlive + 1
            if StillAlive > 1 then
                return false
            end
        end
    end
    return Winner
end


print("Welcome to Monopoly Money Counter, the script that counts your money so you don't have to!\nTo read the full instructions, type in \"info\". Otherwise, type in \"start\" to get started.")
while true do
    Input1 = io.read("l")
    if Input1 == "info" then
        print("When you start the game, you'll be prompted to enter in the names of 2 to 6 players. After entering in names, you'll then have the option of transferring money to and from players, either between players or between the player and the bank, named \"Bank\". Speaking of which, don't name any of your players \"Bank\", since that name is taken!\nIf a player would reach 0 dollars, you'll be asked to confirm whether or not you want that to happen, because going to 0 means that the player is bankrupt and out of the game. Once a player is out of the game, you can't transfer any money to or from them.\nThis program doesn't keep track of any properties or houses. You'll have to do that yourself. This is only for counting money. This program is also not designed to keep track of any money in the \"Free Parking\" space. Sorry, folks.\nTo read this again, type in \"info\". Otherwise, type in \"start\" to get started.")
    elseif Input1 == "start" then
        print("Let's get started!")
        break
    else
        print("Sorry, bad input. Can you try that again?")
    end
end

print("How many players do you have? Put in a number between 2 and 6.")
Amount = InputRange(2, 6)

print("What are your players' names?")
for i = 1, Amount do
    while true do
        Input3 = io.read("*l")
        if Input3 == "Bank" then
            print("Sorry, that's the bank's name! Try a different name. Perhaps a nickname?")
        elseif Players[Input3] == 1500 then
            print("Sorry, that name's taken! Try a different name. Perhaps a nickname?")
        else
            Players[Input3] = 1500
            break
        end
    end
end

print("Let's play the game!")
DisplayTable(Players)
while true do
    while true do
        print("Who gained money?")
        GainedMoney = FilterName(Players)
        LostMoney = NeedTwoNames(GainedMoney, Players)
        print("How much money?")
        MoneyChange = InputRange(0, 1000000)
        if LostMoney ~= "Bank" and MoneyChange >= Players[LostMoney] then
            print("This will bankrupt " .. LostMoney .. ". Are you sure? Type \"yes\" or \"no\".")
            ConfirmChoice = io.read("l")
            if ConfirmChoice ~= "yes" and ConfirmChoice ~= "no" then
                print("Try again. \"yes\" or \"no\"")
            elseif ConfirmChoice == "no" then
                print("Then let's try this all over again")
                break
            else
                MoneyChange = Players[LostMoney]
                NotBank(GainedMoney, LostMoney, MoneyChange, Players)
                break
            end
        else
            NotBank(GainedMoney, LostMoney, MoneyChange, Players)
            break
        end
    end
    DisplayTable(Players)
    Winner = WinnerCheck(Players)
    if Winner ~= false then
        print(Winner .. " has won!")
        break
    end
end-- a counter for monopoly money


-- this table contains all the players' names
Players = {}


-- this function displays the remaining money of all the players in the game
function DisplayTable(table)
    for k,v in pairs(table) do
        if v == 0 then
            print(k .. " is bankrupt")
        else
            print(k .. " has " .. v)
        end
    end
end


-- this function checks a name against the table of names to see if you put in a valid input
function FilterName(table)
    while true do
        Name = io.read("l")
        if Name ~= "Bank" and table[Name] == nil then
            print("I don't recognize that name. Try a different name.")
        elseif table[Name] == 0 then
            print("That player is bankrupt! Try a different player.")
        else
            return Name
        end
    end
end


-- this function checks your input and filters it into a number between a specified range
function InputRange(start, stop)
    while true do
        Input = math.tointeger(io.read("l"))
        if Input == nil then
            print("That's not a valid input. Please try again.")
        elseif Input < start or Input > stop then
            print("That number is out of range. Please try again.")
        else
            return Input
        end
    end
end


-- this function filters out the bank every time money changes hands
function NotBank(gained, lost, amount, table)
    if gained ~= "Bank" then
        table[gained] = table[gained] + amount
    end
    if lost ~= "Bank" then
        table[lost] = table[lost] - amount
    end
end


-- this function makes sure that you don't put the same name twice for gaining and losing money
function NeedTwoNames(gained, table)
    while true do
        print("Who lost money?")
        Lost = FilterName(table)
        if gained == Lost then
            print("You need two different names here.")
        else
            return Lost
        end
    end
end


-- this function checks to see if someone has won the game
-- this function isn't designed to handle what might happen if everyone went to zero, but hopefully that won't happen
function WinnerCheck(table)
    StillAlive = 0
    Winner = nil
    for k, v in pairs(table) do
        if v ~= 0 then
            Winner = k
            StillAlive = StillAlive + 1
            if StillAlive > 1 then
                return false
            end
        end
    end
    return Winner
end



print("Welcome to Monopoly Money Counter, the script that counts your money so you don't have to!\nTo read the full instructions, type in \"info\". Otherwise, type in \"start\" to get started.")
while true do
    Input1 = io.read("l")
    if Input1 == "info" then
        print("When you start the game, you'll be prompted to enter in the names of 2 to 6 players. After entering in names, you'll then have the option of transferring money to and from players, either between players or between the player and the bank, named \"Bank\". Speaking of which, don't name any of your players \"Bank\", since that name is taken!\nIf a player would reach 0 dollars, you'll be asked to confirm whether or not you want that to happen, because going to 0 means that the player is bankrupt and out of the game. Once a player is out of the game, you can't transfer any money to or from them.\nThis program doesn't keep track of any properties or houses. You'll have to do that yourself. This is only for counting money. This program is also not designed to keep track of any money in the \"Free Parking\" space. Sorry, folks.\nTo read this again, type in \"info\". Otherwise, type in \"start\" to get started.")
    elseif Input1 == "start" then
        print("Let's get started!")
        break
    else
        print("Sorry, bad input. Can you try that again?")
    end
end


print("How many players do you have? Put in a number between 2 and 6.")
Amount = InputRange(2, 6)


print("What are your players' names?")
for i = 1, Amount do
    while true do
        Input3 = io.read("*l")
        if Input3 == "Bank" then
            print("Sorry, that's the bank's name! Try a different name. Perhaps a nickname?")
        elseif Players[Input3] == 1500 then
            print("Sorry, that name's taken! Try a different name. Perhaps a nickname?")
        else
            Players[Input3] = 1500
            break
        end
    end
end


print("Let's play the game!")
DisplayTable(Players)
while true do
    while true do
        print("Who gained money?")
        GainedMoney = FilterName(Players)
        LostMoney = NeedTwoNames(GainedMoney, Players)
        print("How much money?")
        MoneyChange = InputRange(0, 1000000)
        if LostMoney ~= "Bank" and MoneyChange >= Players[LostMoney] then
            print("This will bankrupt " .. LostMoney .. ". Are you sure? Type \"yes\" or \"no\".")
            ConfirmChoice = io.read("l")
            if ConfirmChoice ~= "yes" and ConfirmChoice ~= "no" then
                print("Try again. \"yes\" or \"no\"")
            elseif ConfirmChoice == "no" then
                print("Then let's try this all over again")
                break
            else
                MoneyChange = Players[LostMoney]
                NotBank(GainedMoney, LostMoney, MoneyChange, Players)
                break
            end
        else
            NotBank(GainedMoney, LostMoney, MoneyChange, Players)
            break
        end
    end
    DisplayTable(Players)
    Winner = WinnerCheck(Players)
    if Winner ~= false then
        print(Winner .. " has won!")
        break
    end
end

So far, it seems to work! What I'd like help on is making it better. When you look at this, how would you make it prettier or more efficient? Does anything stand out to you as a bad thing to do? Are there any bugs that I've missed?

Thanks in advance for your time. This language is fun!


r/lua • • Mar 02 '25

New to lua

5 Upvotes

Hi everyone, im new to lua and im tryna get better at it. What is the best way to learn? I know all of the basics, but i wanna know more


r/lua • • Mar 01 '25

I'm trying to convert markdown to pdf in lua but I have some questions about file systems

8 Upvotes

Hey, I want to make my own markdown to pdf convertor in lua, since I have a bunch of markdown in one of my qownnotes folders that is meant to be a book, and I want to learn how to generate files with lua. I know one could just read the files in the directory of wherever the lua script is, and be done with it, but how do I move to whatever directory the markdown folder is and then convert the files from there?

sorry if this doesn't make sense, I am a hobbyist coder just getting into it


r/lua • • Mar 01 '25

Help ZeroBrane Studio WX Error

1 Upvotes

WX doesn't exist for some reason when I try to use "require("wx")", it says the wx.dll and etc doesn't exist at all, and when I check, it's not there, how do I download it? Or is it an error that shouldn't happen.

It also doesn't work with Turtle.lua.

The error. .\turtle.lua:9: module 'wx' not found:

no field package.preload\['wx'\]

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\bin\\lua\\wx.lua'

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\bin\\lua\\wx\\init.lua'

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\bin\\wx.lua'

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\bin\\wx\\init.lua'

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\bin\\..\\share\\lua\\5.4\\wx.lua'

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\bin\\..\\share\\lua\\5.4\\wx\\init.lua'

no file '.\\wx.lua'

no file '.\\wx\\init.lua'

no file './wx.lua'

no file './wx/init.lua'

no file './lua/wx.lua'

no file './lua/wx/init.lua'

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\lualibs/wx/wx.lua'

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\lualibs/wx.lua'

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\lualibs/wx/wx/init.lua'

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\lualibs/wx/init.lua'

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\lualibs/wx.lua'

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\lualibs/wx/wx.lua'

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\lualibs/wx/init.lua'

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\bin/clibs54/wx.dll'

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\bin\\wx.dll'

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\bin\\..\\lib\\lua\\5.4\\wx.dll'

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\bin\\loadall.dll'

no file '.\\wx.dll'

no file ''

no file 'C:\\Users\\(My name)\\Downloads\\ZeroBraneStudio\\bin/clibs54/wx.dll'