The query module
Overview
API: query
all_objects_exists(the_set)
tests to see if all the objects in the set exist
Parameters:
Name | Type | Description | Default |
---|---|---|---|
the_set
|
set
|
A set, list or single object internally it will assure it is a list |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
False if any object does not exist, True if all exist |
get_comms_selection(id_or_not)
gets the id of the comms selection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_not
|
agent
|
agent id or object |
required |
Returns:
Type | Description |
---|---|
agent id | None: The agent id or None |
get_grid_selection(id_or_not)
gets the id of the engineering grid selection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_not
|
agent
|
agent id or object |
required |
Returns:
Type | Description |
---|---|
agent id | None: The agent id or None |
get_science_selection(id_or_not)
gets the id of the science selection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_not
|
agent
|
agent id or object |
required |
Returns:
Type | Description |
---|---|
agent id | None: The agent id or None |
get_side(id_or_obj)
gets the side of the agent
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_obj
|
agent
|
agent id or object |
required |
Returns:
Type | Description |
---|---|
str|None: the side |
get_weapons_selection(id_or_not)
gets the id of the weapons selection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_not
|
agent
|
agent id or object |
required |
Returns:
Type | Description |
---|---|
agent id | None: The agent id or None |
is_client_id(id)
checks if the agent is a client/console id
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
agent
|
Agent id or object |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
|
is_grid_object_id(id)
checks if the agent is a grid object id
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
agent
|
Agent id or object |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
grid object |
is_space_object_id(id)
checks if the agent is a space object id
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
agent
|
Agent id or object |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
true if it is a space object |
is_story_id(id)
checks if the agent is a story id
Note
Story agent are object not in the engine. e.g. Fleets
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
agent
|
Agent id or object |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
True if the agent is a story object |
is_task_id(id)
checks if the agent is a task id
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
agent
|
Agent id or object |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
True if the agent is a task |
object_exists(so_id)
check the engine to see if the item exists
Parameters:
Name | Type | Description | Default |
---|---|---|---|
so_id
|
agent
|
agent like data converted to id internally |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
if the object exists in the engine |
random_id(the_set)
get the object from the set provide
Parameters:
Name | Type | Description | Default |
---|---|---|---|
the_set
|
set
|
a set, list etc. of ids or agents |
required |
Returns:
Name | Type | Description |
---|---|---|
id |
The id of one of the objects |
random_object(the_set)
get the object from the set provide
Parameters:
Name | Type | Description | Default |
---|---|---|---|
the_set
|
set
|
a set, list etc. of ids or agents |
required |
Returns:
Name | Type | Description |
---|---|---|
agent |
The one of the objects |
random_object_list(the_set, count=1)
get a list of objects selected randomly from the set provided
Parameters:
Name | Type | Description | Default |
---|---|---|---|
the_set
|
set
|
Set of Ids |
required |
count
|
int
|
The number of objects to pick |
1
|
Returns:
Name | Type | Description |
---|---|---|
list |
A list of Agent |
safe_int(s, defa=0)
gets an integer or None for the passed data
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s
|
str
|
The source assumed str, but could also be a number |
required |
defa
|
int
|
What to return of cannot get an integer. Defaults to 0. |
0
|
Returns:
Name | Type | Description |
---|---|---|
int |
the integer or the default |
set_comms_selection(id_or_not, other_id_or_obj)
sets the id of the comms selection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_not
|
agent
|
agent id or object of the player ship |
required |
other_id_or_obj
|
The agent id or object target agent |
required |
set_grid_selection(id_or_not, other_id_or_obj)
sets the id of the engineering grid selection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_not
|
agent
|
agent id or object of the player ship |
required |
other_id_or_obj
|
The agent id or object target agent |
required |
set_science_selection(id_or_not, other_id_or_obj)
sets the id of the science selection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_not
|
agent
|
agent id or object of the player ship |
required |
other_id_or_obj
|
The agent id or object target agent |
required |
set_weapons_selection(id_or_not, other_id_or_obj)
sets the id of the weapons selection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_not
|
agent
|
agent id or object of the player ship |
required |
other_id_or_obj
|
The agent id or object target agent |
required |
to_blob(id_or_obj)
gets the engine dataset of the specified agent
Note
Same as to_data_set
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_obj
|
agent
|
Agent id or object |
required |
Returns:
Type | Description |
---|---|
data set| None: Returns the data or None if it does not exist |
to_data_set(id_or_obj)
gets the engine dataset of the specified agent
Note
Same as to_data_set
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_or_obj
|
agent
|
Agent id or object |
required |
Returns:
Type | Description |
---|---|
data set| None: Returns the data or None if it does not exist |
to_engine_object(id_or_obj)
converts the agent to get its engine object pointer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
agent
|
Agent id or object |
required |
Returns:
Name | Type | Description |
---|---|---|
pointer |
A C++ pointer to the engine object |
to_id(other)
converts item passed to an agent id
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
Agent | CloseData | int
|
The agent |
required |
Returns:
Name | Type | Description |
---|---|---|
id |
The agent id |
to_id_list(the_set)
converts a set to a list of ids
Parameters:
Name | Type | Description | Default |
---|---|---|---|
the_set
|
set | list
|
a set of agents or ids |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
of agent ids |
to_list(other)
converts a single object/id, set ot list of things to a list
Parameters:
Name | Type | Description | Default |
---|---|---|---|
the_set
|
set | list
|
a set of agent ids |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
containing whatever was passed in |
to_object(other)
converts the item passed to an agent
Note
Retrun of None could mean the agent no longer exists
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
Agent | CloseData | int
|
The agent ID or other agent like data |
required |
Returns:
Type | Description |
---|---|
agent | None: The agent or None |
to_object_list(the_set)
to_object_list converts a set to a list of objects
Parameters:
Name | Type | Description | Default |
---|---|---|---|
the_set
|
set | list
|
a set of agent ids |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
of Agents |
to_py_object_list(the_set)
to_py_object_list
converts a set of ids to a set of objects
Returns:
Type | Description |
---|---|
list Agent |
to_set(other)
converts a single object/id, set ot list of things to a set of ids
Parameters:
Name | Type | Description | Default |
---|---|---|---|
the_set
|
set
|
set, list or single item |
required |
Returns:
Type | Description |
---|---|
set of things |