Added a default action used when item is in inventory.
This commit is contained in:
@@ -39,7 +39,12 @@ export(bool) var player_orients_on_arrival = true
|
||||
|
||||
export(ESCPlayer.Directions) var interaction_direction
|
||||
export(String) var tooltip_name
|
||||
|
||||
# Default action to use if object is not in the inventory
|
||||
export(String) var default_action
|
||||
# Default action to use if object is in the inventory
|
||||
export(String) var default_action_inventory
|
||||
|
||||
# If action used by player is in the list, game will wait for a second click on another item
|
||||
# to combine objects together (typical USE <X> WITH <Y>, GIVE <X> TO <Y>)
|
||||
export(PoolStringArray) var combine_if_action_used_among = []
|
||||
@@ -98,7 +103,6 @@ var last_dir : int
|
||||
|
||||
|
||||
func _ready():
|
||||
|
||||
# Adds movable behavior
|
||||
Movable = Node.new()
|
||||
Movable.set_script(MovableScript)
|
||||
@@ -137,6 +141,11 @@ func _ready():
|
||||
connect("area_exited", self, "element_exited")
|
||||
connect("body_entered", self, "element_entered")
|
||||
connect("body_exited", self, "element_exited")
|
||||
|
||||
# If object can be in the inventory, set default_action_inventory to same as
|
||||
# default_action, if default_action_inventory is not set
|
||||
if use_from_inventory_only and default_action_inventory.empty():
|
||||
default_action_inventory = default_action
|
||||
|
||||
# Perform a first terrain scaling if we have to.
|
||||
if !is_exit or dont_apply_terrain_scaling:
|
||||
|
||||
@@ -5,7 +5,6 @@ func get_class():
|
||||
return "ESCInventoryItem"
|
||||
|
||||
export(String) var global_id
|
||||
#export(String, FILE, "*.esc") var esc_script
|
||||
|
||||
signal mouse_left_inventory_item(item_id)
|
||||
signal mouse_right_inventory_item(item_id)
|
||||
|
||||
@@ -184,12 +184,14 @@ func ev_left_click_on_item(obj, event, default_action = false):
|
||||
esc_runner.current_tool = obj
|
||||
else:
|
||||
if default_action:
|
||||
esc_runner.current_action = obj.default_action
|
||||
if esc_runner.inventory_has(obj.global_id):
|
||||
esc_runner.current_action = obj.default_action_inventory
|
||||
else:
|
||||
esc_runner.current_action = obj.default_action
|
||||
elif esc_runner.current_action in obj.combine_if_action_used_among:
|
||||
esc_runner.current_tool = obj
|
||||
|
||||
|
||||
var action = "walk"
|
||||
# Don't interact after player movement towards object (because object is inactive for example)
|
||||
var dont_interact = false
|
||||
var destination_position : Vector2 = main.current_scene.player.global_position
|
||||
|
||||
@@ -10,58 +10,58 @@
|
||||
|
||||
[sub_resource type="AtlasTexture" id=1]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 120, 0, 24, 70 )
|
||||
region = Rect2( 216, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=2]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 72, 0, 24, 70 )
|
||||
region = Rect2( 240, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=3]
|
||||
atlas = ExtResource( 5 )
|
||||
region = Rect2( 0, 0, 24, 70 )
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 264, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=4]
|
||||
atlas = ExtResource( 5 )
|
||||
region = Rect2( 24, 0, 24, 70 )
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 288, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=5]
|
||||
atlas = ExtResource( 5 )
|
||||
region = Rect2( 48, 0, 24, 70 )
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 312, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=6]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 48, 0, 24, 70 )
|
||||
region = Rect2( 72, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=7]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 24, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=8]
|
||||
atlas = ExtResource( 2 )
|
||||
atlas = ExtResource( 5 )
|
||||
region = Rect2( 0, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=9]
|
||||
atlas = ExtResource( 2 )
|
||||
[sub_resource type="AtlasTexture" id=8]
|
||||
atlas = ExtResource( 5 )
|
||||
region = Rect2( 24, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=10]
|
||||
atlas = ExtResource( 2 )
|
||||
[sub_resource type="AtlasTexture" id=9]
|
||||
atlas = ExtResource( 5 )
|
||||
region = Rect2( 48, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=10]
|
||||
atlas = ExtResource( 7 )
|
||||
region = Rect2( 0, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=11]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 144, 0, 24, 70 )
|
||||
atlas = ExtResource( 7 )
|
||||
region = Rect2( 24, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=12]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 168, 0, 24, 70 )
|
||||
atlas = ExtResource( 7 )
|
||||
region = Rect2( 48, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=13]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 192, 0, 24, 70 )
|
||||
atlas = ExtResource( 7 )
|
||||
region = Rect2( 72, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=14]
|
||||
atlas = ExtResource( 4 )
|
||||
atlas = ExtResource( 7 )
|
||||
region = Rect2( 96, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=15]
|
||||
@@ -89,85 +89,65 @@ atlas = ExtResource( 6 )
|
||||
region = Rect2( 24, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=21]
|
||||
atlas = ExtResource( 7 )
|
||||
region = Rect2( 0, 0, 24, 70 )
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 48, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=22]
|
||||
atlas = ExtResource( 7 )
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 24, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=23]
|
||||
atlas = ExtResource( 7 )
|
||||
region = Rect2( 48, 0, 24, 70 )
|
||||
atlas = ExtResource( 2 )
|
||||
region = Rect2( 0, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=24]
|
||||
atlas = ExtResource( 7 )
|
||||
region = Rect2( 72, 0, 24, 70 )
|
||||
atlas = ExtResource( 2 )
|
||||
region = Rect2( 24, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=25]
|
||||
atlas = ExtResource( 7 )
|
||||
region = Rect2( 96, 0, 24, 70 )
|
||||
atlas = ExtResource( 2 )
|
||||
region = Rect2( 48, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=26]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 216, 0, 24, 70 )
|
||||
region = Rect2( 144, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=27]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 240, 0, 24, 70 )
|
||||
region = Rect2( 168, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=28]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 264, 0, 24, 70 )
|
||||
region = Rect2( 192, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=29]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 288, 0, 24, 70 )
|
||||
region = Rect2( 96, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=30]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 312, 0, 24, 70 )
|
||||
region = Rect2( 120, 0, 24, 70 )
|
||||
|
||||
[sub_resource type="SpriteFrames" id=31]
|
||||
animations = [ {
|
||||
"frames": [ SubResource( 1 ) ],
|
||||
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ],
|
||||
"loop": true,
|
||||
"name": "idle_down_left",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 2 ) ],
|
||||
"loop": true,
|
||||
"name": "idle_up",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ],
|
||||
"loop": true,
|
||||
"name": "speak_down_right",
|
||||
"name": "walk_right",
|
||||
"speed": 6.0
|
||||
}, {
|
||||
"frames": [ SubResource( 6 ) ],
|
||||
"loop": true,
|
||||
"name": "idle_right",
|
||||
"name": "idle_up",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 7 ) ],
|
||||
"frames": [ SubResource( 7 ), SubResource( 8 ), SubResource( 9 ) ],
|
||||
"loop": true,
|
||||
"name": "idle_down_right",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 9 ), SubResource( 10 ) ],
|
||||
"loop": true,
|
||||
"name": "speak_down",
|
||||
"name": "speak_down_right",
|
||||
"speed": 6.0
|
||||
}, {
|
||||
"frames": [ SubResource( 11 ), SubResource( 12 ), SubResource( 13 ) ],
|
||||
"frames": [ SubResource( 10 ), SubResource( 11 ), SubResource( 12 ), SubResource( 13 ), SubResource( 14 ) ],
|
||||
"loop": true,
|
||||
"name": "walk_down",
|
||||
"speed": 6.0
|
||||
}, {
|
||||
"frames": [ SubResource( 14 ) ],
|
||||
"loop": true,
|
||||
"name": "idle_left",
|
||||
"name": "speak_right",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 15 ) ],
|
||||
@@ -185,15 +165,35 @@ animations = [ {
|
||||
"name": "speak_up",
|
||||
"speed": 3.0
|
||||
}, {
|
||||
"frames": [ SubResource( 21 ), SubResource( 22 ), SubResource( 23 ), SubResource( 24 ), SubResource( 25 ) ],
|
||||
"frames": [ SubResource( 21 ) ],
|
||||
"loop": true,
|
||||
"name": "speak_right",
|
||||
"name": "idle_right",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 26 ), SubResource( 27 ), SubResource( 28 ), SubResource( 29 ), SubResource( 30 ) ],
|
||||
"frames": [ SubResource( 22 ) ],
|
||||
"loop": true,
|
||||
"name": "walk_right",
|
||||
"name": "idle_down_right",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 23 ), SubResource( 24 ), SubResource( 25 ), SubResource( 24 ), SubResource( 25 ) ],
|
||||
"loop": true,
|
||||
"name": "speak_down",
|
||||
"speed": 6.0
|
||||
}, {
|
||||
"frames": [ SubResource( 26 ), SubResource( 27 ), SubResource( 28 ) ],
|
||||
"loop": true,
|
||||
"name": "walk_down",
|
||||
"speed": 6.0
|
||||
}, {
|
||||
"frames": [ SubResource( 29 ) ],
|
||||
"loop": true,
|
||||
"name": "idle_left",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 30 ) ],
|
||||
"loop": true,
|
||||
"name": "idle_down_left",
|
||||
"speed": 5.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=32]
|
||||
|
||||
@@ -14,6 +14,7 @@ global_id = "r9_bottle"
|
||||
esc_script = "res://game/items/escitems/bottle.esc"
|
||||
tooltip_name = "Bottle"
|
||||
default_action = "pickup"
|
||||
default_action_inventory = "look"
|
||||
combine_if_action_used_among = PoolStringArray( "use" )
|
||||
use_from_inventory_only = true
|
||||
inventory_item_scene_file = ExtResource( 3 )
|
||||
|
||||
@@ -99,16 +99,24 @@ func left_click_on_inventory_item(inventory_item_global_id : String, event : Inp
|
||||
|
||||
|
||||
func right_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent) -> void:
|
||||
escoria.esc_runner.set_current_action($ui/verbs_layer/verbs_menu.selected_action)
|
||||
escoria.do("item_right_click", [inventory_item_global_id, event])
|
||||
|
||||
func left_double_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent) -> void:
|
||||
pass
|
||||
|
||||
func inventory_item_focused(inventory_item_global_id : String) -> void:
|
||||
$ui/tooltip_layer/tooltip.set_target(escoria.esc_runner.get_object(inventory_item_global_id).tooltip_name)
|
||||
var target_obj = escoria.esc_runner.get_object(inventory_item_global_id)
|
||||
$ui/tooltip_layer/tooltip.set_target(target_obj.tooltip_name)
|
||||
|
||||
if escoria.esc_runner.current_action != "use" && escoria.esc_runner.current_tool == null:
|
||||
if target_obj is ESCItem:
|
||||
$ui/verbs_layer/verbs_menu.set_by_name(target_obj.default_action_inventory)
|
||||
|
||||
|
||||
func inventory_item_unfocused() -> void:
|
||||
$ui/tooltip_layer/tooltip.set_target("")
|
||||
$ui/verbs_layer/verbs_menu.unselect_actions()
|
||||
|
||||
|
||||
func open_inventory():
|
||||
|
||||
@@ -130,6 +130,7 @@ ui/default_dialog_scene="res://game/ui/commons/dialogs/dialog_label.tscn"
|
||||
ui/main_menu_scene="res://game/ui/commons/main_menu.tscn"
|
||||
ui/game_scene="res://game/ui/ui_9verbs/game.tscn"
|
||||
internals/save_data=""
|
||||
ui/tooltip_follows_mouse=false
|
||||
|
||||
[input]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user