ProjectEQ / projecteqquests

Quest scripts for ProjectEQ
http://projecteq.net
44 stars 78 forks source link

Lua math.random values need check #1379

Closed joligario closed 1 year ago

joligario commented 1 year ago

https://github.com/ProjectEQ/projecteqquests/blob/9302f35f04c386df998e1f58f0d89a71411cf93a/lua_modules/npc_ext.lua#L46

This call needs to be re-evaluated. In math.random(a, b), Lua will select a number from a up to b. If b is empty or lower than a, it will throw an error such as: quests/lua_modules/npc_ext.lua:46: bad argument #2 to 'random' (interval is empty) from the logs on Discord

cc: @fryguy503

fryguy503 commented 1 year ago

Thanks, I will take a look at the overall logic when I get a moment and re-write it. Looks like this was written to try and mirror step for step the perl version.

fryguy503 commented 1 year ago

Cleaned up the logic and added a quick flip for negative secondary roll arguments.

https://github.com/ProjectEQ/projecteqquests/commit/7e7d683