Merge pull request 'Command: set_tooltip' (#6) from gymkhana/command-set-tooltip into gymkhana/main

Reviewed-on: gymkhana/gymkhana#6
This commit is contained in:
eneko committed 2023-08-27 19:39:10 +02:00
commit 0a1e8e4d7c
4 files changed
+58 -2

No files matched your search

@@ -0,0 +1,52 @@
# `set_tooltip object action text`
#
# Sets the tooltip text for the given `ESCItemWithTooltip` and action.
#
# **Parameters**
#
# - *object*: Global ID of the object whose toolitp is to be updated
# - *action*: ID of the action, action1, action2, action3 or action4.
# - *toolip*: The tooltip text string
#
# @ESC
extends ESCBaseCommand
class_name SetTooltipCommand
# Return the descriptor of the arguments of this command
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
2,
[TYPE_STRING,TYPE_STRING, TYPE_STRING],
[null, "action1", ""]
)
# Validate whether the given arguments match the command descriptor
func validate(arguments: Array):
if not .validate(arguments):
return false
if 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.object_manager.get_object(command_params[0]).node as ESCItemWithTooltip)\
.set_tooltip(command_params[1],command_params[2])
return ESCExecution.RC_OK
# Function called when the command is interrupted.
func interrupt():
# Do nothing
pass
@@ -68,4 +68,6 @@ func highlight(value: bool):
var a = 0
func set_tooltip(action: String, text: String):
set(action + "_text", text)
@@ -1,5 +1,7 @@
:action1
say player "Hay muchas lentejas."
set_tooltip turno_cocina_despensa_bidon_cntr action1 "Mirar bidon con lentejas"
set_tooltip turno_cocina_despensa_bidon_cntr action2 "Coger lentejas"
:action2
say player "Necesito cogerlas con algo."