msg response when player has item
Jamie Furlong
10 Apr 2024, 07:17Hi,
I am trying to change the response from an NPC if the player has an item. I know this is easy in Quest, but I am trying to implement this in QuestJS.
createItem("fisherman", NPC(true), {
loc:"end_of_the_dock",
synonyms:['man', 'fishermen'],
examine: "A weathered fisherman .",
sayResponses:[
{
regex:/^(hi|hello)$/,
id:"hello",
script:function() {
MSG-IF-HAS-OBJECT????
ELSE >msg("'Oh, hello there,' replies the fishermen.")
},
}
],
askOptions:[
{
test:function(p) { return p.text.match(/weather|sky/); },
MSG-IF-HAS-OBJECT????
ELSE > msg:"'Last night's squall was fierce ",
},
{
test:function(p) { return p.text.match(/fish/); },
msg:"'Just catching some bream '.",
},
Any help appreciated, thank you.
Jamie Furlong
10 Apr 2024, 14:40Hmmmm, I'm guessing it's a variation on this, found on the QuestJS wiki under the Respond function:
sayResponses:[
{
regex:/^(hi|hello)$/,
id:"hello",
script:function() {
msg("'Oh, hello there,' replies Lara.")
if (w.Kyle.isHere()) {
msg("'Have you two met before?' asks Kyle.")
w.Kyle.askQuestion("kyle_question")
}
},
}
],
Although I'm still unsure of the has item part.