Make Main, Settings, ChooseScene, and gameplay run in Godot 4.6
Catch-all commit for everything the --convert-3to4 tool missed during a
manual playtest of the game. All errors raised by clicking through Main
-> Puzzles -> level were fixed.
GDScript:
- PackedScene.instance() -> instantiate() (ChooseScene.gd)
- String(x) constructor doesn't exist -> str(x) (MBase, MScene,
MLevel, Animation, Levels)
- 'x as int/String/bool' doesn't parse strings -> explicit
int()/str()/bool(int()) (MScene, MLevel, MSetting)
- BaseButton.pressed (property) -> button_pressed; set_pressed() ->
direct assignment (Settings.gd)
- AnimationPlayer.add_animation() removed -> go through
AnimationLibrary (Levels.gd)
- PhysicsDirectSpaceState3D.intersect_ray(from, to, ...) ->
PhysicsRayQueryParameters3D.create() (Levels.gd)
- @export with type-hint-in-comment ('# (String, ...)') -> explicit
@export_enum (candle.gd)
- Get effective material with get_active_material() instead of
get_surface_override_material(), with null guard (Levels.gd)
- get_node() -> get_node_or_null() so missing items from ahog.json
(e.g. sm_super_dager in Home) don't crash (Levels.gd)
Scenes/resources:
- Remove 14 Tween nodes from WarCraft.tscn — Tween is no longer a
Node in Godot 4. Rewrite Animation.start_dissolve to use
create_tween().tween_method().
- Rename property material/N -> surface_material_override/N in every
.tscn (10 files) — Godot 3 -> 4 rename that --convert-3to4 missed.
Without this, MeshInstance3D.get_active_material(0) returned the
glTF-imported StandardMaterial3D instead of the project's custom
dissolve ShaderMaterial.
Shaders:
- One-shot scripts/migrate_shaders.gd walks every .material under
assets/ and fixes Godot 3 -> 4 shader code in-place. Fixed 17
materials: depth_draw_alpha_prepass -> depth_prepass_alpha,
hint_color -> source_color, NORMALMAP -> NORMAL_MAP.
Result: Main, Settings, ChooseScene, and the WarCraft level all run
without script or shader errors. Remaining noise is non-blocking
(visual_shader graph in text_outline.material, baked lightmap binary
format from Godot 3, and empty animation tracks).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+30
-12
@@ -73,7 +73,7 @@ func _create_button_info(scene, counter, label_counter):
|
||||
var name = scene.label()
|
||||
|
||||
if label_counter != null and label_counter == scene.label_counter():
|
||||
name = last_button.get_node("Label").text + " " + String(scene.counter())
|
||||
name = last_button.get_node("Label").text + " " + str(scene.counter())
|
||||
_configure_button_object(last_button, scene, name)
|
||||
_create_animation_warning(_get_node_animated().get_node("Label"), name)
|
||||
else:
|
||||
@@ -102,10 +102,18 @@ func _configure_button_object(button, scene, label):
|
||||
button.set_meta("counted", 0)
|
||||
|
||||
func _create_animation_slide(node, name):
|
||||
$ListObjects/AnimationPlayer.add_animation(name, GlobalAnimation.level_hud_slide(node))
|
||||
_add_animation_to_player(name, GlobalAnimation.level_hud_slide(node))
|
||||
|
||||
func _create_animation_warning(node, name):
|
||||
$ListObjects/AnimationPlayer.add_animation(name, GlobalAnimation.level_hud_warning(node))
|
||||
_add_animation_to_player(name, GlobalAnimation.level_hud_warning(node))
|
||||
|
||||
func _add_animation_to_player(name: String, anim: Animation) -> void:
|
||||
var player = $ListObjects/AnimationPlayer
|
||||
var lib = player.get_animation_library("")
|
||||
if lib == null:
|
||||
lib = AnimationLibrary.new()
|
||||
player.add_animation_library("", lib)
|
||||
lib.add_animation(name, anim)
|
||||
|
||||
func _process(_delta):
|
||||
_check_dissolve_mesh()
|
||||
@@ -113,16 +121,25 @@ func _process(_delta):
|
||||
_check_victory_condition()
|
||||
|
||||
func create_dissolve_mesh(key):
|
||||
_node_to_mesh(key).get_surface_override_material(0).set_shader_parameter("dissolve_amount", 0.0)
|
||||
var mesh = _node_to_mesh(key)
|
||||
if mesh == null:
|
||||
return
|
||||
var material = mesh.get_active_material(0)
|
||||
if material == null:
|
||||
return
|
||||
material.set_shader_parameter("dissolve_amount", 0.0)
|
||||
|
||||
func _check_dissolve_mesh():
|
||||
# Event dissolve in object searched by gamer
|
||||
for key in meshes:
|
||||
if bool(meshes[key].lock()) == true and meshes[key].mesh() != null:
|
||||
var mesh = _node_to_mesh(key)
|
||||
if mesh == null:
|
||||
continue
|
||||
if meshes[key].tick_reference() == 0:
|
||||
meshes[key].set_tick_reference(Time.get_ticks_msec())
|
||||
_node_object_list(key)
|
||||
GlobalAnimation.start_dissolve(_node_to_tween(key), _node_to_mesh(key).get_surface_override_material(0))
|
||||
GlobalAnimation.start_dissolve(mesh, mesh.get_active_material(0))
|
||||
|
||||
if Time.get_ticks_msec() < meshes[key].tick_reference() + TIME_MAX:
|
||||
meshes[key].set_value(meshes[key].value() + 0.01)
|
||||
@@ -209,13 +226,10 @@ func _check_victory_condition():
|
||||
Global.goto_scene("res://scenes/UI/ending/Ending.tscn")
|
||||
|
||||
func _node_to_mesh(key):
|
||||
return get_node(meshes[key].mesh())
|
||||
|
||||
func _node_to_tween(key):
|
||||
return get_node(meshes[key].tween())
|
||||
return get_node_or_null(meshes[key].mesh())
|
||||
|
||||
func _node_to_area(key):
|
||||
return get_node(meshes[key].mesh()+"/Area3D")
|
||||
return get_node_or_null(meshes[key].mesh() + "/Area3D")
|
||||
|
||||
func _node_object_list(key):
|
||||
var animation_played = null
|
||||
@@ -232,7 +246,7 @@ func _node_object_list(key):
|
||||
var diff = child.get_meta("counter") - child.get_meta("counted")
|
||||
var txt = child.get_meta("name")
|
||||
if diff != 1:
|
||||
txt = txt + " " + String(diff)
|
||||
txt = txt + " " + str(diff)
|
||||
animation_played = child.get_meta("animation")
|
||||
child.get_node("Label").set_text(txt)
|
||||
|
||||
@@ -250,7 +264,11 @@ func _physics_process(_delta):
|
||||
_check_collider(space_state)
|
||||
|
||||
func _check_collider(space_state):
|
||||
var result = space_state.intersect_ray(from, to, [], 1, false, true)
|
||||
var query = PhysicsRayQueryParameters3D.create(from, to)
|
||||
query.collision_mask = 1
|
||||
query.collide_with_bodies = false
|
||||
query.collide_with_areas = true
|
||||
var result = space_state.intersect_ray(query)
|
||||
from = null
|
||||
to = null
|
||||
if result.has("collider"):
|
||||
|
||||
Reference in New Issue
Block a user