Erase all references to use_from_inventory_only

This commit is contained in:
2023-03-09 19:33:43 +01:00
parent 56bf73b639
commit 99d2b89a4e
5 changed files with 40 additions and 62 deletions

View File

@@ -55,63 +55,50 @@ func _get_event_to_queue(
or combine_with):
# or (combine_with && action in combine_with.node.combine_when_selected_action_is_in)):
# Check if object must be in inventory to be used
if target.node.use_from_inventory_only:
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 target_event = "%s %s" % [
action,
combine_with.global_id
]
var combine_with_event = "%s %s" % [
action,
target.global_id
]
# Player has item in inventory, we check the element to use on
if escoria.inventory_manager.inventory_has(target.global_id):
if combine_with:
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]
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:
# 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
]
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)
if combine_with.node.combine_is_one_way:
errors.append(
("Reason: %s's item interaction " + \
"is one-way.") % combine_with.global_id
)
else:
escoria.logger.warn(
self,
"Invalid action on item: " +
"Trying to run action %s on object %s, " %
[
action,
target.node.global_id
]
+ "but item must be in inventory."
)
escoria.logger.warn(
self,
"Invalid action: " + str(errors)
)
else:
if target.events.has(action):
event_to_return = target.events[action]
@@ -221,12 +208,7 @@ func perform_inputevent_on_object(
current_target
)
else:
# Check if object must be in inventory to be used and update
# action state if necessary
if obj.node.use_from_inventory_only and \
escoria.inventory_manager.inventory_has(obj.global_id) and \
need_combine:
if need_combine:
# We're missing a target here for our tool to be used on
current_tool = obj
set_action_input_state(