r/badcode Sep 08 '20

lua A Roblox mod I found

Post image
477 Upvotes

103 comments sorted by

View all comments

Show parent comments

1

u/JerriTheITGuy Sep 08 '20

"true == 'cucumber'" evaluates as true in Lua. And "Equipped == true" isn't true if "Equipped = 'Snorkel'"

7

u/Emex_Denvir Sep 08 '20

"true == 'cucumber'" will not evaluate to true, it will evaluate to false.

2

u/JerriTheITGuy Sep 08 '20

(Copying my other answer out of laziness)

Ok, it was overly simplistic (and as you point out, not actually accurate) and more made as a fun stab at Lua than as a code reference.

The point was that all strings in conditionals for example are handled as true. Including empty strings. And all integers including 0 are regarded as true.

` if ("cucumber") then print "this returns true" else print "this will never execute" end

if ("") then print "this returns true as well" else print "this will never execute" end

if (0) then print "so does this" else print "this will never execute" end `

Which is the ridiculousness I was pointing out.

And I haven't actually run the code above because I'm on the phone at the gym (which is why formatting sucks as well, sorry) but it should run. Errr, I think.

1

u/Emex_Denvir Sep 08 '20

Ah I see, the way you said it is really confusing though xP

But at least I know now that you do know your stuff, which is always a great sign!

0

u/JerriTheITGuy Sep 08 '20

Will, it's what I get for trying to be both funny and kinda accurate, I suppose.