fix: uses proper casting and updates validation checks

This commit is contained in:
Duncan Brown authored and Julian Murgia committed 2023-01-19 14:34:37 +01:00
1 parent 53c900b36e
commit 327b72f67b
2 files changed
+23 -3

No files matched your search

@@ -34,6 +34,15 @@ func validate(arguments: Array):
% [get_command_name(), arguments[0]]
)
return false
if not (escoria.object_manager.get_object(arguments[0]).node as ESCItem):
escoria.logger.error(
self,
"[%s]: invalid first object. Object to teleport with global id %s must be of or derived from type ESCItem."
% [get_command_name(), arguments[0]]
)
return false
if not escoria.object_manager.has(arguments[1]):
escoria.logger.error(
self,
@@ -46,7 +55,7 @@ func validate(arguments: Array):
# Run the command
func run(command_params: Array) -> int:
(escoria.object_manager.get_object(command_params[0]).node as ESCPlayer)\
(escoria.object_manager.get_object(command_params[0]).node as ESCItem) \
.teleport(
escoria.object_manager.get_object(command_params[1]).node
)
@@ -34,13 +34,24 @@ func validate(arguments: Array):
% [get_command_name(), arguments[0]]
)
return false
if not (escoria.object_manager.get_object(arguments[0]).node as ESCItem):
escoria.logger.error(
self,
"[%s]: invalid first object. Object to teleport with global id %s must be of or derived from type ESCItem."
% [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.teleport_to(
Vector2(int(command_params[1]), int(command_params[2]))
(escoria.object_manager.get_object(command_params[0]).node as ESCItem) \
.teleport_to(
Vector2(int(command_params[1]), int(command_params[2])
)
)
return ESCExecution.RC_OK