Added a new character and modified the way :setup and :ready events are run.
This commit is contained in:
1 parent
f26d96f115
commit
af8a9ea086
58 files changed
+1259
-340
No files matched your search
@@ -42,7 +42,7 @@ var commands = {
|
||||
"cut_scene": { "min_args": 2, "types": [TYPE_STRING, TYPE_STRING, TYPE_BOOL, TYPE_BOOL, TYPE_BOOL] },
|
||||
"debug": { "min_args": 1 },
|
||||
"dec_global": { "min_args": 2, "types": [TYPE_STRING, TYPE_INT] },
|
||||
"dialog_config": { "min_args": 3, "types": [TYPE_STRING, TYPE_BOOL, TYPE_BOOL] },
|
||||
# "dialog_config": { "min_args": 3, "types": [TYPE_STRING, TYPE_BOOL, TYPE_BOOL] },
|
||||
"enable_terrain": { "min_args": 1, "types": [TYPE_STRING]},
|
||||
"game_over": { "min_args": 1, "types": [TYPE_BOOL] },
|
||||
"inc_global": { "min_args": 2, "types": [TYPE_STRING, TYPE_INT] },
|
||||
|
||||
@@ -272,6 +272,13 @@ func set_global(name, val, force_change_reserved : bool = false):
|
||||
# printt("global changed at global_vm, emitting for ", name, val)
|
||||
emit_signal("global_changed", name)
|
||||
|
||||
func set_globals(pattern : String, val):
|
||||
for key in globals:
|
||||
if key.match(pattern):
|
||||
set_global(key, val)
|
||||
# globals[key] = val
|
||||
# emit_signal("global_changed", key)
|
||||
|
||||
func dec_global(name, diff):
|
||||
var global = get_global(name)
|
||||
global = int(global) if global else 0
|
||||
@@ -282,12 +289,6 @@ func inc_global(name, diff):
|
||||
global = int(global) if global else 0
|
||||
set_global(name, str(global + diff))
|
||||
|
||||
func set_globals(pat, val):
|
||||
for key in globals:
|
||||
if key.match(pat):
|
||||
globals[key] = val
|
||||
emit_signal("global_changed", key)
|
||||
|
||||
func is_global_equal_to(name, val):
|
||||
var global = get_global(name)
|
||||
if global and val and global == val:
|
||||
@@ -353,14 +354,27 @@ func change_scene(params, context, run_events=true):
|
||||
if !game_scene:
|
||||
escoria.report_errors("esc_runner.gd:change_scene()",
|
||||
["Failed loading scene " + ProjectSettings.get_setting("escoria/ui/game_scene")])
|
||||
|
||||
|
||||
# Load room scene
|
||||
var room_scene = res_room.instance()
|
||||
if room_scene:
|
||||
room_scene.add_child(game_scene)
|
||||
room_scene.move_child(game_scene, 0)
|
||||
escoria.main.set_scene(room_scene, run_events)
|
||||
var events = escoria.main.set_scene(room_scene, run_events)
|
||||
|
||||
# If scene was never visited, add "ready" event to the events stack
|
||||
if !scenes_cache.has(room_scene.global_id) \
|
||||
and "ready" in events:
|
||||
run_event(events["ready"])
|
||||
|
||||
# :setup is pretty much required in the code, but fortunately
|
||||
# we can help out with cases where one isn't necessary otherwise
|
||||
if not "setup" in events:
|
||||
var fake_setup = escoria.esc_compiler.compile_str(":setup\n")
|
||||
events["setup"] = fake_setup["setup"]
|
||||
# Finally we add the setup on to of the events stack so that it is ran first
|
||||
run_event(events["setup"])
|
||||
|
||||
escoria.inputs_manager.is_hotspot_focused = false
|
||||
if !scenes_cache_list.has(params[0]):
|
||||
scenes_cache_list.push_back(params[0])
|
||||
@@ -628,3 +642,17 @@ func object_exit_scene(name : String):
|
||||
printt("Object " + name + " removed from scene.")
|
||||
objects.erase(name)
|
||||
|
||||
#func jump(p_label):
|
||||
# while stack.size() > 0:
|
||||
# var top = stack[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 || stack.size() == 1:
|
||||
# report_errors("", ["Label not found: "+p_label+", can't jump"])
|
||||
# stack.remove(stack.size()-1)
|
||||
# break
|
||||
# else:
|
||||
# stack.remove(stack.size()-1)
|
||||
@@ -5,14 +5,19 @@ extends Node
|
||||
var current_context
|
||||
onready var esc_runner = get_parent()
|
||||
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
|
||||
func finished(context = null):
|
||||
if context != null:
|
||||
context.waiting = false
|
||||
else:
|
||||
current_context.waiting = false
|
||||
|
||||
if escoria.current_state == escoria.GAME_STATE.WAIT:
|
||||
escoria.current_state = escoria.GAME_STATE.DEFAULT
|
||||
|
||||
|
||||
func check_obj(name, cmd):
|
||||
@@ -22,6 +27,7 @@ func check_obj(name, cmd):
|
||||
return false
|
||||
return true
|
||||
|
||||
|
||||
func resume(context):
|
||||
current_context = context
|
||||
if context.waiting:
|
||||
@@ -49,6 +55,7 @@ func resume(context):
|
||||
context.ip = 0
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
|
||||
|
||||
func run(context):
|
||||
var cmd = context.instructions[context.ip]
|
||||
if cmd.name == "label":
|
||||
@@ -70,25 +77,53 @@ func dialog_line_finished() -> void:
|
||||
escoria.dialog_player.is_speaking = false
|
||||
escoria.current_state = escoria.GAME_STATE.DEFAULT
|
||||
|
||||
|
||||
"""
|
||||
accept_input [ALL|NONE|SKIP]
|
||||
What type of input does the game accept. ALL is the default, SKIP allows skipping
|
||||
of dialog but nothing else, NONE denies all input. Including opening the menu etc.
|
||||
SKIP and NONE also disable autosaves. Note that SKIP gets reset to ALL when the
|
||||
event is done, but NONE persists. This allows you to create cut scenes with SKIP
|
||||
where the dialog can be skipped, but also initiate locked-down cutscenes with
|
||||
accept_input NONE in :setup and accept_input ALL later in :ready.
|
||||
"""
|
||||
func accept_input():
|
||||
func accept_input(command_params : Array):
|
||||
# var p_input = command_params[0]
|
||||
# var input = escoria.esc_runner.acceptable_inputs["INPUT_" + p_input]
|
||||
# escoria.esc_runner.set_accept_input(input)
|
||||
pass
|
||||
|
||||
|
||||
"""
|
||||
"""
|
||||
func autosave():
|
||||
# escoria.request_autosave()
|
||||
pass
|
||||
|
||||
|
||||
"""
|
||||
anim object name [reverse] [flip_x] [flip_y]
|
||||
Executes the animation specificed with the "name" parameter on the object,
|
||||
without blocking. The next command in the event will be executed immediately after.
|
||||
Optional parameters:
|
||||
reverse plays the animation in reverse when true
|
||||
flip_x flips the x axis of the object's sprites when true (object's root node needs to be Node2D)
|
||||
flip_y flips the y axis of the object's sprites when true (object's root node needs to be Node2D)
|
||||
"""
|
||||
func anim():
|
||||
pass
|
||||
func anim(command_params : Array):
|
||||
if !check_obj(command_params[0], "anim"):
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
private_play_animation(command_params)
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
|
||||
|
||||
"""
|
||||
Groups Commands can be grouped using the character ">" to start a group, and
|
||||
incrementing the indentation of the commands that belong to the group. Example:
|
||||
>
|
||||
set_global door_open true
|
||||
animation player pick_up
|
||||
# end of group
|
||||
"""
|
||||
func branch(command_params : Array):
|
||||
var branch_ev = esctypes.ESCEvent.new("branch", command_params, [])
|
||||
@@ -96,65 +131,104 @@ func branch(command_params : Array):
|
||||
|
||||
|
||||
"""
|
||||
camera_push target [time] [type]
|
||||
Push camera to target. Target must have camera_pos set.
|
||||
If it's of type Camera2D, its zoom will be used as well as position.
|
||||
- A time value of 0 will set the camera immediately.
|
||||
- type is any of the Tween.TransitionType values without the prefix, eg. LINEAR,
|
||||
QUART or CIRC; defaults to QUART.
|
||||
"""
|
||||
func camera_push():
|
||||
pass
|
||||
func camera_push(command_params : Array):
|
||||
var target = escoria.esc_runner.get_object(command_params[0])
|
||||
var time = command_params[1] if command_params.size() > 1 else 1
|
||||
var type = command_params[2] if command_params.size() > 2 else "QUAD"
|
||||
escoria.main.current_scene.game.get_node("camera").push(target, time, type)
|
||||
|
||||
|
||||
"""
|
||||
camera_set_drag_margin_enabled h v
|
||||
- "h" and "v" are booleans for whether or not horizontal and vertical drag
|
||||
margins are enabled. You will likely want to set them false for advanced camera
|
||||
motions and true for regular gameplay and/or tracking NPCs.
|
||||
"""
|
||||
func camera_set_drag_margin_enabled():
|
||||
pass
|
||||
|
||||
|
||||
"""
|
||||
camera_set_pos speed x y
|
||||
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.
|
||||
"""
|
||||
func camera_set_pos():
|
||||
pass
|
||||
|
||||
|
||||
"""
|
||||
camera_set_target speed object [object2 object3 ...]
|
||||
Configures the camera to follow 1 or more objects, using "speed" as speed limit.
|
||||
This is the default behavior (default follow object is "player").
|
||||
If there's more than 1 object, the camera follows the average position of all
|
||||
the objects specified.
|
||||
"""
|
||||
func camera_set_target():
|
||||
pass
|
||||
|
||||
|
||||
"""
|
||||
camera_set_zoom magnitude [time]
|
||||
Zooms the camera in/out to the desired magnitude. Values larger than 1 zooms
|
||||
the camera out, and smaller values zooms in, relative to the default value of 1.
|
||||
An optional time in seconds controls how long it takes for the camera to zoom
|
||||
into position.
|
||||
"""
|
||||
func camera_set_zoom():
|
||||
pass
|
||||
|
||||
|
||||
"""
|
||||
camera_set_zoom_height pixels [time]
|
||||
Similar to the command abo/ve, but uses pixel height instead of magnitude to zoom.
|
||||
"""
|
||||
func camera_set_zoom_height():
|
||||
pass
|
||||
|
||||
|
||||
"""
|
||||
camera_shift x y [time] [type]
|
||||
Shift camera by x and y pixels over time seconds.
|
||||
- type is any of the Tween.TransitionType values without the prefix, eg. LINEAR,
|
||||
QUART or CIRC; defaults to QUART.
|
||||
"""
|
||||
func camera_shift():
|
||||
pass
|
||||
|
||||
|
||||
"""
|
||||
change_scene path [run_events]
|
||||
Loads a new scene, specified by "path".
|
||||
The run_events variable is a boolean (default true) which you never want to set
|
||||
manually! It's there only to benefit save games, so they don't conflict with the
|
||||
scene's events.
|
||||
"""
|
||||
func change_scene(params):
|
||||
func change_scene(command_params : Array):
|
||||
# Savegames must have events disabled, so saving the game adds a false to params
|
||||
var run_events = true
|
||||
if params.size() == 2:
|
||||
run_events = bool(params[1])
|
||||
if command_params.size() == 2:
|
||||
run_events = bool(command_params[1])
|
||||
|
||||
# looking for localized string format in scene. this should be somewhere else
|
||||
var sep = params[0].find(":\"")
|
||||
var sep = command_params[0].find(":\"")
|
||||
if sep >= 0:
|
||||
var path = params[0].substr(sep + 2, params[0].length() - (sep + 2))
|
||||
var path = command_params[0].substr(sep + 2, command_params[0].length() - (sep + 2))
|
||||
escoria.esc_runner.call_deferred("change_scene", [path], current_context, run_events)
|
||||
else:
|
||||
escoria.esc_runner.call_deferred("change_scene", params, current_context, run_events)
|
||||
escoria.esc_runner.call_deferred("change_scene", command_params, current_context, run_events)
|
||||
|
||||
current_context.waiting = true
|
||||
return esctypes.EVENT_LEVEL_STATE.YIELD
|
||||
|
||||
|
||||
"""
|
||||
"""
|
||||
func custom():
|
||||
@@ -162,30 +236,76 @@ func custom():
|
||||
|
||||
|
||||
"""
|
||||
cut_scene object name [reverse] [flip_x] [flip_y]
|
||||
Executes the animation specificed with the "name" parameter on the object, BLOCKING.
|
||||
The next command in the event will be executed when the animation is finished
|
||||
playing.
|
||||
Optional parameters:
|
||||
- reverse plays the animation in reverse when true
|
||||
- flip_x flips the x axis of the object's sprites when true
|
||||
(object's root node needs to be Node2D)
|
||||
- flip_y flips the y axis of the object's sprites when true
|
||||
(object's root node needs to be Node2D)
|
||||
"""
|
||||
func cut_scene():
|
||||
pass
|
||||
func cut_scene(command_params : Array):
|
||||
if !check_obj(command_params[0], "cut_scene"):
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
private_play_animation(command_params)
|
||||
return esctypes.EVENT_LEVEL_STATE.YIELD
|
||||
|
||||
|
||||
"""
|
||||
PRIVATE
|
||||
Play animation using parameters.
|
||||
Used by commands anim() and cut_scene()
|
||||
"""
|
||||
func debug():
|
||||
pass
|
||||
func private_play_animation(command_params : Array):
|
||||
var obj = escoria.esc_runner.get_object(command_params[0])
|
||||
var anim_id = command_params[1]
|
||||
var reverse = false
|
||||
if command_params.size() > 2:
|
||||
reverse = command_params[2]
|
||||
var flip = Vector2(1, 1)
|
||||
if command_params.size() > 3 && command_params[3]:
|
||||
flip.x = -1
|
||||
if command_params.size() > 4 && command_params[4]:
|
||||
flip.y = -1
|
||||
current_context.waiting = true
|
||||
obj.play_anim(anim_id, current_context, reverse, flip)
|
||||
|
||||
|
||||
"""
|
||||
debug string [string2 ...]
|
||||
Takes 1 or more strings, prints them to the console.
|
||||
"""
|
||||
func dec_global():
|
||||
pass
|
||||
func debug(command_params : Array):
|
||||
for p in command_params:
|
||||
printt(p)
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
|
||||
|
||||
"""
|
||||
dec_global name value
|
||||
Subtracts the value from global with given "name".
|
||||
Value and global must both be integers.
|
||||
"""
|
||||
func inc_global():
|
||||
pass
|
||||
func dec_global(command_params : Array):
|
||||
escoria.esc_runner.dec_global(command_params[0], command_params[1])
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
|
||||
|
||||
"""
|
||||
inc_global name value
|
||||
Adds the value to global with given "name".
|
||||
Value and global must both be integers.
|
||||
"""
|
||||
func inc_global(command_params : Array):
|
||||
escoria.esc_runner.inc_global(command_params[0], command_params[1])
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
|
||||
|
||||
"""
|
||||
Start a dialog choice.
|
||||
"""
|
||||
func dialog(command_params : Array):
|
||||
current_context.waiting = true
|
||||
@@ -198,13 +318,14 @@ func dialog(command_params : Array):
|
||||
return esctypes.EVENT_LEVEL_STATE.YIELD
|
||||
|
||||
|
||||
"""
|
||||
"""
|
||||
func dialog_config():
|
||||
pass
|
||||
#func dialog_config():
|
||||
## escoria.esc_runner.dialog_config(params)
|
||||
## return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
# pass
|
||||
|
||||
|
||||
"""
|
||||
enable_terrain node_name
|
||||
Enable the ESCTerrain's NavigationPolygonInstance defined by given node name.
|
||||
Disables previously activated NavigationPolygonInstance.
|
||||
"""
|
||||
@@ -223,18 +344,25 @@ func game_over(command_params : Array):
|
||||
|
||||
|
||||
"""
|
||||
Adds element in inventory.
|
||||
Usage: inventory_add my_item
|
||||
equivalent to: set_global i/my_item true
|
||||
"""
|
||||
func inventory_add(command_params : Array):
|
||||
pass
|
||||
set_global(["i/"+command_params[0], "true"])
|
||||
|
||||
|
||||
"""
|
||||
Removes element from inventory.
|
||||
Usage: inventory_remove my_item
|
||||
equivalent to: set_global i/my_item false
|
||||
"""
|
||||
func inventory_remove(command_params : Array):
|
||||
pass
|
||||
set_global(["i/"+command_params[0], "false"])
|
||||
|
||||
|
||||
"""
|
||||
TODO: This is dependant to the user UI. It must remain flexible enough.
|
||||
"""
|
||||
func inventory_open(command_params : Array):
|
||||
pass
|
||||
@@ -243,9 +371,10 @@ func inventory_open(command_params : Array):
|
||||
"""
|
||||
"""
|
||||
func jump(command_params : Array):
|
||||
# escoria.esc_runner.jump(command_params[0])
|
||||
# return esctypes.EVENT_LEVEL_STATE.JUMP
|
||||
pass
|
||||
|
||||
|
||||
"""
|
||||
"""
|
||||
func play_snd(command_params : Array):
|
||||
@@ -318,11 +447,11 @@ func set_active(command_params : Array):
|
||||
Set the angle of an object.
|
||||
Usage: set_angle object_id angle_degrees
|
||||
"""
|
||||
func set_angle(params : Array):
|
||||
if !check_obj(params[0], "set_angle"):
|
||||
func set_angle(command_params : Array):
|
||||
if !check_obj(command_params[0], "set_angle"):
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
var obj = escoria.esc_runner.get_object(params[0])
|
||||
obj.set_angle(int(params[1]))
|
||||
var obj = escoria.esc_runner.get_object(command_params[0])
|
||||
obj.set_angle(int(command_params[1]))
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
|
||||
|
||||
@@ -355,9 +484,16 @@ func set_global(command_params : Array):
|
||||
|
||||
|
||||
"""
|
||||
set_globals pattern value
|
||||
Changes the value of multiple globals using a wildcard pattern.
|
||||
Example:
|
||||
# clears the inventory
|
||||
set_globals i/* false
|
||||
"""
|
||||
func set_globals(command_params : Array):
|
||||
pass
|
||||
var pattern : String = command_params[0]
|
||||
var val = command_params[1]
|
||||
escoria.esc_runner.set_globals(pattern, val)
|
||||
|
||||
|
||||
"""
|
||||
@@ -402,17 +538,18 @@ Teleports obj1 at obj2's position. If angle_degrees is set (int), sets obj1's
|
||||
angle to angle_degrees.
|
||||
Usage: teleport obj1 obj2 [angle_degrees]
|
||||
"""
|
||||
func teleport(params):
|
||||
if !check_obj(params[0], "teleport"):
|
||||
func teleport(command_params : Array):
|
||||
if !check_obj(command_params[0], "teleport"):
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
if !check_obj(params[1], "teleport"):
|
||||
if !check_obj(command_params[1], "teleport"):
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
|
||||
var angle
|
||||
if params.size() > 2:
|
||||
angle = int(params[2])
|
||||
if command_params.size() > 2:
|
||||
angle = int(command_params[2])
|
||||
|
||||
escoria.esc_runner.get_object(params[0]).teleport(escoria.esc_runner.get_object(params[1]), angle)
|
||||
escoria.esc_runner.get_object(command_params[0]) \
|
||||
.teleport(escoria.esc_runner.get_object(command_params[1]), angle)
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
|
||||
|
||||
|
||||
@@ -116,6 +116,8 @@ func update_terrain(on_event_finished_name = null):
|
||||
return
|
||||
if on_event_finished_name != null and on_event_finished_name != "setup":
|
||||
return
|
||||
if is_exit:
|
||||
return
|
||||
|
||||
var pos = position
|
||||
z_index = pos.y if pos.y <= VisualServer.CANVAS_ITEM_Z_MAX else VisualServer.CANVAS_ITEM_Z_MAX
|
||||
|
||||
@@ -126,10 +126,13 @@ func _ready():
|
||||
terrain = escoria.room_terrain
|
||||
|
||||
last_scale = scale
|
||||
|
||||
set_process(true)
|
||||
|
||||
|
||||
func _process(time):
|
||||
if Engine.is_editor_hint():
|
||||
return
|
||||
$debug.text = str(z_index)
|
||||
|
||||
if task == PLAYER_TASKS.WALK or task == PLAYER_TASKS.SLIDE:
|
||||
|
||||
Reference in new issue
Block a user