StendhalScripting/Lua: Difference between revisions
Content deleted Content added
imported>AntumDeluge →Data Types: string concatenation |
imported>AntumDeluge add categories |
||
| (12 intermediate revisions by the same user not shown) | |||
Line 278:
=== Add Zone Music ===
Music can be added to zones with the <code>
*
* <span style="color:darkgreen; font-style:italic;>args:</span> A table of key=value integers.
* Valid keys:
* ''x:'' (optional) The horizontal point for the source of the music.▼
** <span style="color:darkblue; font-style:italic;">volume:</span> Volume level (default: 100).
* ''y:'' (optional) The vertical point for the source of the music.▼
▲**
* ''radius:'' (optional) The radial range at which the music can be heard.▼
▲**
▲**
Example:
<pre>
if game:setZone("0_semos_plains_n") then
end
</pre>
Line 335 ⟶ 337:
}
▲ entities:setPath(npc, nodes)
-- Dialogue
Line 364 ⟶ 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 376 ⟶ 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 402 ⟶ 403:
ConversationPhrases.GREETING_MESSAGES,
{
},
ConversationStates.ATTENDING,
nil,
{
})
</pre>
Line 418 ⟶ 419:
<pre>
local conditions = {
{
},
}
Line 430 ⟶ 431:
nil,
{
})
</pre>
Line 528:
bestiary:setOwner("Ted")
</pre>
= See Also =
* [[StendhalScripting/LuaAPI|Lua API]]
[[Category:Stendhal]]
[[Category:Documentation]]
[[Category:API]]
[[Category:Scripting]]
[[Category:Lua]]
| |||