Lua - Reddit – Telegram
Lua - Reddit
30 subscribers
281 photos
31 videos
4.26K links
News and discussion for the Lua programming language.

Subreddit: https://www.reddit.com/r/lua

Powered by : @r_channels & @reddit2telegram
Download Telegram
Recoil noscript need help is this going to work?

EnablePrimaryMouseButtonEvents(true)

-- Define all weapons and their recoil values (name = {x, y})
local weapons = {
{name = "R4C", recoil = {-1, 20}},
{name = "F2", recoil = {-1, 14}},
{name = "L8", recoil = {0, 10}},
{name = "AR33", recoil = {0, 11}},
{name = "G36C", recoil = {-1, 14}},
{name = "556XL", recoil = {-1, 11}},
{name = "6P41", recoil = {-1, 11}},
-- Add more weapons here
}

local weaponIndex = 1
local recoilEnabled = false

function OnEvent(event, arg)
-- Toggle recoil ON/OFF with Right Mouse Button (3)
if event == "MOUSEBUTTONPRESSED" and arg == 3 then
recoilEnabled = not recoilEnabled
if recoilEnabled then
OutputLogMessage("Recoil ON (%s)\n", weaponsweaponIndex.name)
else
OutputLogMessage("Recoil OFF\n")
end
end

-- Cycle weapons with Mouse Button 4 (arg == 4)
if event == "MOUSEBUTTONPRESSED" and arg == 4 then
weaponIndex = weaponIndex + 1
if weaponIndex > #weapons then
weaponIndex = 1
end
OutputLogMessage("Switched to: %s\n", weaponsweaponIndex.name)
end

-- Recoil control loop
if recoilEnabled and IsMouseButtonPressed(1) then
local recoil = weaponsweaponIndex.recoil
repeat
MoveMouseRelative(recoil1, recoil2)
Sleep(9)
until not IsMouseButtonPressed(1)
end
end

https://redd.it/1l0iljs
@r_lua
hello...

followed a tutorial on youtube from 4 years ago on how to install lua and it didn't work....
how the hell do i install lua????

https://redd.it/1l0lygx
@r_lua
Doxygen Lua documentation help

I'm making a Lua interpreter with the Lua C API and want to make a documentation for it. Everything seems fine, besides writing the functions inside the library: e. g.: This is a function that is for Doxygen:

nil os.delay(number seconds)

I want it to show it as is, but instead, Doxygen parses it like this:

nil os delay(number seconds)

Basically, Doxygen treats the library (os) as a type (nil os delay, this is not what I want), instead of leaving it as is (which is what i want: nil os.delay)

Here are some similar documentation pages I found that do what I want to achieve:

http://onelua.x10.mx/vita/docs/en/group__adhoc.html

https://jcnmsg.github.io/LuaDEV-R0-PSP/original/spanish/html/group___i_n_i.html

I have spent all day trying to fix this, including issuing it to the Doxygen repo, but I haven't found any solution so far.

https://redd.it/1l0pny1
@r_lua
Why do Lua tables need commas?

Wouldn't the grammar still be unambiguous if tables didn't need commas?

https://redd.it/1l0qppp
@r_lua
After Python, which language should I learn??

I’m currently learning Python, and want to learn a new language after to make games as a passion project.
After I learn Python, should I learn GDScript to make games on Godot, or should I learn Lua to make games on Roblox?
Which would be easier or harder to learn?
Which would benefit me the most?

https://redd.it/1l0tntr
@r_lua
After learning Pico8 what is best next (Picotron, Playdate, Love2D or jump to Godot).

Like the noscript says, I'm in love with the Lua language when I started making small games in Pico8, and now I want to make something much bigger, or maybe do the same games but outside Pico8, to learn more advanced things. What is your recommendation? Thanks

https://redd.it/1l146my
@r_lua
How do I get started on Lua?

im quite new to lua and im not too sure on how to get started, is there any advice you guys can give me to start coding?

https://redd.it/1l1ergq
@r_lua
LSPlua_ls Your workspace is set to C:\Users\waffle. Lua language server refused to load this directory.

How to solve this problem?

https://redd.it/1l1ne71
@r_lua
Local Lua Debugger by Tom Blind

Im a beginner in Lua and especially VSCode and i heard that some extensions can have viruses, i wonder if this extension is safe because it only have 50k downloads.

https://redd.it/1l1s3i7
@r_lua
I Wanna learn to program in Lua

Well, here we are. Sorry if you misread anything in this text. It's not my native language, so I want to learn to program in Lua. I've been really interested in this language. I've been doing some research, but I don't know how to get started. I speak Spanish, and the articles out there don't compare to the English ones. Could you please help me? I'd like to learn, but I don't know how. Could you send me articles, videos, or whatever, or explain it to me? That would be great.

https://redd.it/1l1wq7x
@r_lua
How can I compile a single lua file into an exe?

I just want to compile a stand alone (vanilla) .lua into an exe. I tried using srlua but I just couldn't figure it out I guess. There were next to no instructions on how to set it up. I tried to compile the srlua.c into an exe with gcc but that threw an error saying it couldn't find lua.h. there were a few header files I could see it wouldn't be able to find, so I downloaded the lua src and tried to manually link them. To no one's surprise that didn't work. I've tried about 100 different things and nothing works

https://redd.it/1l3lfnl
@r_lua
I Want to Learn

My son loves computers.

I've made a couple of super basic Scratch projects with him showing me the ropes and received more praise than I probably deserved.

That is the extent of my knowledge...but not the extent of my ambition. I really want to learn how to code. Like proper coding.

The kid and I love Roblox so I feel like choosing a first language connected to a shared passion might be best. So Lua....

I tried watching YouTube to get my feet wet only to find that nothing made sense.

Please help me. I need an introduction that starts at level zero. Where do I look/go/watch?

https://redd.it/1l3spff
@r_lua
A Cross-Platform “Batteries-Included” Lua Networking Toolkit

This is my first time posting here—please forgive any mistakes or inappropriate formatting.

silly is a cross-platform “super wrapper” (Windows/Linux/macOS) that bundles TCP/UDP, HTTP, WebSocket, RPC, timers, and more into one easy-to-use framework.

Built-in network primitives (sockets, HTTP client/server, WebSocket, RPC)
Event loop & timers, all exposed as idiomatic Lua functions
Daemonization, logging, process management out of the box
Self-contained deployment (no C modules needed, aside from optional libreadline)

Check out the examples/ folder (socket, HTTP, RPC, WebSocket, timer) to see how fast you can go from zero to a fully event-driven service. Everything is MIT-licensed—fork it, tweak it, or just learn from it.

▶️ Repo & docs: https://github.com/findstr/silly

Feel free to share feedback or ask questions!

https://redd.it/1l3ts1v
@r_lua
Catch output from function called via load(string)

Hey there,

I'm coming back to lua after some time away... I'm trying to call a constructor based on a string from some Tiled output. I've had success doing this using the `load` function - the constructor is being called - but I can't seem to get a reference to the object created. Here's some example code:

function AddElement(_type, _x, _y)
if (_type == null) then return end
local s = _type .. "(" .. tostring(_x) .. "," .. tostring(_y) .. ")"
local makeElement = load(s)
local e = makeElement()
table.insert(elements, 1, e)
print(#elements)
end

I am seeing output from print statements inside the elements' constructors, but the `elements` table is not increasing in size, and `e` seems to be nil. Any ideas?

https://redd.it/1l432f2
@r_lua
I'm new to programming trying to build a timetable generator for my school

when placing the subjects monday will be filled up completely but the other days will have a lot of free slots


function TimeTable_Placement()
local days = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"}
local daily_limit = 11
local doubleCountperday = {}

for class_name, subject_groups in pairs(Grouped_subjects) do
TimeTable[class_name\] = {}
for _, day in ipairs(days) do
TimeTable[class_name\][day\] = {}
doubleCountperday[day\] = 0
for p = 1, daily_limit do
TimeTable[class_name\][day\][p\] = nil
end

local reserved = Reserved_Periods[class_name\][day\] or {}
for period, reserved_name in pairs(reserved) do
TimeTable[class_name\][day\][period\] = reserved_name
end

end

for _, subject_group in ipairs(subject_groups) do
local placed = false
local needs_double = false
local subjects_done
local weekly_periods

for _, day in ipairs(days) do
for p = 1, daily_limit do

local try_double = false

local required_periods = 1
for _, subject in ipairs(subject_group) do

if DoublePeriodSubjects[subject\] then -- looks at the subjects to check if the user set this subject to need double
needs_double = true
end


if needs_double and doubleCountperday[day\] < 3 and ((Classes[class_name\][subject\].subject_periods_per_week - Classes[class_name\][subject\].Subjects_done_in_week ) >= 2 ) then -- checks if the number of double periods scheduled in the day are less than two then checks if the subjects remaining in the week are 2 or more so that it can set double periods
required_periods = 2
try_double = true
else
required_periods = 1
try_double = false
end

end

for _, subject in ipairs(subject_group) do
if subject == "math" then
print(Classes[class_name\][subject\].subject_periods_per_week)
end
end




if try_double then
if TimeTable[class_name\][day\][p + 1\] == nil and TimeTable[class_name\][day\][p\] == nil then
if p + required_periods - 1 <= daily_limit then
local conflict = false

for _, subject in ipairs(subject_group) do
if Classes[class_name\][subject\].Subjects_done_in_week >= Classes[class_name\][subject\].subject_periods_per_week then print("break") placed = false end
end
for offset = 0, required_periods - 1 do
for _, subject in ipairs(subject_group) do
local teacher = Get_teacher((Classes[class_name\][subject\]))
if teacher_schedule[teacher\] and teacher_schedule[teacher\][day .. (p + offset)\] then
conflict = true
break
end
end
if conflict then break end
end

if not conflict then
for offset = 0, required_periods - 1 do
if type(TimeTable[class_name\][day\][p\]) \~= "string" and type(TimeTable[class_name\][day\][p + 1\]) \~= "string" then
for _, subject in ipairs(subject_group) do
local teacher = Get_teacher((Classes[class_name\][subject\]))
TimeTable[class_name\][day\][p + offset\] = TimeTable[class_name\][day\][p + offset\] or {}
doubleCountperday[day\] = doubleCountperday[day\] + 1
table.insert(TimeTable[class_name\][day\][p + offset\], {
subject = subject,
teacher = teacher
})

if teacher then
teacher_schedule[teacher\] = teacher_schedule[teacher\] or {}
teacher_schedule[teacher\][day .. (p + offset)\] = true
end


for _, subject in ipairs(subject_group) do

Classes[class_name\][subject\].Subjects_done_in_week = Classes[class_name\][subject\].Subjects_done_in_week + 2

end
placed = true
break

end
end
end

end
if placed then break end
end
end
end
end

if not placed then
for p = 1, daily_limit do
local conflict = false
if TimeTable[class_name\][day\][p\] == nil then
for _, subject in ipairs(subject_group) do
local teacher = Get_teacher(Classes[class_name\][subject\])
for _, subject in ipairs(subject_group) do
print("Placing
single")
if Classes[class_name\][subject\].Subjects_done_in_week >= Classes[class_name\][subject\].subject_periods_per_week then break end
teacher = Get_teacher(Classes[class_name\][subject\])
if teacher_schedule[teacher\] and teacher_schedule[teacher\][day .. p\] then
conflict = true
break
end
end
end

if not conflict then
for _, subject in ipairs(subject_group) do
local teacher = Get_teacher(Classes[class_name\][subject\])
if not (teacher_schedule[teacher\] and teacher_schedule[teacher\][day .. p\]) then
TimeTable[class_name\][day\][p\] = {{
subject = subject,
teacher = teacher}}
teacher_schedule[teacher\][day .. p\] = true
Classes[class_name\][subject\].Subjects_done_in_week = Classes[class_name\][subject\].Subjects_done_in_week + 1
placed = true
break

end
end
end
end
if placed then break end
end
end
end
end
end
end

https://redd.it/1l45bie
@r_lua
Data entry for lua

This is probably a basic question but I just can't find a good answer. I'm working on a card game in defold and need to add a bunch of cards. I have some in lua files but adding them all manually is a pain. Is there a tool I can use to write the entries in an actual table and have them come out as lua? Is it just, do it as CSV and find a converter?

https://redd.it/1l46h3q
@r_lua
Interest in a Lua based modular game engine written in Rust?

I have an idea and a project I have planned out that is based heavily on modularity and the Lua programming language

For more detail I expect every UI element of the engine to be a "module" (can be written by any user and swapped or replaced and such) for example lets say we have a simple explorer that comes with the engine but is quickly seen to be too simple or lacking features you could either write your own file explorer and replaces its position in UI or download one off the internet and use that instead obviously this is just an example and I plan that other tools separate from the base ones can be created as well

This idea comes from when I was checking out Roblox Studio and saw the potential in the user made extensions where every user can create these UI elements and upload them to be used elsewhere within the engine I think a engine based on this potential would be extremely useful to those with a very unique workflow

https://redd.it/1l49ew7
@r_lua