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):
# Player has item in inventory, we check the element to use on
if combine_with:
var do_combine = true
if combine_with.node is ESCItem \
and combine_with.node.use_from_inventory_only\
and not escoria.inventory_manager.inventory_has(
combine_with.global_id
):
do_combine = false
var target_event = "%s %s" % [
action,
combine_with.global_id
]
var combine_with_event = "%s %s" % [
action,
target.global_id
]
if do_combine:
var target_event = "%s %s" % [
action,
combine_with.global_id
]
var combine_with_event = "%s %s" % [
action,
target.global_id
]
if target.events.has(target_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:
if target.events.has(target_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)
)
event_to_return = combine_with.events[combine_with_event]
else:
escoria.logger.warn(
self,
"Invalid action on item: " +
(
"Trying to combine object %s with %s, "+
"but %s is not in inventory."
) % [
# 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,
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:
escoria.logger.warn(
self,

View File

@@ -58,8 +58,11 @@ signal tooltip_size_updated
# Connect relevant functions
func _ready():
escoria.main.connect("room_ready", self, "_on_room_ready")
escoria.action_manager.connect("action_changed", self, "_on_action_selected")
if escoria.main.connect("room_ready", self, "_on_room_ready") != 0:
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

View File

@@ -86,7 +86,7 @@ func _ready():
escoria.action_manager = ESCActionManagerMonkey.new()
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():
var room_selector_parent = $CanvasLayer/ui/HBoxContainer/VBoxContainer
@@ -418,6 +418,9 @@ func correctPosition(tooltip: ESCRichTooltip, size: Vector2, mouse_position: Vec
func _on_event_done(return_code: int, _event_name: String):
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
$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"
: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
say player "No creo que les haga gracia"

View File

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