Jump to content

Recommended Posts

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.

Edited by seronis

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

 

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) end

The only variables are those that were referenced through env, as well as any that are defined in modinfo.lua prior to calling getfenv().

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...