blt4linux / blt4l

PAYDAY 2 SteamOS/Linux LUA loader.
Other
57 stars 14 forks source link

pcall(func) is not implemented correctly #92

Closed BangL closed 6 years ago

BangL commented 6 years ago

according to countless sources, pcall() should return exactly two values in case of an error: false and the error. this is pretty essential for proper error handling. since blt2 it does not seem to be implemented correctly and instead returns nothing at all. https://www.google.de/search?q=lua+pcall is this a problem on blt's side, or in the game itself?

RomanHargrave commented 6 years ago

BLT isn't responsible for implementing pcall(), so it's likely possible that it has something to do with changes to PAYDAY

BangL commented 6 years ago

that's horrible, but good to know. any chance that this misbehaviour could be fixed by the blt?

RomanHargrave commented 6 years ago

I'm not sure.

RomanHargrave commented 6 years ago

It might be within the realm of possibility that the way we expose it is the problem . I'm not really a lua expert, or even novice, so I'm not sure.

ZNixian commented 6 years ago

I had this same problem, more or less.

Try using vm.pcall, though you should make sure vm and vm.pcall exist first.

See #67

ZNixian commented 6 years ago

The broken version of pcall is implemented in BLT4L - see lapi.cc:30.

ZNixian commented 6 years ago

Here's the behavior of the method, on both platforms:

ZNixian commented 6 years ago

I could fix the function to do what it is supposed to (we even have a copy of the correct function in lapi_vm.cc), but I'm a little worried about having different behavior on BLT4W and BLT4L.

On the other hand, I can't imagine anyone relying on the non-nilness of the second argument to see if the function ran correctly. @BangL What do you think?

BangL commented 6 years ago

in fact i am totally relying on the second param. i am working on an ingame debug console mod, and it is the only way to show error messages in it. thats why i'm interested in it. the vm.pcall does exactly what i want, so i am perfectly happy now. thanks for the information about the vm table!