Fixed use inventory items

This commit is contained in:
2023-02-24 20:33:31 +01:00
parent c78d37b12a
commit c633e4bd23
4 changed files with 35 additions and 26 deletions

View File

@@ -236,17 +236,20 @@ func element_unfocused() -> void:
## ITEMS ##
func click_on_item(item_global_id: String, event: InputEvent, action: String) -> void:
escoria.logger.info(self, "current_action:" + escoria.action_manager.current_action)
escoria.logger.info(self, "action_state:" + String(escoria.action_manager.action_state))
escoria.action_manager.set_current_action(action)
escoria.logger.info(self, "current_action:" + escoria.action_manager.current_action)
if escoria.action_manager.current_target == null:
escoria.logger.info(self, "current_target:null")
else:
escoria.logger.info(self, "current_target:" + escoria.action_manager.current_target.to_string())
if escoria.action_manager.current_tool == null:
escoria.logger.info(self, "current_tool:null")
else:
escoria.logger.info(self, "current_tool:" + escoria.action_manager.current_tool.to_string())
escoria.logger.info(self, "current_action2:" + escoria.action_manager.current_action)
escoria.logger.info(self, "action_state2:" + String(escoria.action_manager.action_state))
# if escoria.action_manager.current_target == null:
# escoria.logger.info(self, "current_target:null")
# else:
# escoria.logger.info(self, "current_target:" + escoria.action_manager.current_target.to_string())
# if escoria.action_manager.current_tool == null:
# escoria.logger.info(self, "current_tool:null")
# else:
# escoria.logger.info(self, "current_tool:" + escoria.action_manager.current_tool.to_string())
var target_obj = escoria.object_manager.get_object(item_global_id).node
@@ -277,17 +280,20 @@ func left_double_click_on_item(item_global_id: String, event: InputEvent) -> voi
## INVENTORY ##
func click_on_inventory_item(item_global_id: String, event: InputEvent, action: String) -> void:
escoria.logger.info(self, "current_action inv:" + escoria.action_manager.current_action)
escoria.logger.info(self, "action_state inv:" + String(escoria.action_manager.action_state))
escoria.action_manager.set_current_action(action)
escoria.logger.info(self, "current_action:" + escoria.action_manager.current_action)
if escoria.action_manager.current_target == null:
escoria.logger.info(self, "current_target:null")
else:
escoria.logger.info(self, "current_target:" + escoria.action_manager.current_target.to_string())
if escoria.action_manager.current_tool == null:
escoria.logger.info(self, "current_tool:null")
else:
escoria.logger.info(self, "current_tool:" + escoria.action_manager.current_tool.to_string())
escoria.logger.info(self, "current_action2 inv:" + escoria.action_manager.current_action)
escoria.logger.info(self, "action_state2 inv:" + String(escoria.action_manager.action_state))
# if escoria.action_manager.current_target == null:
# escoria.logger.info(self, "current_target:null")
# else:
# escoria.logger.info(self, "current_target:" + escoria.action_manager.current_target.to_string())
# if escoria.action_manager.current_tool == null:
# escoria.logger.info(self, "current_tool:null")
# else:
# escoria.logger.info(self, "current_tool:" + escoria.action_manager.current_tool.to_string())
var target_obj = escoria.object_manager.get_object(item_global_id).node
@@ -305,7 +311,8 @@ func left_click_on_inventory_item(inventory_item_global_id: String, event: Input
var target_obj = escoria.object_manager.get_object(inventory_item_global_id).node
if ACTION3 in target_obj.combine_when_selected_action_is_in:
Input.set_custom_mouse_cursor(target_obj.inventory_texture)
click_on_inventory_item(inventory_item_global_id, event, ACTION3)
click_on_inventory_item(inventory_item_global_id, event, ACTION1)
# click_on_inventory_item(inventory_item_global_id, event, ACTION3)
func right_click_on_inventory_item(inventory_item_global_id: String, event: InputEvent) -> void:
click_on_inventory_item(inventory_item_global_id, event, ACTION4)
@@ -413,8 +420,9 @@ func update_tooltip_following_mouse_position(tooltip: Object):
tooltip.rect_position = corrected_position + tooltip.offset_from_cursor
func _on_event_done(return_code: int, _event_name: String):
if return_code == ESCExecution.RC_OK:
escoria.action_manager.clear_current_action()
escoria.logger.info(self, "EVENT DONE! code=" + String(return_code))
# if return_code == ESCExecution.RC_OK:
# escoria.action_manager.clear_current_action()
# Show tooltips, they were hiddeen while performing action
$tooltip_layer/tooltip.show()
$tooltip_layer/tooltip2.show()

View File

@@ -1,4 +1,4 @@
:action3 i_bombona2
:action1 i_bombona2
say player "He usado la 'bombona' con la puerta"
# > [eq r5_dialog_advance 2]
# say player "I already fixed the water leak."

View File

@@ -6,8 +6,8 @@ say player "Voy a cogerla"
set_active i_bombona false
inventory_add i_bombona
:action3
say player "Es el segundo bolsillo más grande que he visto nunca"
# :action3
# say player "Es el segundo bolsillo más grande que he visto nunca"
:action4
say player "Antes era una bombona pero ahora es una llave inglesa."

View File

@@ -93,7 +93,8 @@ script = ExtResource( 28 )
global_id = "i_bombona2"
esc_script = "res://gymkhana/rooms/trasera_cocina/esc/i_bombona2.esc"
tooltip_name = "TT Mirar bombona"
combine_when_selected_action_is_in = [ "action3" ]
combine_when_selected_action_is_in = [ "action1", "action3" ]
use_from_inventory_only = true
inventory_texture = ExtResource( 29 )
dialog_color = Color( 1, 1, 1, 1 )
tooltip2_name = "TT2 Coger bombona"