Issue 315 (#341)

* feat: accept_input implemented

* feat: More fixes for accept_input and tests for it

* feat: play_snd implemented

* fix: Removed game_over and queue_animation commands

* docs: Automatic update of API docs

* fix: FIxes schedule_event command

* feat: Implemented slide and slide_block

* feat: Implemented turn_to

* docs: Automatic update of API docs

Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
Co-authored-by: dploeger <dploeger@users.noreply.github.com>
This commit is contained in:
Dennis Ploeger
2021-07-29 23:05:24 +02:00
committed by GitHub
parent df1ec0c814
commit 90f880d090
38 changed files with 622 additions and 480 deletions

View File

@@ -9,7 +9,6 @@
# skipped, but also initiate locked#### down cutscenes with accept_input # skipped, but also initiate locked#### down cutscenes with accept_input
# NONE in :setup and accept_input ALL later in :ready. # NONE in :setup and accept_input ALL later in :ready.
# #
# @STUB
# @ESC # @ESC
extends ESCBaseCommand extends ESCBaseCommand
class_name AcceptInputCommand class_name AcceptInputCommand
@@ -40,8 +39,12 @@ func validate(arguments: Array):
# Run the command # Run the command
func run(command_params: Array) -> int: func run(command_params: Array) -> int:
escoria.logger.report_errors( var mode = escoria.inputs_manager.INPUT_ALL
"accept_input: command not implemented", match command_params[0]:
[] "NONE":
) mode = escoria.inputs_manager.INPUT_NONE
return ESCExecution.RC_ERROR "SKIP":
mode = escoria.inputs_manager.INPUT_SKIP
escoria.inputs_manager.input_mode = mode
return ESCExecution.RC_OK

View File

@@ -1,29 +0,0 @@
# `game_over continue_enabled show_credits`
#
# Ends the game. Use the "continue_enabled" parameter to enable or disable the
# continue button in the main menu afterwards. The "show_credits" parameter
# loads the ui/end_credits scene if true. You can configure it to your regular
# credits scene if you want.
#
# @STUB
# @ESC
extends ESCBaseCommand
class_name GameOverCommand
# Return the descriptor of the arguments of this command
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
0,
[TYPE_BOOL, TYPE_BOOL],
[false, true]
)
# Run the command
func run(command_params: Array) -> int:
escoria.logger.report_errors(
"game_over: command not implemented",
[]
)
return ESCExecution.RC_ERROR

View File

@@ -1,10 +1,8 @@
# `play_snd object file [loop]` # `play_snd file [player]`
# #
# Plays the sound specificed with the "file" parameter on the object, without # Plays the sound specificed with the "file" parameter on the sound player
# blocking. You can play background sounds, eg. during scene changes, with # `player`, without blocking. (player defaults to bg_sound)
# `play_snd bg_snd res://...`
# #
# @STUB
# @ESC # @ESC
extends ESCBaseCommand extends ESCBaseCommand
class_name PlaySndCommand class_name PlaySndCommand
@@ -14,15 +12,31 @@ class_name PlaySndCommand
func configure() -> ESCCommandArgumentDescriptor: func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new( return ESCCommandArgumentDescriptor.new(
2, 2,
[TYPE_STRING, TYPE_STRING, TYPE_BOOL], [TYPE_STRING, TYPE_STRING],
[null, null, false] [null, "bg_sound"]
) )
# Validate wether the given arguments match the command descriptor
func validate(arguments: Array):
if not escoria.object_manager.has(arguments[0]):
escoria.logger.report_errors(
"play_snd: invalid sound player",
["Sound player %s not registered" % arguments[0]]
)
return false
if not ResourceLoader.exists(arguments[1]):
escoria.logger.report_errors(
"play_snd: invalid parameter",
["File %s not found" % arguments[1]]
)
return false
return .validate(arguments)
# Run the command # Run the command
func run(command_params: Array) -> int: func run(command_params: Array) -> int:
escoria.logger.report_errors( escoria.object_manager.get_object(command_params[1]).node.set_state(
"play_snd: command not implemented", command_params[0]
[]
) )
return ESCExecution.RC_ERROR return ESCExecution.RC_OK

View File

@@ -1,42 +0,0 @@
# `queue_animation object animation`
#
# Similar to queue_resource, queues the resources necessary to have an
# animation loaded on an item. The resource paths are taken from the item
# placeholders.
#
# @STUB
# @ESC
extends ESCBaseCommand
class_name QueueAnimationCommand
# Return the descriptor of the arguments of this command
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
2,
[TYPE_STRING, TYPE_STRING],
[null, null]
)
# Validate wether the given arguments match the command descriptor
func validate(arguments: Array):
if not escoria.object_manager.objects.has(arguments[0]):
escoria.logger.report_errors(
"queue_animation: invalid first object",
[
"Object with global id %s not found" % arguments[0]
]
)
return false
# TODO: Check if animation is valid
return .validate(arguments)
# Run the command
func run(command_params: Array) -> int:
escoria.logger.report_errors(
"queue_animation: command not implemented",
[]
)
return ESCExecution.RC_ERROR

View File

@@ -53,21 +53,6 @@ func run(command_params: Array) -> int:
if command_params.size() > 2: if command_params.size() > 2:
dialog_scene_name = command_params[2] dialog_scene_name = command_params[2]
# Manage translation/voice lines keys in the form of:
# line_key:"Default line text"
# If a line_key exists, we'll set it a label as it will automatically be
# translated
var dialog_key_line = command_params[1].split(":", true, 1)
if dialog_key_line.size() > 1:
dialog_key_line[1] = dialog_key_line[1].trim_prefix("\"")
dict = {
"key": dialog_key_line[0],
"line": dialog_key_line[1] if dialog_key_line.size() > 1 \
else dialog_key_line[0],
"ui": dialog_scene_name
}
escoria.current_state = escoria.GAME_STATE.DIALOG escoria.current_state = escoria.GAME_STATE.DIALOG
if !escoria.dialog_player: if !escoria.dialog_player:
@@ -80,6 +65,10 @@ func run(command_params: Array) -> int:
) )
return ESCExecution.RC_ERROR return ESCExecution.RC_ERROR
escoria.dialog_player.say(command_params[0], dict) escoria.dialog_player.say(
command_params[0],
dialog_scene_name,
command_params[1]
)
yield(escoria.dialog_player, "dialog_line_finished") yield(escoria.dialog_player, "dialog_line_finished")
return ESCExecution.RC_OK return ESCExecution.RC_OK

View File

@@ -20,7 +20,7 @@ func configure() -> ESCCommandArgumentDescriptor:
# Validate wether the given arguments match the command descriptor # Validate wether the given arguments match the command descriptor
func validate(arguments: Array): func validate(arguments: Array):
if not escoria.object_manager.objects.has(arguments[1]): if not escoria.object_manager.has(arguments[1]):
escoria.logger.report_errors( escoria.logger.report_errors(
"sched_event: invalid object", "sched_event: invalid object",
[ [

View File

@@ -11,12 +11,16 @@ extends ESCBaseCommand
class_name SlideCommand class_name SlideCommand
# A hash of tweens currently active for animated items
var _tweens: Dictionary
# Return the descriptor of the arguments of this command # Return the descriptor of the arguments of this command
func configure() -> ESCCommandArgumentDescriptor: func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new( return ESCCommandArgumentDescriptor.new(
2, 2,
[TYPE_STRING, TYPE_STRING, TYPE_INT], [TYPE_STRING, TYPE_STRING, TYPE_INT],
[null, null, null] [null, null, -1]
) )
@@ -34,17 +38,64 @@ func validate(arguments: Array):
escoria.logger.report_errors( escoria.logger.report_errors(
"slide: invalid second object", "slide: invalid second object",
[ [
"Object with global id %s not found" % arguments[0] "Object with global id %s not found" % arguments[1]
] ]
) )
return false return false
return .validate(arguments) return .validate(arguments)
# Slide the object by generating a tween
#
# #### Parameters
#
# - source: The item to slide
# - destination: The destination item to slide to
# - speed: The speed at which to slide (will default to the
#
# **Returns** The generated (and started) tween
func _slide_object(
source: ESCObject,
destination: ESCObject,
speed: int = -1
) -> Tween:
if speed == -1:
speed = source.node.speed
if _tweens.has(source.global_id):
var tween = (_tweens.get(source.global_id) as Tween)
tween.stop_all()
if (escoria.main as Node).has_node(tween.name):
(escoria.main as Node).remove_child(tween)
var tween = Tween.new()
(escoria.main as Node).add_child(tween)
var duration = source.node.position.distance_to(
destination.node.position
) / speed
tween.interpolate_property(
source.node,
"global_position",
source.node.global_position,
destination.node.global_position,
duration
)
tween.start()
_tweens[source.global_id] = tween
return tween
# Run the command # Run the command
func run(command_params: Array) -> int: func run(command_params: Array) -> int:
escoria.logger.report_errors( _slide_object(
"slide: command not implemented", escoria.object_manager.get_object(command_params[0]),
[] escoria.object_manager.get_object(command_params[1]),
command_params[2]
) )
return ESCExecution.RC_ERROR return ESCExecution.RC_OK

View File

@@ -7,44 +7,16 @@
# #
# @STUB # @STUB
# @ESC # @ESC
extends ESCBaseCommand extends SlideCommand
class_name SlideBlockCommand class_name SlideBlockCommand
# Return the descriptor of the arguments of this command
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
2,
[TYPE_STRING, TYPE_STRING, TYPE_INT],
[null, null, null]
)
# Validate wether the given arguments match the command descriptor
func validate(arguments: Array):
if not escoria.object_manager.objects.has(arguments[0]):
escoria.logger.report_errors(
"slide_block: invalid first object",
[
"Object with global id %s not found" % arguments[0]
]
)
return false
if not escoria.object_manager.objects.has(arguments[1]):
escoria.logger.report_errors(
"slide_block: invalid second object",
[
"Object with global id %s not found" % arguments[0]
]
)
return false
return .validate(arguments)
# Run the command # Run the command
func run(command_params: Array) -> int: func run(command_params: Array) -> int:
escoria.logger.report_errors( var tween = _slide_object(
"slide_block: command not implemented", escoria.object_manager.get_object(command_params[0]),
[] escoria.object_manager.get_object(command_params[1]),
command_params[2]
) )
return ESCExecution.RC_ERROR yield(tween, "tween_all_completed")
return ESCExecution.RC_OK

View File

@@ -1,4 +1,4 @@
# `turn_to object degrees` # `turn_to object degrees [immediate]`
# #
# Turns object to a degrees angle with a directions animation. # Turns object to a degrees angle with a directions animation.
# #
@@ -7,6 +7,9 @@
# defined in animations. object must be player or interactive. degrees must # defined in animations. object must be player or interactive. degrees must
# be between [0, 360] or an error is reported. # be between [0, 360] or an error is reported.
# #
# Set immediate to true to show directly switch to the direction and not
# show intermediate angles
#
# @STUB # @STUB
# @ESC # @ESC
extends ESCBaseCommand extends ESCBaseCommand
@@ -17,8 +20,8 @@ class_name TurnToCommand
func configure() -> ESCCommandArgumentDescriptor: func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new( return ESCCommandArgumentDescriptor.new(
2, 2,
[TYPE_STRING, TYPE_INT], [TYPE_STRING, TYPE_INT, TYPE_BOOL],
[null, true] [null, null, false]
) )
@@ -32,13 +35,22 @@ func validate(arguments: Array):
] ]
) )
return false return false
if arguments[1] < 0 or arguments[1] > 360:
escoria.logger.report_errors(
"turn_to: invalid degrees",
[
"Degree %d not between 0 and 360" % arguments[1]
]
)
return false
return .validate(arguments) return .validate(arguments)
# Run the command # Run the command
func run(command_params: Array) -> int: func run(command_params: Array) -> int:
escoria.logger.report_errors( (escoria.object_manager.get_object(command_params[0]).node as ESCItem)\
"turn_to: command not implemented", .set_angle(
[] command_params[1],
) command_params[2]
return ESCExecution.RC_ERROR )
return ESCExecution.RC_OK

View File

@@ -15,3 +15,10 @@ var timeout: float
func _init(p_event: ESCEvent, p_timeout: float): func _init(p_event: ESCEvent, p_timeout: float):
self.event = p_event self.event = p_event
self.timeout = p_timeout self.timeout = p_timeout
# Run the event
#
# **Returns** The execution code
func run() -> int:
return event.run()

View File

@@ -318,7 +318,9 @@ func has_moved() -> bool:
# #
# #### Parameters # #### Parameters
# #
# Set the angle # - deg: The angle degree to set
# - immediate: Set the angle immediately. If false will show intermediate
# angles
func set_angle(deg: int, immediate = true): func set_angle(deg: int, immediate = true):
_movable.set_angle(deg, immediate) _movable.set_angle(deg, immediate)

View File

@@ -52,7 +52,7 @@ var main_menu_instance
var room_terrain var room_terrain
# Dialog player instantiator. This instance is called directly for dialogs. # Dialog player instantiator. This instance is called directly for dialogs.
var dialog_player var dialog_player: ESCDialogsPlayer
# Inventory scene # Inventory scene
var inventory var inventory
@@ -71,7 +71,7 @@ onready var game_size = get_viewport().size
onready var main = $main onready var main = $main
# The escoria inputs manager # The escoria inputs manager
onready var inputs_manager = $inputs_manager var inputs_manager: ESCInputsManager
# Savegames and settings manager # Savegames and settings manager
var save_manager: ESCSaveManager var save_manager: ESCSaveManager
@@ -92,6 +92,7 @@ func _init():
self.resource_cache = ESCResourceCache.new() self.resource_cache = ESCResourceCache.new()
self.resource_cache.start() self.resource_cache.start()
self.save_manager = ESCSaveManager.new() self.save_manager = ESCSaveManager.new()
self.inputs_manager = ESCInputsManager.new()
# Load settings # Load settings

View File

@@ -1,15 +1,11 @@
[gd_scene load_steps=4 format=2] [gd_scene load_steps=3 format=2]
[ext_resource path="res://addons/escoria-core/game/main.tscn" type="PackedScene" id=2] [ext_resource path="res://addons/escoria-core/game/main.tscn" type="PackedScene" id=2]
[ext_resource path="res://addons/escoria-core/game/escoria.gd" type="Script" id=3] [ext_resource path="res://addons/escoria-core/game/escoria.gd" type="Script" id=3]
[ext_resource path="res://addons/escoria-core/game/inputs_manager.gd" type="Script" id=5]
[node name="escoria" type="Node"] [node name="escoria" type="Node"]
script = ExtResource( 3 ) script = ExtResource( 3 )
[node name="inputs_manager" type="Node" parent="."]
script = ExtResource( 5 )
[node name="main" parent="." instance=ExtResource( 2 )] [node name="main" parent="." instance=ExtResource( 2 )]
[editable path="main"] [editable path="main"]

View File

@@ -1,14 +1,29 @@
# Escoria inputs manager # Escoria inputs manager
# Catches, handles and distributes input events for the game # Catches, handles and distributes input events for the game
tool
extends Node extends Node
class_name ESCInputsManager
# Valid input flags
# * INPUT_ALL: All input is allowed
# * INPUT_NONE: No input is allowed at all
# * INPUT_SKIP: Only skipping dialogs is allowed
enum {
INPUT_ALL,
INPUT_NONE,
INPUT_SKIP,
}
# The current input mode
var input_mode = INPUT_ALL
# A LIFO stack of hovered items # A LIFO stack of hovered items
onready var hover_stack: Array = [] var hover_stack: Array = []
# The global id fo the topmost item from the hover_stack # The global id fo the topmost item from the hover_stack
onready var hotspot_focused: String = "" var hotspot_focused: String = ""
# Input event handler # Input event handler
@@ -20,7 +35,7 @@ func _input(event: InputEvent) -> void:
if event.is_action_pressed("esc_show_debug_prompt"): if event.is_action_pressed("esc_show_debug_prompt"):
escoria.main.get_node("layers/debug_layer/esc_prompt_popup").popup() escoria.main.get_node("layers/debug_layer/esc_prompt_popup").popup()
if event.is_action_pressed("ui_cancel"): if input_mode == INPUT_ALL and event.is_action_pressed("ui_cancel"):
_on_pause_menu_requested() _on_pause_menu_requested()
if ProjectSettings.get_setting("escoria/ui/tooltip_follows_mouse"): if ProjectSettings.get_setting("escoria/ui/tooltip_follows_mouse"):
@@ -35,7 +50,7 @@ func _input(event: InputEvent) -> void:
# #
# - position: Position of the click # - position: Position of the click
func _on_left_click_on_bg(position: Vector2) -> void: func _on_left_click_on_bg(position: Vector2) -> void:
if hotspot_focused.empty(): if input_mode == INPUT_ALL and hotspot_focused.empty():
escoria.logger.info("Left click on background at ", [str(position)]) escoria.logger.info("Left click on background at ", [str(position)])
escoria.main.current_scene.game.left_click_on_bg(position) escoria.main.current_scene.game.left_click_on_bg(position)
@@ -46,8 +61,10 @@ func _on_left_click_on_bg(position: Vector2) -> void:
# #
# - position: Position of the click # - position: Position of the click
func _on_double_left_click_on_bg(position: Vector2) -> void: func _on_double_left_click_on_bg(position: Vector2) -> void:
if hotspot_focused.empty(): if input_mode == INPUT_ALL and hotspot_focused.empty():
escoria.logger.info("Double left click on background at ", [str(position)]) escoria.logger.info(
"Double left click on background at %s" % str(position)
)
escoria.main.current_scene.game.left_double_click_on_bg(position) escoria.main.current_scene.game.left_double_click_on_bg(position)
@@ -57,7 +74,7 @@ func _on_double_left_click_on_bg(position: Vector2) -> void:
# #
# - position: Position of the click # - position: Position of the click
func _on_right_click_on_bg(position: Vector2) -> void: func _on_right_click_on_bg(position: Vector2) -> void:
if hotspot_focused.empty(): if input_mode == INPUT_ALL and hotspot_focused.empty():
escoria.logger.info("Right click on background at ", [str(position)]) escoria.logger.info("Right click on background at ", [str(position)])
escoria.main.current_scene.game.right_click_on_bg(position) escoria.main.current_scene.game.right_click_on_bg(position)
@@ -68,9 +85,17 @@ func _on_right_click_on_bg(position: Vector2) -> void:
# #
# - inventory_item_global_id: The global id of the clicked inventory item # - inventory_item_global_id: The global id of the clicked inventory item
# - event: The input event received # - event: The input event received
func _on_mouse_left_click_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void: func _on_mouse_left_click_inventory_item(
escoria.logger.info("Inventory item left clicked ", [inventory_item_global_id]) inventory_item_global_id: String,
escoria.main.current_scene.game.left_click_on_inventory_item(inventory_item_global_id, event) event: InputEvent
) -> void:
escoria.logger.info(
"Inventory item left clicked %s " % inventory_item_global_id
)
escoria.main.current_scene.game.left_click_on_inventory_item(
inventory_item_global_id,
event
)
# An inventory item was clicked with the RMB # An inventory item was clicked with the RMB
@@ -79,9 +104,18 @@ func _on_mouse_left_click_inventory_item(inventory_item_global_id: String, event
# #
# - inventory_item_global_id: The global id of the clicked inventory item # - inventory_item_global_id: The global id of the clicked inventory item
# - event: The input event received # - event: The input event received
func _on_mouse_right_click_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void: func _on_mouse_right_click_inventory_item(
escoria.logger.info("Inventory item right clicked ", [inventory_item_global_id]) inventory_item_global_id: String,
escoria.main.current_scene.game.right_click_on_inventory_item(inventory_item_global_id, event) event: InputEvent
) -> void:
if input_mode == INPUT_ALL:
escoria.logger.info(
"Inventory item right clicked " % inventory_item_global_id
)
escoria.main.current_scene.game.right_click_on_inventory_item(
inventory_item_global_id,
event
)
# An inventory item was doublce-clicked with the LMB # An inventory item was doublce-clicked with the LMB
@@ -90,19 +124,33 @@ func _on_mouse_right_click_inventory_item(inventory_item_global_id: String, even
# #
# - inventory_item_global_id: The global id of the clicked inventory item # - inventory_item_global_id: The global id of the clicked inventory item
# - event: The input event received # - event: The input event received
func _on_mouse_double_left_click_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void: func _on_mouse_double_left_click_inventory_item(
escoria.logger.info("Inventory item double left clicked ", [inventory_item_global_id]) inventory_item_global_id: String,
escoria.main.current_scene.game.left_double_click_on_inventory_item(inventory_item_global_id, event) event: InputEvent
) -> void:
if input_mode == INPUT_ALL:
escoria.logger.info(
"Inventory item double left clicked " % inventory_item_global_id
)
escoria.main.current_scene.game.left_double_click_on_inventory_item(
inventory_item_global_id,
event
)
# The mouse entered an inventory item # The mouse entered an inventory item
# #
# #### Parameters # #### Parameters
# #
# - inventory_item_global_id: The global id of the inventory item that is hovered # - inventory_item_global_id: The global id of the inventory item
# that is hovered
func _on_mouse_entered_inventory_item(inventory_item_global_id: String) -> void: func _on_mouse_entered_inventory_item(inventory_item_global_id: String) -> void:
escoria.logger.info("Inventory item focused ", [inventory_item_global_id]) escoria.logger.info(
escoria.main.current_scene.game.inventory_item_focused(inventory_item_global_id) "Inventory item focused " % inventory_item_global_id
)
escoria.main.current_scene.game.inventory_item_focused(
inventory_item_global_id
)
# The mouse exited an inventory item # The mouse exited an inventory item
@@ -155,9 +203,13 @@ func _on_mouse_exited_item(item: ESCItem) -> void:
# - item: The Escoria item clicked # - item: The Escoria item clicked
# - event: The input event from the click # - event: The input event from the click
func _on_mouse_left_clicked_item(item: ESCItem, event: InputEvent) -> void: func _on_mouse_left_clicked_item(item: ESCItem, event: InputEvent) -> void:
if hover_stack.empty() or hover_stack.back() == item: if input_mode == INPUT_ALL:
escoria.logger.info("Item left clicked", [item.global_id, event]) if hover_stack.empty() or hover_stack.back() == item:
escoria.main.current_scene.game.left_click_on_item(item.global_id, event) escoria.logger.info("Item left clicked", [item.global_id, event])
escoria.main.current_scene.game.left_click_on_item(
item.global_id,
event
)
# An Escoria item was double-clicked with the LMB # An Escoria item was double-clicked with the LMB
@@ -166,9 +218,16 @@ func _on_mouse_left_clicked_item(item: ESCItem, event: InputEvent) -> void:
# #
# - item: The Escoria item clicked # - item: The Escoria item clicked
# - event: The input event from the click # - event: The input event from the click
func _on_mouse_left_double_clicked_item(item: ESCItem, event: InputEvent) -> void: func _on_mouse_left_double_clicked_item(
escoria.logger.info("Item left double clicked", [item.global_id, event]) item: ESCItem,
escoria.main.current_scene.game.left_double_click_on_item(item.global_id, event) event: InputEvent
) -> void:
if input_mode == INPUT_ALL:
escoria.logger.info("Item left double clicked", [item.global_id, event])
escoria.main.current_scene.game.left_double_click_on_item(
item.global_id,
event
)
# An Escoria item was clicked with the RMB # An Escoria item was clicked with the RMB
@@ -178,8 +237,12 @@ func _on_mouse_left_double_clicked_item(item: ESCItem, event: InputEvent) -> voi
# - item: The Escoria item clicked # - item: The Escoria item clicked
# - event: The input event from the click # - event: The input event from the click
func _on_mouse_right_clicked_item(item: ESCItem, event: InputEvent) -> void: func _on_mouse_right_clicked_item(item: ESCItem, event: InputEvent) -> void:
escoria.logger.info("Item right clicked", [item.global_id, event]) if input_mode == INPUT_ALL:
escoria.main.current_scene.game.right_click_on_item(item.global_id, event) escoria.logger.info("Item right clicked", [item.global_id, event])
escoria.main.current_scene.game.right_click_on_item(
item.global_id,
event
)
# The mousewheel was turned # The mousewheel was turned

View File

@@ -32,6 +32,13 @@ func _ready():
preload_resources(ProjectSettings.get_setting("escoria/ui/dialogs_folder")) preload_resources(ProjectSettings.get_setting("escoria/ui/dialogs_folder"))
# Trigger the finish fast function on the dialog ui
func _input(event):
if event is InputEventMouseButton and \
event.pressed:
finish_fast()
# Preload the dialog UI resources # Preload the dialog UI resources
# #
# #### Parameters # #### Parameters
@@ -72,20 +79,23 @@ func preload_resources(path: String) -> void:
# #### Parameters # #### Parameters
# #
# - character: Character that is talking # - character: Character that is talking
# - params: A dictionary of parameters. Currently only "line" is supported and # - ui: UI to use for the dialog
# holds the line the character should say # - line: Line to say
func say(character: String, params: Dictionary) -> void: func say(character: String, ui: String, line: String) -> void:
is_speaking = true is_speaking = true
_dialog_ui = get_resource(params.ui).instance() _dialog_ui = get_resource(ui).instance()
get_parent().add_child(_dialog_ui) get_parent().add_child(_dialog_ui)
_dialog_ui.say(character, params) _dialog_ui.say(character, line)
yield(_dialog_ui, "dialog_line_finished") yield(_dialog_ui, "dialog_line_finished")
is_speaking = false
emit_signal("dialog_line_finished") emit_signal("dialog_line_finished")
# Called when a dialog line is skipped # Called when a dialog line is skipped
func finish_fast() -> void: func finish_fast() -> void:
_dialog_ui.finish_fast() if is_speaking and\
escoria.inputs_manager.input_mode != escoria.inputs_manager.INPUT_NONE:
_dialog_ui.finish_fast()
# Display a list of choices # Display a list of choices

View File

@@ -1,19 +1,42 @@
# A dialog GUI showing a dialog box and character portraits
tool tool
extends PanelContainer extends PanelContainer
# Signal emitted when a dialog line has started
signal dialog_line_started signal dialog_line_started
# Signal emitted when a dialog line has finished
signal dialog_line_finished signal dialog_line_finished
export(String) var current_character setget set_current_character
onready var avatar_node = $MarginContainer/HSplitContainer/VBoxContainer/avatar
onready var name_node = $MarginContainer/HSplitContainer/VBoxContainer/name
onready var text_node = $MarginContainer/HSplitContainer/text
onready var tween = text_node.get_node("Tween")
# The currently speaking character
export(String) var current_character setget set_current_character
# The text speed per character for normal display
export(float, 0.0, 0.3) var text_speed_per_character = 0.1 export(float, 0.0, 0.3) var text_speed_per_character = 0.1
# The text speed per character if the dialog line is skipped
export(float) var fast_text_speed_per_character = 0.25 export(float) var fast_text_speed_per_character = 0.25
# The time to wait before the dialog is finished
export(float) var max_time_to_text_disappear = 1.0 export(float) var max_time_to_text_disappear = 1.0
# The node holding the avatar
onready var avatar_node = $MarginContainer/HSplitContainer/VBoxContainer/avatar
# The node holding the player name
onready var name_node = $MarginContainer/HSplitContainer/VBoxContainer/name
# The node showing the text
onready var text_node = $MarginContainer/HSplitContainer/text
# The tween node for text animations
onready var tween = text_node.get_node("Tween")
# Build up the UI
func _ready(): func _ready():
var centered_position_on_screen = Vector2( var centered_position_on_screen = Vector2(
ProjectSettings.get_setting("display/window/size/width") / 2, ProjectSettings.get_setting("display/window/size/width") / 2,
@@ -21,8 +44,17 @@ func _ready():
) - rect_size / 2 ) - rect_size / 2
rect_position = centered_position_on_screen rect_position = centered_position_on_screen
text_node.bbcode_enabled = true text_node.bbcode_enabled = true
$MarginContainer/HSplitContainer/text/Tween.connect("tween_completed", self, "_on_dialog_line_typed") $MarginContainer/HSplitContainer/text/Tween.connect(
"tween_completed",
self,
"_on_dialog_line_typed"
)
# Switch the current character
#
# #### Parameters
# - name: The name of the current character
func set_current_character(name: String): func set_current_character(name: String):
current_character = name current_character = name
if $dialog_avatars: if $dialog_avatars:
@@ -32,32 +64,28 @@ func set_current_character(name: String):
avatar_node.texture = null avatar_node.texture = null
""" # Make a character say something
Make a character say something. #
# #### Parameters
character: global id of the character who speaks # - character: The global id of the character speaking
params: Dictionary # - line: Line to say
line: line of dialog to say func say(character: String, line: String) :
"""
func say(character : String, params : Dictionary) :
show() show()
emit_signal("dialog_line_started") emit_signal("dialog_line_started")
set_current_character(character) set_current_character(character)
if !params["line"]: text_node.bbcode_text = tr(line)
escoria.logger.report_errors("dialog_box_inset.gd:say()", ["No line field in params!"])
return
text_node.bbcode_text = params["line"]
text_node.percent_visible = 0.0 text_node.percent_visible = 0.0
var time_show_full_text = text_speed_per_character * len(params["line"]) var time_show_full_text = text_speed_per_character * len(line)
tween.interpolate_property(text_node, "percent_visible", tween.interpolate_property(text_node, "percent_visible",
0.0, 1.0, time_show_full_text, 0.0, 1.0, time_show_full_text,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start() tween.start()
# Called by the dialog player when the
func finish_fast(): func finish_fast():
tween.stop(text_node) tween.stop(text_node)
tween.interpolate_property(text_node, "percent_visible", tween.interpolate_property(text_node, "percent_visible",
@@ -66,18 +94,18 @@ func finish_fast():
tween.start() tween.start()
# The dialog line was printed, start the waiting time and then finish
# the dialog
func _on_dialog_line_typed(object, key): func _on_dialog_line_typed(object, key):
text_node.visible_characters = -1 text_node.visible_characters = -1
$Timer.start(max_time_to_text_disappear) $Timer.start(max_time_to_text_disappear)
$Timer.connect("timeout", self, "_on_dialog_finished") $Timer.connect("timeout", self, "_on_dialog_finished")
# Ending the dialog
func _on_dialog_finished(): func _on_dialog_finished():
escoria.current_state = escoria.GAME_STATE.DEFAULT escoria.current_state = escoria.GAME_STATE.DEFAULT
emit_signal("dialog_line_finished") emit_signal("dialog_line_finished")
queue_free() queue_free()
func _input(event):
if event is InputEventMouseButton:
if event.pressed:
finish_fast()

View File

@@ -1,39 +1,51 @@
# A dialog UI using a label above the head of the character
extends RichTextLabel extends RichTextLabel
# Signal emitted when a dialog line has started
signal dialog_line_started signal dialog_line_started
# Signal emitted when a dialog line has finished
signal dialog_line_finished signal dialog_line_finished
onready var tween = $Tween
onready var text_node = self
# The text speed per character for normal display
export(float, 0.0, 0.3) var text_speed_per_character = 0.1 export(float, 0.0, 0.3) var text_speed_per_character = 0.1
# The text speed per character if the dialog line is skipped
export(float) var fast_text_speed_per_character = 0.25 export(float) var fast_text_speed_per_character = 0.25
# The time to wait before the dialog is finished
export(float) var max_time_to_text_disappear = 2.0 export(float) var max_time_to_text_disappear = 2.0
# Current character speaking, to keep track of reference for animation purposes # Current character speaking, to keep track of reference for animation purposes
var current_character var current_character
# Tween node for text animation
onready var tween = $Tween
# The node showing the text
onready var text_node = self
# Enable bbcode and catch the signal when a tween completed
func _ready(): func _ready():
bbcode_enabled = true bbcode_enabled = true
$Tween.connect("tween_completed", self, "_on_dialog_line_typed") $Tween.connect("tween_completed", self, "_on_dialog_line_typed")
"""
Make a character say something.
character: global id of the character who speaks # Make a character say something
params: Dictionary #
line: line of dialog to say # #### Parameters
""" # - character: The global id of the character speaking
func say(character: String, params: Dictionary) : # - line: Line to say
func say(character: String, line: String) :
show() show()
emit_signal("dialog_line_started") emit_signal("dialog_line_started")
if !params["line"]:
escoria.logger.report_errors("dialog_box_inset.gd:say()", ["No line field in params!"])
return
# Position the RichTextLabel on the character's dialog position, if any. # Position the RichTextLabel on the character's dialog position, if any.
current_character = escoria.object_manager.get_object(character).node current_character = escoria.object_manager.get_object(character).node
rect_position = current_character.get_node("dialog_position").get_global_transform_with_canvas().origin rect_position = current_character.get_node("dialog_position").get_global_transform_with_canvas().origin
@@ -45,21 +57,19 @@ func say(character: String, params: Dictionary) :
var text_color = current_character.dialog_color var text_color = current_character.dialog_color
var text_color_html = text_color.to_html(false) var text_color_html = text_color.to_html(false)
if params["key"] != params["line"]: text_node.bbcode_text = "[center][color=#" + text_color_html + "]" \
text_node.bbcode_text = "[center][color=#" + text_color_html + "]" \ .format([text_color_html]) + tr(line) + "[/color][center]"
.format([text_color_html]) + tr(params["key"]) + "[/color][center]"
else:
text_node.bbcode_text = "[center][color=#" + text_color_html + "]" \
.format([text_color_html]) + params["line"] + "[/color][center]"
text_node.percent_visible = 0.0 text_node.percent_visible = 0.0
var time_show_full_text = text_speed_per_character * len(params["line"]) var time_show_full_text = text_speed_per_character * len(line)
tween.interpolate_property(text_node, "percent_visible", tween.interpolate_property(text_node, "percent_visible",
0.0, 1.0, time_show_full_text, 0.0, 1.0, time_show_full_text,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start() tween.start()
# Called by the dialog player when the
func finish_fast(): func finish_fast():
tween.stop(text_node) tween.stop(text_node)
tween.interpolate_property(text_node, "percent_visible", tween.interpolate_property(text_node, "percent_visible",
@@ -68,11 +78,15 @@ func finish_fast():
tween.start() tween.start()
# The dialog line was printed, start the waiting time and then finish
# the dialog
func _on_dialog_line_typed(object, key): func _on_dialog_line_typed(object, key):
text_node.visible_characters = -1 text_node.visible_characters = -1
$Timer.start(max_time_to_text_disappear) $Timer.start(max_time_to_text_disappear)
$Timer.connect("timeout", self, "_on_dialog_finished") $Timer.connect("timeout", self, "_on_dialog_finished")
# Ending the dialog
func _on_dialog_finished(): func _on_dialog_finished():
current_character.stop_talking() current_character.stop_talking()
emit_signal("dialog_line_finished") emit_signal("dialog_line_finished")

View File

@@ -17,7 +17,6 @@ This allows you to create cut scenes with SKIP where the dialog can be
skipped, but also initiate locked#### down cutscenes with accept_input skipped, but also initiate locked#### down cutscenes with accept_input
NONE in :setup and accept_input ALL later in :ready. NONE in :setup and accept_input ALL later in :ready.
@STUB
@ESC @ESC
## Method Descriptions ## Method Descriptions

View File

@@ -35,7 +35,7 @@ Preload the dialog UI resources
### say ### say
```gdscript ```gdscript
func say(character: String, params: Dictionary) -> var func say(character: String, ui: String, line: String) -> var
``` ```
A short one line dialog A short one line dialog
@@ -43,8 +43,8 @@ A short one line dialog
#### Parameters #### Parameters
- character: Character that is talking - character: Character that is talking
- params: A dictionary of parameters. Currently only "line" is supported and - ui: UI to use for the dialog
holds the line the character should say - line: Line to say
### finish\_fast ### finish\_fast

View File

@@ -1,6 +1,6 @@
<!-- Auto-generated from JSON by GDScript docs maker. Do not edit this document directly. --> <!-- Auto-generated from JSON by GDScript docs maker. Do not edit this document directly. -->
# inputs\_manager.gd # ESCInputsManager
**Extends:** [Node](../Node) **Extends:** [Node](../Node)
@@ -9,8 +9,36 @@
Escoria inputs manager Escoria inputs manager
Catches, handles and distributes input events for the game Catches, handles and distributes input events for the game
## Constants Descriptions
### INPUT\_ALL
```gdscript
const INPUT_ALL: int = 0
```
### INPUT\_NONE
```gdscript
const INPUT_NONE: int = 1
```
### INPUT\_SKIP
```gdscript
const INPUT_SKIP: int = 2
```
## Property Descriptions ## Property Descriptions
### input\_mode
```gdscript
var input_mode
```
The current input mode
### hover\_stack ### hover\_stack
```gdscript ```gdscript

View File

@@ -346,7 +346,9 @@ Set the angle
#### Parameters #### Parameters
Set the angle - deg: The angle degree to set
- immediate: Set the angle immediately. If false will show intermediate
angles
### start\_talking ### start\_talking

View File

@@ -35,3 +35,13 @@ func _init(p_event: ESCEvent, p_timeout: float)
``` ```
Create a new scheduled event Create a new scheduled event
### run
```gdscript
func run() -> int
```
Run the event
**Returns** The execution code

View File

@@ -1,35 +0,0 @@
<!-- Auto-generated from JSON by GDScript docs maker. Do not edit this document directly. -->
# GameOverCommand
**Extends:** [ESCBaseCommand](../ESCBaseCommand) < [Node](../Node)
## Description
`game_over continue_enabled show_credits`
Ends the game. Use the "continue_enabled" parameter to enable or disable the
continue button in the main menu afterwards. The "show_credits" parameter
loads the ui/end_credits scene if true. You can configure it to your regular
credits scene if you want.
@STUB
@ESC
## Method Descriptions
### configure
```gdscript
func configure() -> ESCCommandArgumentDescriptor
```
Return the descriptor of the arguments of this command
### run
```gdscript
func run(command_params: Array) -> int
```
Run the command

View File

@@ -6,13 +6,11 @@
## Description ## Description
`play_snd object file [loop]` `play_snd file [player]`
Plays the sound specificed with the "file" parameter on the object, without Plays the sound specificed with the "file" parameter on the sound player
blocking. You can play background sounds, eg. during scene changes, with `player`, without blocking. (player defaults to bg_sound)
`play_snd bg_snd res://...`
@STUB
@ESC @ESC
## Method Descriptions ## Method Descriptions
@@ -25,6 +23,14 @@ func configure() -> ESCCommandArgumentDescriptor
Return the descriptor of the arguments of this command Return the descriptor of the arguments of this command
### validate
```gdscript
func validate(arguments: Array)
```
Validate wether the given arguments match the command descriptor
### run ### run
```gdscript ```gdscript

View File

@@ -1,42 +0,0 @@
<!-- Auto-generated from JSON by GDScript docs maker. Do not edit this document directly. -->
# QueueAnimationCommand
**Extends:** [ESCBaseCommand](../ESCBaseCommand) < [Node](../Node)
## Description
`queue_animation object animation`
Similar to queue_resource, queues the resources necessary to have an
animation loaded on an item. The resource paths are taken from the item
placeholders.
@STUB
@ESC
## Method Descriptions
### configure
```gdscript
func configure() -> ESCCommandArgumentDescriptor
```
Return the descriptor of the arguments of this command
### validate
```gdscript
func validate(arguments: Array)
```
Validate wether the given arguments match the command descriptor
### run
```gdscript
func run(command_params: Array) -> int
```
Run the command

View File

@@ -2,7 +2,7 @@
# SlideBlockCommand # SlideBlockCommand
**Extends:** [ESCBaseCommand](../ESCBaseCommand) < [Node](../Node) **Extends:** [SlideCommand](../SlideCommand) < [ESCBaseCommand](../ESCBaseCommand) < [Node](../Node)
## Description ## Description
@@ -18,26 +18,10 @@ where the player can't walk.
## Method Descriptions ## Method Descriptions
### configure
```gdscript
func configure() -> ESCCommandArgumentDescriptor
```
Return the descriptor of the arguments of this command
### validate
```gdscript
func validate(arguments: Array)
```
Validate wether the given arguments match the command descriptor
### run ### run
```gdscript ```gdscript
func run(command_params: Array) -> int func run(command_params: Array) -> var
``` ```
Run the command Run the command

View File

@@ -1,40 +0,0 @@
<!-- Auto-generated from JSON by GDScript docs maker. Do not edit this document directly. -->
# SpawnCommand
**Extends:** [ESCBaseCommand](../ESCBaseCommand) < [Node](../Node)
## Description
`spawn path [object2]`
Instances a scene determined by "path", and places in the position of
object2 (object2 is optional)
@ESC
## Method Descriptions
### configure
```gdscript
func configure() -> ESCCommandArgumentDescriptor
```
Return the descriptor of the arguments of this command
### validate
```gdscript
func validate(arguments: Array)
```
Validate wether the given arguments match the command descriptor
### run
```gdscript
func run(command_params: Array) -> int
```
Run the command

View File

@@ -6,7 +6,7 @@
## Description ## Description
`turn_to object degrees` `turn_to object degrees [immediate]`
Turns object to a degrees angle with a directions animation. Turns object to a degrees angle with a directions animation.
@@ -15,6 +15,9 @@ When turning to the destination angle, animations are played if they're
defined in animations. object must be player or interactive. degrees must defined in animations. object must be player or interactive. degrees must
be between [0, 360] or an error is reported. be between [0, 360] or an error is reported.
Set immediate to true to show directly switch to the direction and not
show intermediate angles
@STUB @STUB
@ESC @ESC

View File

@@ -6,6 +6,8 @@
## Description ## Description
A dialog GUI showing a dialog box and character portraits
## Property Descriptions ## Property Descriptions
### current\_character ### current\_character
@@ -16,29 +18,7 @@ export var current_character = ""
- **Setter**: `set_current_character` - **Setter**: `set_current_character`
### avatar\_node The currently speaking character
```gdscript
var avatar_node
```
### name\_node
```gdscript
var name_node
```
### text\_node
```gdscript
var text_node
```
### tween
```gdscript
var tween
```
### text\_speed\_per\_character ### text\_speed\_per\_character
@@ -46,18 +26,56 @@ var tween
export var text_speed_per_character = 0.1 export var text_speed_per_character = 0.1
``` ```
The text speed per character for normal display
### fast\_text\_speed\_per\_character ### fast\_text\_speed\_per\_character
```gdscript ```gdscript
export var fast_text_speed_per_character = 0.25 export var fast_text_speed_per_character = 0.25
``` ```
The text speed per character if the dialog line is skipped
### max\_time\_to\_text\_disappear ### max\_time\_to\_text\_disappear
```gdscript ```gdscript
export var max_time_to_text_disappear = 1 export var max_time_to_text_disappear = 1
``` ```
The time to wait before the dialog is finished
### avatar\_node
```gdscript
var avatar_node
```
The node holding the avatar
### name\_node
```gdscript
var name_node
```
The node holding the player name
### text\_node
```gdscript
var text_node
```
The node showing the text
### tween
```gdscript
var tween
```
The tween node for text animations
## Method Descriptions ## Method Descriptions
### set\_current\_character ### set\_current\_character
@@ -66,19 +84,32 @@ export var max_time_to_text_disappear = 1
func set_current_character(name: String) func set_current_character(name: String)
``` ```
Switch the current character
#### Parameters
- name: The name of the current character
### say ### say
```gdscript ```gdscript
func say(character: String, params: Dictionary) func say(character: String, line: String)
``` ```
Make a character say something
#### Parameters
- character: The global id of the character speaking
- line: Line to say
### finish\_fast ### finish\_fast
```gdscript ```gdscript
func finish_fast() func finish_fast()
``` ```
Called by the dialog player when the
## Signals ## Signals
- signal dialog_line_started(): - signal dialog_line_started(): Signal emitted when a dialog line has started
- signal dialog_line_finished(): - signal dialog_line_finished(): Signal emitted when a dialog line has finished

View File

@@ -6,38 +6,34 @@
## Description ## Description
A dialog UI using a label above the head of the character
## Property Descriptions ## Property Descriptions
### tween
```gdscript
var tween
```
### text\_node
```gdscript
var text_node
```
### text\_speed\_per\_character ### text\_speed\_per\_character
```gdscript ```gdscript
export var text_speed_per_character = 0.1 export var text_speed_per_character = 0.1
``` ```
The text speed per character for normal display
### fast\_text\_speed\_per\_character ### fast\_text\_speed\_per\_character
```gdscript ```gdscript
export var fast_text_speed_per_character = 0.25 export var fast_text_speed_per_character = 0.25
``` ```
The text speed per character if the dialog line is skipped
### max\_time\_to\_text\_disappear ### max\_time\_to\_text\_disappear
```gdscript ```gdscript
export var max_time_to_text_disappear = 2 export var max_time_to_text_disappear = 2
``` ```
The time to wait before the dialog is finished
### current\_character ### current\_character
```gdscript ```gdscript
@@ -46,21 +42,45 @@ var current_character
Current character speaking, to keep track of reference for animation purposes Current character speaking, to keep track of reference for animation purposes
### tween
```gdscript
var tween
```
Tween node for text animation
### text\_node
```gdscript
var text_node
```
The node showing the text
## Method Descriptions ## Method Descriptions
### say ### say
```gdscript ```gdscript
func say(character: String, params: Dictionary) func say(character: String, line: String)
``` ```
Make a character say something
#### Parameters
- character: The global id of the character speaking
- line: Line to say
### finish\_fast ### finish\_fast
```gdscript ```gdscript
func finish_fast() func finish_fast()
``` ```
Called by the dialog player when the
## Signals ## Signals
- signal dialog_line_started(): - signal dialog_line_started(): Signal emitted when a dialog line has started
- signal dialog_line_finished(): - signal dialog_line_finished(): Signal emitted when a dialog line has finished

View File

@@ -132,7 +132,7 @@ Terrain of the current room
### dialog\_player ### dialog\_player
```gdscript ```gdscript
var dialog_player var dialog_player: ESCDialogsPlayer
``` ```
Dialog player instantiator. This instance is called directly for dialogs. Dialog player instantiator. This instance is called directly for dialogs.
@@ -180,7 +180,7 @@ The main scene
### inputs\_manager ### inputs\_manager
```gdscript ```gdscript
var inputs_manager var inputs_manager: ESCInputsManager
``` ```
The escoria inputs manager The escoria inputs manager

View File

@@ -140,8 +140,6 @@ Some commands will block execution of the event until they finish, others won't.
<!-- ESCCOMMANDS --> <!-- ESCCOMMANDS -->
#### <a name="AcceptInputCommand.md"></a>`accept_input [ALL|NONE|SKIP]` [API-Doc](api/AcceptInputCommand.md) #### <a name="AcceptInputCommand.md"></a>`accept_input [ALL|NONE|SKIP]` [API-Doc](api/AcceptInputCommand.md)
**This command is currently not fully implemented.**
What type of input does the game accept. ALL is the default, SKIP allows What type of input does the game accept. ALL is the default, SKIP allows
skipping of dialog but nothing else, NONE denies all input. Including opening skipping of dialog but nothing else, NONE denies all input. Including opening
the menu etc. SKIP and NONE also disable autosaves. the menu etc. SKIP and NONE also disable autosaves.
@@ -222,14 +220,6 @@ both be integers.
Enable the ESCTerrain's NavigationPolygonInstance defined by given node name. Enable the ESCTerrain's NavigationPolygonInstance defined by given node name.
Disables previously activated NavigationPolygonInstance. Disables previously activated NavigationPolygonInstance.
#### <a name="GameOverCommand.md"></a>`game_over continue_enabled show_credits` [API-Doc](api/GameOverCommand.md)
**This command is currently not fully implemented.**
Ends the game. Use the "continue_enabled" parameter to enable or disable the
continue button in the main menu afterwards. The "show_credits" parameter
loads the ui/end_credits scene if true. You can configure it to your regular
credits scene if you want.
#### <a name="IncGlobalCommand.md"></a>`inc_global name value` [API-Doc](api/IncGlobalCommand.md) #### <a name="IncGlobalCommand.md"></a>`inc_global name value` [API-Doc](api/IncGlobalCommand.md)
Adds the value to global with given "name". Value and global must both be Adds the value to global with given "name". Value and global must both be
@@ -240,20 +230,10 @@ Add an item to the inventory
#### <a name="InventoryRemoveCommand.md"></a>`inventory_remove item` [API-Doc](api/InventoryRemoveCommand.md) #### <a name="InventoryRemoveCommand.md"></a>`inventory_remove item` [API-Doc](api/InventoryRemoveCommand.md)
Remove an item from the inventory. Remove an item from the inventory.
#### <a name="PlaySndCommand.md"></a>`play_snd object file [loop]` [API-Doc](api/PlaySndCommand.md) #### <a name="PlaySndCommand.md"></a>`play_snd file [player]` [API-Doc](api/PlaySndCommand.md)
**This command is currently not fully implemented.** Plays the sound specificed with the "file" parameter on the sound player
`player`, without blocking. (player defaults to bg_sound)
Plays the sound specificed with the "file" parameter on the object, without
blocking. You can play background sounds, eg. during scene changes, with
`play_snd bg_snd res://...`
#### <a name="QueueAnimationCommand.md"></a>`queue_animation object animation` [API-Doc](api/QueueAnimationCommand.md)
**This command is currently not fully implemented.**
Similar to queue_resource, queues the resources necessary to have an
animation loaded on an item. The resource paths are taken from the item
placeholders.
#### <a name="QueueResourceCommand.md"></a>`queue_resource path [front_of_queue]` [API-Doc](api/QueueResourceCommand.md) #### <a name="QueueResourceCommand.md"></a>`queue_resource path [front_of_queue]` [API-Doc](api/QueueResourceCommand.md)
Queues the load of a resource in a background thread. The `path` must be a Queues the load of a resource in a background thread. The `path` must be a
@@ -345,10 +325,6 @@ Moves object1 towards the position of object2, at the speed determined by
object1's "speed" property, unless overridden. This command is non-blocking. object1's "speed" property, unless overridden. This command is non-blocking.
It does not respect the room's navigation polygons, so you can move items It does not respect the room's navigation polygons, so you can move items
where the player can't walk. where the player can't walk.
#### <a name="SpawnCommand.md"></a>`spawn path [object2]` [API-Doc](api/SpawnCommand.md)
Instances a scene determined by "path", and places in the position of
object2 (object2 is optional)
#### <a name="StopCommand.md"></a>`stop` [API-Doc](api/StopCommand.md) #### <a name="StopCommand.md"></a>`stop` [API-Doc](api/StopCommand.md)
Stops the event's execution. Stops the event's execution.
@@ -360,7 +336,7 @@ FIXME re-add the angle parameter here
Sets the position of object1 to the position (x,y). Sets the position of object1 to the position (x,y).
FIXME re-add the angle parameter here FIXME re-add the angle parameter here
#### <a name="TurnToCommand.md"></a>`turn_to object degrees` [API-Doc](api/TurnToCommand.md) #### <a name="TurnToCommand.md"></a>`turn_to object degrees [immediate]` [API-Doc](api/TurnToCommand.md)
**This command is currently not fully implemented.** **This command is currently not fully implemented.**
@@ -370,6 +346,9 @@ Turns object to a degrees angle with a directions animation.
When turning to the destination angle, animations are played if they're When turning to the destination angle, animations are played if they're
defined in animations. object must be player or interactive. degrees must defined in animations. object must be player or interactive. degrees must
be between [0, 360] or an error is reported. be between [0, 360] or an error is reported.
Set immediate to true to show directly switch to the direction and not
show intermediate angles
#### <a name="WaitCommand.md"></a>`wait seconds` [API-Doc](api/WaitCommand.md) #### <a name="WaitCommand.md"></a>`wait seconds` [API-Doc](api/WaitCommand.md)
Blocks execution of the current script for a number of seconds specified by the "seconds" parameter. Blocks execution of the current script for a number of seconds specified by the "seconds" parameter.
@@ -407,7 +386,6 @@ Makes the `player` walk to the position `x`/`y`.
## Dialogs ## Dialogs
Dialogs are specified by writing `?` with optional parameters, followed by a list of dialog options starting with `-`. Use `!` to end the dialog. Dialogs are specified by writing `?` with optional parameters, followed by a list of dialog options starting with `-`. Use `!` to end the dialog.

View File

@@ -0,0 +1,11 @@
# Test the accept_input command
:use
say player "Hello. I will now walk a bit and won't listen at what you say!"
accept_input NONE
walk_block player player_start
walk_block player accept_input_location
say player "Ha! Now you can't even skip this text!" dialog_box_inset
accept_input SKIP
say player "Okay, you can skip this text, but still not move me."
accept_input ALL

View File

@@ -1,3 +1,3 @@
:use :use
set_sound_state bg_sound res://game/sfx/sounds/laser1.ogg false play_snd res://game/sfx/sounds/laser1.ogg

View File

@@ -0,0 +1,18 @@
# Testing the slide and slide_block command
:use
say player "UUUuugh. I'm not feeling so well..."
slide_block player slide_pos_1
say player "Ugh!"
slide player slide_pos_2
sched_event 5 button_slide slide_back
say player "Heeeeeeeelp!"
:slide_back
slide_block player slide_location
say player "That's better."

View File

@@ -0,0 +1,9 @@
:use
say player "Huh?"
turn_to player 180 true
say player "Nothing."
turn_to player 0

View File

@@ -131,6 +131,81 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="player_start" type="Position2D" parent="."] [node name="button_accept_input" parent="Hotspots" instance=ExtResource( 8 )]
position = Vector2( 76.7617, 437.649 ) position = Vector2( 823.113, 155.354 )
global_id = "test_accept_input"
esc_script = "res://game/rooms/room10/esc/button_accept_input_test.esc"
tooltip_name = "Test Accept Input"
[node name="Label" type="Label" parent="Hotspots/button_accept_input"]
margin_left = -3.6864
margin_top = -38.4435
margin_right = 71.3136
margin_bottom = -7.44354
text = "Test Accept
Input"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ESCLocation" type="Position2D" parent="Hotspots/button_accept_input"]
position = Vector2( -1.05322, 214.863 )
script = ExtResource( 5 ) script = ExtResource( 5 )
global_id = "accept_input_location"
[node name="button_slide" parent="Hotspots" instance=ExtResource( 8 )]
position = Vector2( 939.497, 154.301 )
global_id = "button_slide"
esc_script = "res://game/rooms/room10/esc/button_slide.esc"
tooltip_name = "Test slide"
[node name="Label" type="Label" parent="Hotspots/button_slide"]
margin_left = -3.6864
margin_top = -38.4435
margin_right = 71.3136
margin_bottom = -7.44354
text = "Test Slide"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ESCLocation" type="Position2D" parent="Hotspots/button_slide"]
position = Vector2( 4.21295, 214.863 )
script = ExtResource( 5 )
global_id = "slide_location"
[node name="button_turn_to" parent="Hotspots" instance=ExtResource( 8 )]
position = Vector2( 1041.66, 152.721 )
global_id = "button_turn_to"
esc_script = "res://game/rooms/room10/esc/button_turn_to.esc"
tooltip_name = "Test turn_to"
[node name="Label" type="Label" parent="Hotspots/button_turn_to"]
margin_left = -3.6864
margin_top = -38.4435
margin_right = 71.3136
margin_bottom = -7.44354
text = "Test turn_to"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ESCLocation" type="Position2D" parent="Hotspots/button_turn_to"]
position = Vector2( 4.21295, 214.863 )
script = ExtResource( 5 )
global_id = "slide_location"
[node name="slide_pos_1" type="Position2D" parent="."]
position = Vector2( 469.097, 65.8522 )
script = ExtResource( 5 )
global_id = "slide_pos_1"
[node name="slide_pos_2" type="Position2D" parent="."]
position = Vector2( 958.33, 638.293 )
script = ExtResource( 5 )
global_id = "slide_pos_2"
[node name="player_start" type="Position2D" parent="."]
position = Vector2( 542.824, 468.193 )
script = ExtResource( 5 )
global_id = "player_start"

View File

@@ -184,6 +184,11 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/types/esc_group.gd" "path": "res://addons/escoria-core/game/core-scripts/esc/types/esc_group.gd"
}, { }, {
"base": "Node",
"class": "ESCInputsManager",
"language": "GDScript",
"path": "res://addons/escoria-core/game/inputs_manager.gd"
}, {
"base": "Control", "base": "Control",
"class": "ESCInventory", "class": "ESCInventory",
"language": "GDScript", "language": "GDScript",
@@ -300,11 +305,6 @@ _global_script_classes=[ {
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/enable_terrain.gd" "path": "res://addons/escoria-core/game/core-scripts/esc/commands/enable_terrain.gd"
}, { }, {
"base": "ESCBaseCommand", "base": "ESCBaseCommand",
"class": "GameOverCommand",
"language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/game_over.gd"
}, {
"base": "ESCBaseCommand",
"class": "IncGlobalCommand", "class": "IncGlobalCommand",
"language": "GDScript", "language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/inc_global.gd" "path": "res://addons/escoria-core/game/core-scripts/esc/commands/inc_global.gd"
@@ -325,11 +325,6 @@ _global_script_classes=[ {
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/play_snd.gd" "path": "res://addons/escoria-core/game/core-scripts/esc/commands/play_snd.gd"
}, { }, {
"base": "ESCBaseCommand", "base": "ESCBaseCommand",
"class": "QueueAnimationCommand",
"language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/queue_animation.gd"
}, {
"base": "ESCBaseCommand",
"class": "QueueResourceCommand", "class": "QueueResourceCommand",
"language": "GDScript", "language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/queue_resource.gd" "path": "res://addons/escoria-core/game/core-scripts/esc/commands/queue_resource.gd"
@@ -399,7 +394,7 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/set_state.gd" "path": "res://addons/escoria-core/game/core-scripts/esc/commands/set_state.gd"
}, { }, {
"base": "ESCBaseCommand", "base": "SlideCommand",
"class": "SlideBlockCommand", "class": "SlideBlockCommand",
"language": "GDScript", "language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/slide_block.gd" "path": "res://addons/escoria-core/game/core-scripts/esc/commands/slide_block.gd"
@@ -495,6 +490,7 @@ _global_script_class_icons={
"ESCGame": "", "ESCGame": "",
"ESCGlobalsManager": "", "ESCGlobalsManager": "",
"ESCGroup": "", "ESCGroup": "",
"ESCInputsManager": "",
"ESCInventory": "", "ESCInventory": "",
"ESCInventoryItem": "", "ESCInventoryItem": "",
"ESCInventoryManager": "", "ESCInventoryManager": "",
@@ -518,12 +514,10 @@ _global_script_class_icons={
"ESCUtils": "", "ESCUtils": "",
"ESCWalkContext": "", "ESCWalkContext": "",
"EnableTerrainCommand": "", "EnableTerrainCommand": "",
"GameOverCommand": "",
"IncGlobalCommand": "", "IncGlobalCommand": "",
"InventoryAddCommand": "", "InventoryAddCommand": "",
"InventoryRemoveCommand": "", "InventoryRemoveCommand": "",
"PlaySndCommand": "", "PlaySndCommand": "",
"QueueAnimationCommand": "",
"QueueResourceCommand": "", "QueueResourceCommand": "",
"RandGlobalCommand": "", "RandGlobalCommand": "",
"RepeatCommand": "", "RepeatCommand": "",
@@ -588,7 +582,7 @@ main/force_quit=true
debug/terminate_on_warnings=false debug/terminate_on_warnings=false
debug/terminate_on_errors=true debug/terminate_on_errors=true
debug/development_lang="en" debug/development_lang="en"
ui/tooltip_follows_mouse=true ui/tooltip_follows_mouse=false
ui/dialogs_folder="res://game/ui/commons/dialogs" ui/dialogs_folder="res://game/ui/commons/dialogs"
ui/default_dialog_scene="res://game/ui/commons/dialogs/dialog_label.tscn" ui/default_dialog_scene="res://game/ui/commons/dialogs/dialog_label.tscn"
ui/main_menu_scene="res://game/ui/commons/main_menu/main_menu.tscn" ui/main_menu_scene="res://game/ui/commons/main_menu/main_menu.tscn"
@@ -610,13 +604,13 @@ main/savegames_path="res://saves/"
main/settings_path="user://" main/settings_path="user://"
main/escoria_version="" main/escoria_version=""
sound/speech_enabled=1 sound/speech_enabled=1
ui/game_scene="res://addons/escoria-ui-simplemouse/game.tscn" ui/game_scene="res://addons/escoria-ui-9verbs/game.tscn"
[input] [input]
esc_show_debug_prompt={ esc_show_debug_prompt={
"deadzone": 0.5, "deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777245,"physical_scancode":0,"unicode":0,"echo":false,"script":null) "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777245,"unicode":0,"echo":false,"script":null)
] ]
} }
switch_action_verb={ switch_action_verb={