Facepunch / garrysmod-issues

Garry's Mod issue tracker
147 stars 56 forks source link

require() function does not return anything #3244

Open Python1320 opened 7 years ago

Python1320 commented 7 years ago

Issues

require('modulename') never returns anything for either pure lua files or binary modules.

Details

require() is apparently supposed to return success values, but it has never done this. Require on pure lua modules should return whatever the module lua file returns the very least, this does not happen either. We could greatly benefit from having the original behaviour of Lua by the means of code reuse from any normal pure lua library. There are NO drawbacks for this.

Just because require has been like this for as long as I can remember does not mean it isn't a bug. Not being able to use third party libraries without modifications is a pretty darn big bug in my books.

Steps to reproduce

Imagine being able to use https://github.com/ToxicFrog/vstruct just by the means of copypaste instead of having to do something like this: https://github.com/Python1320/gmod_vstruct/blob/master/lua/includes/modules/vstruct.lua

danielga commented 7 years ago

https://github.com/danielga/gmod_require

Please fix this. It's so easy, even your kids can do it. And if modules depend on tier0 or vstdlib, for example, you can also make it so you don't need a relative path (like bin/libtier0.so) and just linking with the file (ldd will report it as just libtier0.so) will work. This is so annoying because it requires an impressive amount of hacks.

neico commented 7 years ago

https://github.com/Facepunch/garrysmod-requests/issues/445

danielga commented 7 years ago

Not going to happen.

Kefta commented 7 years ago

I don't see any reason for require to not be completely fixed at once.

Myaats commented 7 years ago

I see no reason why this should not be fixed

sanny-io commented 6 years ago

This has been a problem for quite a while @robotboy655 @willox

meepen commented 6 years ago

can't really fix it without breaking modules returning random values at the end of gmod13_open

they completely ignore that return value

Kefta commented 6 years ago

Most modules I've seen just return 0 for no returns - even if they didn't, the returns wouldn't be utilised by current Lua code. Modules should be able to return from require and take arguments.

sanny-io commented 5 years ago

Boggles the mind how this could go unfixed for so long. I just don't understand. I can't understand.

Vurv78 commented 3 years ago

Obligatory almost three years later bump