solarus-games / solarus

This repository was moved to GitLab: https://gitlab.com/solarus-games/solarus
http://www.solarus-games.org
Other
710 stars 133 forks source link

Make the engine compatible with Lua 5.2 #203

Open christopho opened 11 years ago

christopho commented 11 years ago

The only problem in Solarus code between Lua 5.1 and Lua 5.2 should be the usage of setfenv(). setfenv() no longer exists in 5.2, instead we have to use the ENV special variable. And ENV does not exist in 5.1.

Bertram25 commented 11 years ago

Hi, I'm interested in the resolution of this one as I had to reimplement setenv() when in lua5.2. See: https://github.com/Bertram25/ValyriaTear/blob/master/dat/config/editor.lua

If you've got something more simple, I'd be happy to learn from you :)

christopho commented 11 years ago

Here is an interesting dicussion about setfenv and Lua 5.2: http://stackoverflow.com/questions/14290527/recreating-setfenv-in-lua-5-2. If you really have to recreate setfenv, there doesn't seem to be a simpler solution. So your code looks nice :)

In solarus I won't do that, I will use _ENV directly if the Lua version is 5.2. (I never need to set the environment of a function after it was loaded.)