StendhalScripting/Lua: Difference between revisions
Content deleted Content added
imported>AntumDeluge →Add Zone Music: "setZoneMusic" replaced with "game:setMusic" |
imported>AntumDeluge add categories |
||
| (8 intermediate revisions by the same user not shown) | |||
Line 337:
}
▲ entities:setPath(npc, nodes)
-- Dialogue
Line 366 ⟶ 365:
This simply adds a response to saying "hello" & sets the NPC to attend to the player (equivalent of <code>frank:addGreeting("Hello")</code>).
For more complicated behavior, we need to use some helper methods. If we want to check a condition we use the <code>
Example:
<pre>
frank:add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
ConversationStates.ATTENDING,
"Hello.",
Line 378 ⟶ 379:
In this scenario, the NPC will only respond if the player is carrying <item>money</item>.
A NotCondition instance can be created with the <code>
Example usage:
<pre>
local condition = conditions.
▲local condition = conditions.not(newCondition("PlayerHasItemWithHimCondition", "money")
</pre>
To add a ChatAction, we use the <code>
Example:
<pre>
frank:add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
ConversationStates.ATTENDING,
"Hello.",
</pre>
Line 404 ⟶ 403:
ConversationPhrases.GREETING_MESSAGES,
{
},
ConversationStates.ATTENDING,
nil,
{
})
</pre>
Line 420 ⟶ 419:
<pre>
local conditions = {
{
},
}
Line 432 ⟶ 431:
nil,
{
})
</pre>
Line 534 ⟶ 532:
* [[StendhalScripting/LuaAPI|Lua API]]
[[Category:Stendhal]]
[[Category:Documentation]]
[[Category:API]]
[[Category:Scripting]]
[[Category:Lua]]
| |||