I'm working atm on coding some cool addons and some userscripts for MM.
I have a solid coding knowledge and just "learned" LUA in 3-4 days (I'm still improving and learning of course)
The reason of this post is that I don't understand why some script is working in Scite (LUA Editor/Debugger) and not in RoM.
By example "require" is returning a nil value when executing the script via RoM. But "require" is a valid LUA built-in function

It's maybe not super clear, then I'll give an example. In this script I'm just sending the Mob ID using the RoM API.
The idea is to get drops of the mob and displaying it into the Chat window. The script is doing more (like adding drops to the table when the combo mobid+itemid doesn't exist, and so on...)
Code: Select all
function GetMobDrops(MobID)
-- loading the MySQL dll
assert (package.loadlib ("luasql/mysql.dll", "luaopen_luasqlmysql")) ()
env = assert(luasql.mysql())
con = assert(env:connect("RoM_db","user","pass","localhost","3306"))
cur = assert (con:execute"SELECT mob_id, mob_name, item_name FROM mob_drops WHERE `mob_id` = '"..MobID.."'")
row = cur:fetch ({}, "a")
while row do
local OutputMessage = string.format("%s drops: %s", row.mob_name, row.item_name)
DEFAULT_CHAT_FRAME:AddMessage(OutputMessage);
row = cur:fetch (row, "a")
end
cur:close()
con:close()
env:close()
end
When i'm executing this (and replacing DEFAULT_CHAT_FRAME:AddMessage(OutputMessage); by print(OutputMessage);) in Scite, I got a correct output like:
My question is: Why it's not working when executing this script from the game?Scite Debugger wrote: MobSomething drops: SomeItem
MobSomething drops: AnotherItem
...
I have LUA installed on my PC and every librairies I need are installed as well.
Thanks a LOT for your help.