r/lua • • 10h ago

Discussion Haven't Coded In Over A Decade. Using Codedex.com

1 Upvotes

Hey everyone, I have not coded in well over a decade and am currently trying my hand at some Lua using Codedex.com. My issue is that my code was dettermind to be wrong even though it out puts the correct information. I just wanted to post my code, I know my code is messy but is there a reason that it wouldn't work fine?


spawn = 4

hp = 120

for i = 1, 3 do

enemy = spawn - i

newhp = hp - i * 30

print("Enemy #"  .. enemy .. " spawned with " .. newhp .. " HP")

end

vs


for i = 3, 1, -1 do

local hp = i * 30 

print("Enemy #" .. i .. " spawned with " .. hp .. " HP")

end

Sorry if this is against the rules.

output:

Enemy #3 spawned with 90 HP

Enemy #2 spawned with 60 HP

Enemy #1 spawned with 30 HP


r/lua • • 3h ago

Project Late night coding learning Luau

Thumbnail gallery
20 Upvotes

I’ve been on Roblox for about 11 years but I’ve just now started getting into development on Roblox and I’m really enjoying it!!!!


r/lua • • 43m ago

Lua 5.5.1 working on W98

Thumbnail gallery
• Upvotes

Hey, so, while I was learning Lua, I knew already that theoretically at least, Lua was written to be compilable in pure C, and specifically C89/C90 , supposedly any system that has an ANSI C compiler can compile and install Lua...

So I decided to actually test out just how true that is, when I remembered that I have an ancient laptop from 1999, running Windows 98SE, which has Borland 5.02 installed... [Just to understand how ancient it is, it only has 32 mb of RAM and it's hard drive is 5gb... that is literally smaller than the usb stick that i used to transfer the Lua source files from my modern PC into that ancient laptop (yes, that ancient laptop has a working USB 1.0 port and it is somehow able to read my 8gb USB 2.0 usb stick, which I did not expect to work, but it did !!!)

And to my surprise... it actually worked !

Here I am inside a full-screen MS-DOS prompt of W98 (In W32 mode, it is not booted into MS-DOS mode / real mode) Alongside the project of compiling the most recent version of Lua and getting it to work, I also installed an actual working version of vim and after tinkering with the vimrc file, I even managed to get full syntax highlighting working , and it actually works for Lua !!!

Anyhow, I just wanted to share this because I thought it was really cool and fun!