fix most of the script errors and warnings, fixed a couple tiny bugs in the process :)

This commit is contained in:
Haze Weathers 2024-03-08 15:11:48 -05:00
parent 9435089f21
commit 72733db609
23 changed files with 55 additions and 63 deletions

View file

@ -22,15 +22,15 @@ func _init() -> void:
func get_key(action: String) -> int:
var scancode = cfg.get_value(action, "keyboard")
if scancode == null:
var scancode = cfg.get_value(action, "keyboard", -1)
if scancode == -1:
scancode = _get_default_key(action)
return scancode
func get_button(action: String) -> int:
var button_index = cfg.get_value(action, "gamepad")
if button_index == null:
var button_index = cfg.get_value(action, "gamepad", -1)
if button_index == -1:
button_index = _get_default_button(action)
return button_index
@ -58,8 +58,8 @@ func _apply_saved_bindings() -> void:
func _configure_action_key(action: String) -> void:
var scancode = cfg.get_value(action, "keyboard")
if scancode == null:
var scancode = cfg.get_value(action, "keyboard", -1)
if scancode == -1:
scancode = _get_default_key(action)
_apply_action_key(action, scancode)
var linked_action = LINKED_ACTIONS.get(action)
@ -68,8 +68,8 @@ func _configure_action_key(action: String) -> void:
func _configure_action_button(action: String) -> void:
var button_index = cfg.get_value(action, "gamepad")
if button_index == null:
var button_index = cfg.get_value(action, "gamepad", -1)
if button_index == -1:
button_index = _get_default_button(action)
_apply_action_button(action, button_index)
var linked_action = LINKED_ACTIONS.get(action)

View file

@ -95,7 +95,7 @@ func _set_difficulty(value: int) -> void:
func instance_node(node:PackedScene,x:float,y:float,parent):
var Instance = node.instance()
Instance.global_position = Vector2(x,y)
parent.add_child(Instance)
parent.call_deferred("add_child", Instance)
#Get position in sectors
func get_sector(pos):
@ -122,12 +122,12 @@ func tally_scores() -> void:
shards_collected[5] = true
# 100% time bonus
if time < map.target_time_100:
time_bonus = max(2500 - int(2500.0 * time / map.target_time_100), 0)
time_bonus = max(2500 - int(2500.0 * time / map.target_time_100), 0) as int
shards_collected[6] = true
else:
# any% time bonus
if time < map.target_time_any:
time_bonus = max(2500 - int(2500.0 * time / map.target_time_any), 0)
time_bonus = max(2500 - int(2500.0 * time / map.target_time_any), 0) as int
shards_collected[6] = true
# life bonus
if deaths == 0:
@ -195,10 +195,10 @@ func save():
# save score and time depending on completion
if _get_shards() >= 5 && keys >= 50:
save_data.score_100 = max(save_data.score_100, final_score)
save_data.score_100 = max(save_data.score_100, final_score) as int
save_data.time_100 = min(save_data.time_100, time)
else:
save_data.score_any = max(save_data.score_any, final_score)
save_data.score_any = max(save_data.score_any, final_score) as int
save_data.time_any = min(save_data.time_any, time)
# set shards
@ -207,7 +207,7 @@ func save():
save_data.shards_collected[i] = true
# set keys
save_data.keys_collected = max(save_data.keys_collected, keys)
save_data.keys_collected = max(save_data.keys_collected, keys) as int
# mark as completed
save_data.completed = true
@ -272,9 +272,9 @@ func restart_level():
Audio.ac_music.stream_paused = false
#Freeze frame
func freeze_frame(time):
func freeze_frame(freeze_time):
get_tree().paused = true
var timer = get_tree().create_timer(time, true)
var timer = get_tree().create_timer(freeze_time, true)
timer.connect("timeout", get_tree(), "set_pause", [false])
return timer
@ -321,6 +321,6 @@ func _on_player_died() -> void:
Audio.play_sound(Audio.a_die, Audio.ac_die)
# death score penalty
if use_lives == false && lives < 0:
score = max(0, score - 500)
score = max(0, score - 500) as int
# freezeframe
Game.freeze_frame(0.3)

View file

@ -174,6 +174,8 @@ func request_execute(component: String, parameters: Dictionary = {}, echo: Strin
var body = "input=" + to_json(request).percent_encode()
# make request
var err = http.request(GATEWAY_URI, headers, true, HTTPClient.METHOD_POST, body)
if err != OK:
push_error("Invalid HTTP request")
# yield response
yield(http, "request_completed")
return _response

View file

@ -4,6 +4,10 @@ extends Light2D
onready var viewport: Viewport = $Viewport
func _ready() -> void:
texture = viewport.get_texture()
func _process(delta: float) -> void:
var main_viewport = get_viewport()
if viewport.canvas_transform != main_viewport.canvas_transform:

View file

@ -1,12 +1,8 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=2 format=2]
[ext_resource path="res://autoloads/stain_layer.gd" type="Script" id=1]
[sub_resource type="ViewportTexture" id=1]
viewport_path = NodePath("Viewport")
[node name="StainLight" type="Light2D" groups=["viewport_autoload"]]
texture = SubResource( 1 )
offset = Vector2( 128, 96 )
mode = 2
range_item_cull_mask = 2