AI Lua API: Difference between revisions

From Off Grid Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
(6 intermediate revisions by 3 users not shown)
Line 4: Line 4:
API to control the logic of AI in the mission
API to control the logic of AI in the mission
== Functions ==
== Functions ==
=== Pause ===
<syntaxhighlight source lang="lua">AI.Pause(characterName)</syntaxhighlight>
'''Expected parameter types'''
{| class="wikitable"
|-
! Name !! Type
|-
| characterName || string
|}
'''Description''': Pauses the agent, and stops it from doing anything.
'''Returns''': Nothing
'''Notes''': The AI will be hidden from networks, meaning it will no longer interact with devices or send/receive messages.
=== Unpause ===
<syntaxhighlight source lang="lua">AI.Unpause(characterName)</syntaxhighlight>
'''Expected parameter types'''
{| class="wikitable"
|-
! Name !! Type
|-
| characterName || string
|}
'''Description''': Unpauses a hidden agent, resuming standard behaviour.
'''Returns''': Nothing
=== IsPaused ===
<syntaxhighlight source lang="lua">AI.IsPaused(characterName)</syntaxhighlight>
'''Expected parameter types'''
{| class="wikitable"
|-
! Name !! Type
|-
| characterName || string
|}
'''Description''': Returns a bool based on if a character is currently paused or not
'''Returns''': bool
=== AddGoal ===
<syntaxhighlight source lang="lua">AI.AddGoal(characterName, goal)</syntaxhighlight>
'''Expected parameter types'''
{| class="wikitable"
|-
! Name !! Type
|-
| characterName || string
|-
| goal || Lua Table
|}
'''Description''': Adds a defined goal
'''Returns''': Nothing
=== RemoveGoal ===
<syntaxhighlight source lang="lua">AI.RemoveGoal(characterName, goalName)</syntaxhighlight>
'''Expected parameter types'''
{| class="wikitable"
|-
! Name !! Type
|-
| characterName || string
|-
| goalName || string
|}
'''Description''': Removes any defined goals
'''Returns''': Nothing
=== AddTemporaryGoal ===
=== AddTemporaryGoal ===
<syntaxhighlight source lang="lua">AI.AddTemporaryGoal(characterName, goal)</syntaxhighlight>
<syntaxhighlight source lang="lua">AI.AddTemporaryGoal(characterName, goal)</syntaxhighlight>
Line 47: Line 117:
| state || string
| state || string
|-
|-
| value || bool
| value || Lua Type
|}
|}
'''Description''': Change the World State of an NPC.
'''Description''': Change the World State of an NPC.
Line 66: Line 136:
| permanent || bool
| permanent || bool
|}
|}
'''Description''': Reduce the cost of an AI using a particular Device
'''Description''': Reduce the cost of an AI using a particular Interest


'''Returns''': Nothing
'''Returns''': Nothing
Line 84: Line 154:
| permanent || bool
| permanent || bool
|}
|}
'''Description''': Increase the cost of an AI using a particular Device
'''Description''': Increase the cost of an AI using a particular Interest


'''Returns''': Nothing
'''Returns''': Nothing


'''Notes''': If permanent is false, the cost will revert to normal the next time this is successfully used
'''Notes''': If permanent is false, the cost will revert to normal the next time this is successfully used
=== ChangeSubject ===
<syntaxhighlight source lang="lua">AI.ChangeSubject(characterName, subject, value)</syntaxhighlight>
'''Expected parameter types'''
{| class="wikitable"
|-
! Name !! Type
|-
| characterName || string
|-
| subject || string
|-
| value || string
|}
'''Description''': Set the value of a particular subject, enabling Actions with Personality requirements
'''Returns''': Nothing
'''Notes''': value can be null or empty (to unset/reset the subject)
=== ReactTo ===
<syntaxhighlight source lang="lua">AI.ReactTo(characterName, subject, value)</syntaxhighlight>
'''Expected parameter types'''
{| class="wikitable"
|-
! Name !! Type
|-
| characterName || string
|-
| subject || string
|-
| value || string
|}
'''Description''': Much like ChangeSubject, but instead of enabling Actions, this will alter stats within the Agent, modifying its WorldState (and as a result, enabling Actions)
'''Returns''': Nothing
'''Notes''': value can be null or empty (to unset/reset the subject)
=== CreateReactable ===
=== CreateReactable ===
<syntaxhighlight source lang="lua">AI.CreateReactable(actionType, attraction, targetObject)</syntaxhighlight>
<syntaxhighlight source lang="lua">AI.CreateReactable(actionType, attraction, targetObject)</syntaxhighlight>
Line 118: Line 224:
|}
|}
'''Description''': Set NPC's computer, this will be used for a variety of actions
'''Description''': Set NPC's computer, this will be used for a variety of actions
'''Returns''': Nothing
=== AddAction ===
<syntaxhighlight source lang="lua">AI.AddAction(characterName, action)</syntaxhighlight>
'''Expected parameter types'''
{| class="wikitable"
|-
! Name !! Type
|-
| characterName || string
|-
| action || Lua Table
|}
'''Description''': Adds an action that can be used immediately
'''Returns''': Nothing
=== RemoveAction ===
<syntaxhighlight source lang="lua">AI.RemoveAction(characterName, actionName)</syntaxhighlight>
'''Expected parameter types'''
{| class="wikitable"
|-
! Name !! Type
|-
| characterName || string
|-
| actionName || string
|}
'''Description''': Removes any action


'''Returns''': Nothing
'''Returns''': Nothing
Line 125: Line 261:
This file is auto generated, please don't edit manually!
This file is auto generated, please don't edit manually!


'''Docs last hacked together on''': 02/11/2018 12:59
'''Docs last hacked together on''': 28/10/2020 18:12
[[Category:Modding]][[Category:LuaAPI]]
[[Category:Modding]][[Category:LuaAPI]]

Revision as of 18:13, 28 October 2020

AI

Description

API to control the logic of AI in the mission

Functions

Pause

AI.Pause(characterName)

Expected parameter types

Name Type
characterName string

Description: Pauses the agent, and stops it from doing anything.

Returns: Nothing

Notes: The AI will be hidden from networks, meaning it will no longer interact with devices or send/receive messages.

Unpause

AI.Unpause(characterName)

Expected parameter types

Name Type
characterName string

Description: Unpauses a hidden agent, resuming standard behaviour.

Returns: Nothing

IsPaused

AI.IsPaused(characterName)

Expected parameter types

Name Type
characterName string

Description: Returns a bool based on if a character is currently paused or not

Returns: bool

AddGoal

AI.AddGoal(characterName, goal)

Expected parameter types

Name Type
characterName string
goal Lua Table

Description: Adds a defined goal

Returns: Nothing

RemoveGoal

AI.RemoveGoal(characterName, goalName)

Expected parameter types

Name Type
characterName string
goalName string

Description: Removes any defined goals

Returns: Nothing

AddTemporaryGoal

AI.AddTemporaryGoal(characterName, goal)

Expected parameter types

Name Type
characterName string
goal Lua Table

Description: Adds a goal, taking top priority, to the named AI

Returns: Nothing

Notes: This goal will be removed from the AI once complete. If it isn't achievable it will be removed immediately.

AlterNPCMotivation

AI.AlterNPCMotivation(characterName, motivationDelta)

Expected parameter types

Name Type
characterName string
motivationDelta number

Description: Alters an NPCS motivation state

Returns: Nothing

Notes: When an NPCs motivation hits 0, they're no longer motivated and will attempt to take a break

AlterNPCWorldState

AI.AlterNPCWorldState(characterName, state, value)

Expected parameter types

Name Type
characterName string
state string
value Lua Type

Description: Change the World State of an NPC.

Returns: Nothing

FavourInterest

AI.FavourInterest(characterName, device, permanent)

Expected parameter types

Name Type
characterName string
device string
permanent bool

Description: Reduce the cost of an AI using a particular Interest

Returns: Nothing

Notes: If permanent is false, the cost will revert to normal the next time this is successfully used

AvoidInterest

AI.AvoidInterest(characterName, device, permanent)

Expected parameter types

Name Type
characterName string
device string
permanent bool

Description: Increase the cost of an AI using a particular Interest

Returns: Nothing

Notes: If permanent is false, the cost will revert to normal the next time this is successfully used

ChangeSubject

AI.ChangeSubject(characterName, subject, value)

Expected parameter types

Name Type
characterName string
subject string
value string

Description: Set the value of a particular subject, enabling Actions with Personality requirements

Returns: Nothing

Notes: value can be null or empty (to unset/reset the subject)

ReactTo

AI.ReactTo(characterName, subject, value)

Expected parameter types

Name Type
characterName string
subject string
value string

Description: Much like ChangeSubject, but instead of enabling Actions, this will alter stats within the Agent, modifying its WorldState (and as a result, enabling Actions)

Returns: Nothing

Notes: value can be null or empty (to unset/reset the subject)

CreateReactable

AI.CreateReactable(actionType, attraction, targetObject)

Expected parameter types

Name Type
actionType AIReaction+Type
attraction number
targetObject MissionObject

Description: Create a new distraction that AI can pick up on

Returns: Nothing

SetNPCFavouredComputer

AI.SetNPCFavouredComputer(characterName, computer)

Expected parameter types

Name Type
characterName string
computer MissionObject

Description: Set NPC's computer, this will be used for a variety of actions

Returns: Nothing

AddAction

AI.AddAction(characterName, action)

Expected parameter types

Name Type
characterName string
action Lua Table

Description: Adds an action that can be used immediately

Returns: Nothing

RemoveAction

AI.RemoveAction(characterName, actionName)

Expected parameter types

Name Type
characterName string
actionName string

Description: Removes any action

Returns: Nothing


This file is auto generated, please don't edit manually!

Docs last hacked together on: 28/10/2020 18:12