If you are also having trouble with powers, use the carrot (^) as math.pow gives an error. (Original file rewardbag.lua) Code: local level = config.getParameter("treasure.level") local variance = config.getParameter("treasure.variance") local factor = config.getParameter("treasure.factor") if variance == 0 then return level end local rez = math.floor( math.random(level^factor, (level + variance)^factor)^(1/factor) + 0.5 ) return variance - rez + 2 * level But this gives a nil value... Code: local level = config.getParameter("treasure.level") local variance = config.getParameter("treasure.variance") local factor = config.getParameter("treasure.factor") if variance == 0 then return level end local rez = math.floor( math.pow( math.random( math.pow( level, factor ), math.pow( level + variance, factor ) ), 1/factor ) + 0.5 ) return variance - rez + 2 * level P.S. Why is this the case and could this be fixed? I didn't even know you could exclude functions in the base script.
Modding help should not be used in this situation. Modding Discussion would be appropriate, and Tutorial slightly more precise
math.pow is depreciated in LUA 5.3 edit: Easily remedied if you like. Code: math.pow = function(num, factor) return num^factor end