Phystus
August 21st, 2012, 03:19
I'm trying to create an extension for 3.5e to add a slash command to import NPC's, similar to the one to import characters. I've got it calling the file dialog, and returning a message that it has imported the NPC, but nothing shows up in the db.
Here's the code I've got:
In manager_chat.lua, I register the slashhandler, and add the process it defines.
function onInit()
if User.isHost() then
Module.onActivationRequested = moduleActivationRequested;
end
Module.onUnloadedReference = moduleUnloadedReference;
Comm.registerSlashHandler("die", processDie);
Comm.registerSlashHandler("mod", processMod);
if User.isHost() then
Comm.registerSlashHandler("importchar", processImport);
Comm.registerSlashHandler("exportchar", processExport);
Comm.registerSlashHandler("importnpc", processImportnpc);
end
end
...
function processImportnpc(sCommand, sParams)
CharManager.importNPC();
end
In manager_char.lua I define the importNPC function:
function importNPC()
local sFile = Interface.dialogFileOpen();
if sFile then
DB.import(sFile, "npc", "category");
ChatManager.SystemMessage("Imported NPC(s) from: " .. sFile);
end
end
I get the file dialog and the system message just fine, but nothing is saved in the database. So I think the 3rd argument of the DB.import call is incorrect, but I can't find what the correct value would be. Any ideas?
Thanks in advance,
~P
Here's the code I've got:
In manager_chat.lua, I register the slashhandler, and add the process it defines.
function onInit()
if User.isHost() then
Module.onActivationRequested = moduleActivationRequested;
end
Module.onUnloadedReference = moduleUnloadedReference;
Comm.registerSlashHandler("die", processDie);
Comm.registerSlashHandler("mod", processMod);
if User.isHost() then
Comm.registerSlashHandler("importchar", processImport);
Comm.registerSlashHandler("exportchar", processExport);
Comm.registerSlashHandler("importnpc", processImportnpc);
end
end
...
function processImportnpc(sCommand, sParams)
CharManager.importNPC();
end
In manager_char.lua I define the importNPC function:
function importNPC()
local sFile = Interface.dialogFileOpen();
if sFile then
DB.import(sFile, "npc", "category");
ChatManager.SystemMessage("Imported NPC(s) from: " .. sFile);
end
end
I get the file dialog and the system message just fine, but nothing is saved in the database. So I think the 3rd argument of the DB.import call is incorrect, but I can't find what the correct value would be. Any ideas?
Thanks in advance,
~P