sequences, random & global variables
This commit is contained in:
13
GYMKHANA.md
Normal file
13
GYMKHANA.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Gymkhana
|
||||||
|
> Las gymkhanikas de Uli
|
||||||
|
|
||||||
|
## ESC Commands
|
||||||
|
- `item_count_add item_id value`
|
||||||
|
- `play_lib_snd filename namespace`
|
||||||
|
- `play_video "res://file"`
|
||||||
|
- `set_tooltip object action text`
|
||||||
|
- `say_random player list_id lenght`
|
||||||
|
- Generates a global variable `{list_id}_count`
|
||||||
|
- `say_sequence player list_id lenght [loop]`
|
||||||
|
- Generates a global variable `{list_id}_current_index`
|
||||||
|
- Generates a global variable `{list_id}_count`
|
||||||
@@ -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
|
# Displays the specified string as dialog spoken by the player. This command
|
||||||
# blocks further event execution until the dialog has finished being 'said'
|
# blocks further event execution until the dialog has finished being 'said'
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
# like Maniac Mansion or Day of the Tentacle.
|
# like Maniac Mansion or Day of the Tentacle.
|
||||||
# - *randomizer_list_id*: ID for the list of sentences.
|
# - *randomizer_list_id*: ID for the list of sentences.
|
||||||
# - *lenght*: lenght of the list.
|
# - *lenght*: lenght of the list.
|
||||||
# - *offset*: starting offset index of the list.
|
|
||||||
#
|
#
|
||||||
# Example: `say_random player random_list 4`
|
# Example: `say_random player random_list 4`
|
||||||
#
|
#
|
||||||
@@ -39,17 +38,15 @@ func _init() -> void:
|
|||||||
func configure() -> ESCCommandArgumentDescriptor:
|
func configure() -> ESCCommandArgumentDescriptor:
|
||||||
return ESCCommandArgumentDescriptor.new(
|
return ESCCommandArgumentDescriptor.new(
|
||||||
3,
|
3,
|
||||||
[TYPE_STRING, TYPE_STRING, TYPE_INT, TYPE_INT],
|
[TYPE_STRING, TYPE_STRING, TYPE_INT],
|
||||||
[
|
[
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null
|
||||||
0
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
false,
|
|
||||||
false
|
false
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@@ -75,7 +72,10 @@ func validate(arguments: Array):
|
|||||||
# Run the command
|
# Run the command
|
||||||
func run(command_params: Array) -> int:
|
func run(command_params: Array) -> int:
|
||||||
escoria.current_state = escoria.GAME_STATE.DIALOG
|
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:
|
if !escoria.dialog_player:
|
||||||
escoria.logger.error(
|
escoria.logger.error(
|
||||||
self,
|
self,
|
||||||
@@ -94,11 +94,11 @@ func run(command_params: Array) -> int:
|
|||||||
escoria.current_state = escoria.GAME_STATE.DEFAULT
|
escoria.current_state = escoria.GAME_STATE.DEFAULT
|
||||||
return ESCExecution.RC_CANCEL
|
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 \
|
var speaking_character_global_id = escoria.main.current_scene.player.global_id \
|
||||||
if command_params[0].to_upper() == CURRENT_PLAYER_KEYWORD \
|
if param_global_id.to_upper() == CURRENT_PLAYER_KEYWORD \
|
||||||
else command_params[0]
|
else param_global_id
|
||||||
|
|
||||||
escoria.dialog_player.say(
|
escoria.dialog_player.say(
|
||||||
speaking_character_global_id,
|
speaking_character_global_id,
|
||||||
@@ -107,6 +107,14 @@ func run(command_params: Array) -> int:
|
|||||||
)
|
)
|
||||||
yield(escoria.dialog_player, "say_finished")
|
yield(escoria.dialog_player, "say_finished")
|
||||||
escoria.current_state = escoria.GAME_STATE.DEFAULT
|
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
|
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.
|
# 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.
|
# Sets the tooltip text for the given `ESCItemWithTooltip` and action.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
:action1
|
:action1
|
||||||
say_random current_player turno_cocina_pegatinas 5 1
|
say_sequence current_player turno_cocina_pegatinas 5 true
|
||||||
|
|
||||||
:action2
|
: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.
|
|
||||||
|
@@ -575,6 +575,11 @@ _global_script_classes=[ {
|
|||||||
"path": "res://gymkhana/addons/escoria-ui-return-monkey-island-dialog-simple/commands/say_random.gd"
|
"path": "res://gymkhana/addons/escoria-ui-return-monkey-island-dialog-simple/commands/say_random.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "ESCBaseCommand",
|
"base": "ESCBaseCommand",
|
||||||
|
"class": "SaySequenceCommand",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://gymkhana/addons/escoria-ui-return-monkey-island-dialog-simple/commands/say_sequence.gd"
|
||||||
|
}, {
|
||||||
|
"base": "ESCBaseCommand",
|
||||||
"class": "SchedEventCommand",
|
"class": "SchedEventCommand",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/sched_event.gd"
|
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/sched_event.gd"
|
||||||
@@ -838,6 +843,7 @@ _global_script_class_icons={
|
|||||||
"RepeatCommand": "",
|
"RepeatCommand": "",
|
||||||
"SayCommand": "",
|
"SayCommand": "",
|
||||||
"SayRandomCommand": "",
|
"SayRandomCommand": "",
|
||||||
|
"SaySequenceCommand": "",
|
||||||
"SchedEventCommand": "",
|
"SchedEventCommand": "",
|
||||||
"SetActiveCommand": "",
|
"SetActiveCommand": "",
|
||||||
"SetActiveIfExistsCommand": "",
|
"SetActiveIfExistsCommand": "",
|
||||||
@@ -984,7 +990,7 @@ ui_show_room_selector={
|
|||||||
|
|
||||||
[locale]
|
[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", "res://gymkhana/translations/randomizer/turno_cocina_pegatinas.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/lists/turno_cocina_pegatinas.es.translation" )
|
||||||
locale_filter=[ 0, [ ] ]
|
locale_filter=[ 0, [ ] ]
|
||||||
translation_remaps={
|
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" ),
|
"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