How do I?: Wire an NPC
Posted: Wed Aug 15, 2012 10:29 am
I'm trying to wire up Mhoji Roccoruh in Port Windurst to sell me maps of the Windurst regions, but I'm having trouble. I've copied the lua file based on Elesca in Northern San d'Oria to /home/work/trunk/scripts/zones/Port_Windurst/npcs/Mhoji_Roccoruh.lua, and changed stuff to reflect her new location and maps she offers, but she still won't talk to me. Here's my script:
michael@carter /home/work/trunk/scripts/zones/Port_Windurst/npcs $ cat Mhoji_Roccoruh.lua
-----------------------------------
-- Area: Port Windurst
-- NPC: Mhoji Roccoruh
-- Map Seller NPC
-----------------------------------
package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/zones/Port_Windurst/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
mapVar = 0;
if player:hasKeyItem(MAP_OF_THE_SANDORIA_AREA) then
mapVar = mapVar + 4;
end
if player:hasKeyItem(MAP_OF_THE_BASTOK_AREA) then
mapVar = mapVar + 8;
end
if player:hasKeyItem(MAP_OF_THE_JEUNO_AREA) then
mapVar = mapVar + 32;
end
if player:hasKeyItem(MAP_OF_GIDDEUS) then
mapVar = mapVar + 64;
end
if player:hasKeyItem(MAP_OF_MAZE_OF_SHAKHRAMI) then
mapVar = mapVar + 128;
end
if player:hasKeyItem(MAP_OF_CASTLE_OZTROJA) then
mapVar = mapVar + 256;
end
if player:hasKeyItem(MAP_OF_THE_WINDURST_AREA) then
mapVar = mapVar + 512;
end
player:startEvent(0x2710, mapVar);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID2: %u",csid);
--printf("RESULT2: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
keyItem = option;
gil = 0;
if (csid==0x2710 and option ~= 1073741824) then
if option == MAP_OF_THE_SANDORIA_AREA then
gil = 200;
elseif option == MAP_OF_THE_BASTOK_AREA then
gil = 200;
elseif option == MAP_OF_THE_WINDURST_AREA then
gil = 200;
elseif option == MAP_OF_THE_JEUNO_AREA then
gil = 600;
elseif option == MAP_OF_GIDDEUS then
gil = 600;
elseif option == MAP_OF_MAZE_OF_SHAKHRAMI then
gil = 600;
elseif option == MAP_OF_CASTLE_OZTROJA then
gil = 3000;
if (gil > 0 and player:getGil() >= gil) then
player:setGil(player:getGil() - gil);
player:addKeyItem(option);
player:messageSpecial(KEYITEM_OBTAINED,keyItem);
else
player:messageSpecial(6572);
end
end
end;
Is this not correct? This is my first attempt at scripting so any help would be greatly appreciated...
michael@carter /home/work/trunk/scripts/zones/Port_Windurst/npcs $ cat Mhoji_Roccoruh.lua
-----------------------------------
-- Area: Port Windurst
-- NPC: Mhoji Roccoruh
-- Map Seller NPC
-----------------------------------
package.loaded["scripts/zones/Port_Windurst/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/zones/Port_Windurst/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
mapVar = 0;
if player:hasKeyItem(MAP_OF_THE_SANDORIA_AREA) then
mapVar = mapVar + 4;
end
if player:hasKeyItem(MAP_OF_THE_BASTOK_AREA) then
mapVar = mapVar + 8;
end
if player:hasKeyItem(MAP_OF_THE_JEUNO_AREA) then
mapVar = mapVar + 32;
end
if player:hasKeyItem(MAP_OF_GIDDEUS) then
mapVar = mapVar + 64;
end
if player:hasKeyItem(MAP_OF_MAZE_OF_SHAKHRAMI) then
mapVar = mapVar + 128;
end
if player:hasKeyItem(MAP_OF_CASTLE_OZTROJA) then
mapVar = mapVar + 256;
end
if player:hasKeyItem(MAP_OF_THE_WINDURST_AREA) then
mapVar = mapVar + 512;
end
player:startEvent(0x2710, mapVar);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID2: %u",csid);
--printf("RESULT2: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
keyItem = option;
gil = 0;
if (csid==0x2710 and option ~= 1073741824) then
if option == MAP_OF_THE_SANDORIA_AREA then
gil = 200;
elseif option == MAP_OF_THE_BASTOK_AREA then
gil = 200;
elseif option == MAP_OF_THE_WINDURST_AREA then
gil = 200;
elseif option == MAP_OF_THE_JEUNO_AREA then
gil = 600;
elseif option == MAP_OF_GIDDEUS then
gil = 600;
elseif option == MAP_OF_MAZE_OF_SHAKHRAMI then
gil = 600;
elseif option == MAP_OF_CASTLE_OZTROJA then
gil = 3000;
if (gil > 0 and player:getGil() >= gil) then
player:setGil(player:getGil() - gil);
player:addKeyItem(option);
player:messageSpecial(KEYITEM_OBTAINED,keyItem);
else
player:messageSpecial(6572);
end
end
end;
Is this not correct? This is my first attempt at scripting so any help would be greatly appreciated...