Page 1 of 1

How do I?: Wire an NPC

Posted: Wed Aug 15, 2012 10:29 am
by msulli1355
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...

Re: How do I?: Wire an NPC

Posted: Wed Aug 15, 2012 10:32 am
by msulli1355
Looking at my server output I do now see:

[10:10:38][Error] luautils::OnTrigger: scripts/zones/Port_Windurst/npcs/Mhoji_Roccoruh.lua:99: 'end' expected (to close 'function' at line 66) near '<eof>'


So it's probable that I need to end my function. I'll go back and look.

Re: How do I?: Wire an NPC

Posted: Wed Aug 15, 2012 10:37 am
by msulli1355
That fixed it. She'll talk to me now. She offers me a map of the Windurst area for 200g and a map of Castle Oztroja for 3000g. The problem I'm having now is that I already have those maps and she still offers them. How would I go about fixing that?

Re: How do I?: Wire an NPC

Posted: Wed Aug 15, 2012 5:19 pm
by bluekirby0
I haven't tested that particular event but I'm going to guess that your

Code: Select all

if player:hasKeyItem(MAP_OF_THE_SANDORIA_AREA) then
    mapVar = mapVar + 4;
end
should read

Code: Select all

if(player:hasKeyItem(MAP_OF_THE_SANDORIA_AREA) == false) then
    mapVar = mapVar + 4;
end
or to further simplify the code:

Code: Select all

if(player:hasKeyItem(MAP_OF_THE_SANDORIA_AREA) == false)
    mapVar = mapVar + 4;

Re: How do I?: Wire an NPC

Posted: Wed Sep 05, 2012 8:56 am
by msulli1355
WTF? Can we do anything about zddxkmczda? Pretty sure it's a spambot...