fix: combine items without use_from_inventory_only

This commit is contained in:
2023-03-09 19:22:41 +01:00
parent ad4acae88d
commit 56bf73b639
5 changed files with 47 additions and 62 deletions

View File

@@ -60,69 +60,47 @@ func _get_event_to_queue(
if escoria.inventory_manager.inventory_has(target.global_id): if escoria.inventory_manager.inventory_has(target.global_id):
# Player has item in inventory, we check the element to use on # Player has item in inventory, we check the element to use on
if combine_with: if combine_with:
var do_combine = true var target_event = "%s %s" % [
if combine_with.node is ESCItem \ action,
and combine_with.node.use_from_inventory_only\ combine_with.global_id
and not escoria.inventory_manager.inventory_has( ]
combine_with.global_id var combine_with_event = "%s %s" % [
): action,
do_combine = false target.global_id
]
if do_combine: if target.events.has(target_event):
var target_event = "%s %s" % [ event_to_return = target.events[target_event]
action, elif combine_with.events.has(combine_with_event)\
combine_with.global_id and not combine_with.node.combine_is_one_way:
]
var combine_with_event = "%s %s" % [
action,
target.global_id
]
if target.events.has(target_event): event_to_return = combine_with.events[combine_with_event]
event_to_return = target.events[target_event]
elif combine_with.events.has(combine_with_event)\
and not combine_with.node.combine_is_one_way:
event_to_return = combine_with.events[combine_with_event]
else:
# Check to see if there isn't a "fallback" action to
# run before we declare this a failure.
if escoria.action_default_script \
and escoria.action_default_script.events.has(action):
event_to_return = escoria.action_default_script.events[action]
else:
var errors = [
"Attempted to execute action %s between item %s and item %s" % [
action,
target.global_id,
combine_with.global_id
]
]
if combine_with.node.combine_is_one_way:
errors.append(
("Reason: %s's item interaction " + \
"is one-way.") % combine_with.global_id
)
escoria.logger.warn(
self,
"Invalid action: " + str(errors)
)
else: else:
escoria.logger.warn( # Check to see if there isn't a "fallback" action to
self, # run before we declare this a failure.
"Invalid action on item: " + if escoria.action_default_script \
( and escoria.action_default_script.events.has(action):
"Trying to combine object %s with %s, "+
"but %s is not in inventory." event_to_return = escoria.action_default_script.events[action]
) % [ else:
var errors = [
"Attempted to execute action %s between item %s and item %s" % [
action,
target.global_id, target.global_id,
combine_with.global_id,
combine_with.global_id combine_with.global_id
] ]
) ]
if combine_with.node.combine_is_one_way:
errors.append(
("Reason: %s's item interaction " + \
"is one-way.") % combine_with.global_id
)
escoria.logger.warn(
self,
"Invalid action: " + str(errors)
)
else: else:
escoria.logger.warn( escoria.logger.warn(
self, self,

View File

@@ -58,8 +58,11 @@ signal tooltip_size_updated
# Connect relevant functions # Connect relevant functions
func _ready(): func _ready():
escoria.main.connect("room_ready", self, "_on_room_ready") if escoria.main.connect("room_ready", self, "_on_room_ready") != 0:
escoria.action_manager.connect("action_changed", self, "_on_action_selected") escoria.logger.error(self, "Error connecting room_ready with _on_room_ready")
if escoria.action_manager.connect("action_changed", self, "_on_action_selected") != 0:
escoria.logger.error(self, "Error connecting action_changed with _on_action_selected")
# Set the color of the label # Set the color of the label

View File

@@ -86,7 +86,7 @@ func _ready():
escoria.action_manager = ESCActionManagerMonkey.new() escoria.action_manager = ESCActionManagerMonkey.new()
if $tooltip_layer/tooltip.connect("tooltip_size_updated", self, "update_tooltip_following_mouse_position", [tooltip_node]) != 0: if $tooltip_layer/tooltip.connect("tooltip_size_updated", self, "update_tooltip_following_mouse_position", [tooltip_node]) != 0:
escoria.logger.error(self, "Error connecting tooltip_size_updated") escoria.logger.error(self, "Error connecting tooltip_size_updated with update_tooltip_following_mouse_position")
func _enter_tree(): func _enter_tree():
var room_selector_parent = $CanvasLayer/ui/HBoxContainer/VBoxContainer var room_selector_parent = $CanvasLayer/ui/HBoxContainer/VBoxContainer
@@ -419,6 +419,9 @@ func correctPosition(tooltip: ESCRichTooltip, size: Vector2, mouse_position: Vec
func _on_event_done(return_code: int, _event_name: String): func _on_event_done(return_code: int, _event_name: String):
escoria.logger.info(self, "EVENT DONE! code=" + String(return_code)) escoria.logger.info(self, "EVENT DONE! code=" + String(return_code))
# Reset mouse cursor (should be not needed, but avoids not resetting the cursor on bugs)
Input.set_custom_mouse_cursor(null)
# Show tooltips, they were hidden while performing action # Show tooltips, they were hidden while performing action
$tooltip_layer/tooltip.update_tooltip_text() $tooltip_layer/tooltip.update_tooltip_text()

View File

@@ -6,7 +6,7 @@ play_snd res://game/sfx/sounds/doorOpen_2.ogg
change_scene "res://gymkhana/rooms/interior_cocina/interior_cocina.tscn" change_scene "res://gymkhana/rooms/interior_cocina/interior_cocina.tscn"
:action3 bombona2 :action3 bombona2
say player "He usado la 'bombona' con la puerta" say player "¿Cómo se usa una bómbona con una puerta?"
:action4 bombona2 :action4 bombona2
say player "No creo que les haga gracia" say player "No creo que les haga gracia"

View File

@@ -3,7 +3,8 @@ say current_player "Tiene pinta de que fuma"
:action2 :action2
> [whatsapp_blocked] > [whatsapp_blocked]
say current_player "Hola..." say current_player "Hola"
say current_player "..."
say current_player "No me escucha, parece que me tiene bloqueado" say current_player "No me escucha, parece que me tiene bloqueado"
stop stop