sequences, random & global variables
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# `say_random player list_id lenght [offset]`
|
||||
# `say_random global_id list_id lenght`
|
||||
#
|
||||
# Displays the specified string as dialog spoken by the player. This command
|
||||
# blocks further event execution until the dialog has finished being 'said'
|
||||
@@ -16,7 +16,6 @@
|
||||
# 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`
|
||||
#
|
||||
@@ -39,17 +38,15 @@ func _init() -> void:
|
||||
func configure() -> ESCCommandArgumentDescriptor:
|
||||
return ESCCommandArgumentDescriptor.new(
|
||||
3,
|
||||
[TYPE_STRING, TYPE_STRING, TYPE_INT, TYPE_INT],
|
||||
[TYPE_STRING, TYPE_STRING, TYPE_INT],
|
||||
[
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
0
|
||||
null
|
||||
],
|
||||
[
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
)
|
||||
@@ -75,7 +72,10 @@ func validate(arguments: Array):
|
||||
# Run the command
|
||||
func run(command_params: Array) -> int:
|
||||
escoria.current_state = escoria.GAME_STATE.DIALOG
|
||||
|
||||
var param_global_id = command_params[0]
|
||||
var param_list_id = command_params[1]
|
||||
var param_lenght = command_params[2]
|
||||
|
||||
if !escoria.dialog_player:
|
||||
escoria.logger.error(
|
||||
self,
|
||||
@@ -94,11 +94,11 @@ func run(command_params: Array) -> int:
|
||||
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 text = param_list_id + "_" + String(rng.randi_range(0,param_lenght -1)) + ':" "'
|
||||
|
||||
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]
|
||||
if param_global_id.to_upper() == CURRENT_PLAYER_KEYWORD \
|
||||
else param_global_id
|
||||
|
||||
escoria.dialog_player.say(
|
||||
speaking_character_global_id,
|
||||
@@ -107,6 +107,14 @@ func run(command_params: Array) -> int:
|
||||
)
|
||||
yield(escoria.dialog_player, "say_finished")
|
||||
escoria.current_state = escoria.GAME_STATE.DEFAULT
|
||||
|
||||
var current_count_global_key = "%s_count" % [param_list_id]
|
||||
var current_count = escoria.globals_manager.get_global(current_count_global_key)
|
||||
if(current_count == null):
|
||||
current_count = 0
|
||||
|
||||
escoria.globals_manager.set_global(current_count_global_key, current_count + 1)
|
||||
|
||||
return ESCExecution.RC_OK
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
# `say_random global_id list_id lenght [loop]`
|
||||
#
|
||||
# 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**
|
||||
#
|
||||
# - *global_id*: 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.
|
||||
# - *loop*: . Loop the list.Can be true or false. Default: false
|
||||
#
|
||||
# Example: `say_random player random_list 4 false`
|
||||
#
|
||||
# @ESC
|
||||
extends ESCBaseCommand
|
||||
class_name SaySequenceCommand
|
||||
|
||||
|
||||
const CURRENT_PLAYER_KEYWORD = "CURRENT_PLAYER"
|
||||
|
||||
|
||||
|
||||
|
||||
# Return the descriptor of the arguments of this command
|
||||
func configure() -> ESCCommandArgumentDescriptor:
|
||||
return ESCCommandArgumentDescriptor.new(
|
||||
3,
|
||||
[TYPE_STRING, TYPE_STRING, TYPE_INT, TYPE_BOOL],
|
||||
[
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
false
|
||||
],
|
||||
[
|
||||
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
|
||||
var param_global_id = command_params[0]
|
||||
var param_list_id = command_params[1]
|
||||
var param_lenght = command_params[2]
|
||||
var loop = command_params[3]
|
||||
|
||||
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 current_index_global_key = "%s_current_iteration" % [param_list_id]
|
||||
var current_index = escoria.globals_manager.get_global(current_index_global_key)
|
||||
if(current_index == null):
|
||||
current_index = 0
|
||||
var text = '%s_%s:" "' % [param_list_id,current_index]
|
||||
|
||||
|
||||
var speaking_character_global_id = escoria.main.current_scene.player.global_id \
|
||||
if param_global_id.to_upper() == CURRENT_PLAYER_KEYWORD \
|
||||
else param_global_id
|
||||
|
||||
escoria.dialog_player.say(
|
||||
speaking_character_global_id,
|
||||
"",
|
||||
text
|
||||
)
|
||||
yield(escoria.dialog_player, "say_finished")
|
||||
escoria.current_state = escoria.GAME_STATE.DEFAULT
|
||||
|
||||
current_index += 1
|
||||
if(current_index == param_lenght):
|
||||
if loop:
|
||||
current_index = 0
|
||||
else:
|
||||
current_index = param_lenght -1 #Don't like it but for now it works.
|
||||
|
||||
escoria.globals_manager.set_global(current_index_global_key, current_index)
|
||||
|
||||
|
||||
var current_count_global_key = "%s_count" % [param_list_id]
|
||||
var current_count = escoria.globals_manager.get_global(current_count_global_key)
|
||||
if(current_count == null):
|
||||
current_count = 0
|
||||
|
||||
escoria.globals_manager.set_global(current_count_global_key, current_count + 1)
|
||||
|
||||
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()
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
# `play_lib_snd`
|
||||
# `play_lib_snd filename namespace`
|
||||
#
|
||||
# Plays a sound from the library.
|
||||
#
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# `set_tooltip object action text`
|
||||
# `set_tooltip global_id action text`
|
||||
#
|
||||
# Sets the tooltip text for the given `ESCItemWithTooltip` and action.
|
||||
#
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
:action1
|
||||
say_random current_player turno_cocina_pegatinas 5 1
|
||||
|
||||
say_sequence current_player turno_cocina_pegatinas 5 true
|
||||
|
||||
:action2
|
||||
say eneko_smoking pegatinas_action2_eneko_smoking_say:"Eh! las pegatinas no se tocan"
|
||||
say_random eneko_smoking turno_cocina_pegatinas_eneko_smoking 4
|
||||
say eneko_smoking "Deja de intentarlo! Llevas ya {turno_cocina_pegatinas_eneko_smoking_count} veces!" [eq turno_cocina_pegatinas_eneko_smoking_count 2]
|
||||
say eneko_smoking "Deja de intentarlo! Llevas ya {turno_cocina_pegatinas_eneko_smoking_count} veces!" [eq turno_cocina_pegatinas_eneko_smoking_count 10]
|
||||
say eneko_smoking "Deja de intentarlo! Llevas ya {turno_cocina_pegatinas_eneko_smoking_count} veces!" [eq turno_cocina_pegatinas_eneko_smoking_count 20]
|
||||
|
||||
11
gymkhana/translations/lists/turno_cocina_pegatinas.csv
Normal file
11
gymkhana/translations/lists/turno_cocina_pegatinas.csv
Normal file
@@ -0,0 +1,11 @@
|
||||
keys,es
|
||||
turno_cocina_pegatinas_0,La proxima vez que venga traere alguna pegatina.
|
||||
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_eneko_smoking_0,Eh! las pegatinas no se tocan.
|
||||
turno_cocina_pegatinas_eneko_smoking_1,Eh! Ni se te ocurra tocarlas.
|
||||
turno_cocina_pegatinas_eneko_smoking_2,Eh! Cuidado que las tengo contadas.
|
||||
turno_cocina_pegatinas_eneko_smoking_3,Eh! No insistas!.
|
||||
turno_cocina_pegatinas_eneko_smoking_count,"Deja de intentarlo! Llevas ya {turno_cocina_pegatinas_eneko_smoking_count} veces!"
|
||||
|
@@ -1,6 +0,0 @@
|
||||
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.
|
||||
|
Reference in New Issue
Block a user