Skip to content

Logic - Functions Module

anvil.api.logic.functions

Function

Bases: AddonObject

add_to_setup property

Adds the function to the setup function. Meaning this will run when your execute your setup function.

execute property

Returns the execute command of the function.

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

path property

Gets the path of the function. To use this properly, the function must be queued.

tick property

Adds the function to the tick.json file.

__init__(name)

Inintializes the Function class. The function is limited to 10000 commands. If you exceed this limit, the function will be split into multiple functions.

Parameters:

Name Type Description Default
name str

The name of the function.

required

__len__()

Returns the number of commands in the function.

add(*commands)

Adds a command to the function.

content(content)

Sets the content of the addon object and returns the object.

Parameters:

Name Type Description Default
content any

The content to be set for the addon object.

required

Returns:

Name Type Description
self AddonObject

The instance of the current AddonObject.

do_not_shorten()

Setter property that disables shortening of dict when exporting.

queue(directory=None)

Queues the function to be exported.

Parameters:

Name Type Description Default
directory str

The directory to queue the function to. Defaults to None.

None

Tick

Bases: AddonObject

Handles tick functions for the addon.

Attributes:

Name Type Description
_functions list

Stores all the tick functions.

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

queue property

Generates the content and queues the functions.

Returns:

Name Type Description
object

The parent's queue method result.

__init__()

Initializes a _Tick instance.

add_function(*functions)

Adds the provided functions to the tick function list.

Parameters:

Name Type Description Default
functions Function

Functions to add to the list.

()

content(content)

Sets the content of the addon object and returns the object.

Parameters:

Name Type Description Default
content any

The content to be set for the addon object.

required

Returns:

Name Type Description
self AddonObject

The instance of the current AddonObject.

do_not_shorten()

Setter property that disables shortening of dict when exporting.