Faintly Macabre Posted May 25, 2016 Share Posted May 25, 2016 I'm trying to set my mod up to be able to serve up character-specific strings, but GetString is crashing with the usual "attempt to call global 'GetString' (a nil value)". Something I need to declare to be able to use it? Link to comment Share on other sites More sharing options...
Muche Posted May 25, 2016 Share Posted May 25, 2016 If you're trying to access it from modmain, then you need to either localize it: local GetString = GLOBAL.GetString ... str = GetString(...) or use it directly: str = GLOBAL.GetString(...) Link to comment Share on other sites More sharing options...
Faintly Macabre Posted May 25, 2016 Author Share Posted May 25, 2016 7 minutes ago, Muche said: If you're trying to access it from modmain, then you need to either localize it: local GetString = GLOBAL.GetString ... str = GetString(...) or use it directly: str = GLOBAL.GetString(...) I guess I could have just tried that. Is there some kind of rhyme or reason to what is or isn't readily available without localization, or do you just have to trial-and-error it? Link to comment Share on other sites More sharing options...
Muche Posted May 25, 2016 Share Posted May 25, 2016 (edited) Environment available in mod's modmain.lua (and modworldgenmain.lua) is created in mods.lua|CreateEnvironment() and modutil.lua|InsertPostInitFunctions(). Anything that isn't added into it explicitly, has to be accessed via GLOBAL (which incidentally is one of the fields made available in there). Edited May 25, 2016 by Muche Link to comment Share on other sites More sharing options...
Faintly Macabre Posted May 25, 2016 Author Share Posted May 25, 2016 Alright. Thanks much. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now