seronis Posted February 19, 2015 Share Posted February 19, 2015 Prefixes of _G and GLOBAL dont seem to make table.insert() function from inside modinfo.lua. Neither does it just work on its own. Any way to get this to work ? Also why cant percentile symbols show up in the 'description' part of a button? I've tried escaping it with double percentile symbols and with a slash. Neither escape method worked to get it to show up in the interface. Link to comment Share on other sites More sharing options...
Mobbstar Posted February 19, 2015 Share Posted February 19, 2015 modinfo isn't allowed to perform functions or arithmetics. Simplex could sing a song about it. EDIT Link to comment Share on other sites More sharing options...
seronis Posted February 19, 2015 Author Share Posted February 19, 2015 Well it performs functions perfectly fine. Just doesnt seem to call library functions. Mostly due to something i saw in Simplexs mods im setting up configuration utility functions. local function op_bool(name, label, defval) return { name = name, label = label, options = { {description = "Yes", data = 1}, {description = "No", data = 0}, }, default = defval and 1 or 0, }endlocal function op_prct(name, label, defval) return { name = name, label = label, options = { {description = "0%", data = 0 }, {description = "10%", data = 10 }, {description = "20%", data = 20 }, {description = "30%", data = 30 }, {description = "40%", data = 40 }, {description = "50%", data = 50 }, {description = "60%", data = 60 }, {description = "70%", data = 70 }, {description = "80%", data = 80 }, {description = "90%", data = 90 }, {description = "100%", data = 100}, }, default = defval or 0, }endlocal function op_valx(_name, _label, _valBase, _valIncBy, _valIncNum, _defval) _options = {} _i = 0 finish = _valBase + ( _valIncBy * _valIncNum ) for _val = _valBase, finish, _valIncBy do _i = _i + 1 _options[_i] = {description = _val, data = _val} end return { name = _name, label = _label, options = _options, default = _defval or _valBase, }end configuration_options = {-- the number of dashes is how many letters are available for the label name op_bool("op_enabled", "*---------------------*", true), op_prct("op_ignored", "*---------------------*", 0), op_valx("op_testing", "--1-2-3-4-5-6-7-8-9-0--", 0, 10, 10 ), op_valx("op_testing", "--1-2-3-4-5-6-7-8-9-0--", 0, 10, 10, 50 ), op_valx("op_testing", "--1-2-3-4-5-6-7-8-9-0--", 50, 5, 10, 75 ),}I had originally tried using table.insert for the 3rd utility function. But can get by without it. Im not sure why percentiles dont show up though Link to comment Share on other sites More sharing options...
Corrosive Posted February 20, 2015 Share Posted February 20, 2015 As far as I know, you can't. modinfo.lua is run in a sandboxed environment using setfenv(). You're given pretty much a blank environment with nothing to work with apart from basic lua keywords. You can confirm this by changing line 205 of modindex.lua to: local env = {print = print, getfenv = getfenv, pairs = pairs}and then from within any modinfo.lua:for k,v in pairs(getfenv()) do print(k,v) endThe only variables are those that were referenced through env, as well as any that are defined in modinfo.lua prior to calling getfenv(). Link to comment Share on other sites More sharing options...
Corrosive Posted February 20, 2015 Share Posted February 20, 2015 .....They really should give you at least read-access to data your mod has saved, imo =/ Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.