StendhalScripting/LuaAPI: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
imported>AntumDeluge
SkinColor: example usage
imported>AntumDeluge
add scripting category
 
(8 intermediate revisions by the same user not shown)
Line 65: Line 65:


Defines functions for accessing Java system properties.
Defines functions for accessing Java system properties.

Methods:

; ''<span style="color:green;">properties:getValue</span>(p)''
: Retrieves the value of a property.
: '''''p:''''' (string) Property name.
: '''''returns:''''' (string) Property value or `nil`.

; ''<span style="color:green;">properties:enabled</span>(p)''
: Checks if a property is enabed.
: '''''p:''''' (string) Property name.
: '''''returns:''''' (boolean) `true` if enabled.

; ''<span style="color:green;">properties:equals</span>(p, v)''
: Checks if a property is set to a specified value.
: '''''p:''''' (string) Property name.
: '''''v:''''' (string) Value to compare with.
: '''''returns:''''' (boolean) `true` if the value of the property is the same as `v`.

Examples usage:

<pre>
-- example of only executing script contents on test server

if not properties:enabed("stendhal.testserver") then
do return end
end
</pre>


== game ==
== game ==
Line 593: Line 621:


The {{StendhalFile|master|src/games/stendhal/server/entity/npc/ConversationStates.java|games.stendhal.server.entity.npc.ConversationStates}} enum.
The {{StendhalFile|master|src/games/stendhal/server/entity/npc/ConversationStates.java|games.stendhal.server.entity.npc.ConversationStates}} enum.

Example usage:
<pre>
local npc = entities:createSpeakerNPC("foo")
npc:setCurrentState(ConversationStates.IDLE)
</pre>


== ConversationPhrases ==
== ConversationPhrases ==


The {{StendhalFile|master|src/games/stendhal/server/entity/npc/ConversationPhrases.java|games.stendhal.server.entity.npc.ConversationPhrases}} class.
The {{StendhalFile|master|src/games/stendhal/server/entity/npc/ConversationPhrases.java|games.stendhal.server.entity.npc.ConversationPhrases}} class.

Example usage:
<pre>
local npc = entities:createSpeakerNPC("foo")
npc:add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
nil,
ConversationStates.ATTENDING,
"Hello! How can I help you.",
nil)
</pre>


== CollisionAction ==
== CollisionAction ==


The {{StendhalFile|master|src/games/stendhal/server/entity/CollisionAction.java|games.stendhal.server.entity.CollisionAction}} enum.
The {{StendhalFile|master|src/games/stendhal/server/entity/CollisionAction.java|games.stendhal.server.entity.CollisionAction}} enum.

Example usage:
<pre>
local npc = entities:createSilentNPC()
npc:setCollisionAction(CollisionAction.STOP)
</pre>


== SkinColor ==
== SkinColor ==
Line 616: Line 667:


The {{StendhalFile|master|src/games/stendhal/common/Direction.java|games.stendhal.common.Direction}} enum.
The {{StendhalFile|master|src/games/stendhal/common/Direction.java|games.stendhal.common.Direction}} enum.

Example usage:
<pre>
local npc = entities:createSpeakerNPC("foo")
npc:setDirection(Direction.DOWN)
</pre>


== DaylightPhase ==
== DaylightPhase ==
Line 632: Line 689:


The [https://docs.oracle.com/javase/8/docs/api/java/awt/Color.html java.awt.Color] class.
The [https://docs.oracle.com/javase/8/docs/api/java/awt/Color.html java.awt.Color] class.

Example usage:
<pre>
local npc = entities:createSpeakerNPC("foo")
npc:setOutfit("body=0,head=0,hair=3,dress=5")
npc:setOutfitColor("dress", Color.BLUE)
</pre>


= Supplemental Methods =
= Supplemental Methods =
Line 710: Line 774:
* [[StendhalScripting/Lua#Lua_Basics|Lua: Basics]]
* [[StendhalScripting/Lua#Lua_Basics|Lua: Basics]]
* [[StendhalScripting/Lua#Stendhal_Application|Lua: Stendhal Application]]
* [[StendhalScripting/Lua#Stendhal_Application|Lua: Stendhal Application]]


[[Category:Stendhal]]
[[Category:Documentation]]
[[Category:API]]
[[Category:Scripting]]
[[Category:Lua]]