say_random command
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
# `say_random player list_id lenght [offset]`
|
||||
#
|
||||
# Displays the specified string as dialog spoken by the player. This command
|
||||
# blocks further event execution until the dialog has finished being 'said'
|
||||
# (either as displayed text or as audible speech from a file).
|
||||
#
|
||||
# Global variables can be substituted into the text by wrapping the global
|
||||
# name in braces.
|
||||
# e.g. say player "I have {coin_count} coins remaining".
|
||||
#
|
||||
# **Parameters**
|
||||
#
|
||||
# - *player*: Global ID of the `ESCPlayer` or `ESCItem` object that is active.
|
||||
# You can specify `current_player` in order to refer to the currently active
|
||||
# player, e.g. in cases where multiple players are playable such as in games
|
||||
# like Maniac Mansion or Day of the Tentacle.
|
||||
# - *randomizer_list_id*: ID for the list of sentences.
|
||||
# - *lenght*: lenght of the list.
|
||||
# - *offset*: starting offset index of the list.
|
||||
#
|
||||
# Example: `say_random player random_list 4`
|
||||
#
|
||||
# @ESC
|
||||
extends ESCBaseCommand
|
||||
class_name SayRandomCommand
|
||||
|
||||
|
||||
const CURRENT_PLAYER_KEYWORD = "CURRENT_PLAYER"
|
||||
|
||||
|
||||
var rng: RandomNumberGenerator
|
||||
|
||||
# Constructor
|
||||
func _init() -> void:
|
||||
rng = RandomNumberGenerator.new()
|
||||
|
||||
|
||||
# Return the descriptor of the arguments of this command
|
||||
func configure() -> ESCCommandArgumentDescriptor:
|
||||
return ESCCommandArgumentDescriptor.new(
|
||||
3,
|
||||
[TYPE_STRING, TYPE_STRING, TYPE_INT, TYPE_INT],
|
||||
[
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
0
|
||||
],
|
||||
[
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
# Validate whether the given arguments match the command descriptor
|
||||
func validate(arguments: Array):
|
||||
if not .validate(arguments):
|
||||
return false
|
||||
|
||||
if arguments[0].to_upper() != CURRENT_PLAYER_KEYWORD \
|
||||
and not escoria.object_manager.has(arguments[0]):
|
||||
escoria.logger.error(
|
||||
self,
|
||||
"[%s]: Invalid object: Object with global id %s not found."
|
||||
% [get_command_name(), arguments[0]]
|
||||
)
|
||||
return false
|
||||
|
||||
return true
|
||||
|
||||
|
||||
# Run the command
|
||||
func run(command_params: Array) -> int:
|
||||
escoria.current_state = escoria.GAME_STATE.DIALOG
|
||||
|
||||
if !escoria.dialog_player:
|
||||
escoria.logger.error(
|
||||
self,
|
||||
"[%s]: No dialog player was registered and the say command was encountered."
|
||||
% get_command_name()
|
||||
)
|
||||
escoria.current_state = escoria.GAME_STATE.DEFAULT
|
||||
return ESCExecution.RC_ERROR
|
||||
|
||||
if not escoria.main.current_scene.player:
|
||||
escoria.logger.warn(
|
||||
self,
|
||||
"[%s]: No player item in the current scene was registered and the say command was encountered."
|
||||
% get_command_name()
|
||||
)
|
||||
escoria.current_state = escoria.GAME_STATE.DEFAULT
|
||||
return ESCExecution.RC_CANCEL
|
||||
|
||||
var text = command_params[1] + "_" + String(rng.randi_range(command_params[2],command_params[3])) + ':" "'
|
||||
|
||||
var speaking_character_global_id = escoria.main.current_scene.player.global_id \
|
||||
if command_params[0].to_upper() == CURRENT_PLAYER_KEYWORD \
|
||||
else command_params[0]
|
||||
|
||||
escoria.dialog_player.say(
|
||||
speaking_character_global_id,
|
||||
"",
|
||||
text
|
||||
)
|
||||
yield(escoria.dialog_player, "say_finished")
|
||||
escoria.current_state = escoria.GAME_STATE.DEFAULT
|
||||
return ESCExecution.RC_OK
|
||||
|
||||
|
||||
# Function called when the command is interrupted.
|
||||
func interrupt():
|
||||
escoria.logger.debug(
|
||||
self,
|
||||
"[%s] interrupt() function not implemented." % get_command_name()
|
||||
)
|
||||
@@ -46,7 +46,7 @@ onready var is_paused: bool = true
|
||||
# Enable bbcode and catch the signal when a tween completed
|
||||
func _ready():
|
||||
_text_time_per_character = ProjectSettings.get_setting(
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS
|
||||
RTMISimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS
|
||||
)
|
||||
|
||||
if _text_time_per_character < 0:
|
||||
@@ -54,15 +54,15 @@ func _ready():
|
||||
self,
|
||||
"%s setting must be a non-negative number. Will use default value of %s." %
|
||||
[
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS,
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
|
||||
RTMISimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS,
|
||||
RTMISimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
|
||||
]
|
||||
)
|
||||
|
||||
_text_time_per_character = SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
|
||||
_text_time_per_character = RTMISimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
|
||||
|
||||
_fast_text_time_per_character = ProjectSettings.get_setting(
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST
|
||||
RTMISimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST
|
||||
)
|
||||
|
||||
if _fast_text_time_per_character < 0:
|
||||
@@ -70,15 +70,15 @@ func _ready():
|
||||
self,
|
||||
"%s setting must be a non-negative number. Will use default value of %s." %
|
||||
[
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST,
|
||||
SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
|
||||
RTMISimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST,
|
||||
RTMISimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
|
||||
]
|
||||
)
|
||||
|
||||
_fast_text_time_per_character = SimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
|
||||
_fast_text_time_per_character = RTMISimpleDialogPlugin.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
|
||||
|
||||
_reading_speed_in_wpm = ProjectSettings.get_setting(
|
||||
SimpleDialogPlugin.READING_SPEED_IN_WPM
|
||||
RTMISimpleDialogPlugin.READING_SPEED_IN_WPM
|
||||
)
|
||||
|
||||
if _reading_speed_in_wpm <= 0:
|
||||
@@ -86,12 +86,12 @@ func _ready():
|
||||
self,
|
||||
"%s setting must be a positive number. Will use default value of %s." %
|
||||
[
|
||||
SimpleDialogPlugin.READING_SPEED_IN_WPM,
|
||||
SimpleDialogPlugin.READING_SPEED_IN_WPM_DEFAULT_VALUE
|
||||
RTMISimpleDialogPlugin.READING_SPEED_IN_WPM,
|
||||
RTMISimpleDialogPlugin.READING_SPEED_IN_WPM_DEFAULT_VALUE
|
||||
]
|
||||
)
|
||||
|
||||
_reading_speed_in_wpm = SimpleDialogPlugin.READING_SPEED_IN_WPM_DEFAULT_VALUE
|
||||
_reading_speed_in_wpm = RTMISimpleDialogPlugin.READING_SPEED_IN_WPM_DEFAULT_VALUE
|
||||
|
||||
_word_regex.compile("\\S+")
|
||||
|
||||
@@ -227,7 +227,7 @@ func _get_number_of_words() -> int:
|
||||
# Ending the dialog
|
||||
func _on_dialog_finished():
|
||||
# Only trigger to clear the text if we aren't limiting the clearing trigger to a click.
|
||||
if not ESCProjectSettingsManager.get_setting(SimpleDialogPlugin.CLEAR_TEXT_BY_CLICK_ONLY):
|
||||
if not ESCProjectSettingsManager.get_setting(RTMISimpleDialogPlugin.CLEAR_TEXT_BY_CLICK_ONLY):
|
||||
emit_signal("say_finished")
|
||||
|
||||
|
||||
|
||||
@@ -18,3 +18,4 @@ func set_outline_color(color):
|
||||
func set_outline_width(new_width):
|
||||
Width = new_width
|
||||
update()
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ is_exit = true
|
||||
combine_when_selected_action_is_in = [ ]
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
tooltips = {
|
||||
"action1": "Ir detrás"
|
||||
"action1": "Ir detrás"
|
||||
}
|
||||
animations = null
|
||||
|
||||
@@ -84,7 +84,7 @@ is_exit = true
|
||||
combine_when_selected_action_is_in = [ ]
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
tooltips = {
|
||||
"action1": "Salir de la cocina"
|
||||
"action1": "Salir de la cocina"
|
||||
}
|
||||
animations = null
|
||||
|
||||
@@ -130,8 +130,8 @@ esc_script = "res://gymkhana/rooms/turno_cocina/cocina/esc/fregadero_der.esc"
|
||||
combine_when_selected_action_is_in = [ ]
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
tooltips = {
|
||||
"action1": "Mirar fregadero",
|
||||
"action2": "Usar"
|
||||
"action1": "Mirar fregadero",
|
||||
"action2": "Usar"
|
||||
}
|
||||
action3_target_texts = {
|
||||
"turno_cocina_bol": "Llenar el bol de agua",
|
||||
@@ -155,8 +155,8 @@ esc_script = "res://gymkhana/rooms/turno_cocina/cocina/esc/fregadero_izq.esc"
|
||||
combine_when_selected_action_is_in = [ ]
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
tooltips = {
|
||||
"action1": "Mirar fregadero",
|
||||
"action2": "Usar"
|
||||
"action1": "Mirar fregadero",
|
||||
"action2": "Usar"
|
||||
}
|
||||
action3_target_texts = {
|
||||
"turno_cocina_bol": "Llenar el bol de agua",
|
||||
@@ -180,8 +180,8 @@ esc_script = "res://gymkhana/rooms/turno_cocina/cocina/esc/debajo_sofa.esc"
|
||||
combine_when_selected_action_is_in = [ "action4" ]
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
tooltips = {
|
||||
"action1": "Mirar debajo del sofa",
|
||||
"action2": "Meter la mano"
|
||||
"action1": "Mirar debajo del sofa",
|
||||
"action2": "Meter la mano"
|
||||
}
|
||||
action3_target_texts = {
|
||||
"turno_cocina_frontal": "Mirar denajo del sofa"
|
||||
|
||||
@@ -45,7 +45,7 @@ is_exit = true
|
||||
combine_when_selected_action_is_in = [ ]
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
tooltips = {
|
||||
"action1": "Entrar en la cocina"
|
||||
"action1": "Entrar en la cocina"
|
||||
}
|
||||
animations = null
|
||||
|
||||
@@ -68,7 +68,7 @@ is_exit = true
|
||||
combine_when_selected_action_is_in = [ ]
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
tooltips = {
|
||||
"action1": "Bajar a la despensa"
|
||||
"action1": "Bajar a la despensa"
|
||||
}
|
||||
animations = null
|
||||
|
||||
@@ -91,7 +91,7 @@ is_exit = true
|
||||
combine_when_selected_action_is_in = [ ]
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
tooltips = {
|
||||
"action1": "Ir detrás"
|
||||
"action1": "Ir detrás"
|
||||
}
|
||||
animations = null
|
||||
|
||||
@@ -109,12 +109,12 @@ global_id = "puerta_detras_start"
|
||||
position = Vector2( 813, 440 )
|
||||
dialog_color = Color( 0, 1, 0.462745, 1 )
|
||||
tooltips = {
|
||||
"action1": "Observar sujeto",
|
||||
"action2": "Hablar"
|
||||
"action1": "Observar sujeto",
|
||||
"action2": "Hablar"
|
||||
}
|
||||
action3_target_texts = {
|
||||
"bombona2": "Toma, un regalo",
|
||||
"caja_herramientas": "Regalar"
|
||||
"caja_herramientas": "Regalar",
|
||||
"turno_cocina_frontal": "Ofrecer"
|
||||
}
|
||||
target_when_selected_action_is_in = [ "action3" ]
|
||||
selectable = true
|
||||
@@ -134,3 +134,28 @@ position = Vector2( 1425, 527 )
|
||||
script = ExtResource( 5 )
|
||||
global_id = "new_game_start_location"
|
||||
is_start_location = true
|
||||
|
||||
|
||||
[node name="pegatinas" type="Area2D" parent="."]
|
||||
position = Vector2( 870, 264 )
|
||||
pause_mode = 1
|
||||
script = ExtResource( 6 )
|
||||
global_id = "cocina_delante_pegatinas"
|
||||
esc_script = "res://gymkhana/rooms/turno_cocina/cocina_delante/esc/pegatinas.esc"
|
||||
dialog_color = Color( 1, 1, 1, 1 )
|
||||
tooltips = {
|
||||
"action1": "Observar pegatinas",
|
||||
"action2": "Coger una pegatina"
|
||||
}
|
||||
action3_target_texts = {}
|
||||
target_when_selected_action_is_in = []
|
||||
animations = null
|
||||
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="pegatinas"]
|
||||
position = Vector2( -33, -25 )
|
||||
polygon = PoolVector2Array( -17, 86, 39, 87, 57, 86, 93, 79, 91, -16, 47, -17, -20, -17, -19, 38 )
|
||||
|
||||
[node name="ESCLocation" type="Position2D" parent="pegatinas"]
|
||||
position = Vector2( -99, 213 )
|
||||
script = ExtResource( 5 )
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
:action1
|
||||
say_random current_player turno_cocina_pegatinas 5 1
|
||||
|
||||
:action2
|
||||
say eneko_smoking pegatinas_action2_eneko_smoking_say:"Eh! las pegatinas no se tocan"
|
||||
@@ -0,0 +1,6 @@
|
||||
keys,es
|
||||
turno_cocina_pegatinas_1,Hay muchas que molan!!
|
||||
turno_cocina_pegatinas_2,Algunas no las entiendo.
|
||||
turno_cocina_pegatinas_3,Alguna ya la conocia.
|
||||
turno_cocina_pegatinas_4,Ya casi no se ve la ventana.
|
||||
turno_cocina_pegatinas_5,La proxima vez que venga traere alguna pegatina.
|
||||
|
@@ -2,4 +2,5 @@ keys,en,fr,es
|
||||
hello_start_game,"Alo Uli!","Alo Uli!","Alo Uli!"
|
||||
frontal_action3,"Admire","Admire","Admirar"
|
||||
frontal_action3_say,"It's my lifelong headlight, I love it","C'est ma lampe frontale de toujours, je l'adore","Es mi frontal de toda la vida, le tengo cariño"
|
||||
frontal_action4,"Use","Utiliser","Usar"
|
||||
frontal_action4,"Use","Utiliser","Usar"
|
||||
pegatinas_action2_eneko_smoking_say,"Eh! las pegatinas no se tocan","Eh! las pegatinas no se tocan","Eh! las pegatinas no se tocan"
|
||||
|
@@ -545,6 +545,11 @@ _global_script_classes=[ {
|
||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/say.gd"
|
||||
}, {
|
||||
"base": "ESCBaseCommand",
|
||||
"class": "SayRandomCommand",
|
||||
"language": "GDScript",
|
||||
"path": "res://gymkhana/addons/escoria-ui-return-monkey-island-dialog-simple/commands/say_random.gd"
|
||||
}, {
|
||||
"base": "ESCBaseCommand",
|
||||
"class": "SchedEventCommand",
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/sched_event.gd"
|
||||
@@ -802,6 +807,7 @@ _global_script_class_icons={
|
||||
"RandGlobalCommand": "",
|
||||
"RepeatCommand": "",
|
||||
"SayCommand": "",
|
||||
"SayRandomCommand": "",
|
||||
"SchedEventCommand": "",
|
||||
"SetActiveCommand": "",
|
||||
"SetActiveIfExistsCommand": "",
|
||||
@@ -873,7 +879,7 @@ enabled=PoolStringArray( "res://addons/escoria-core/plugin.cfg", "res://gymkhana
|
||||
main/game_version="0.1.0"
|
||||
main/game_start_script="res://gymkhana/start_game.esc"
|
||||
main/force_quit=true
|
||||
main/command_directories=[ "res://addons/escoria-core/game/core-scripts/esc/commands", "res://gymkhana/addons/escoria-ui-return-monkey-island/esc/commands" ]
|
||||
main/command_directories=[ "res://addons/escoria-core/game/core-scripts/esc/commands", "res://gymkhana/addons/escoria-ui-return-monkey-island/esc/commands", "res://gymkhana/addons/escoria-ui-return-monkey-island-dialog-simple/commands" ]
|
||||
main/text_lang="es_ES"
|
||||
main/voice_lang="es_ES"
|
||||
main/savegames_path="res://saves/"
|
||||
@@ -947,7 +953,7 @@ ui_show_room_selector={
|
||||
|
||||
[locale]
|
||||
|
||||
translations=PoolStringArray( "res://game/translations/game.en.translation", "res://game/translations/game.fr.translation", "res://game/translations/main_menu.en.translation", "res://game/translations/main_menu.fr.translation", "res://game/translations/game.de.translation", "res://game/translations/main_menu.de.translation", "res://gymkhana/translations/turno_cocina.en.translation", "res://gymkhana/translations/turno_cocina.es.translation", "res://gymkhana/translations/turno_cocina.fr.translation", "res://game/translations/game.es.translation", "res://game/translations/main_menu.es.translation" )
|
||||
translations=PoolStringArray( "res://game/translations/game.en.translation", "res://game/translations/game.fr.translation", "res://game/translations/main_menu.en.translation", "res://game/translations/main_menu.fr.translation", "res://game/translations/game.de.translation", "res://game/translations/main_menu.de.translation", "res://gymkhana/translations/turno_cocina.en.translation", "res://gymkhana/translations/turno_cocina.es.translation", "res://gymkhana/translations/turno_cocina.fr.translation", "res://game/translations/game.es.translation", "res://game/translations/main_menu.es.translation", "res://gymkhana/translations/randomizer/turno_cocina_pegatinas.es.translation" )
|
||||
locale_filter=[ 0, [ ] ]
|
||||
translation_remaps={
|
||||
"res://game/speech/room01/ROOM1_look_wall_item_1.ogg": PoolStringArray( "res://game/speech/room01/ROOM1_look_wall_item_1_de.ogg:de" ),
|
||||
|
||||
Reference in New Issue
Block a user