-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configurable LUA_COMPAT_FLOATSTRING #113
Comments
Added with b2c7f18. However, it wasn't easily configurable. Now with 96f8515 I think this should work: const fengari = require("fengari");
fengari.luaconf.LUA_COMPAT_FLOATSTRING = true;
// normal fengari things... I don't love that it's a global setting. But not sure what else to do while staying in the spirit of the lua C api. |
Wait no that won't work: lobject.js squirrels away the original value before you get a chance to modify it |
I'm still looking for ways to make luaconf.js... configurable.
Let me know if you have any ideas @timkurvers @fallenoak
|
Thanks for looking into this @daurnimator, appreciated! Using the module syntax from ES6 would make this relatively easy as all bindings are live, e.g: let LUA_COMPAT_FLOATSTRING = false;
export {
LUA_COMPAT_FLOATSTRING,
}; import { LUA_COMPAT_FLOATSTRING } from './luaconf.js'` The value can be changed at runtime (although most likely not from an import, may have to happen with a function call in Using only CJS, I suppose the best bet would be to emulate those live bindings, by fetching values from const {
ldexp,
lua_getlocaledecpoint,
lua_integer2str,
lua_number2str
} = require('./luaconf.js');
const luaconf = require('./luaconf');
// later, at runtime:
luaconf.LUA_COMPAT_FLOATSTRING |
@giann did you mean to close this? @timkurvers huh. I didn't realise ES6 imports worked like that. |
My bad. Didn’t mean to close this. |
@daurnimator Yeah, I can see how that would be a pretty large overhaul. What do you think about the approach of fetching values at runtime from a |
@timkurvers the problem is that we need to make sure that the values don't change at runtime. They can only ever be changed before the first fengari call. So maybe we e.g. call Object.freeze() as soon as the first non-luaconf module is loaded? Or before the first |
Ah sorry @daurnimator, I see. Had you considered using Node's Edit: What's neat about |
FYI |
process.env can change at runtime. |
@timkurvers let me know what you think about #116 |
Looks great!
Yeah, once it's gone we'll probably have to look into other options or perhaps maintain a fork or something. Thanks again for now! 👍 |
As @fallenoak mentioned in fengari-lua/fengari-interop#31, we're dealing with Lua scripts from a game client that we'd like to use unmodified.
These scripts were originally written for Lua 5.1 and do not use any string formatting utils, solely relying on integer interpolation into strings.
A (dumbed down) example of a script that causes issues:
In addition, these scripts are a global bonanza and frequently require referencing objects through named globals.
Object1.0
is not a valid identifier and that is essentially as far as we get.As kindly pointed out by @daurnimator, Fengari currently assumes
LUA_COMPAT_FLOATSTRING
is not set when dealing with float to string conversion:Would it be possible to make
LUA_COMPAT_FLOATSTRING
configurable?The text was updated successfully, but these errors were encountered: