StendhalScripting/Lua: Difference between revisions
Content deleted Content added
imported>AntumDeluge →Add Zone Music: "setZoneMusic" replaced with "game:setMusic" |
imported>AntumDeluge →Adding Transitions: "newAction", "newCondition", & "newNotCondition" replaced by member methods of "actions" & "conditions" objects |
||
Line 366:
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 ⟶ 380:
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:
ConversationPhrases.GREETING_MESSAGES,
{
},
ConversationStates.ATTENDING,
nil,
{
})
</pre>
Line 420:
<pre>
local conditions = {
{
},
}
Line 432:
nil,
{
})
</pre>
| |||