Finished ESC camera commands reimplementation.
Some cleaning done, and all logging commands put in escoria.logger script.
This commit is contained in:
@@ -88,7 +88,7 @@ func _process(time):
|
|||||||
else:
|
else:
|
||||||
bypass_missing_animation = true
|
bypass_missing_animation = true
|
||||||
current_animation = animation_to_play
|
current_animation = animation_to_play
|
||||||
escoria.report_warnings("movable.gd:_process()",
|
escoria.logger.report_warnings("movable.gd:_process()",
|
||||||
["Character " + parent.global_id + " has no animation " + animation_to_play,
|
["Character " + parent.global_id + " has no animation " + animation_to_play,
|
||||||
"Bypassing missing animation and proceed movement."], true)
|
"Bypassing missing animation and proceed movement."], true)
|
||||||
|
|
||||||
@@ -106,16 +106,18 @@ func teleport(target, angle : Object = null) -> void:
|
|||||||
target can be Vector2 or Object
|
target can be Vector2 or Object
|
||||||
"""
|
"""
|
||||||
if typeof(target) == TYPE_VECTOR2:
|
if typeof(target) == TYPE_VECTOR2:
|
||||||
printt("Item teleported at position", target, "with angle", angle)
|
escoria.logger.info("Object " + target + " teleported at position" +
|
||||||
|
str(target) + "with angle", [angle])
|
||||||
parent.position = target
|
parent.position = target
|
||||||
elif typeof(target) == TYPE_OBJECT:
|
elif typeof(target) == TYPE_OBJECT:
|
||||||
if target.get("interact_positions") != null:
|
if target.get("interact_positions") != null:
|
||||||
parent.position = target.interact_positions.default #.global_position
|
parent.position = target.interact_positions.default #.global_position
|
||||||
else:
|
else:
|
||||||
parent.position = target.position
|
parent.position = target.position
|
||||||
printt("Item teleported at", target.name, "position", parent.position, "with angle", angle)
|
escoria.logger.info("Object " + target.name + " teleported at position "
|
||||||
|
+ str(parent.position) + " with angle ", str(angle))
|
||||||
else:
|
else:
|
||||||
escoria.report_errors("escitem.gd:teleport()", ["Target to teleport to is null or unusable (" + target + ")"])
|
escoria.logger.report_errors("escitem.gd:teleport()", ["Target to teleport to is null or unusable (" + target + ")"])
|
||||||
|
|
||||||
# PUBLIC FUNCTION
|
# PUBLIC FUNCTION
|
||||||
func walk_to(pos : Vector2, p_walk_context = null):
|
func walk_to(pos : Vector2, p_walk_context = null):
|
||||||
@@ -208,7 +210,7 @@ func walk_stop(pos):
|
|||||||
# walk_context = null
|
# walk_context = null
|
||||||
|
|
||||||
yield(parent.animation_sprite, "animation_finished")
|
yield(parent.animation_sprite, "animation_finished")
|
||||||
printt(parent.global_id + " arrived at ", walk_context)
|
escoria.logger.info(parent.global_id + " arrived at " + str(walk_context))
|
||||||
parent.emit_signal("arrived", walk_context)
|
parent.emit_signal("arrived", walk_context)
|
||||||
|
|
||||||
|
|
||||||
@@ -271,7 +273,7 @@ func _get_dir_deg(deg : int, animations) -> int:
|
|||||||
|
|
||||||
# It's an error to have the animations misconfigured
|
# It's an error to have the animations misconfigured
|
||||||
if dir == -1:
|
if dir == -1:
|
||||||
escoria.report_errors("escitem.gd:_get_dir_deg()", ["No direction found for " + str(deg)])
|
escoria.logger.report_errors("escitem.gd:_get_dir_deg()", ["No direction found for " + str(deg)])
|
||||||
|
|
||||||
return dir
|
return dir
|
||||||
|
|
||||||
@@ -315,7 +317,7 @@ Whatever the implementation, this should be activated using "parameter "immediat
|
|||||||
"""
|
"""
|
||||||
func set_angle(deg : int, immediate = true):
|
func set_angle(deg : int, immediate = true):
|
||||||
if deg < 0 or deg > 360:
|
if deg < 0 or deg > 360:
|
||||||
escoria.report_errors("movable.gd:set_angle()", ["Invalid degree to turn to " + str(deg)])
|
escoria.logger.report_errors("movable.gd:set_angle()", ["Invalid degree to turn to " + str(deg)])
|
||||||
moved = true
|
moved = true
|
||||||
last_deg = deg
|
last_deg = deg
|
||||||
last_dir = _get_dir_deg(deg, parent.animations)
|
last_dir = _get_dir_deg(deg, parent.animations)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ var commands = {
|
|||||||
"inc_global": { "min_args": 2, "types": [TYPE_STRING, TYPE_INT] },
|
"inc_global": { "min_args": 2, "types": [TYPE_STRING, TYPE_INT] },
|
||||||
"inventory_add": { "min_args": 1 },
|
"inventory_add": { "min_args": 1 },
|
||||||
"inventory_remove": { "min_args": 1 },
|
"inventory_remove": { "min_args": 1 },
|
||||||
"inventory_open": { "min_args": 1, "types": [TYPE_BOOL] },
|
"inventory_display": { "min_args": 1, "types": [TYPE_BOOL] },
|
||||||
"jump": { "min_args": 1 },
|
"jump": { "min_args": 1 },
|
||||||
"play_snd": { "min_args": 2, "types": [TYPE_STRING, TYPE_STRING, TYPE_BOOL] },
|
"play_snd": { "min_args": 2, "types": [TYPE_STRING, TYPE_STRING, TYPE_BOOL] },
|
||||||
"queue_animation": { "min_args": 2, "types": [TYPE_STRING, TYPE_STRING, TYPE_BOOL] },
|
"queue_animation": { "min_args": 2, "types": [TYPE_STRING, TYPE_STRING, TYPE_BOOL] },
|
||||||
@@ -76,6 +76,7 @@ var commands = {
|
|||||||
"wait": true,
|
"wait": true,
|
||||||
"walk": { "min_args": 2 },
|
"walk": { "min_args": 2 },
|
||||||
"walk_to_pos": { "min_args": 3},
|
"walk_to_pos": { "min_args": 3},
|
||||||
|
"walk_to_pos_block": { "min_args": 3},
|
||||||
"walk_block": { "min_args": 2 },
|
"walk_block": { "min_args": 2 },
|
||||||
|
|
||||||
"%": { "alias": "label", "min_args": 1},
|
"%": { "alias": "label", "min_args": 1},
|
||||||
@@ -96,7 +97,7 @@ var debug_commands = {
|
|||||||
func load_esc_file(esc_file_path : String) -> Dictionary:
|
func load_esc_file(esc_file_path : String) -> Dictionary:
|
||||||
var f = File.new()
|
var f = File.new()
|
||||||
if !f.file_exists(esc_file_path):
|
if !f.file_exists(esc_file_path):
|
||||||
escoria.report_errors("esc_compiler.gd:load_esc_file()", ["File " + esc_file_path + " not found."])
|
escoria.logger.report_errors("esc_compiler.gd:load_esc_file()", ["File " + esc_file_path + " not found."])
|
||||||
return {}
|
return {}
|
||||||
return compile_script(esc_file_path)
|
return compile_script(esc_file_path)
|
||||||
|
|
||||||
@@ -114,7 +115,7 @@ func compile_script(p_path : String) -> Dictionary:
|
|||||||
var errors = []
|
var errors = []
|
||||||
ev_table = compile(p_path, errors)
|
ev_table = compile(p_path, errors)
|
||||||
if errors.size() > 0:
|
if errors.size() > 0:
|
||||||
escoria.call_deferred("report_errors", p_path, errors)
|
escoria.logger.call_deferred("report_errors", p_path, errors)
|
||||||
return ev_table
|
return ev_table
|
||||||
|
|
||||||
func check_command(commands_list : Dictionary, cmd : esctypes.ESCCommand, state : esctypes.ESCState, errors : Array):
|
func check_command(commands_list : Dictionary, cmd : esctypes.ESCCommand, state : esctypes.ESCState, errors : Array):
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
# This is the script that runs in background, checking for events in the events stack
|
"""
|
||||||
# and executing them.
|
This is the script that runs in background, checking for events in the events
|
||||||
# Events are managed using 2 structures:
|
stack and executing them.
|
||||||
# - event_queue: a queue for scheduled events. On each iteration, every event in the queue is updated
|
Events are managed using 2 structures:
|
||||||
# according time delta. If an event time occurs, it is run (see check_event_queue()).
|
- event_queue: a queue for scheduled events. On each iteration, every event
|
||||||
# - levels_stack: stack of events to be run immediately (from an event in ESC file usually)
|
in the queue is updated according time delta. If an event time occurs, it is run
|
||||||
|
(see check_event_queue()).
|
||||||
|
- levels_stack: stack of events to be run immediately (from an event in ESC file
|
||||||
|
usually)
|
||||||
|
"""
|
||||||
|
|
||||||
signal global_changed(global_name)
|
signal global_changed(global_name)
|
||||||
signal inventory_changed
|
signal inventory_changed
|
||||||
@@ -18,7 +22,6 @@ signal action_changed
|
|||||||
signal paused(p_paused)
|
signal paused(p_paused)
|
||||||
|
|
||||||
onready var resource_cache = load("res://addons/escoria-core/game/core-scripts/resource_queue.gd").new()
|
onready var resource_cache = load("res://addons/escoria-core/game/core-scripts/resource_queue.gd").new()
|
||||||
#save_data = load(ProjectSettings.get_setting("escoria/internals/save_data")).new()
|
|
||||||
onready var save_data = load("res://addons/escoria-core/game/core-scripts/save_data/save_data.gd").new()
|
onready var save_data = load("res://addons/escoria-core/game/core-scripts/save_data/save_data.gd").new()
|
||||||
|
|
||||||
# Cached scenes
|
# Cached scenes
|
||||||
@@ -80,14 +83,14 @@ func _ready():
|
|||||||
randomize()
|
randomize()
|
||||||
save_data.load_settings([self, "settings_loaded"])
|
save_data.load_settings([self, "settings_loaded"])
|
||||||
|
|
||||||
printt("calling res cache start")
|
printt("Calling resource cache start")
|
||||||
resource_cache.start()
|
resource_cache.start()
|
||||||
|
|
||||||
if !ProjectSettings.get_setting("escoria/platform/skip_cache"):
|
if !ProjectSettings.get_setting("escoria/platform/skip_cache"):
|
||||||
scenes_cache_list.push_back(ProjectSettings.get_setting("escoria/main/curtain"))
|
scenes_cache_list.push_back(ProjectSettings.get_setting("escoria/main/curtain"))
|
||||||
scenes_cache_list.push_back(ProjectSettings.get_setting("escoria/main/hud"))
|
scenes_cache_list.push_back(ProjectSettings.get_setting("escoria/main/hud"))
|
||||||
|
|
||||||
printt("cache list ", scenes_cache_list)
|
printt("Cache list ", [scenes_cache_list])
|
||||||
for s in scenes_cache_list:
|
for s in scenes_cache_list:
|
||||||
if s != null:
|
if s != null:
|
||||||
resource_cache.queue_resource(s, false, true)
|
resource_cache.queue_resource(s, false, true)
|
||||||
@@ -265,7 +268,7 @@ func get_global(name):
|
|||||||
#
|
#
|
||||||
func set_global(name, val, force_change_reserved : bool = false):
|
func set_global(name, val, force_change_reserved : bool = false):
|
||||||
if name in reserved_globals and !force_change_reserved:
|
if name in reserved_globals and !force_change_reserved:
|
||||||
escoria.report_warnings("esc_runner.gd:set_global()",
|
escoria.logger.report_warnings("esc_runner.gd:set_global()",
|
||||||
["Global " + name + " is reserved. Value not modified."])
|
["Global " + name + " is reserved. Value not modified."])
|
||||||
return
|
return
|
||||||
globals[name] = val
|
globals[name] = val
|
||||||
@@ -304,12 +307,28 @@ func is_global_less_than(name, val):
|
|||||||
if global and val and int(global) < int(val):
|
if global and val and int(global) < int(val):
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
func jump(p_label):
|
||||||
|
while levels_stack.size() > 0:
|
||||||
|
var top = levels_stack[levels_stack.size()-1]
|
||||||
|
printt("top labels: ", top.labels, p_label)
|
||||||
|
if p_label in top.labels:
|
||||||
|
top.ip = top.labels[p_label]
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
if top.break_stop || levels_stack.size() == 1:
|
||||||
|
escoria.logger.report_errors("esc_runner.gd:jump()",
|
||||||
|
["ESC: Jump to inexisting label: " + p_label])
|
||||||
|
levels_stack.remove(levels_stack.size()-1)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
levels_stack.remove(levels_stack.size()-1)
|
||||||
|
|
||||||
func check_autosave():
|
func check_autosave():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func set_current_action(action : String):
|
func set_current_action(action : String):
|
||||||
if ! action is String:
|
if ! action is String:
|
||||||
escoria.report_errors("esc_runner.gd",
|
escoria.logger.report_errors("esc_runner.gd",
|
||||||
["Trying to set_current_action: " + str(typeof(action))])
|
["Trying to set_current_action: " + str(typeof(action))])
|
||||||
|
|
||||||
if action != current_action:
|
if action != current_action:
|
||||||
@@ -325,7 +344,7 @@ func clear_current_tool():
|
|||||||
current_tool = null
|
current_tool = null
|
||||||
|
|
||||||
func change_scene(params, context, run_events=true):
|
func change_scene(params, context, run_events=true):
|
||||||
printt("change scene to ", params[0], " with run_events ", run_events)
|
escoria.logger.info("Change scene to " + params[0] + " with run_events " + str(run_events))
|
||||||
# check_cache()
|
# check_cache()
|
||||||
# main.clear_scene()
|
# main.clear_scene()
|
||||||
# camera = null
|
# camera = null
|
||||||
@@ -341,10 +360,10 @@ func change_scene(params, context, run_events=true):
|
|||||||
var res_room = resource_cache.get_resource(params[0])
|
var res_room = resource_cache.get_resource(params[0])
|
||||||
var res_game = resource_cache.get_resource(ProjectSettings.get_setting("escoria/ui/game_scene"))
|
var res_game = resource_cache.get_resource(ProjectSettings.get_setting("escoria/ui/game_scene"))
|
||||||
if !res_room:
|
if !res_room:
|
||||||
escoria.report_errors("esc_runner.gd:change_scene()",
|
escoria.logger.report_errors("esc_runner.gd:change_scene()",
|
||||||
["Resource not found: " + params[0]])
|
["Resource not found: " + params[0]])
|
||||||
if !res_game:
|
if !res_game:
|
||||||
escoria.report_errors("esc_runner.gd:change_scene()",
|
escoria.logger.report_errors("esc_runner.gd:change_scene()",
|
||||||
["Resource not found: " + ProjectSettings.get_setting("escoria/ui/game_scene")])
|
["Resource not found: " + ProjectSettings.get_setting("escoria/ui/game_scene")])
|
||||||
|
|
||||||
resource_cache.clear()
|
resource_cache.clear()
|
||||||
@@ -352,7 +371,7 @@ func change_scene(params, context, run_events=true):
|
|||||||
# Load game scene
|
# Load game scene
|
||||||
var game_scene = res_game.instance()
|
var game_scene = res_game.instance()
|
||||||
if !game_scene:
|
if !game_scene:
|
||||||
escoria.report_errors("esc_runner.gd:change_scene()",
|
escoria.logger.report_errors("esc_runner.gd:change_scene()",
|
||||||
["Failed loading scene " + ProjectSettings.get_setting("escoria/ui/game_scene")])
|
["Failed loading scene " + ProjectSettings.get_setting("escoria/ui/game_scene")])
|
||||||
|
|
||||||
# Load room scene
|
# Load room scene
|
||||||
@@ -380,7 +399,7 @@ func change_scene(params, context, run_events=true):
|
|||||||
scenes_cache_list.push_back(params[0])
|
scenes_cache_list.push_back(params[0])
|
||||||
scenes_cache[room_scene.global_id] = params[0]
|
scenes_cache[room_scene.global_id] = params[0]
|
||||||
else:
|
else:
|
||||||
escoria.report_errors("esc_runner.gd:change_scene()",
|
escoria.logger.report_errors("esc_runner.gd:change_scene()",
|
||||||
["Failed loading scene " + params[0]])
|
["Failed loading scene " + params[0]])
|
||||||
|
|
||||||
if context != null:
|
if context != null:
|
||||||
@@ -411,10 +430,10 @@ func superpose_scene(params, context, run_events=true):
|
|||||||
var res_room = resource_cache.get_resource(params[0])
|
var res_room = resource_cache.get_resource(params[0])
|
||||||
var res_game = resource_cache.get_resource(ProjectSettings.get_setting("escoria/ui/game_scene"))
|
var res_game = resource_cache.get_resource(ProjectSettings.get_setting("escoria/ui/game_scene"))
|
||||||
if !res_room:
|
if !res_room:
|
||||||
escoria.report_errors("esc_runner.gd:superpose_scene()",
|
escoria.logger.report_errors("esc_runner.gd:superpose_scene()",
|
||||||
["Resource not found: " + params[0]])
|
["Resource not found: " + params[0]])
|
||||||
if !res_game:
|
if !res_game:
|
||||||
escoria.report_errors("esc_runner.gd:superpose_scene()",
|
escoria.logger.report_errors("esc_runner.gd:superpose_scene()",
|
||||||
["Resource not found: " + ProjectSettings.get_setting("escoria/ui/game_scene")])
|
["Resource not found: " + ProjectSettings.get_setting("escoria/ui/game_scene")])
|
||||||
|
|
||||||
resource_cache.clear()
|
resource_cache.clear()
|
||||||
@@ -422,7 +441,7 @@ func superpose_scene(params, context, run_events=true):
|
|||||||
# Load game scene
|
# Load game scene
|
||||||
var game_scene = res_game.instance()
|
var game_scene = res_game.instance()
|
||||||
if !game_scene:
|
if !game_scene:
|
||||||
escoria.report_errors("esc_runner.gd:superpose_scene()",
|
escoria.logger.report_errors("esc_runner.gd:superpose_scene()",
|
||||||
["Failed loading scene " + ProjectSettings.get_setting("escoria/ui/game_scene")])
|
["Failed loading scene " + ProjectSettings.get_setting("escoria/ui/game_scene")])
|
||||||
|
|
||||||
# Load room scene
|
# Load room scene
|
||||||
@@ -430,6 +449,13 @@ func superpose_scene(params, context, run_events=true):
|
|||||||
if room_scene:
|
if room_scene:
|
||||||
get_node("/root").add_child(room_scene)
|
get_node("/root").add_child(room_scene)
|
||||||
|
|
||||||
|
var target = context.get("set_position")
|
||||||
|
if target:
|
||||||
|
if target is Vector2:
|
||||||
|
room_scene.set_position(target)
|
||||||
|
if target is String:
|
||||||
|
var obj = get_object(target)
|
||||||
|
room_scene.set_position(obj.get_global_position())
|
||||||
|
|
||||||
escoria.inputs_manager.hotspot_focused = false
|
escoria.inputs_manager.hotspot_focused = false
|
||||||
if !scenes_cache_list.has(params[0]):
|
if !scenes_cache_list.has(params[0]):
|
||||||
@@ -439,7 +465,7 @@ func superpose_scene(params, context, run_events=true):
|
|||||||
else:
|
else:
|
||||||
scenes_cache[room_scene.name] = params[0]
|
scenes_cache[room_scene.name] = params[0]
|
||||||
else:
|
else:
|
||||||
escoria.report_errors("esc_runner.gd:superpose_scene()",
|
escoria.logger.report_errors("esc_runner.gd:superpose_scene()",
|
||||||
["Failed loading scene " + params[0]])
|
["Failed loading scene " + params[0]])
|
||||||
|
|
||||||
if context != null:
|
if context != null:
|
||||||
@@ -453,8 +479,6 @@ func superpose_scene(params, context, run_events=true):
|
|||||||
# autosave_pending = true
|
# autosave_pending = true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func run_game(actions : Dictionary):
|
func run_game(actions : Dictionary):
|
||||||
set_process(true)
|
set_process(true)
|
||||||
# `load` and `ready` are exclusive because you probably don't want to
|
# `load` and `ready` are exclusive because you probably don't want to
|
||||||
@@ -487,11 +511,11 @@ func clear():
|
|||||||
|
|
||||||
func register_object(name : String, val : Object, force : bool = false):
|
func register_object(name : String, val : Object, force : bool = false):
|
||||||
if !name:
|
if !name:
|
||||||
escoria.report_errors("esc_runner.gd:register_object()",
|
escoria.logger.report_errors("esc_runner.gd:register_object()",
|
||||||
["global_id not given for " + val.get_class() + " " + val.name])
|
["global_id not given for " + val.get_class() + " " + val.name])
|
||||||
|
|
||||||
if name in objects and not force:
|
if name in objects and not force:
|
||||||
escoria.report_errors("esc_runner.gd:register_object()",
|
escoria.logger.report_errors("esc_runner.gd:register_object()",
|
||||||
["Trying to register already registered object " + name + ": " \
|
["Trying to register already registered object " + name + ": " \
|
||||||
+ val.get_class() + " (" + val.name + ")"])
|
+ val.get_class() + " (" + val.name + ")"])
|
||||||
|
|
||||||
@@ -528,7 +552,7 @@ func get_object(name):
|
|||||||
# p_params Array
|
# p_params Array
|
||||||
# - 0 Object Target object
|
# - 0 Object Target object
|
||||||
func activate(p_action : String, p_param : Array):
|
func activate(p_action : String, p_param : Array):
|
||||||
printt("Action", p_action, "with params", p_param)
|
escoria.logger.info("Action " + p_action + " with params ", [p_param])
|
||||||
# if p_param[0].global_id:
|
# if p_param[0].global_id:
|
||||||
# printt("("+p_param[0].global_id+")")
|
# printt("("+p_param[0].global_id+")")
|
||||||
var what = p_param[0]
|
var what = p_param[0]
|
||||||
@@ -539,8 +563,8 @@ func activate(p_action : String, p_param : Array):
|
|||||||
if what is ESCItem and what.use_from_inventory_only:
|
if what is ESCItem and what.use_from_inventory_only:
|
||||||
if !inventory_has(what.global_id):
|
if !inventory_has(what.global_id):
|
||||||
# TODO Either use fallback here, or run pickup action before use
|
# TODO Either use fallback here, or run pickup action before use
|
||||||
escoria.report_warnings("esc_runner.gd:activate()", ["Trying to "
|
escoria.logger.report_warnings("esc_runner.gd:activate()",
|
||||||
+ p_action + " on object " + what.global_id
|
["Trying to " + p_action + " on object " + what.global_id
|
||||||
+ " but item must be in inventory."])
|
+ " but item must be in inventory."])
|
||||||
return esctypes.EVENT_LEVEL_STATE.YIELD
|
return esctypes.EVENT_LEVEL_STATE.YIELD
|
||||||
else:
|
else:
|
||||||
@@ -570,7 +594,7 @@ func activate(p_action : String, p_param : Array):
|
|||||||
if combine_with.get("combine_is_one_way") != null \
|
if combine_with.get("combine_is_one_way") != null \
|
||||||
and combine_with.combine_is_one_way:
|
and combine_with.combine_is_one_way:
|
||||||
errors.append("Reason: " + combine_with.global_id + "'s item interaction is one-way.")
|
errors.append("Reason: " + combine_with.global_id + "'s item interaction is one-way.")
|
||||||
escoria.report_warnings("esc_runner.gd:activate()", errors)
|
escoria.logger.report_warnings("esc_runner.gd:activate()", errors)
|
||||||
|
|
||||||
return esctypes.EVENT_LEVEL_STATE.YIELD
|
return esctypes.EVENT_LEVEL_STATE.YIELD
|
||||||
else:
|
else:
|
||||||
@@ -588,13 +612,13 @@ func activate(p_action : String, p_param : Array):
|
|||||||
if p_action in objects_events_table[what.global_id]:
|
if p_action in objects_events_table[what.global_id]:
|
||||||
run_event(objects_events_table[what.global_id][p_action])
|
run_event(objects_events_table[what.global_id][p_action])
|
||||||
else:
|
else:
|
||||||
escoria.report_warnings("esc_runner.gd:activate()",
|
escoria.logger.report_warnings("esc_runner.gd:activate()",
|
||||||
["Action '" + p_action + "' requested on object '" \
|
["Action '" + p_action + "' requested on object '" \
|
||||||
+ what.global_id + "' but action doesn't exist in attached ESC file.",
|
+ what.global_id + "' but action doesn't exist in attached ESC file.",
|
||||||
"TODO: manage fallbacks."])
|
"TODO: manage fallbacks."])
|
||||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||||
else:
|
else:
|
||||||
escoria.report_warnings("esc_runner.gd:activate()",
|
escoria.logger.report_warnings("esc_runner.gd:activate()",
|
||||||
["Action '" + p_action + "' requested on object '" + what.global_id \
|
["Action '" + p_action + "' requested on object '" + what.global_id \
|
||||||
+ "' but object does not exist in objects_events_table.", \
|
+ "' but object does not exist in objects_events_table.", \
|
||||||
"Does object " + what.global_id + " have an attached ESC file?"])
|
"Does object " + what.global_id + " have an attached ESC file?"])
|
||||||
@@ -662,7 +686,7 @@ func set_state(global_id : String, p_params : Array):
|
|||||||
var animation = actual_animator.get_animation(p_params[0])
|
var animation = actual_animator.get_animation(p_params[0])
|
||||||
var animation_length = animation.length
|
var animation_length = animation.length
|
||||||
animation_node.seek(animation_length)
|
animation_node.seek(animation_length)
|
||||||
print_debug("Item " + obj.global_id + " changed state to: " + p_params[0])
|
escoria.logger.info("Item " + obj.global_id + " changed state to: " + p_params[0])
|
||||||
|
|
||||||
"""
|
"""
|
||||||
When object is active, it is VISIBLE.
|
When object is active, it is VISIBLE.
|
||||||
@@ -698,7 +722,7 @@ func object_exit_scene(name : String):
|
|||||||
if inventory_has(name):
|
if inventory_has(name):
|
||||||
objects[name] = objects[name].duplicate()
|
objects[name] = objects[name].duplicate()
|
||||||
else:
|
else:
|
||||||
printt("Object " + name + " removed from scene.")
|
escoria.logger.info("Object " + name + " removed from scene.")
|
||||||
objects.erase(name)
|
objects.erase(name)
|
||||||
|
|
||||||
#func jump(p_label):
|
#func jump(p_label):
|
||||||
@@ -710,7 +734,7 @@ func object_exit_scene(name : String):
|
|||||||
# return
|
# return
|
||||||
# else:
|
# else:
|
||||||
# if top.break_stop || stack.size() == 1:
|
# if top.break_stop || stack.size() == 1:
|
||||||
# report_errors("", ["Label not found: "+p_label+", can't jump"])
|
# escoria.logger.report_errors("", ["Label not found: "+p_label+", can't jump"])
|
||||||
# stack.remove(stack.size()-1)
|
# stack.remove(stack.size()-1)
|
||||||
# break
|
# break
|
||||||
# else:
|
# else:
|
||||||
@@ -720,6 +744,6 @@ func object_exit_scene(name : String):
|
|||||||
func check_obj(name, cmd):
|
func check_obj(name, cmd):
|
||||||
var obj = escoria.esc_runner.get_object(name)
|
var obj = escoria.esc_runner.get_object(name)
|
||||||
if obj == null:
|
if obj == null:
|
||||||
escoria.report_errors("", ["Global id "+name+" not found for " + cmd])
|
escoria.logger.report_errors("", ["Global id "+name+" not found for " + cmd])
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
# This script runs the ESCCommands contained in the ESCEvent.
|
# This script implements the ESCCommands contained in the ESCEvent.
|
||||||
|
# TODO : this script should use "Command" pattern.
|
||||||
|
|
||||||
var current_context
|
var current_context
|
||||||
onready var esc_runner = get_parent()
|
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func finished(context = null):
|
func finished(context = null):
|
||||||
@@ -26,10 +22,10 @@ func resume(context):
|
|||||||
return esctypes.EVENT_LEVEL_STATE.YIELD
|
return esctypes.EVENT_LEVEL_STATE.YIELD
|
||||||
var count = context.instructions.size()
|
var count = context.instructions.size()
|
||||||
while context.ip < count:
|
while context.ip < count:
|
||||||
var top = esc_runner.levels_stack.size()
|
var top = escoria.esc_runner.levels_stack.size()
|
||||||
var ret = run(context)
|
var ret = run(context)
|
||||||
context.ip += 1
|
context.ip += 1
|
||||||
if top < esc_runner.levels_stack.size():
|
if top < escoria.esc_runner.levels_stack.size():
|
||||||
return esctypes.EVENT_LEVEL_STATE.CALL
|
return esctypes.EVENT_LEVEL_STATE.CALL
|
||||||
if ret == esctypes.EVENT_LEVEL_STATE.YIELD:
|
if ret == esctypes.EVENT_LEVEL_STATE.YIELD:
|
||||||
return esctypes.EVENT_LEVEL_STATE.YIELD
|
return esctypes.EVENT_LEVEL_STATE.YIELD
|
||||||
@@ -52,11 +48,11 @@ func run(context):
|
|||||||
var cmd = context.instructions[context.ip]
|
var cmd = context.instructions[context.ip]
|
||||||
if cmd.name == "label":
|
if cmd.name == "label":
|
||||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||||
if !esc_runner.test(cmd):
|
if !escoria.esc_runner.test(cmd):
|
||||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||||
#print("name is ", cmd.name)
|
#print("name is ", cmd.name)
|
||||||
#if !(cmd.name in self):
|
#if !(cmd.name in self):
|
||||||
# esc_runner.report_errors("", ["Unexisting command "+cmd.name])
|
# escoria.logger.report_errors("", ["Unexisting command "+cmd.name])
|
||||||
return call(cmd.name, cmd.params)
|
return call(cmd.name, cmd.params)
|
||||||
|
|
||||||
|
|
||||||
@@ -137,18 +133,28 @@ func camera_push(command_params : Array):
|
|||||||
escoria.esc_runner.get_object("camera").push(target, time, type)
|
escoria.esc_runner.get_object("camera").push(target, time, type)
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
camera_set_limits camlimits_id
|
||||||
|
Sets the camera limits to the one defined under "camlimits_id" in ESCRoom's
|
||||||
|
camera_limits array.
|
||||||
|
- camlimits_id : int : id of the camera limits to apply (defined in ESCRoom's
|
||||||
|
camera_limits array)
|
||||||
|
"""
|
||||||
func camera_set_limits(command_params : Array):
|
func camera_set_limits(command_params : Array):
|
||||||
escoria.main.set_camera_limits(command_params[0])
|
escoria.main.set_camera_limits(command_params[0])
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
camera_set_drag_margin_enabled h v
|
camera_set_drag_margin_enabled horizontal_enabled vertical_enabled
|
||||||
- "h" and "v" are booleans for whether or not horizontal and vertical drag
|
- horizontal_enabled : bool
|
||||||
|
- vertical_enabled : bool are booleans for whether or not horizontal and vertical drag
|
||||||
margins are enabled. You will likely want to set them false for advanced camera
|
margins are enabled. You will likely want to set them false for advanced camera
|
||||||
motions and true for regular gameplay and/or tracking NPCs.
|
motions and true for regular gameplay and/or tracking NPCs.
|
||||||
"""
|
"""
|
||||||
func camera_set_drag_margin_enabled():
|
func camera_set_drag_margin_enabled(command_params : Array):
|
||||||
pass
|
var horizontal_enabled = command_params[0]
|
||||||
|
var vertical_enabled = command_params[1]
|
||||||
|
escoria.esc_runner.get_object("camera").set_drag_margin_enabled(horizontal_enabled, vertical_enabled)
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -157,11 +163,10 @@ Moves the camera to a position defined by "x" and "y", at the speed defined by
|
|||||||
"speed" in pixels per second. If speed is 0, camera is teleported to the position.
|
"speed" in pixels per second. If speed is 0, camera is teleported to the position.
|
||||||
"""
|
"""
|
||||||
func camera_set_pos(command_params : Array):
|
func camera_set_pos(command_params : Array):
|
||||||
# var speed = command_params[0]
|
var speed = command_params[0]
|
||||||
# var x = command_params[1]
|
var pos = Vector2(command_params[1], command_params[2])
|
||||||
# var y = command_params[2]
|
escoria.esc_runner.get_object("camera").set_target(pos, speed)
|
||||||
# escoria.esc_runner.get_object("camera").set_pos(speed, x, y)
|
|
||||||
pass
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
camera_set_target speed object [object2 object3 ...]
|
camera_set_target speed object [object2 object3 ...]
|
||||||
@@ -193,8 +198,10 @@ func camera_set_zoom(command_params : Array):
|
|||||||
camera_set_zoom_height pixels [time]
|
camera_set_zoom_height pixels [time]
|
||||||
Similar to the command above, but uses pixel height instead of magnitude to zoom.
|
Similar to the command above, but uses pixel height instead of magnitude to zoom.
|
||||||
"""
|
"""
|
||||||
func camera_set_zoom_height():
|
func camera_set_zoom_height(command_params : Array):
|
||||||
pass
|
var magnitude = command_params[0] / escoria.game_size.y
|
||||||
|
var time = command_params[1] if command_params.size() > 1 else 0
|
||||||
|
escoria.esc_runner.get_object("camera").set_camera_zoom(magnitude, float(time))
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -369,18 +376,25 @@ func inventory_remove(command_params : Array):
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
TODO: This is dependant to the user UI. It must remain flexible enough.
|
inventory_open true/false
|
||||||
|
Shows or hides inventory. Uses code in game.tscn scene, thus developed outside of Escoria.
|
||||||
"""
|
"""
|
||||||
func inventory_open(command_params : Array):
|
func inventory_display(command_params : Array):
|
||||||
pass
|
var display : bool = bool(command_params[0])
|
||||||
|
if display:
|
||||||
|
escoria.main.current_scene.game.open_inventory()
|
||||||
|
else:
|
||||||
|
escoria.main.current_scene.game.close_inventory()
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
jump label_name
|
||||||
|
Jump to label_name block. Labels are blocks defined the same way as action_verbs:
|
||||||
|
:label
|
||||||
"""
|
"""
|
||||||
func jump(command_params : Array):
|
func jump(command_params : Array):
|
||||||
# escoria.esc_runner.jump(command_params[0])
|
escoria.esc_runner.jump(command_params[0])
|
||||||
# return esctypes.EVENT_LEVEL_STATE.JUMP
|
return esctypes.EVENT_LEVEL_STATE.JUMP
|
||||||
pass
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
@@ -389,21 +403,34 @@ func play_snd(command_params : Array):
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
queue_animation object animation
|
||||||
"""
|
"""
|
||||||
func queue_animation(command_params : Array):
|
func queue_animation(command_params : Array):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
queue_resource path [front_of_queue]
|
||||||
|
Queues the load of a resource in a background thread. The path must be a full
|
||||||
|
path inside your game, for example "res://scenes/next_scene.tscn".
|
||||||
|
The "front_of_queue" parameter is optional (default value false), to put the
|
||||||
|
resource in the front of the queue. Queued resources are cleared when a change
|
||||||
|
scene happens (but after the scene is loaded, meaning you can queue resources
|
||||||
|
that belong to the next scene).
|
||||||
"""
|
"""
|
||||||
func queue_resource(command_params : Array):
|
func queue_resource(command_params : Array):
|
||||||
pass
|
var path : String = command_params[0]
|
||||||
|
var in_front : bool = command_params[1] if command_params.size() > 1 else false
|
||||||
|
escoria.esc_runner.resource_cache.queue_resource(path, in_front)
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
repeat
|
||||||
|
Restarts the execution of the current scope at the start. A scope can be a group
|
||||||
|
or an event.
|
||||||
"""
|
"""
|
||||||
func repeat(command_params : Array):
|
func repeat(command_params : Array):
|
||||||
pass
|
return esctypes.EVENT_LEVEL_STATE.REPEAT
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -419,7 +446,9 @@ func say(command_params : Array) -> esctypes:
|
|||||||
var dialog_scene_name = ProjectSettings.get_setting("escoria/ui/default_dialog_scene")
|
var dialog_scene_name = ProjectSettings.get_setting("escoria/ui/default_dialog_scene")
|
||||||
|
|
||||||
if dialog_scene_name.empty():
|
if dialog_scene_name.empty():
|
||||||
escoria.report_errors("level_esc_runners.gd:say()", ["Project setting 'escoria/ui/default_dialog_scene' is not set. Please set a default dialog scene."])
|
escoria.logger.report_errors("level_esc_runners.gd:say()",
|
||||||
|
["Project setting 'escoria/ui/default_dialog_scene' is not set.",
|
||||||
|
"Please set a default dialog scene."])
|
||||||
var file = dialog_scene_name.get_file()
|
var file = dialog_scene_name.get_file()
|
||||||
var extension = dialog_scene_name.get_extension()
|
var extension = dialog_scene_name.get_extension()
|
||||||
dialog_scene_name = file.rstrip("." + extension)
|
dialog_scene_name = file.rstrip("." + extension)
|
||||||
@@ -442,8 +471,9 @@ func say(command_params : Array) -> esctypes:
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Sets object as active or inactive. Active objects are displayed in scene and respond
|
set_active global_id true/false
|
||||||
to inputs. Inactives are hidden.
|
Sets object as active or inactive. Active objects are displayed in scene and
|
||||||
|
respond to inputs. Inactives are hidden.
|
||||||
"""
|
"""
|
||||||
func set_active(command_params : Array):
|
func set_active(command_params : Array):
|
||||||
if !escoria.esc_runner.check_obj(command_params[0], "set_active"):
|
if !escoria.esc_runner.check_obj(command_params[0], "set_active"):
|
||||||
@@ -453,8 +483,8 @@ func set_active(command_params : Array):
|
|||||||
escoria.esc_runner.set_active(name, value)
|
escoria.esc_runner.set_active(name, value)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
set_angle object_id angle_degrees
|
||||||
Set the angle of an object.
|
Set the angle of an object.
|
||||||
Usage: set_angle object_id angle_degrees
|
|
||||||
"""
|
"""
|
||||||
func set_angle(command_params : Array):
|
func set_angle(command_params : Array):
|
||||||
if !escoria.esc_runner.check_obj(command_params[0], "set_angle"):
|
if !escoria.esc_runner.check_obj(command_params[0], "set_angle"):
|
||||||
@@ -468,6 +498,9 @@ func set_angle(command_params : Array):
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
set_state object_id state_name
|
||||||
|
Set object state to state_name. States are recorded in escoria.states[].
|
||||||
|
If the object has an animation named 'state_name', Escoria plays it.
|
||||||
"""
|
"""
|
||||||
func set_state(command_params : Array):
|
func set_state(command_params : Array):
|
||||||
var global_id : String = command_params[0]
|
var global_id : String = command_params[0]
|
||||||
@@ -476,9 +509,14 @@ func set_state(command_params : Array):
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
set_hud_visible true/false
|
||||||
|
Hides the UI. Uses code in game.tscn scene, thus developed outside of Escoria.
|
||||||
"""
|
"""
|
||||||
func set_hud_visible(command_params : Array):
|
func set_hud_visible(command_params : Array):
|
||||||
pass
|
if command_params[0]:
|
||||||
|
escoria.main.current_scene.game.show_ui()
|
||||||
|
else:
|
||||||
|
escoria.main.current_scene.game.hide_ui()
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -488,6 +526,8 @@ func sched_event(command_params : Array):
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
set_global global_variable value
|
||||||
|
Sets a global variable value. Value can be string, integer or boolean.
|
||||||
"""
|
"""
|
||||||
func set_global(command_params : Array):
|
func set_global(command_params : Array):
|
||||||
var name : String = command_params[0]
|
var name : String = command_params[0]
|
||||||
@@ -509,17 +549,27 @@ func set_globals(command_params : Array):
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
set_interactive global_id true/false
|
||||||
|
Sets object as interactive or not. Interactive objects can be pointed and
|
||||||
|
interacted with.
|
||||||
"""
|
"""
|
||||||
func set_interactive(command_params : Array):
|
func set_interactive(command_params : Array):
|
||||||
var name : String = command_params[0]
|
var global_id : String = command_params[0]
|
||||||
var value = command_params[1]
|
var value = command_params[1]
|
||||||
escoria.esc_runner.set_interactive(name, value)
|
escoria.esc_runner.set_interactive(global_id, value)
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
set_speed global_id speed_value
|
||||||
|
Sets the speed of object defined by 'global_id' to 'speed_value'
|
||||||
"""
|
"""
|
||||||
func set_speed(command_params : Array):
|
func set_speed(command_params : Array):
|
||||||
pass
|
if !escoria.esc_runner.check_obj(command_params[0], "set_speed"):
|
||||||
|
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||||
|
|
||||||
|
var global_id : String = command_params[0]
|
||||||
|
var speed_value = command_params[1]
|
||||||
|
escoria.get_object(global_id).set_speed(speed_value)
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -528,6 +578,12 @@ func slide(command_params : Array):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
func slide_to_pos(command_params : Array):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
func slide_block(command_params : Array):
|
func slide_block(command_params : Array):
|
||||||
@@ -536,11 +592,22 @@ func slide_block(command_params : Array):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
func spawn(command_params : Array):
|
func slide_to_pos_block(command_params : Array):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
spawn path [object2]
|
||||||
|
Instances a scene determined by "path", and places in the position of object2
|
||||||
|
(object2 is optional)
|
||||||
|
"""
|
||||||
|
func spawn(command_params : Array):
|
||||||
|
superpose_scene(command_params)
|
||||||
|
|
||||||
|
"""
|
||||||
|
stop
|
||||||
|
Stops the execution of the current script when it reaches the 'stop' instruction.
|
||||||
|
Usually used in the end of commands blocks.
|
||||||
"""
|
"""
|
||||||
func stop(command_params : Array):
|
func stop(command_params : Array):
|
||||||
return esctypes.EVENT_LEVEL_STATE.BREAK
|
return esctypes.EVENT_LEVEL_STATE.BREAK
|
||||||
@@ -560,7 +627,10 @@ func superpose_scene(command_params : Array):
|
|||||||
# Savegames must have events disabled, so saving the game adds a false to params
|
# Savegames must have events disabled, so saving the game adds a false to params
|
||||||
var run_events = true
|
var run_events = true
|
||||||
if command_params.size() == 2:
|
if command_params.size() == 2:
|
||||||
run_events = bool(command_params[1])
|
if command_params[1] in ["true", "false"]:
|
||||||
|
run_events = true if command_params[1] == "true" else false
|
||||||
|
else:
|
||||||
|
current_context["set_position"] = command_params[1]
|
||||||
|
|
||||||
# looking for localized string format in scene. this should be somewhere else
|
# looking for localized string format in scene. this should be somewhere else
|
||||||
var sep = command_params[0].find(":\"")
|
var sep = command_params[0].find(":\"")
|
||||||
@@ -575,9 +645,9 @@ func superpose_scene(command_params : Array):
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
teleport obj1 obj2 [angle_degrees]
|
||||||
Teleports obj1 at obj2's position. If angle_degrees is set (int), sets obj1's
|
Teleports obj1 at obj2's position. If angle_degrees is set (int), sets obj1's
|
||||||
angle to angle_degrees.
|
angle to angle_degrees.
|
||||||
Usage: teleport obj1 obj2 [angle_degrees]
|
|
||||||
"""
|
"""
|
||||||
func teleport(command_params : Array):
|
func teleport(command_params : Array):
|
||||||
if !escoria.esc_runner.check_obj(command_params[0], "teleport"):
|
if !escoria.esc_runner.check_obj(command_params[0], "teleport"):
|
||||||
@@ -595,9 +665,22 @@ func teleport(command_params : Array):
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
teleport obj1 x y [angle_degrees]
|
||||||
|
Teleports obj1 at (x,y). If angle_degrees is set (int), sets obj1's
|
||||||
|
angle to angle_degrees.
|
||||||
"""
|
"""
|
||||||
func teleport_pos(command_params : Array):
|
func teleport_pos(command_params : Array):
|
||||||
pass
|
if !escoria.esc_runner.check_obj(command_params[0], "teleport"):
|
||||||
|
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||||
|
var x = command_params[1]
|
||||||
|
var y = command_params[2]
|
||||||
|
|
||||||
|
var angle
|
||||||
|
if command_params.size() > 2:
|
||||||
|
angle = int(command_params[3])
|
||||||
|
|
||||||
|
escoria.esc_runner.get_object(command_params[0]).teleport(Vector2(x,y), angle)
|
||||||
|
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -622,29 +705,48 @@ func wait(command_params : Array):
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
walk object_id1 object_id2
|
||||||
Make object1 walk towards object2. This command is not blocking (user input not disabled)
|
Make object1 walk towards object2. This command is not blocking (user input not disabled)
|
||||||
Usage: walk object_id1 object_id2
|
|
||||||
"""
|
"""
|
||||||
func walk(command_params : Array):
|
func walk(command_params : Array):
|
||||||
|
current_context.waiting = false
|
||||||
|
escoria.do("walk", command_params)
|
||||||
|
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
walk_block object_id1 object_id2
|
||||||
|
Make object1 walk towards object2. This command is blocking (user input disabled)
|
||||||
|
"""
|
||||||
|
func walk_block(command_params : Array):
|
||||||
current_context.waiting = true
|
current_context.waiting = true
|
||||||
escoria.do("walk", command_params)
|
escoria.do("walk", command_params)
|
||||||
return esctypes.EVENT_LEVEL_STATE.YIELD
|
return esctypes.EVENT_LEVEL_STATE.YIELD
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
walk_to_pos object_id1 pos_x pos_y
|
||||||
Make object1 walk towards object2. This command is not blocking (user input not disabled)
|
Make object1 walk towards object2. This command is not blocking (user input not disabled)
|
||||||
Usage: walk_to_pos object_id1 pos_x pos_y
|
|
||||||
"""
|
"""
|
||||||
func walk_to_pos(command_params : Array):
|
func walk_to_pos(command_params : Array):
|
||||||
|
current_context.waiting = false
|
||||||
|
var destination_pos = Vector2(command_params[1], command_params[2])
|
||||||
|
escoria.do("walk", [command_params[0], destination_pos])
|
||||||
|
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||||
|
|
||||||
|
"""
|
||||||
|
walk_to_pos_block object_id1 pos_x pos_y
|
||||||
|
Make object1 walk towards object2. This command is blocking (user input disabled)
|
||||||
|
"""
|
||||||
|
func walk_to_pos_block(command_params : Array):
|
||||||
current_context.waiting = true
|
current_context.waiting = true
|
||||||
var destination_pos = Vector2(command_params[1], command_params[2])
|
var destination_pos = Vector2(command_params[1], command_params[2])
|
||||||
escoria.do("walk", [command_params[0], destination_pos])
|
escoria.do("walk", [command_params[0], destination_pos])
|
||||||
return esctypes.EVENT_LEVEL_STATE.YIELD
|
return esctypes.EVENT_LEVEL_STATE.YIELD
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
"""
|
|
||||||
func walk_block(command_params : Array):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ var last_dir : int
|
|||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
assert(!global_id.empty())
|
|
||||||
|
|
||||||
# Adds movable behavior
|
# Adds movable behavior
|
||||||
Movable = Node.new()
|
Movable = Node.new()
|
||||||
@@ -210,9 +209,12 @@ func element_exited(body):
|
|||||||
func teleport(target, angle : Object = null) -> void:
|
func teleport(target, angle : Object = null) -> void:
|
||||||
Movable.teleport(target, angle)
|
Movable.teleport(target, angle)
|
||||||
|
|
||||||
func walk_to(pos : Vector2, p_walk_context = null):
|
func walk_to(pos : Vector2, p_walk_context = null) -> void:
|
||||||
Movable.walk_to(pos, p_walk_context)
|
Movable.walk_to(pos, p_walk_context)
|
||||||
|
|
||||||
|
func set_speed(speed_value : int) -> void:
|
||||||
|
speed = speed_value
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# TALKATIVE object functions
|
# TALKATIVE object functions
|
||||||
|
|||||||
@@ -129,18 +129,20 @@ func _process(time):
|
|||||||
$debug.text = str(z_index)
|
$debug.text = str(z_index)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func anim_finished():
|
func anim_finished():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
func get_camera_pos():
|
func get_camera_pos():
|
||||||
if camera_position_node and get_node(camera_position_node):
|
if camera_position_node and get_node(camera_position_node):
|
||||||
return get_node(camera_position_node).global_position
|
return get_node(camera_position_node).global_position
|
||||||
return global_position
|
return global_position
|
||||||
|
|
||||||
|
|
||||||
func get_animations_list() -> PoolStringArray:
|
func get_animations_list() -> PoolStringArray:
|
||||||
return animation_sprite.get_sprite_frames().get_animation_names()
|
return animation_sprite.get_sprite_frames().get_animation_names()
|
||||||
|
|
||||||
|
|
||||||
func start_talking():
|
func start_talking():
|
||||||
if animation_sprite.is_playing():
|
if animation_sprite.is_playing():
|
||||||
animation_sprite.stop()
|
animation_sprite.stop()
|
||||||
@@ -162,3 +164,8 @@ func walk_to(pos : Vector2, p_walk_context = null):
|
|||||||
|
|
||||||
func set_angle(deg : int, immediate = true):
|
func set_angle(deg : int, immediate = true):
|
||||||
Movable.set_angle(deg, immediate)
|
Movable.set_angle(deg, immediate)
|
||||||
|
|
||||||
|
|
||||||
|
func set_speed(speed_value : int) -> void:
|
||||||
|
speed = speed_value
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ func _ready():
|
|||||||
if n is NavigationPolygonInstance:
|
if n is NavigationPolygonInstance:
|
||||||
if n.enabled:
|
if n.enabled:
|
||||||
if navigation_enabled_found:
|
if navigation_enabled_found:
|
||||||
escoria.report_errors("escterrain.gd:_ready()", ["Multiple NavigationPolygonInstances enabled at the same time."])
|
escoria.logger.report_errors("escterrain.gd:_ready()", ["Multiple NavigationPolygonInstances enabled at the same time."])
|
||||||
navigation_enabled_found = true
|
navigation_enabled_found = true
|
||||||
current_active_navigation_instance = n
|
current_active_navigation_instance = n
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
tool
|
|
||||||
extends Area2D
|
|
||||||
class_name ESCTriggerZone
|
|
||||||
|
|
||||||
func get_class():
|
|
||||||
return "ESCTriggerZone"
|
|
||||||
|
|
||||||
|
|
||||||
export(String) var global_id
|
|
||||||
export(String, FILE, "*.esc") var esc_script
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
assert(!global_id.empty())
|
|
||||||
escoria.register_object(self)
|
|
||||||
connect("area_entered", self, "element_entered")
|
|
||||||
connect("area_exited", self, "element_exited")
|
|
||||||
connect("body_entered", self, "element_entered")
|
|
||||||
connect("body_exited", self, "element_exited")
|
|
||||||
|
|
||||||
|
|
||||||
func element_entered(body):
|
|
||||||
if body is ESCBackground or body.get_parent() is ESCBackground:
|
|
||||||
return
|
|
||||||
escoria.do("trigger_in", [global_id, body.global_id])
|
|
||||||
|
|
||||||
|
|
||||||
func element_exited(body):
|
|
||||||
escoria.do("trigger_out", [global_id, body.global_id])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,9 +1,49 @@
|
|||||||
|
# Logging
|
||||||
|
onready var warning_is_reported : bool = false
|
||||||
|
var warning_path : String
|
||||||
|
|
||||||
func warning(string : String):
|
func warning(string : String, args = []):
|
||||||
printerr("(W)\t" + string)
|
var argsstr = str(args) if !args.empty() else ""
|
||||||
|
printerr("(W)\t" + string + " \t" + argsstr)
|
||||||
|
|
||||||
func info(string : String):
|
|
||||||
print("(I)\t" + string)
|
|
||||||
|
|
||||||
func error(string : String):
|
func info(string : String, args = []):
|
||||||
printerr("(E)\t" + string)
|
var argsstr = str(args) if !args.empty() else ""
|
||||||
|
print("(I)\t" + string + " \t" + argsstr)
|
||||||
|
|
||||||
|
|
||||||
|
func error(string : String, args = []):
|
||||||
|
var argsstr = str(args) if !args.empty() else ""
|
||||||
|
printerr("(E)\t" + string + " \t" + argsstr)
|
||||||
|
|
||||||
|
|
||||||
|
func report_warnings(p_path : String, warnings : Array, report_once = false) -> void:
|
||||||
|
if p_path != warning_path:
|
||||||
|
warning_is_reported = false
|
||||||
|
|
||||||
|
if !warning_is_reported:
|
||||||
|
var text = "Warnings in file "+p_path+"\n"
|
||||||
|
for w in warnings:
|
||||||
|
if w is Array:
|
||||||
|
text += str(w)+"\n"
|
||||||
|
else:
|
||||||
|
text += w+"\n"
|
||||||
|
warning(text)
|
||||||
|
|
||||||
|
if report_once:
|
||||||
|
warning_is_reported = true
|
||||||
|
|
||||||
|
|
||||||
|
func report_errors(p_path : String, errors : Array) -> void:
|
||||||
|
var text = "Errors in file "+p_path+"\n"
|
||||||
|
for e in errors:
|
||||||
|
if e is Array:
|
||||||
|
text += str(e)+"\n"
|
||||||
|
else:
|
||||||
|
text += e+"\n"
|
||||||
|
error(text)
|
||||||
|
if ProjectSettings.get_setting("escoria/debug/terminate_on_errors"):
|
||||||
|
print_stack()
|
||||||
|
assert(false)
|
||||||
|
# If your game stopped here, you may want to look at the Output tab and
|
||||||
|
# check for the error that caused the game to stop.
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
extends Sprite
|
|
||||||
|
|
||||||
signal left_click_on_bg
|
|
||||||
signal right_click_on_bg # Connect this in your game/signal_script
|
|
||||||
|
|
||||||
export var action = "walk"
|
|
||||||
var area
|
|
||||||
|
|
||||||
# Godot doesn't do doubleclicks so we must
|
|
||||||
var last_lmb_dt = 0
|
|
||||||
var waiting_dblclick = null # null or [pos, event]
|
|
||||||
|
|
||||||
func input(_viewport, event, _shape_idx):
|
|
||||||
if event is InputEventMouseButton and event.pressed:
|
|
||||||
# If we are hovering items, do not allow background to receive a click
|
|
||||||
# and let the items sort out who's on top and gets to be `clicked`
|
|
||||||
if vm.hover_stack:
|
|
||||||
return
|
|
||||||
|
|
||||||
if event.is_action("game_general"):
|
|
||||||
last_lmb_dt = 0
|
|
||||||
waiting_dblclick = [get_global_mouse_position(), event]
|
|
||||||
elif event.is_action("game_rmb"):
|
|
||||||
emit_signal("right_click_on_bg", self, get_global_mouse_position(), event)
|
|
||||||
|
|
||||||
func get_action():
|
|
||||||
return action
|
|
||||||
|
|
||||||
func _physics_process(dt):
|
|
||||||
last_lmb_dt += dt
|
|
||||||
|
|
||||||
if waiting_dblclick and last_lmb_dt > vm.DOUBLECLICK_TIMEOUT:
|
|
||||||
emit_signal("left_click_on_bg", self, waiting_dblclick[0], waiting_dblclick[1])
|
|
||||||
last_lmb_dt = 0
|
|
||||||
waiting_dblclick = null
|
|
||||||
|
|
||||||
func _enter_tree():
|
|
||||||
# Use size of background texture to calculate collision shape
|
|
||||||
var size = get_texture().get_size()
|
|
||||||
|
|
||||||
area = Area2D.new()
|
|
||||||
var shape = RectangleShape2D.new()
|
|
||||||
|
|
||||||
var sid = area.create_shape_owner(area)
|
|
||||||
|
|
||||||
# Move origin of Area2D to center of Sprite
|
|
||||||
var transform = area.shape_owner_get_transform(sid)
|
|
||||||
transform.origin = size / 2
|
|
||||||
area.shape_owner_set_transform(sid, transform)
|
|
||||||
|
|
||||||
# Set extents of RectangleShape2D to cover entire Sprite
|
|
||||||
shape.set_extents(size / 2)
|
|
||||||
area.shape_owner_add_shape(sid, shape)
|
|
||||||
|
|
||||||
add_child(area)
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
var conn_err
|
|
||||||
|
|
||||||
conn_err = area.connect("input_event", self, "input")
|
|
||||||
if conn_err:
|
|
||||||
vm.report_errors("item", ["area.input_event -> input error: " + String(conn_err)])
|
|
||||||
|
|
||||||
conn_err = connect("left_click_on_bg", $"/root/scene/game", "ev_left_click_on_bg")
|
|
||||||
if conn_err:
|
|
||||||
vm.report_errors("item", ["left_click_on_bg -> ev_left_click_on_bg error: " + String(conn_err)])
|
|
||||||
|
|
||||||
add_to_group("background")
|
|
||||||
|
|
||||||
@@ -132,7 +132,6 @@ func load_autosave(p_callback):
|
|||||||
|
|
||||||
|
|
||||||
func _do_load(fname):
|
func _do_load(fname):
|
||||||
|
|
||||||
var f = File.new()
|
var f = File.new()
|
||||||
if !f.file_exists(fname):
|
if !f.file_exists(fname):
|
||||||
return null
|
return null
|
||||||
|
|||||||
@@ -26,9 +26,8 @@ enum GAME_STATE {
|
|||||||
}
|
}
|
||||||
onready var current_state = GAME_STATE.DEFAULT
|
onready var current_state = GAME_STATE.DEFAULT
|
||||||
|
|
||||||
|
onready var game_size = get_viewport().size
|
||||||
|
|
||||||
# Logging
|
|
||||||
onready var is_reported : bool = false
|
|
||||||
|
|
||||||
##################################################################################
|
##################################################################################
|
||||||
func _ready():
|
func _ready():
|
||||||
@@ -41,42 +40,9 @@ func new_game():
|
|||||||
$esc_runner.run_game(actions)
|
$esc_runner.run_game(actions)
|
||||||
|
|
||||||
|
|
||||||
func change_scene_path(scene_path):
|
|
||||||
var scene = load(scene_path).instance()
|
|
||||||
get_tree().get_root().call_deferred("add_child", scene)
|
|
||||||
return scene
|
|
||||||
|
|
||||||
|
|
||||||
func set_main_menu(scene):
|
func set_main_menu(scene):
|
||||||
main_menu_instance = scene
|
main_menu_instance = scene
|
||||||
|
|
||||||
func report_warnings(p_path : String, warnings : Array, report_once = false) -> void:
|
|
||||||
if !is_reported:
|
|
||||||
var text = "Warnings in file "+p_path+"\n"
|
|
||||||
for w in warnings:
|
|
||||||
if w is Array:
|
|
||||||
text += str(w)+"\n"
|
|
||||||
else:
|
|
||||||
text += w+"\n"
|
|
||||||
printerr("warning is: ", text)
|
|
||||||
|
|
||||||
if report_once:
|
|
||||||
is_reported = true
|
|
||||||
|
|
||||||
|
|
||||||
func report_errors(p_path : String, errors : Array) -> void:
|
|
||||||
var text = "Errors in file "+p_path+"\n"
|
|
||||||
for e in errors:
|
|
||||||
if e is Array:
|
|
||||||
text += str(e)+"\n"
|
|
||||||
else:
|
|
||||||
text += e+"\n"
|
|
||||||
printerr("error is: ", text)
|
|
||||||
if ProjectSettings.get_setting("escoria/debug/terminate_on_errors"):
|
|
||||||
print_stack()
|
|
||||||
assert(false)
|
|
||||||
# If your game stopped here, you may want to look at the Output tab and check for
|
|
||||||
# the error that caused the game to stop.
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -113,8 +79,6 @@ func register_object(object : Object):
|
|||||||
if object is ESCInventory:
|
if object is ESCInventory:
|
||||||
inventory = object
|
inventory = object
|
||||||
|
|
||||||
if object is ESCTriggerZone:
|
|
||||||
$esc_runner.register_object(object_id, object, true)
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -130,7 +94,7 @@ func do(action : String, params : Array = []) -> void:
|
|||||||
|
|
||||||
# Check moving object.
|
# Check moving object.
|
||||||
if !escoria.esc_runner.check_obj(params[0], "escoria.do(walk)"):
|
if !escoria.esc_runner.check_obj(params[0], "escoria.do(walk)"):
|
||||||
report_errors("escoria.gd:do()",
|
escoria.logger.report_errors("escoria.gd:do()",
|
||||||
["Walk action requested on inexisting object: " + params[0]])
|
["Walk action requested on inexisting object: " + params[0]])
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -148,7 +112,7 @@ func do(action : String, params : Array = []) -> void:
|
|||||||
# Walk to object from its id
|
# Walk to object from its id
|
||||||
elif params[1] is String:
|
elif params[1] is String:
|
||||||
if !escoria.esc_runner.check_obj(params[1], "escoria.do(walk)"):
|
if !escoria.esc_runner.check_obj(params[1], "escoria.do(walk)"):
|
||||||
report_errors("escoria.gd:do()",
|
escoria.logger.report_errors("escoria.gd:do()",
|
||||||
["Walk action requested TOWARDS inexisting object: " + params[1]])
|
["Walk action requested TOWARDS inexisting object: " + params[1]])
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -164,34 +128,32 @@ func do(action : String, params : Array = []) -> void:
|
|||||||
|
|
||||||
"item_left_click":
|
"item_left_click":
|
||||||
if params[0] is String:
|
if params[0] is String:
|
||||||
printt("escoria.do : item_left_click on item ", params[0])
|
escoria.logger.info("escoria.do() : item_left_click on item ", [params[0]])
|
||||||
var item = $esc_runner.get_object(params[0])
|
var item = $esc_runner.get_object(params[0])
|
||||||
ev_left_click_on_item(item, params[1])
|
ev_left_click_on_item(item, params[1])
|
||||||
|
|
||||||
"item_right_click":
|
"item_right_click":
|
||||||
if params[0] is String:
|
if params[0] is String:
|
||||||
printt("escoria.do : item_right_click on item ", params[0])
|
escoria.logger.info("escoria.do() : item_right_click on item ", [params[0]])
|
||||||
ev_left_click_on_item($esc_runner.get_object(params[0]), params[1], true)
|
ev_left_click_on_item($esc_runner.get_object(params[0]), params[1], true)
|
||||||
|
|
||||||
"trigger_in":
|
"trigger_in":
|
||||||
var trigger_id = params[0]
|
var trigger_id = params[0]
|
||||||
var object_id = params[1]
|
var object_id = params[1]
|
||||||
var trigger_in_verb = params[2]
|
var trigger_in_verb = params[2]
|
||||||
printt("escoria.do() : trigger_in ", trigger_id, " by ", object_id)
|
escoria.logger.info("escoria.do() : trigger_in " + trigger_id + " by " + object_id)
|
||||||
esc_runner.run_event(esc_runner.objects_events_table[trigger_id][trigger_in_verb])
|
esc_runner.run_event(esc_runner.objects_events_table[trigger_id][trigger_in_verb])
|
||||||
|
|
||||||
"trigger_out":
|
"trigger_out":
|
||||||
var trigger_id = params[0]
|
var trigger_id = params[0]
|
||||||
var object_id = params[1]
|
var object_id = params[1]
|
||||||
var trigger_out_verb = params[2]
|
var trigger_out_verb = params[2]
|
||||||
printt("escoria.do() : trigger_out ", trigger_id, " by ", object_id)
|
escoria.logger.info("escoria.do() : trigger_out " + trigger_id + " by " + object_id)
|
||||||
esc_runner.run_event(esc_runner.objects_events_table[trigger_id][trigger_out_verb])
|
esc_runner.run_event(esc_runner.objects_events_table[trigger_id][trigger_out_verb])
|
||||||
|
|
||||||
_:
|
_:
|
||||||
# $esc_runner.activate(action, params[0])
|
escoria.logger.report_warnings("escoria.gd:do()",
|
||||||
report_warnings("escoria.gd:do()", ["Action received:", action, "with params ", params])
|
["Action received:", action, "with params ", params])
|
||||||
# elif current_state == GAME_STATE.DIALOG:
|
|
||||||
# dialog_player.finish_fast()
|
|
||||||
elif current_state == GAME_STATE.WAIT:
|
elif current_state == GAME_STATE.WAIT:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -206,7 +168,7 @@ func ev_left_click_on_item(obj, event, default_action = false):
|
|||||||
"""
|
"""
|
||||||
if obj is String:
|
if obj is String:
|
||||||
obj = esc_runner.objects[obj]
|
obj = esc_runner.objects[obj]
|
||||||
printt(obj.global_id, "left-clicked with", event)
|
escoria.logger.info(obj.global_id + " left-clicked with event ", [event])
|
||||||
|
|
||||||
var need_combine = false
|
var need_combine = false
|
||||||
# Check if current_action and current_tool are already set
|
# Check if current_action and current_tool are already set
|
||||||
@@ -250,7 +212,7 @@ func ev_left_click_on_item(obj, event, default_action = false):
|
|||||||
|
|
||||||
# Wait for the player to arrive before continuing with action.
|
# Wait for the player to arrive before continuing with action.
|
||||||
var context = yield(main.current_scene.player, "arrived")
|
var context = yield(main.current_scene.player, "arrived")
|
||||||
printt("context arrived: ", context)
|
escoria.logger.info("Context arrived: ", [context])
|
||||||
if context.has("target_object") and walk_context.has("target_object"):
|
if context.has("target_object") and walk_context.has("target_object"):
|
||||||
if (context.target_object.global_id != walk_context.target_object.global_id) \
|
if (context.target_object.global_id != walk_context.target_object.global_id) \
|
||||||
or (context.target_object.global_id == walk_context.target_object.global_id and is_already_walking):
|
or (context.target_object.global_id == walk_context.target_object.global_id and is_already_walking):
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ onready var hotspot_focused : String = ""
|
|||||||
func _ready():
|
func _ready():
|
||||||
set_process_input(true)
|
set_process_input(true)
|
||||||
|
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if event.is_action_pressed("esc_show_debug_prompt"):
|
if event.is_action_pressed("esc_show_debug_prompt"):
|
||||||
escoria.main.get_node("layers/debug_layer/esc_prompt_popup").popup()
|
escoria.main.get_node("layers/debug_layer/esc_prompt_popup").popup()
|
||||||
@@ -16,48 +17,53 @@ func _input(event):
|
|||||||
|
|
||||||
func _on_left_click_on_bg(position : Vector2):
|
func _on_left_click_on_bg(position : Vector2):
|
||||||
if hotspot_focused.empty():
|
if hotspot_focused.empty():
|
||||||
printt("Left click on background at ", str(position))
|
escoria.logger.info("Left click on background at ", [str(position)])
|
||||||
escoria.main.current_scene.game.left_click_on_bg(position)
|
escoria.main.current_scene.game.left_click_on_bg(position)
|
||||||
|
|
||||||
|
|
||||||
func _on_double_left_click_on_bg(position : Vector2):
|
func _on_double_left_click_on_bg(position : Vector2):
|
||||||
if hotspot_focused.empty():
|
if hotspot_focused.empty():
|
||||||
printt("Double left click on background at ", str(position))
|
escoria.logger.info("Double left click on background at ", [str(position)])
|
||||||
escoria.main.current_scene.game.left_double_click_on_bg(position)
|
escoria.main.current_scene.game.left_double_click_on_bg(position)
|
||||||
|
|
||||||
|
|
||||||
func _on_right_click_on_bg(position : Vector2):
|
func _on_right_click_on_bg(position : Vector2):
|
||||||
if hotspot_focused.empty():
|
if hotspot_focused.empty():
|
||||||
printt("Right click on background at ", str(position))
|
escoria.logger.info("Right click on background at ", [str(position)])
|
||||||
escoria.main.current_scene.game.right_click_on_bg(position)
|
escoria.main.current_scene.game.right_click_on_bg(position)
|
||||||
|
|
||||||
##################################################################################
|
##################################################################################
|
||||||
|
|
||||||
func _on_mouse_left_click_inventory_item(inventory_item_global_id, event : InputEvent) -> void:
|
func _on_mouse_left_click_inventory_item(inventory_item_global_id, event : InputEvent) -> void:
|
||||||
printt("Inventory item left clicked ", inventory_item_global_id)
|
escoria.logger.info("Inventory item left clicked ", [inventory_item_global_id])
|
||||||
escoria.main.current_scene.game.left_click_on_inventory_item(inventory_item_global_id, event)
|
escoria.main.current_scene.game.left_click_on_inventory_item(inventory_item_global_id, event)
|
||||||
|
|
||||||
|
|
||||||
func _on_mouse_right_click_inventory_item(inventory_item_global_id, event : InputEvent) -> void:
|
func _on_mouse_right_click_inventory_item(inventory_item_global_id, event : InputEvent) -> void:
|
||||||
printt("Inventory item right clicked ", inventory_item_global_id)
|
escoria.logger.info("Inventory item right clicked ", [inventory_item_global_id])
|
||||||
escoria.main.current_scene.game.right_click_on_inventory_item(inventory_item_global_id, event)
|
escoria.main.current_scene.game.right_click_on_inventory_item(inventory_item_global_id, event)
|
||||||
|
|
||||||
|
|
||||||
func _on_mouse_double_left_click_inventory_item(inventory_item_global_id, event : InputEvent) -> void:
|
func _on_mouse_double_left_click_inventory_item(inventory_item_global_id, event : InputEvent) -> void:
|
||||||
printt("Inventory item double left clicked ", inventory_item_global_id)
|
escoria.logger.info("Inventory item double left clicked ", [inventory_item_global_id])
|
||||||
escoria.main.current_scene.game.left_double_click_on_inventory_item(inventory_item_global_id, event)
|
escoria.main.current_scene.game.left_double_click_on_inventory_item(inventory_item_global_id, event)
|
||||||
|
|
||||||
|
|
||||||
func _on_mouse_entered_inventory_item(inventory_item_global_id) -> void:
|
func _on_mouse_entered_inventory_item(inventory_item_global_id) -> void:
|
||||||
printt("Inventory item focused ", inventory_item_global_id)
|
escoria.logger.info("Inventory item focused ", [inventory_item_global_id])
|
||||||
escoria.main.current_scene.game.inventory_item_focused(inventory_item_global_id)
|
escoria.main.current_scene.game.inventory_item_focused(inventory_item_global_id)
|
||||||
|
|
||||||
|
|
||||||
func _on_mouse_exited_inventory_item() -> void:
|
func _on_mouse_exited_inventory_item() -> void:
|
||||||
printt("Inventory item unfocused")
|
escoria.logger.info("Inventory item unfocused")
|
||||||
escoria.main.current_scene.game.inventory_item_unfocused()
|
escoria.main.current_scene.game.inventory_item_unfocused()
|
||||||
|
|
||||||
|
|
||||||
##################################################################################
|
##################################################################################
|
||||||
|
|
||||||
func _on_mouse_entered_item(item : ESCItem) -> void:
|
func _on_mouse_entered_item(item : ESCItem) -> void:
|
||||||
printt("Item focused : ", item.global_id)
|
escoria.logger.info("Item focused : ", [item.global_id])
|
||||||
|
clean_hover_stack()
|
||||||
|
|
||||||
if !hover_stack.empty():
|
if !hover_stack.empty():
|
||||||
if item.z_index > hover_stack.back().z_index:
|
if item.z_index > hover_stack.back().z_index:
|
||||||
@@ -72,7 +78,7 @@ func _on_mouse_entered_item(item : ESCItem) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_mouse_exited_item(item : ESCItem) -> void:
|
func _on_mouse_exited_item(item : ESCItem) -> void:
|
||||||
printt("Item unfocused : ", item.global_id)
|
escoria.logger.info("Item unfocused : ", [item.global_id])
|
||||||
hover_stack.erase(item)
|
hover_stack.erase(item)
|
||||||
if hover_stack.empty():
|
if hover_stack.empty():
|
||||||
hotspot_focused = ""
|
hotspot_focused = ""
|
||||||
@@ -84,15 +90,17 @@ func _on_mouse_exited_item(item : ESCItem) -> void:
|
|||||||
|
|
||||||
func _on_mouse_left_clicked_item(item : ESCItem, event : InputEvent) -> void:
|
func _on_mouse_left_clicked_item(item : ESCItem, event : InputEvent) -> void:
|
||||||
if hover_stack.empty() or hover_stack.back() == item:
|
if hover_stack.empty() or hover_stack.back() == item:
|
||||||
printt("Item left clicked", item.global_id, event)
|
escoria.logger.info("Item left clicked", [item.global_id, event])
|
||||||
escoria.main.current_scene.game.left_click_on_item(item.global_id, event)
|
escoria.main.current_scene.game.left_click_on_item(item.global_id, event)
|
||||||
|
|
||||||
|
|
||||||
func _on_mouse_left_double_clicked_item(item : ESCItem, event : InputEvent) -> void:
|
func _on_mouse_left_double_clicked_item(item : ESCItem, event : InputEvent) -> void:
|
||||||
printt("Item left double clicked", item.global_id, event)
|
escoria.logger.info("Item left double clicked", [item.global_id, event])
|
||||||
escoria.main.current_scene.game.left_double_click_on_item(item.global_id, event)
|
escoria.main.current_scene.game.left_double_click_on_item(item.global_id, event)
|
||||||
|
|
||||||
|
|
||||||
func _on_mouse_right_clicked_item(item : ESCItem, event : InputEvent) -> void:
|
func _on_mouse_right_clicked_item(item : ESCItem, event : InputEvent) -> void:
|
||||||
printt("Item right clicked", item.global_id, event)
|
escoria.logger.info("Item right clicked", [item.global_id, event])
|
||||||
escoria.main.current_scene.game.right_click_on_item(item.global_id, event)
|
escoria.main.current_scene.game.right_click_on_item(item.global_id, event)
|
||||||
|
|
||||||
|
|
||||||
@@ -100,3 +108,11 @@ func _on_mouse_right_clicked_item(item : ESCItem, event : InputEvent) -> void:
|
|||||||
|
|
||||||
func _on_mousewheel_action(direction : int):
|
func _on_mousewheel_action(direction : int):
|
||||||
escoria.main.current_scene.game.mousewheel_action(direction)
|
escoria.main.current_scene.game.mousewheel_action(direction)
|
||||||
|
|
||||||
|
|
||||||
|
##################################################################################
|
||||||
|
|
||||||
|
func clean_hover_stack():
|
||||||
|
for e in hover_stack:
|
||||||
|
if e == null or !is_instance_valid(e):
|
||||||
|
hover_stack.erase(e)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func set_scene(p_scene, run_events=true):
|
|||||||
If run_events=true, plays the events defined in :setup event
|
If run_events=true, plays the events defined in :setup event
|
||||||
"""
|
"""
|
||||||
if !p_scene:
|
if !p_scene:
|
||||||
escoria.report_errors("main", ["Trying to set empty scene"])
|
escoria.logger.report_errors("main", ["Trying to set empty scene"])
|
||||||
|
|
||||||
if current_scene != null:
|
if current_scene != null:
|
||||||
clear_scene()
|
clear_scene()
|
||||||
@@ -69,10 +69,10 @@ func set_current_scene(p_scene, run_events=true):
|
|||||||
# Having a game with `:setup` means we must wait for it to finish
|
# Having a game with `:setup` means we must wait for it to finish
|
||||||
if "setup" in escoria.esc_runner.game:
|
if "setup" in escoria.esc_runner.game:
|
||||||
if not escoria.esc_runner.running_event:
|
if not escoria.esc_runner.running_event:
|
||||||
escoria.report_errors("main.gd:set_current_scene()", ["escoria.esc_runner.game has setup but no running_event"])
|
escoria.logger.report_errors("main.gd:set_current_scene()", ["escoria.esc_runner.game has setup but no running_event"])
|
||||||
|
|
||||||
if escoria.esc_runner.running_event.ev_name != "setup":
|
if escoria.esc_runner.running_event.ev_name != "setup":
|
||||||
escoria.report_errors("main.gd:set_current_scene()", ["escoria.esc_runner.game has setup but it is not running: " + escoria.esc_runner.running_event.ev_name])
|
escoria.logger.report_errors("main.gd:set_current_scene()", ["escoria.esc_runner.game has setup but it is not running: " + escoria.esc_runner.running_event.ev_name])
|
||||||
|
|
||||||
yield(escoria.esc_runner, "event_done")
|
yield(escoria.esc_runner, "event_done")
|
||||||
else:
|
else:
|
||||||
@@ -127,10 +127,11 @@ func set_camera_limits(camera_limit_id : int = 0):
|
|||||||
|
|
||||||
# if the background is smaller than the viewport, we want the camera to stick centered on the background
|
# if the background is smaller than the viewport, we want the camera to stick centered on the background
|
||||||
if area.size.x == 0 or area.size.y == 0 or area.size < get_viewport().size:
|
if area.size.x == 0 or area.size.y == 0 or area.size < get_viewport().size:
|
||||||
printt("No limit area! Using viewport")
|
escoria.logger.report_warning("main.gd:set_camera_limits()",
|
||||||
|
"No limit area! Using viewport.")
|
||||||
area.size = get_viewport().size
|
area.size = get_viewport().size
|
||||||
|
|
||||||
printt("setting camera limits from scene ", area)
|
escoria.logger.info("Setting camera limits from scene ", [area])
|
||||||
limits = {
|
limits = {
|
||||||
"limit_left": area.position.x,
|
"limit_left": area.position.x,
|
||||||
"limit_right": area.position.x + area.size.x,
|
"limit_right": area.position.x + area.size.x,
|
||||||
@@ -146,7 +147,7 @@ func set_camera_limits(camera_limit_id : int = 0):
|
|||||||
"limit_bottom": scene_camera_limits.position.y + scene_camera_limits.size.y + screen_ofs.y * 2,
|
"limit_bottom": scene_camera_limits.position.y + scene_camera_limits.size.y + screen_ofs.y * 2,
|
||||||
"set_default": true,
|
"set_default": true,
|
||||||
}
|
}
|
||||||
printt("setting camera limits from parameter ", scene_camera_limits)
|
escoria.logger.info("Setting camera limits from parameter ", [scene_camera_limits])
|
||||||
|
|
||||||
current_scene.game.get_node("camera").set_limits(limits)
|
current_scene.game.get_node("camera").set_limits(limits)
|
||||||
current_scene.game.get_node("camera").set_offset(screen_ofs * 2)
|
current_scene.game.get_node("camera").set_offset(screen_ofs * 2)
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ extends Node
|
|||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
var main_menu_path = ProjectSettings.get_setting("escoria/main/main_menu_scene")
|
var main_menu_path = ProjectSettings.get_setting("escoria/main/main_menu_scene")
|
||||||
var main_menu = escoria.change_scene_path(main_menu_path)
|
var main_menu_scene = load(main_menu_path).instance()
|
||||||
escoria.set_main_menu(main_menu)
|
get_tree().get_root().call_deferred("add_child", main_menu_scene)
|
||||||
|
escoria.set_main_menu(main_menu_scene)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ onready var tween = $"tween"
|
|||||||
var default_limits = {} # This does not change once set
|
var default_limits = {} # This does not change once set
|
||||||
|
|
||||||
var speed = 0.0
|
var speed = 0.0
|
||||||
|
# Target can be object or Vector2. See resove_target_pos()
|
||||||
var target
|
var target
|
||||||
var target_pos
|
var target_pos : Vector2
|
||||||
|
|
||||||
var zoom_time
|
var zoom_time
|
||||||
var zoom_target
|
var zoom_target
|
||||||
@@ -72,6 +73,7 @@ func set_target(p_target, p_speed : float = 0.0):
|
|||||||
target = p_target
|
target = p_target
|
||||||
|
|
||||||
resolve_target_pos()
|
resolve_target_pos()
|
||||||
|
escoria.logger.info("Current camera position = " + str(self.global_position))
|
||||||
|
|
||||||
if speed == 0.0:
|
if speed == 0.0:
|
||||||
self.global_position = target_pos
|
self.global_position = target_pos
|
||||||
@@ -80,7 +82,7 @@ func set_target(p_target, p_speed : float = 0.0):
|
|||||||
|
|
||||||
if tween.is_active():
|
if tween.is_active():
|
||||||
var tweenstat = String(tween.tell()) + "/" + String(tween.get_runtime())
|
var tweenstat = String(tween.tell()) + "/" + String(tween.get_runtime())
|
||||||
escoria.report_warnings("camera.gd:set_target()",
|
escoria.logger.report_warnings("camera.gd:set_target()",
|
||||||
["Tween still active running camera_set_target: " + tweenstat])
|
["Tween still active running camera_set_target: " + tweenstat])
|
||||||
tween.emit_signal("tween_completed")
|
tween.emit_signal("tween_completed")
|
||||||
|
|
||||||
@@ -90,7 +92,7 @@ func set_target(p_target, p_speed : float = 0.0):
|
|||||||
|
|
||||||
func set_camera_zoom(p_zoom_level, p_time):
|
func set_camera_zoom(p_zoom_level, p_time):
|
||||||
if p_zoom_level <= 0.0:
|
if p_zoom_level <= 0.0:
|
||||||
escoria.report_errors("camera.gd:set_camera_zoom()",
|
escoria.logger.report_errors("camera.gd:set_camera_zoom()",
|
||||||
["Tried to set negative or zero zoom level"])
|
["Tried to set negative or zero zoom level"])
|
||||||
|
|
||||||
zoom_time = p_time
|
zoom_time = p_time
|
||||||
@@ -101,7 +103,7 @@ func set_camera_zoom(p_zoom_level, p_time):
|
|||||||
else:
|
else:
|
||||||
if tween.is_active():
|
if tween.is_active():
|
||||||
var tweenstat = String(tween.tell()) + "/" + String(tween.get_runtime())
|
var tweenstat = String(tween.tell()) + "/" + String(tween.get_runtime())
|
||||||
escoria.report_warnings("camera",
|
escoria.logger.report_warnings("camera",
|
||||||
["Tween still active running camera_set_zoom: " + tweenstat])
|
["Tween still active running camera_set_zoom: " + tweenstat])
|
||||||
tween.emit_signal("tween_completed")
|
tween.emit_signal("tween_completed")
|
||||||
|
|
||||||
@@ -132,7 +134,7 @@ func push(p_target, p_time, p_type):
|
|||||||
else:
|
else:
|
||||||
if tween.is_active():
|
if tween.is_active():
|
||||||
var tweenstat = String(tween.tell()) + "/" + String(tween.get_runtime())
|
var tweenstat = String(tween.tell()) + "/" + String(tween.get_runtime())
|
||||||
escoria.report_warnings("camera",
|
escoria.logger.report_warnings("camera",
|
||||||
["Tween still active running camera_push: " + tweenstat])
|
["Tween still active running camera_push: " + tweenstat])
|
||||||
tween.emit_signal("tween_completed")
|
tween.emit_signal("tween_completed")
|
||||||
|
|
||||||
@@ -156,7 +158,7 @@ func shift(p_x, p_y, p_time, p_type):
|
|||||||
|
|
||||||
if tween.is_active():
|
if tween.is_active():
|
||||||
var tweenstat = String(tween.tell()) + "/" + String(tween.get_runtime())
|
var tweenstat = String(tween.tell()) + "/" + String(tween.get_runtime())
|
||||||
escoria.report_warnings("camera",
|
escoria.logger.report_warnings("camera",
|
||||||
["Tween still active running camera_shift: " + tweenstat])
|
["Tween still active running camera_shift: " + tweenstat])
|
||||||
tween.emit_signal("tween_completed")
|
tween.emit_signal("tween_completed")
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ func preload_resources(path : String):
|
|||||||
add_resource(basename, dialog_scene)
|
add_resource(basename, dialog_scene)
|
||||||
file_name = dialog_folder.get_next()
|
file_name = dialog_folder.get_next()
|
||||||
else:
|
else:
|
||||||
escoria.report_errors("dialog_player.gd:preload_resources()", ["An error occurred when trying to access the path: {_}.".format(path)])
|
escoria.logger.report_errors("dialog_player.gd:preload_resources()", ["An error occurred when trying to access the path: {_}.".format(path)])
|
||||||
|
|
||||||
|
|
||||||
func say(character : String, params : Dictionary):
|
func say(character : String, params : Dictionary):
|
||||||
@@ -60,7 +60,7 @@ func finish_fast():
|
|||||||
# timeout_option: (default value 0) option selected when timeout is reached.
|
# timeout_option: (default value 0) option selected when timeout is reached.
|
||||||
func start_dialog_choices(answers : Array, options : Array):
|
func start_dialog_choices(answers : Array, options : Array):
|
||||||
if answers.empty():
|
if answers.empty():
|
||||||
escoria.report_errors("dialog_player.gd:start_dialog_choices()", ["Received answers array was empty."])
|
escoria.logger.report_errors("dialog_player.gd:start_dialog_choices()", ["Received answers array was empty."])
|
||||||
dialog_chooser_ui = get_resource("text_dialog_choice").instance()
|
dialog_chooser_ui = get_resource("text_dialog_choice").instance()
|
||||||
get_parent().add_child(dialog_chooser_ui)
|
get_parent().add_child(dialog_chooser_ui)
|
||||||
dialog_chooser_ui.set_answers(answers)
|
dialog_chooser_ui.set_answers(answers)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func _ready():
|
|||||||
escoria.register_object(self)
|
escoria.register_object(self)
|
||||||
|
|
||||||
if items_container == null or items_container.is_empty():
|
if items_container == null or items_container.is_empty():
|
||||||
escoria.report_errors(self.get_path(), ["Items container is empty."])
|
escoria.logger.report_errors(self.get_path(), ["Items container is empty."])
|
||||||
return
|
return
|
||||||
for c in get_node(items_container).get_items():
|
for c in get_node(items_container).get_items():
|
||||||
items_ids_in_inventory[c.item_id] = c
|
items_ids_in_inventory[c.item_id] = c
|
||||||
@@ -46,11 +46,11 @@ func add_new_item_by_id(item_id : String) -> void:
|
|||||||
item_id = item_id.rsplit("i/", false)[0]
|
item_id = item_id.rsplit("i/", false)[0]
|
||||||
if !items_ids_in_inventory.has(item_id):
|
if !items_ids_in_inventory.has(item_id):
|
||||||
if !escoria.esc_runner.check_obj(item_id, "add_new_item_by_id"):
|
if !escoria.esc_runner.check_obj(item_id, "add_new_item_by_id"):
|
||||||
escoria.report_errors("inventory_ui.gd:add_new_item_by_id()",
|
escoria.logger.report_errors("inventory_ui.gd:add_new_item_by_id()",
|
||||||
["Item global id '"+ item_id + "' does not exist.",
|
["Item global id '"+ item_id + "' does not exist.",
|
||||||
"Check item's id in ESCORIA_ALL_ITEMS scene."])
|
"Check item's id in ESCORIA_ALL_ITEMS scene."])
|
||||||
if !all_items.get_inventory_item(item_id):
|
if !all_items.get_inventory_item(item_id):
|
||||||
escoria.report_errors("inventory_ui.gd:add_new_item_by_id()",
|
escoria.logger.report_errors("inventory_ui.gd:add_new_item_by_id()",
|
||||||
["Item global id '"+ item_id + "' doesn't have corresponding inventory item.",
|
["Item global id '"+ item_id + "' doesn't have corresponding inventory item.",
|
||||||
"Check item's id in ESCORIA_ALL_ITEMS scene."])
|
"Check item's id in ESCORIA_ALL_ITEMS scene."])
|
||||||
var item_inventory_button = all_items.get_inventory_item(item_id).duplicate()
|
var item_inventory_button = all_items.get_inventory_item(item_id).duplicate()
|
||||||
@@ -104,7 +104,7 @@ func _on_escoria_global_changed(global : String) -> void:
|
|||||||
elif escoria.esc_runner.globals[global] == "false":
|
elif escoria.esc_runner.globals[global] == "false":
|
||||||
remove_item_by_id(item[0])
|
remove_item_by_id(item[0])
|
||||||
else:
|
else:
|
||||||
escoria.report_warnings("inventory_ui.gd:_on_escoria_global_changed()", \
|
escoria.logger.report_warnings("inventory_ui.gd:_on_escoria_global_changed()", \
|
||||||
["Inventory global " + global + " is neither 'true' nor 'false' (was " + escoria.esc_runner.globals[global] + "). "])
|
["Inventory global " + global + " is neither 'true' nor 'false' (was " + escoria.esc_runner.globals[global] + "). "])
|
||||||
else:
|
else:
|
||||||
escoria.report_errors("inventory_ui.gd:_on_escoria_global_changed()", ["Global must contain 1 item name.", "(received: " + global + ")"])
|
escoria.logger.report_errors("inventory_ui.gd:_on_escoria_global_changed()", ["Global must contain 1 item name.", "(received: " + global + ")"])
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func say(character : String, params : Dictionary) :
|
|||||||
set_current_character(character)
|
set_current_character(character)
|
||||||
|
|
||||||
if !params["line"]:
|
if !params["line"]:
|
||||||
escoria.report_errors("dialog_box_inset.gd:say()", ["No line field in params!"])
|
escoria.logger.report_errors("dialog_box_inset.gd:say()", ["No line field in params!"])
|
||||||
return
|
return
|
||||||
|
|
||||||
text_node.bbcode_text = params["line"]
|
text_node.bbcode_text = params["line"]
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func say(character : String, params : Dictionary) :
|
|||||||
show()
|
show()
|
||||||
|
|
||||||
if !params["line"]:
|
if !params["line"]:
|
||||||
escoria.report_errors("dialog_box_inset.gd:say()", ["No line field in params!"])
|
escoria.logger.report_errors("dialog_box_inset.gd:say()", ["No line field in params!"])
|
||||||
return
|
return
|
||||||
|
|
||||||
# Position the RichTextLabel on the character's dialog position, if any.
|
# Position the RichTextLabel on the character's dialog position, if any.
|
||||||
|
|||||||
@@ -19,32 +19,6 @@ func on_action_selected() -> void:
|
|||||||
current_action = escoria.esc_runner.current_action
|
current_action = escoria.esc_runner.current_action
|
||||||
update_tooltip_text()
|
update_tooltip_text()
|
||||||
|
|
||||||
#func element_focused(element_id : String) -> void:
|
|
||||||
# printt("action_target_tooltip.gd:on_element_focused()", "Element focused: ", element_id)
|
|
||||||
#
|
|
||||||
# if element_id == "":
|
|
||||||
# set_target("")
|
|
||||||
# return
|
|
||||||
#
|
|
||||||
# var object = escoria.esc_runner.get_object(element_id)
|
|
||||||
#
|
|
||||||
# if object == null or !is_instance_valid(object):
|
|
||||||
# escoria.report_warnings("action_target_tooltip.gd:on_element_focused()",
|
|
||||||
# ["Object exists but is not loaded for id " + element_id])
|
|
||||||
# set_target(element_id)
|
|
||||||
# return
|
|
||||||
#
|
|
||||||
# if !escoria.esc_runner.get_interactive(element_id) and !object is ESCInventoryItem:
|
|
||||||
# set_target("")
|
|
||||||
# return
|
|
||||||
#
|
|
||||||
# var wait_for_target = false
|
|
||||||
# if object is ESCItem or object is ESCInventoryItem:
|
|
||||||
# if current_action in object.combine_if_action_used_among:
|
|
||||||
# wait_for_target = true
|
|
||||||
#
|
|
||||||
# set_target(object.tooltip_name, wait_for_target)
|
|
||||||
|
|
||||||
|
|
||||||
func set_target(target : String, needs_second_target : bool = false) -> void:
|
func set_target(target : String, needs_second_target : bool = false) -> void:
|
||||||
current_target = target
|
current_target = target
|
||||||
|
|||||||
@@ -39,5 +39,5 @@ interact_positions = {
|
|||||||
[node name="bottle" parent="." instance=ExtResource( 6 )]
|
[node name="bottle" parent="." instance=ExtResource( 6 )]
|
||||||
position = Vector2( 59.4604, 167.678 )
|
position = Vector2( 59.4604, 167.678 )
|
||||||
interact_positions = {
|
interact_positions = {
|
||||||
"default": Vector2( 0, 0 )
|
"default": Vector2( 59.4604, 167.678 )
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,8 +66,6 @@ tracks/0/keys = {
|
|||||||
|
|
||||||
[node name="button" type="Area2D"]
|
[node name="button" type="Area2D"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
global_id = "r3_button"
|
|
||||||
esc_script = "res://game/rooms/room3/esc/button.esc"
|
|
||||||
tooltip_name = "Button"
|
tooltip_name = "Button"
|
||||||
default_action = "use"
|
default_action = "use"
|
||||||
dialog_color = Color( 1, 1, 1, 1 )
|
dialog_color = Color( 1, 1, 1, 1 )
|
||||||
@@ -85,6 +83,7 @@ polygon = PoolVector2Array( 343.993, 396.767, 323.298, 415.689, 344.585, 438.158
|
|||||||
|
|
||||||
[node name="Particles2D" type="Particles2D" parent="."]
|
[node name="Particles2D" type="Particles2D" parent="."]
|
||||||
position = Vector2( 344.768, 142.144 )
|
position = Vector2( 344.768, 142.144 )
|
||||||
|
emitting = false
|
||||||
amount = 16
|
amount = 16
|
||||||
lifetime = 4.0
|
lifetime = 4.0
|
||||||
preprocess = 1.99
|
preprocess = 1.99
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
:ready
|
:ready
|
||||||
set_global bridge_closed false
|
set_global bridge_closed false
|
||||||
|
set_state r3_button button_broken
|
||||||
set_global button_broken true
|
set_global button_broken true
|
||||||
|
|
||||||
# DEBUG
|
# DEBUG
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ polygon = PoolVector2Array( -2.71457, 437.818, 6.6293, 121.462, 89.3893, 74.7422
|
|||||||
position = Vector2( 44.1375, 384.691 )
|
position = Vector2( 44.1375, 384.691 )
|
||||||
|
|
||||||
[node name="button" parent="Hotspots" instance=ExtResource( 7 )]
|
[node name="button" parent="Hotspots" instance=ExtResource( 7 )]
|
||||||
|
global_id = "r3_button"
|
||||||
|
esc_script = "res://game/rooms/room3/esc/button.esc"
|
||||||
interact_positions = {
|
interact_positions = {
|
||||||
"default": Vector2( 347.767, 378.011 )
|
"default": Vector2( 347.767, 378.011 )
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ say player "I don't think he'd like that."
|
|||||||
|
|
||||||
|
|
||||||
:use r5_filled_sheet
|
:use r5_filled_sheet
|
||||||
say player "I'll give you this!"
|
jump give r5_filled_sheet
|
||||||
|
|
||||||
:give r5_filled_sheet
|
:give r5_filled_sheet
|
||||||
inventory_remove r5_filled_sheet
|
inventory_remove r5_filled_sheet
|
||||||
|
|||||||
14
game/rooms/room7/esc/button_set_pos.esc
Executable file
14
game/rooms/room7/esc/button_set_pos.esc
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
:look
|
||||||
|
say player "That button triggers a camera set_pos effect."
|
||||||
|
|
||||||
|
:use
|
||||||
|
camera_set_limits 2
|
||||||
|
camera_set_pos 500 150 150
|
||||||
|
wait 6
|
||||||
|
|
||||||
|
camera_set_pos 1 1080 1000
|
||||||
|
wait 1
|
||||||
|
camera_set_limits 0
|
||||||
|
|
||||||
|
camera_set_target 0 player
|
||||||
|
|
||||||
@@ -2,16 +2,6 @@
|
|||||||
|
|
||||||
say player "movin up"
|
say player "movin up"
|
||||||
|
|
||||||
|
|
||||||
#camera_push player 1 LINEAR
|
|
||||||
#camera_set_drag_margin_enabled bool bool
|
|
||||||
#camera_set_pos real int int
|
|
||||||
#camera_set_target real
|
|
||||||
#camera_set_zoom real
|
|
||||||
#camera_set_zoom_height int
|
|
||||||
#camera_shift int int
|
|
||||||
|
|
||||||
|
|
||||||
teleport player r7_upper_stairs
|
teleport player r7_upper_stairs
|
||||||
set_angle player 270
|
set_angle player 270
|
||||||
camera_set_limits 2
|
camera_set_limits 2
|
||||||
|
|||||||
@@ -345,6 +345,28 @@ __meta__ = {
|
|||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="button_camera_set_pos" parent="Hotspots" instance=ExtResource( 3 )]
|
||||||
|
position = Vector2( 910.482, 1464.03 )
|
||||||
|
global_id = "r7_button_set_pos"
|
||||||
|
esc_script = "res://game/rooms/room7/esc/button_set_pos.esc"
|
||||||
|
interact_positions = {
|
||||||
|
"default": Vector2( 682.785, 1765.65 )
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Position2D" type="Position2D" parent="Hotspots/button_camera_set_pos"]
|
||||||
|
position = Vector2( 350.258, 301.616 )
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="Hotspots/button_camera_set_pos"]
|
||||||
|
margin_left = 292.919
|
||||||
|
margin_top = 96.8108
|
||||||
|
margin_right = 390.919
|
||||||
|
margin_bottom = 112.811
|
||||||
|
custom_fonts/font = ExtResource( 5 )
|
||||||
|
text = "Camera_set_pos"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
[node name="trigger_left" type="Area2D" parent="Hotspots"]
|
[node name="trigger_left" type="Area2D" parent="Hotspots"]
|
||||||
position = Vector2( 406, 0 )
|
position = Vector2( 406, 0 )
|
||||||
script = ExtResource( 7 )
|
script = ExtResource( 7 )
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ say player "That must be the command to open the door."
|
|||||||
|
|
||||||
:use
|
:use
|
||||||
> [!r8_m_door_open]
|
> [!r8_m_door_open]
|
||||||
superpose_scene "res://game/rooms/room8/puzzle/10_buttons_puzzle.tscn"
|
#superpose_scene "res://game/rooms/room8/puzzle/10_buttons_puzzle.tscn"
|
||||||
|
spawn "res://game/rooms/room8/puzzle/10_buttons_puzzle.tscn"
|
||||||
|
|
||||||
> [r8_m_door_open]
|
> [r8_m_door_open]
|
||||||
say player "The door is already open."
|
say player "The door is already open."
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/escitem.gd" type="Script" id=1]
|
[ext_resource path="res://addons/escoria-core/game/core-scripts/escitem.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://game/items/escitems/bottle_escitem.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://game/items/escitems/bottle_escitem.tscn" type="PackedScene" id=2]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=2]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 66.4415, 154.457 )
|
extents = Vector2( 66.4415, 154.457 )
|
||||||
|
|
||||||
[sub_resource type="Animation" id=3]
|
[sub_resource type="Animation" id=2]
|
||||||
length = 0.5
|
length = 0.5
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
tracks/0/path = NodePath("base/closed:visible")
|
tracks/0/path = NodePath("base/closed:visible")
|
||||||
@@ -57,6 +57,57 @@ tracks/3/keys = {
|
|||||||
"values": [ false ]
|
"values": [ false ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id=3]
|
||||||
|
length = 0.5
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/path = NodePath("base/closed:visible")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PoolRealArray( 0 ),
|
||||||
|
"transitions": PoolRealArray( 1 ),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ false ]
|
||||||
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/path = NodePath("base/open_no_object:visible")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PoolRealArray( 0 ),
|
||||||
|
"transitions": PoolRealArray( 1 ),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ true ]
|
||||||
|
}
|
||||||
|
tracks/2/type = "value"
|
||||||
|
tracks/2/path = NodePath("base/open_object:visible")
|
||||||
|
tracks/2/interp = 1
|
||||||
|
tracks/2/loop_wrap = true
|
||||||
|
tracks/2/imported = false
|
||||||
|
tracks/2/enabled = true
|
||||||
|
tracks/2/keys = {
|
||||||
|
"times": PoolRealArray( 0 ),
|
||||||
|
"transitions": PoolRealArray( 1 ),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ false ]
|
||||||
|
}
|
||||||
|
tracks/3/type = "value"
|
||||||
|
tracks/3/path = NodePath("bottle:visible")
|
||||||
|
tracks/3/interp = 1
|
||||||
|
tracks/3/loop_wrap = true
|
||||||
|
tracks/3/imported = false
|
||||||
|
tracks/3/enabled = true
|
||||||
|
tracks/3/keys = {
|
||||||
|
"times": PoolRealArray( 0 ),
|
||||||
|
"transitions": PoolRealArray( 1 ),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ false ]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id=4]
|
[sub_resource type="Animation" id=4]
|
||||||
length = 0.5
|
length = 0.5
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
@@ -81,57 +132,6 @@ tracks/1/keys = {
|
|||||||
"times": PoolRealArray( 0 ),
|
"times": PoolRealArray( 0 ),
|
||||||
"transitions": PoolRealArray( 1 ),
|
"transitions": PoolRealArray( 1 ),
|
||||||
"update": 1,
|
"update": 1,
|
||||||
"values": [ true ]
|
|
||||||
}
|
|
||||||
tracks/2/type = "value"
|
|
||||||
tracks/2/path = NodePath("base/open_object:visible")
|
|
||||||
tracks/2/interp = 1
|
|
||||||
tracks/2/loop_wrap = true
|
|
||||||
tracks/2/imported = false
|
|
||||||
tracks/2/enabled = true
|
|
||||||
tracks/2/keys = {
|
|
||||||
"times": PoolRealArray( 0 ),
|
|
||||||
"transitions": PoolRealArray( 1 ),
|
|
||||||
"update": 1,
|
|
||||||
"values": [ false ]
|
|
||||||
}
|
|
||||||
tracks/3/type = "value"
|
|
||||||
tracks/3/path = NodePath("bottle:visible")
|
|
||||||
tracks/3/interp = 1
|
|
||||||
tracks/3/loop_wrap = true
|
|
||||||
tracks/3/imported = false
|
|
||||||
tracks/3/enabled = true
|
|
||||||
tracks/3/keys = {
|
|
||||||
"times": PoolRealArray( 0 ),
|
|
||||||
"transitions": PoolRealArray( 1 ),
|
|
||||||
"update": 1,
|
|
||||||
"values": [ false ]
|
|
||||||
}
|
|
||||||
|
|
||||||
[sub_resource type="Animation" id=5]
|
|
||||||
length = 0.5
|
|
||||||
tracks/0/type = "value"
|
|
||||||
tracks/0/path = NodePath("base/closed:visible")
|
|
||||||
tracks/0/interp = 1
|
|
||||||
tracks/0/loop_wrap = true
|
|
||||||
tracks/0/imported = false
|
|
||||||
tracks/0/enabled = true
|
|
||||||
tracks/0/keys = {
|
|
||||||
"times": PoolRealArray( 0 ),
|
|
||||||
"transitions": PoolRealArray( 1 ),
|
|
||||||
"update": 1,
|
|
||||||
"values": [ false ]
|
|
||||||
}
|
|
||||||
tracks/1/type = "value"
|
|
||||||
tracks/1/path = NodePath("base/open_no_object:visible")
|
|
||||||
tracks/1/interp = 1
|
|
||||||
tracks/1/loop_wrap = true
|
|
||||||
tracks/1/imported = false
|
|
||||||
tracks/1/enabled = true
|
|
||||||
tracks/1/keys = {
|
|
||||||
"times": PoolRealArray( 0 ),
|
|
||||||
"transitions": PoolRealArray( 1 ),
|
|
||||||
"update": 1,
|
|
||||||
"values": [ false ]
|
"values": [ false ]
|
||||||
}
|
}
|
||||||
tracks/2/type = "value"
|
tracks/2/type = "value"
|
||||||
@@ -163,7 +163,7 @@ tracks/3/keys = {
|
|||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
dialog_color = Color( 1, 1, 1, 1 )
|
dialog_color = Color( 1, 1, 1, 1 )
|
||||||
interact_positions = {
|
interact_positions = {
|
||||||
"default": null
|
"default": Vector2( 64.2172, 153.408 )
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="base" type="Line2D" parent="."]
|
[node name="base" type="Line2D" parent="."]
|
||||||
@@ -224,17 +224,17 @@ visible = false
|
|||||||
position = Vector2( 51.1535, 45.7845 )
|
position = Vector2( 51.1535, 45.7845 )
|
||||||
scale = Vector2( 0.507, 0.507 )
|
scale = Vector2( 0.507, 0.507 )
|
||||||
interact_positions = {
|
interact_positions = {
|
||||||
"default": Vector2( 51.1535, 45.7845 )
|
"default": Vector2( 45.4966, 321.556 )
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Position2D" type="Position2D" parent="bottle"]
|
[node name="Position2D" type="Position2D" parent="bottle"]
|
||||||
position = Vector2( 298.463, 596.926 )
|
position = Vector2( -11.1576, 543.928 )
|
||||||
|
|
||||||
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="."]
|
||||||
position = Vector2( 64.2172, 153.408 )
|
position = Vector2( 64.2172, 153.408 )
|
||||||
shape = SubResource( 2 )
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
anims/closed = SubResource( 3 )
|
anims/closed = SubResource( 2 )
|
||||||
anims/open_no_object = SubResource( 4 )
|
anims/open_no_object = SubResource( 3 )
|
||||||
anims/open_object = SubResource( 5 )
|
anims/open_object = SubResource( 4 )
|
||||||
|
|||||||
@@ -6,19 +6,19 @@ var options_paths = []
|
|||||||
func _ready():
|
func _ready():
|
||||||
var rooms_folder = "res://game/rooms/"
|
var rooms_folder = "res://game/rooms/"
|
||||||
var dir = Directory.new()
|
var dir = Directory.new()
|
||||||
var i = 1
|
|
||||||
if dir.open(rooms_folder) == OK:
|
if dir.open(rooms_folder) == OK:
|
||||||
dir.list_dir_begin(true)
|
dir.list_dir_begin(true)
|
||||||
var file_name = dir.get_next()
|
var file_name = dir.get_next()
|
||||||
while file_name != "":
|
while file_name != "":
|
||||||
if dir.current_is_dir():
|
if dir.current_is_dir():
|
||||||
add_item(file_name)
|
add_item(file_name)
|
||||||
options_paths.push_back("res://game/rooms/" + file_name + "/" + file_name + ".tscn")
|
options_paths.push_back("res://game/rooms/" + file_name + "/" +
|
||||||
i += 1
|
file_name + ".tscn")
|
||||||
file_name = dir.get_next()
|
file_name = dir.get_next()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
escoria.report_errors("room_select.gd:_ready()",
|
escoria.logger.report_errors("room_select.gd:_ready()",
|
||||||
["A problem occurred while opening rooms folder."])
|
["A problem occurred while opening rooms folder."])
|
||||||
|
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ func _on_button_pressed():
|
|||||||
|
|
||||||
if errors.empty():
|
if errors.empty():
|
||||||
#past_actions.text += str(events)
|
#past_actions.text += str(events)
|
||||||
var ret = escoria.esc_runner.run_event(events["debug"])
|
var _ret = escoria.esc_runner.run_event(events["debug"])
|
||||||
|
|
||||||
func _on_option_item_selected(index):
|
func _on_option_item_selected(index):
|
||||||
selected_id = index
|
selected_id = index
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func add_item(inventory_item : ESCInventoryItem):
|
|||||||
center_container.size_flags_horizontal = SIZE_EXPAND_FILL
|
center_container.size_flags_horizontal = SIZE_EXPAND_FILL
|
||||||
center_container.connect("mouse_entered", inventory_item, "_on_inventory_item_mouse_enter")
|
center_container.connect("mouse_entered", inventory_item, "_on_inventory_item_mouse_enter")
|
||||||
center_container.connect("mouse_exited", inventory_item, "_on_inventory_item_mouse_exit")
|
center_container.connect("mouse_exited", inventory_item, "_on_inventory_item_mouse_exit")
|
||||||
center_container.connect("gui_input", self, "_on_gui_input", [inventory_item])
|
# center_container.connect("gui_input", self, "_on_gui_input", [inventory_item])
|
||||||
center_container.add_child(inventory_item)
|
center_container.add_child(inventory_item)
|
||||||
add_child(center_container)
|
add_child(center_container)
|
||||||
current_nodes_in_container[inventory_item] = center_container
|
current_nodes_in_container[inventory_item] = center_container
|
||||||
@@ -33,7 +33,7 @@ func remove_item(inventory_item : ESCInventoryItem):
|
|||||||
current_nodes_in_container.erase(node_to_remove)
|
current_nodes_in_container.erase(node_to_remove)
|
||||||
node_to_remove.disconnect("mouse_entered", inventory_item, "_on_inventory_item_mouse_enter")
|
node_to_remove.disconnect("mouse_entered", inventory_item, "_on_inventory_item_mouse_enter")
|
||||||
node_to_remove.disconnect("mouse_exited", inventory_item, "_on_inventory_item_mouse_exit")
|
node_to_remove.disconnect("mouse_exited", inventory_item, "_on_inventory_item_mouse_exit")
|
||||||
node_to_remove.disconnect("pressed", self, "_on_gui_input")
|
# node_to_remove.disconnect("pressed", self, "_on_gui_input")
|
||||||
remove_child(node_to_remove)
|
remove_child(node_to_remove)
|
||||||
node_to_remove.queue_free()
|
node_to_remove.queue_free()
|
||||||
|
|
||||||
|
|||||||
@@ -59,11 +59,6 @@ _global_script_classes=[ {
|
|||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/escoria-core/game/core-scripts/escterrain.gd"
|
"path": "res://addons/escoria-core/game/core-scripts/escterrain.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "Area2D",
|
|
||||||
"class": "ESCTriggerZone",
|
|
||||||
"language": "GDScript",
|
|
||||||
"path": "res://addons/escoria-core/game/core-scripts/esctriggerzone.gd"
|
|
||||||
}, {
|
|
||||||
"base": "Node",
|
"base": "Node",
|
||||||
"class": "Movable",
|
"class": "Movable",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
@@ -80,7 +75,6 @@ _global_script_class_icons={
|
|||||||
"ESCPlayer": "",
|
"ESCPlayer": "",
|
||||||
"ESCRoom": "",
|
"ESCRoom": "",
|
||||||
"ESCTerrain": "",
|
"ESCTerrain": "",
|
||||||
"ESCTriggerZone": "",
|
|
||||||
"Movable": ""
|
"Movable": ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +85,7 @@ run/main_scene="res://addons/escoria-core/game/main_scene.tscn"
|
|||||||
boot_splash/image="res://addons/escoria-core/logo/escoria-logo-small.png"
|
boot_splash/image="res://addons/escoria-core/logo/escoria-logo-small.png"
|
||||||
boot_splash/fullsize=false
|
boot_splash/fullsize=false
|
||||||
boot_splash/use_filter=false
|
boot_splash/use_filter=false
|
||||||
|
boot_splash/bg_color=Color( 0.960784, 0.384314, 0, 1 )
|
||||||
config/icon="res://icon.png"
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|||||||
Reference in New Issue
Block a user