fix: uses proper casting and updates validation checks
This commit is contained in:
committed by
Julian Murgia
parent
53c900b36e
commit
327b72f67b
@@ -34,6 +34,15 @@ func validate(arguments: Array):
|
|||||||
% [get_command_name(), arguments[0]]
|
% [get_command_name(), arguments[0]]
|
||||||
)
|
)
|
||||||
return false
|
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]):
|
if not escoria.object_manager.has(arguments[1]):
|
||||||
escoria.logger.error(
|
escoria.logger.error(
|
||||||
self,
|
self,
|
||||||
@@ -46,7 +55,7 @@ func validate(arguments: Array):
|
|||||||
|
|
||||||
# Run the command
|
# Run the command
|
||||||
func run(command_params: Array) -> int:
|
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(
|
.teleport(
|
||||||
escoria.object_manager.get_object(command_params[1]).node
|
escoria.object_manager.get_object(command_params[1]).node
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -34,13 +34,24 @@ func validate(arguments: Array):
|
|||||||
% [get_command_name(), arguments[0]]
|
% [get_command_name(), arguments[0]]
|
||||||
)
|
)
|
||||||
return false
|
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
|
return true
|
||||||
|
|
||||||
|
|
||||||
# Run the command
|
# Run the command
|
||||||
func run(command_params: Array) -> int:
|
func run(command_params: Array) -> int:
|
||||||
escoria.object_manager.get_object(command_params[0]).node.teleport_to(
|
(escoria.object_manager.get_object(command_params[0]).node as ESCItem) \
|
||||||
Vector2(int(command_params[1]), int(command_params[2]))
|
.teleport_to(
|
||||||
|
Vector2(int(command_params[1]), int(command_params[2])
|
||||||
|
)
|
||||||
)
|
)
|
||||||
return ESCExecution.RC_OK
|
return ESCExecution.RC_OK
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user