StendhalScripting/LuaAPI: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
imported>AntumDeluge
conditions: conditions:notCondition argument can be LuaFunction
imported>AntumDeluge
entities: LuaSpeakerNPC & LuaSilentNPC
Line 183: Line 183:
: Retrieves an existing SpeakerNPC.
: Retrieves an existing SpeakerNPC.
: '''''name:''''' (<code>String</code>) Name of NPC.
: '''''name:''''' (<code>String</code>) Name of NPC.
: ''returns:'' {{StendhalFile|master|src/games/stendhal/server/entity/npc/SpeakerNPC.java|SpeakerNPC}} instance or <code>null</code>.
: ''returns:'' {{StendhalFile|master|src/games/stendhal/server/entity/npc/SpeakerNPC.java|SpeakerNPC}} instance or <code>null</code> ('''FIXME:''' this should return <code>LuaSpeakerNPC</code>).


; ''<span style="color:green">entities:getItem</span>(name)''
; ''<span style="color:green">entities:getItem</span>(name)''
Line 198: Line 198:
: Creates an interactive NPC.
: Creates an interactive NPC.
: '''''name:''''' (<code>String</code>) Name of new NPC.
: '''''name:''''' (<code>String</code>) Name of new NPC.
: ''returns:'' New {{StendhalFile|master|src/games/stendhal/server/entity/npc/SpeakerNPC.java|SpeakerNPC}} instance.
: ''returns:'' New [[StendhalScripting/LuaAPI#LuaSpeakerNPC|SpeakerNPC]] instance.


; ''<span style="color:green">entities:createSilentNPC</span>()''
; ''<span style="color:green">entities:createSilentNPC</span>()''
: Creates a non-interactive NPC.
: Creates a non-interactive NPC.
: ''returns:'' New {{StendhalFile|master|src/games/stendhal/server/entity/npc/SilentNPC.java|SilentNPC}} instance.
: ''returns:'' New [[StendhalScripting/LuaAPI#LuaSilentNPC|SilentNPC]] instance.


; ''<span style="color:green">entities:setPath</span>(entity, table, loop)''
; ''<span style="color:green">entities:setPath</span>(entity, table, loop)''
Line 241: Line 241:
:: ''<span style="color:blue;">summoner:</span>'' (<code>string</code>) (optional) Name of entity doing the summoning (used for logging game events).
:: ''<span style="color:blue;">summoner:</span>'' (<code>string</code>) (optional) Name of entity doing the summoning (used for logging game events).
:: ''<span style="color:blue;">raid:</span>'' (<code>bool</code>) (optional) Whether or not the creature should be a <code>RaidCreature</code> instance (default: true).
:: ''<span style="color:blue;">raid:</span>'' (<code>bool</code>) (optional) Whether or not the creature should be a <code>RaidCreature</code> instance (default: true).

=== Lua Entity Classes ===

==== LuaSpeakerNPC ====

* Inherits: [[StendhalAPI#SpeakerNPC|SpeakerNPC]]

Public methods:

{{PublicMethod | add | params=states, triggers, conditions, nextState, reply, actions | desc=Additional method to support passing Lua data types as parameters. | paramlist=
{{MethodParam | states | desc=The conversation state(s) the entity should be in to trigger response. Can be [[StendhalAPI#ConversationStates|ConversationStates enum]] value or <code>LuaTable</code> of ConversationStates. }}
{{MethodParam | triggers | desc=<code>String</code> or <code>LuaTable</code> of strings to trigger response. }}
{{MethodParam | conditions | desc=Conditions to check for this response. Can be [[StendhalAPI#ChatCondition|ChatCondition instance]], a <code>LuaTable</code> of ChatCondition instances, or a function. }}
{{MethodParam | nextState | type=ConversationState | desc=Conversation state to set entity to after response. }}
{{MethodParam | reply | type=String | desc=The NPC's response or <code>null</code>. }}
{{MethodParam | actions | desc=Actions to execute. Can be [[StendhalAPI#ChatAction|ChatAction instance]], a <code>LuaTable</code> of ChatAction instances, or a function. }} }}

{{PublicMethod | setPath | params=table, loop | desc=Set a path for this entity to follow. | paramlist=
{{MethodParam | table | type=table | desc=Table of coordinates to set as path. Example: <code>{{35, 79}, {35, 89}, {40, 89}}</code> }}
{{MethodParam | loop | type=boolean | desc=(optional) If <code>true</code>, entity should loop around to restart path when reaching the end. }} }}

{{PublicMethod | setPathAndPosition | params=table, loop | desc=Set path & starting position for entity. The starting position is the first node in the path. | paramlist=
{{MethodParam | table | type=table | desc=Table of coordinates to set as path. Example: <code>{{35, 79}, {35, 89}, {40, 89}}</code> }}
{{MethodParam | loop | type=boolean | desc=(optional) If <code>true</code>, entity should loop around to restart path when reaching the end. }} }}

==== LuaSilentNPC ====

* Inherits: [[StendhalAPI#SilentNPC|SilentNPC]]

Public methods:

{{PublicMethod | setPath | params=table, loop | desc=Set a path for this entity to follow. | paramlist=
{{MethodParam | table | type=table | desc=Table of coordinates to set as path. Example: <code>{{35, 79}, {35, 89}, {40, 89}}</code> }}
{{MethodParam | loop | type=boolean | desc=(optional) If <code>true</code>, entity should loop around to restart path when reaching the end. }} }}

{{PublicMethod | setPathAndPosition | params=table, loop | desc=Set path & starting position for entity. The starting position is the first node in the path. | paramlist=
{{MethodParam | table | type=table | desc=Table of coordinates to set as path. Example: <code>{{35, 79}, {35, 89}, {40, 89}}</code> }}
{{MethodParam | loop | type=boolean | desc=(optional) If <code>true</code>, entity should loop around to restart path when reaching the end. }} }}


=== entities.manager ===
=== entities.manager ===