Update custom-tasks.rst
Fix some spacing typos to prevent mixed space/tab errors when copy/pasting into the Godot editor.
This commit is contained in:
parent
caff21137d
commit
9576cdc8e7
|
@ -54,13 +54,13 @@ Task anatomy
|
||||||
|
|
||||||
# Called each time this task is ticked (aka executed).
|
# Called each time this task is ticked (aka executed).
|
||||||
func _tick(delta: float) -> Status:
|
func _tick(delta: float) -> Status:
|
||||||
return SUCCESS
|
return SUCCESS
|
||||||
|
|
||||||
|
|
||||||
# Strings returned from this method are displayed as warnings in the editor.
|
# Strings returned from this method are displayed as warnings in the editor.
|
||||||
func _get_configuration_warnings() -> PackedStringArray:
|
func _get_configuration_warnings() -> PackedStringArray:
|
||||||
var warnings := PackedStringArray()
|
var warnings := PackedStringArray()
|
||||||
return warnings
|
return warnings
|
||||||
|
|
||||||
|
|
||||||
Example 1: A simple action
|
Example 1: A simple action
|
||||||
|
@ -81,16 +81,16 @@ Example 1: A simple action
|
||||||
|
|
||||||
# Called to generate a display name for the task (requires @tool).
|
# Called to generate a display name for the task (requires @tool).
|
||||||
func _generate_name() -> String:
|
func _generate_name() -> String:
|
||||||
return "SetVisible %s node_path: \"%s\"" % [visible, node_path]
|
return "SetVisible %s node_path: \"%s\"" % [visible, node_path]
|
||||||
|
|
||||||
|
|
||||||
# Called each time this task is ticked (aka executed).
|
# Called each time this task is ticked (aka executed).
|
||||||
func _tick(p_delta: float) -> Status:
|
func _tick(p_delta: float) -> Status:
|
||||||
var n: CanvasItem = agent.get_node_or_null(node_path)
|
var n: CanvasItem = agent.get_node_or_null(node_path)
|
||||||
if is_instance_valid(n):
|
if is_instance_valid(n):
|
||||||
n.visible = visible
|
n.visible = visible
|
||||||
return SUCCESS
|
return SUCCESS
|
||||||
return FAILURE
|
return FAILURE
|
||||||
|
|
||||||
|
|
||||||
Example 2: InRange condition
|
Example 2: InRange condition
|
||||||
|
@ -116,24 +116,24 @@ Example 2: InRange condition
|
||||||
|
|
||||||
# Called to generate a display name for the task.
|
# Called to generate a display name for the task.
|
||||||
func _generate_name() -> String:
|
func _generate_name() -> String:
|
||||||
return "InRange (%d, %d) of %s" % [distance_min, distance_max,
|
return "InRange (%d, %d) of %s" % [distance_min, distance_max,
|
||||||
LimboUtility.decorate_var(target_var)]
|
LimboUtility.decorate_var(target_var)]
|
||||||
|
|
||||||
|
|
||||||
# Called to initialize the task.
|
# Called to initialize the task.
|
||||||
func _setup() -> void:
|
func _setup() -> void:
|
||||||
_min_distance_squared = distance_min * distance_min
|
_min_distance_squared = distance_min * distance_min
|
||||||
_max_distance_squared = distance_max * distance_max
|
_max_distance_squared = distance_max * distance_max
|
||||||
|
|
||||||
|
|
||||||
# Called when the task is executed.
|
# Called when the task is executed.
|
||||||
func _tick(_delta: float) -> Status:
|
func _tick(_delta: float) -> Status:
|
||||||
var target: Node2D = blackboard.get_var(target_var, null)
|
var target: Node2D = blackboard.get_var(target_var, null)
|
||||||
if not is_instance_valid(target):
|
if not is_instance_valid(target):
|
||||||
return FAILURE
|
return FAILURE
|
||||||
|
|
||||||
var dist_sq: float = agent.global_position.distance_squared_to(target.global_position)
|
var dist_sq: float = agent.global_position.distance_squared_to(target.global_position)
|
||||||
if dist_sq >= _min_distance_squared and dist_sq <= _max_distance_squared:
|
if dist_sq >= _min_distance_squared and dist_sq <= _max_distance_squared:
|
||||||
return SUCCESS
|
return SUCCESS
|
||||||
else:
|
else:
|
||||||
return FAILURE
|
return FAILURE
|
||||||
|
|
Loading…
Reference in New Issue