Compiling with LUA in Visual Studio

I’m having a problem getting LUA to work compiling the build in VS. I downloaded the LUA executables and put them on my path, and I can run lua53 just fine from the command line. I generate the cata_bindings file and it seems to come out fine. Compiling works.

But when I start up the game lua functions don’t seem to be working correctly. I tested some of the StatsThroughSkills functions in the lua console and it keeps giving me errors like "attempt to call a nil value (field ‘pow’) on line 99. I can use the math.pow function just fine if I start up lua in my command line, though.

Any ideas on why this isn’t working?

Can you provide code which you tried to run in the lua console?

I just ran calculate_bonuses(). It’s outputting the first console message but is throwing the math.pow error when it gets into the calc_bonus(skills_set) function. It works fine on precompiled builds.

Screenshot of error:

Try running following commands in console:


What’s the output?

Oh, it seems you better use 5.2 instead of 5.3 (or update lua code) - some functions were deprecated in 5.3 (see

The following functions were deprecated in the mathematical library: `atan2`, `cosh`, `sinh`, `tanh`, `pow`, `frexp`, and `ldexp`. You can replace `math.pow(x,y)` with `x^y; you can replace `math.atan2` with `math.atan`, which now accepts one or two parameters; you can replace `math.ldexp(x,exp)` with `x * 2.0^exp`. For the other operations, you can either use an external library or implement them in Lua.

Replacing math.pow with ^ fixed the problem in that function, but now it’s telling me that the player.str_max value is nil. says to use lua53…

I believe that’s not the issue with compilation - the lua in console works, so it compiled properly with lua support.

As for the syntax used in STS mod - it was apparently written for lua 5.2, but the strange thing how is it even working in precompiled binaries which has Lua 5.3.

Try this in the console: