Skip to content

Instantly share code, notes, and snippets.

@aaronfranke
Last active April 2, 2024 16:20
Show Gist options
  • Star 27 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aaronfranke/79b424226475d277d0035b7835b09c5f to your computer and use it in GitHub Desktop.
Save aaronfranke/79b424226475d277d0035b7835b09c5f to your computer and use it in GitHub Desktop.
This script bulk-renames many things in Godot 3 projects to hopefully make it easier to convert them to Godot 4.
#!/usr/bin/env bash
# This script bulk-renames many things in Godot 3 projects to hopefully
# make it easier to convert them to Godot 4. The goal is to do as much
# replacing as possible here so that the diffs Godot produces are smaller.
set -uo pipefail
IFS=$'\n\t'
# Loops through all text files tracked by Git.
git grep -zIl '' |
while IFS= read -rd '' f; do
if [[ "$f" == *"md" ]]; then
continue
elif [[ "$f" == *"txt" ]]; then
continue
elif [[ "$f" == *".shader" ]]; then
# Rename ".shader" files to ".gdshader".
mv "$f" "${f%.shader}.gdshader"
continue
fi
# Bulk actions for all files.
perl -i -pe 's/ARVR/XR/g' "$f"
perl -i -pe 's/Navigation/Node3D/g' "$f"
perl -i -pe 's/NavigationAgent/NavigationAgent3D/g' "$f"
perl -i -pe 's/NavigationMeshInstance/NavigationRegion3D/g' "$f"
perl -i -pe 's/NavigationObstacle\b/NavigationObstacle3D/g' "$f"
perl -i -pe 's/NavigationPolygonInstance/NavigationRegion3D/g' "$f"
perl -i -pe 's/\.shader/\.gdshader/g' "$f"
perl -i -pe 's/\bAnimatedSprite\b/AnimatedSprite2D/g' "$f"
perl -i -pe 's/\bAnimationTreePlayer\b/AnimationTree/g' "$f"
perl -i -pe 's/\bArea\b/Area3D/g' "$f"
perl -i -pe 's/\bBakedLightmap\b/LightmapGI/g' "$f"
perl -i -pe 's/\bBitmapFont\b/Font/g' "$f"
perl -i -pe 's/\bBoneAttachment\b/BoneAttachment3D/g' "$f"
perl -i -pe 's/\bBone\b/Bone3D/g' "$f"
perl -i -pe 's/\bBoxShape\b/BoxShape3D/g' "$f"
perl -i -pe 's/\bBulletPhysicsDirectBodyState\b/BulletPhysicsDirectBodyState3D/g' "$f"
perl -i -pe 's/\bBulletPhysicsServer\b/BulletPhysicsServer3D/g' "$f"
perl -i -pe 's/\bButtonList\b/MouseButton/g' "$f"
perl -i -pe 's/\bCPUParticles\b/CPUParticles3D/g' "$f"
perl -i -pe 's/\bCSGBox\b/CSGBox3D/g' "$f"
perl -i -pe 's/\bCSGCombiner\b/CSGCombiner3D/g' "$f"
perl -i -pe 's/\bCSGCylinder\b/CSGCylinder3D/g' "$f"
perl -i -pe 's/\bCSGMesh\b/CSGMesh3D/g' "$f"
perl -i -pe 's/\bCSGPolygon\b/CSGPolygon3D/g' "$f"
perl -i -pe 's/\bCSGPrimitive\b/CSGPrimitive3D/g' "$f"
perl -i -pe 's/\bCSGShape\b/CSGShape3D/g' "$f"
perl -i -pe 's/\bCSGSphere\b/CSGSphere3D/g' "$f"
perl -i -pe 's/\bCSGTorus\b/CSGTorus3D/g' "$f"
perl -i -pe 's/\bCamera\b/Camera3D/g' "$f"
perl -i -pe 's/\bCapsuleShape\b/CapsuleShape3D/g' "$f"
perl -i -pe 's/\bClippedCamera\b/ClippedCamera3D/g' "$f"
perl -i -pe 's/\bCollisionObject\b/CollisionObject3D/g' "$f"
perl -i -pe 's/\bCollisionPolygon\b/CollisionPolygon3D/g' "$f"
perl -i -pe 's/\bCollisionShape\b/CollisionShape3D/g' "$f"
perl -i -pe 's/\bConcavePolygonShape\b/ConcavePolygonShape3D/g' "$f"
perl -i -pe 's/\bConeTwistJoint\b/ConeTwistJoint3D/g' "$f"
perl -i -pe 's/\bConvexPolygonShape\b/ConvexPolygonShape3D/g' "$f"
perl -i -pe 's/\bCubeMesh\b/BoxMesh/g' "$f"
perl -i -pe 's/\bCylinderShape\b/CylinderShape3D/g' "$f"
perl -i -pe 's/\bDirectionalLight\b/DirectionalLight3D/g' "$f"
perl -i -pe 's/\bDynamicFontData\b/FontData/g' "$f"
perl -i -pe 's/\bDynamicFont\b/Font/g' "$f"
perl -i -pe 's/\bEditorSpatialGizmo\b/EditorNode3DGizmo/g' "$f"
perl -i -pe 's/\bGIProbe\b/VoxelGI/g' "$f"
perl -i -pe 's/\bGeneric6DOFJoint\b/Generic6DOFJoint3D/g' "$f"
perl -i -pe 's/\bGeometryInstance\b/GeometryInstance3D/g' "$f"
perl -i -pe 's/\bHeightMapShape\b/HeightMapShape3D/g' "$f"
perl -i -pe 's/\bHingeJoint\b/HingeJoint3D/g' "$f"
perl -i -pe 's/\bIP_Unix\b/IPUnix/g' "$f"
perl -i -pe 's/\bImmediateGeometry\b/ImmediateGeometry3D/g' "$f"
perl -i -pe 's/\bInterpolatedCamera\b/InterpolatedCamera3D/g' "$f"
perl -i -pe 's/\bJoint\b/Joint3D/g' "$f"
perl -i -pe 's/\bKinematicBody2D\b/CharacterBody2D/g' "$f"
perl -i -pe 's/\bKinematicBody\b/CharacterBody3D/g' "$f"
perl -i -pe 's/\bKinematicCollision\b/KinematicCollision3D/g' "$f"
perl -i -pe 's/\bLight2D\b/PointLight2D/g' "$f"
perl -i -pe 's/\bLight\b/Light3D/g' "$f"
perl -i -pe 's/\bListener\b/Listener3D/g' "$f"
perl -i -pe 's/\bMODE_OPEN_ANY\b/FILE_MODE_OPEN_ANY/g' "$f"
perl -i -pe 's/\bMODE_OPEN_DIR\b/FILE_MODE_OPEN_DIR/g' "$f"
perl -i -pe 's/\bMODE_OPEN_FILES\b/FILE_MODE_OPEN_FILE/g' "$f"
perl -i -pe 's/\bMODE_OPEN_FILE\b/FILE_MODE_OPEN_FILE/g' "$f"
perl -i -pe 's/\bMODE_SAVE_FILE\b/FILE_MODE_SAVE_FILE/g' "$f"
perl -i -pe 's/\bMeshInstance\b/MeshInstance3D/g' "$f"
perl -i -pe 's/\bMultiMeshInstance\b/MultiMeshInstance3D/g' "$f"
perl -i -pe 's/\bNavigation2DServer\b/NavigationServer2D/g' "$f"
perl -i -pe 's/\bNavigationServer\b/NavigationServer3D/g' "$f"
perl -i -pe 's/\bOmniLight\b/OmniLight3D/g' "$f"
perl -i -pe 's/\bPAUSE_MODE_INHERIT\b/PROCESS_MODE_INHERIT/g' "$f"
perl -i -pe 's/\bPAUSE_MODE_PROCESS\b/PROCESS_MODE_ALWAYS/g' "$f"
perl -i -pe 's/\bPAUSE_MODE_STOP\b/PROCESS_MODE_PAUSABLE/g' "$f"
perl -i -pe 's/\bPHashTranslation\b/OptimizedTranslation/g' "$f"
perl -i -pe 's/\bPanoramaSky\b/PanoramaSkyMaterial/g' "$f"
perl -i -pe 's/\bParticles2D\b/GPUParticles2D/g' "$f"
perl -i -pe 's/\bParticles\b/GPUParticles3D/g' "$f"
perl -i -pe 's/\bPathFollow\b/PathFollow3D/g' "$f"
perl -i -pe 's/\bPath\b/Path3D/g' "$f"
perl -i -pe 's/\bPhysicalBone\b/PhysicalBone3D/g' "$f"
perl -i -pe 's/\bPhysics2DDirectBodyStateSW\b/PhysicsDirectBodyState2DSW/g' "$f"
perl -i -pe 's/\bPhysics2DDirectBodyState\b/PhysicsDirectBodyState2D/g' "$f"
perl -i -pe 's/\bPhysics2DDirectSpaceState\b/PhysicsDirectSpaceState2D/g' "$f"
perl -i -pe 's/\bPhysics2DServer\b/PhysicsServer2D/g' "$f"
perl -i -pe 's/\bPhysics2DShapeQueryParameters\b/PhysicsShapeQueryParameters2D/g' "$f"
perl -i -pe 's/\bPhysics2DShapeQueryResult\b/PhysicsShapeQueryResult2D/g' "$f"
perl -i -pe 's/\bPhysics2DTestMotionResult\b/PhysicsTestMotionResult2D/g' "$f"
perl -i -pe 's/\bPhysicsBody\b/PhysicsBody3D/g' "$f"
perl -i -pe 's/\bPhysicsDirectBodyState\b/PhysicsDirectBodyState3D/g' "$f"
perl -i -pe 's/\bPhysicsDirectSpaceState\b/PhysicsDirectSpaceState3D/g' "$f"
perl -i -pe 's/\bPhysicsServer\b/PhysicsServer3D/g' "$f"
perl -i -pe 's/\bPhysicsShapeQueryParameters\b/PhysicsShapeQueryParameters3D/g' "$f"
perl -i -pe 's/\bPhysicsShapeQueryResult\b/PhysicsShapeQueryResult3D/g' "$f"
perl -i -pe 's/\bPinJoint\b/PinJoint3D/g' "$f"
perl -i -pe 's/\bPlaneShape\b/WorldMarginShape3D/g' "$f"
perl -i -pe 's/\bPoolByteArray\b/PackedByteArray/g' "$f"
perl -i -pe 's/\bPoolColorArray\b/PackedColorArray/g' "$f"
perl -i -pe 's/\bPoolIntArray\b/PackedInt32Array/g' "$f"
perl -i -pe 's/\bPoolRealArray\b/PackedFloat32Array/g' "$f"
perl -i -pe 's/\bPoolStringArray\b/PackedStringArray/g' "$f"
perl -i -pe 's/\bPoolVector2Array\b/PackedVector2Array/g' "$f"
perl -i -pe 's/\bPoolVector3Array\b/PackedVector3Array/g' "$f"
perl -i -pe 's/\bPopupDialog\b/Popup/g' "$f"
perl -i -pe 's/\bProceduralSky\b/Sky/g' "$f"
perl -i -pe 's/\bProximityGroup\b/ProximityGroup3D/g' "$f"
perl -i -pe 's/\bQuat\b/Quaternion/g' "$f"
perl -i -pe 's/\bRayCast\b/RayCast3D/g' "$f"
perl -i -pe 's/\bRayShape\b/RayShape3D/g' "$f"
perl -i -pe 's/\bRemoteTransform\b/RemoteTransform3D/g' "$f"
perl -i -pe 's/\bRigidBody\b/RigidDynamicBody3D/g' "$f"
perl -i -pe 's/\bShape\b/Shape3D/g' "$f"
perl -i -pe 's/\bShortCut\b/Shortcut/g' "$f"
perl -i -pe 's/\bSkeletonIK\b/SkeletonIK3D/g' "$f"
perl -i -pe 's/\bSkeleton\b/Skeleton3D/g' "$f"
perl -i -pe 's/\bSliderJoint\b/SliderJoint3D/g' "$f"
perl -i -pe 's/\bSoftBody\b/SoftBody3D/g' "$f"
perl -i -pe 's/\bSpatialMaterial\b/StandardMaterial3D/g' "$f"
perl -i -pe 's/\bSpatialVelocityTracker\b/VelocityTracker3D/g' "$f"
perl -i -pe 's/\bSpatial\b/Node3D/g' "$f"
perl -i -pe 's/\bSphereShape\b/SphereShape3D/g' "$f"
perl -i -pe 's/\bSpotLight\b/SpotLight3D/g' "$f"
perl -i -pe 's/\bSpringArm\b/SpringArm3D/g' "$f"
perl -i -pe 's/\bSprite\b/Sprite2D/g' "$f"
perl -i -pe 's/\bStaticBody\b/StaticBody3D/g' "$f"
perl -i -pe 's/\bStreamTexture\b/StreamTexture2D/g' "$f"
perl -i -pe 's/\bTCP_Server\b/TCPServer/g' "$f"
perl -i -pe 's/\bTYPE_QUAT\b/TYPE_QUATERNION/g' "$f"
perl -i -pe 's/\bTYPE_REAL\b/TYPE_FLOAT/g' "$f"
perl -i -pe 's/\bTextureArray\b/Texture2DArray/g' "$f"
perl -i -pe 's/\bTextureProgress\b/TextureProgressBar/g' "$f"
perl -i -pe 's/\bTexture\b/Texture2D/g' "$f"
perl -i -pe 's/\bToolButton\b/Button/g' "$f"
perl -i -pe 's/\bTransform\b/Transform3D/g' "$f"
perl -i -pe 's/\bVehicleBody\b/VehicleBody3D/g' "$f"
perl -i -pe 's/\bVehicleWheel\b/VehicleWheel3D/g' "$f"
perl -i -pe 's/\bViewportContainer\b/SubViewportContainer/g' "$f"
perl -i -pe 's/\bViewport\b/SubViewport/g' "$f"
perl -i -pe 's/\bVisibilityEnabler2D\b/VisibleOnScreenEnabler2D/g' "$f"
perl -i -pe 's/\bVisibilityEnabler\b/VisibleOnScreenEnabler3D/g' "$f"
perl -i -pe 's/\bVisibilityNotifier2D\b/VisibleOnScreenNotifier2D/g' "$f"
perl -i -pe 's/\bVisibilityNotifier\b/VisibleOnScreenNotifier3D/g' "$f"
perl -i -pe 's/\bVisualInstance\b/VisualInstance3D/g' "$f"
perl -i -pe 's/\bVisualServer\b/RenderingServer/g' "$f"
perl -i -pe 's/\bWorld\b/World3D/g' "$f"
perl -i -pe 's/\bXRAnchor\b/XRAnchor3D/g' "$f"
perl -i -pe 's/\bXRController\b/XRController3D/g' "$f"
perl -i -pe 's/\bXROrigin\b/XROrigin3D/g' "$f"
perl -i -pe 's/\bYSort\b/Node2D/g' "$f"
perl -i -pe 's/as_normalmap/as_normal_map/g' "$f"
perl -i -pe 's/button_release/button_released/g' "$f"
perl -i -pe 's/doubleclick/double_click/g' "$f"
perl -i -pe 's/is_valid_integer/is_valid_int/g' "$f"
perl -i -pe 's/linear_interpolate/lerp/g' "$f"
perl -i -pe 's/pause_mode = 2/process_mode = 3/g' "$f"
perl -i -pe 's/pause_mode/process_mode/g' "$f"
perl -i -pe 's/popup_centered_minsize/popup_centered_clamped/g' "$f"
perl -i -pe 's/tab_close/tab_closed/g' "$f"
perl -i -pe 's/tab_hover/tab_hovered/g' "$f"
perl -i -pe 's/toplevel/top_level/g' "$f"
perl -i -pe 's/zfar/far/g' "$f"
perl -i -pe 's/znear/near/g' "$f"
perl -i -pe 's/3D2D/2D/g' "$f"
if [[ "$f" == *"tscn" ]]; then
# Bulk actions for scenes.
perl -i -pe 's/(Color|Vector[23]|Rect2|AABB|Basis|Plane|Quaternion|Transform[23]D|Packed[^(]*)\( ([^)]*) \)/\1\(\2\)/g' "$f"
perl -i -pe 's/\:translation/\:position/g' "$f"
perl -i -pe 's/\[ /\[/g' "$f"
perl -i -pe 's/ \]/\]/g' "$f"
perl -i -pe 's/margin_/offset_/g' "$f"
perl -i -pe 's/material\/0 \= /surface_material_override\/0 \= /g' "$f"
elif [[ "$f" == *"csproj" ]]; then
# Bulk actions for csproj files.
perl -i -pe 's/Godot\.NET\.Sdk\/3\.3\.0/Godot\.NET\.Sdk\/4\.0\.0\-dev5/g' "$f"
elif [[ "$f" == *"cs" ]]; then
# Bulk actions for C# files.
perl -i -pe 's/GetPositionInParent/GetIndex/g' "$f"
perl -i -pe 's/Instance\(/Instantiate\(/g' "$f"
perl -i -pe 's/Texture2D\ \=/Texture\ \=/g' "$f"
perl -i -pe 's/Transform3D\ \=/Transform\ \=/g' "$f"
perl -i -pe 's/Transform3D\;/Transform\;/g' "$f"
perl -i -pe 's/Translation\ \=/Position\ \=/g' "$f"
perl -i -pe 's/Translation\;/Position\;/g' "$f"
perl -i -pe 's/public\ class/public\ partial\ class/g' "$f"
elif [[ "$f" == *"gd" ]]; then
# Keep these first.
perl -i -pe 's/camera_translation/camera_position/g' "$f"
perl -i -pe 's/parent_translation/parent_position/g' "$f"
perl -i -pe 's/\*\ ([^(^*^\s]+)\.xform\(([^)]+)\)/* \(\1 * \2\)/g' "$f"
# Bulk actions for GDScript files.
perl -i -pe 's/(\t+)\./\1super\./g' "$f"
perl -i -pe 's/(\t+)return \./\1return super\./g' "$f"
perl -i -pe 's/(\t+)var (.+) = parse_json\((.+)\)/\1var json = JSON\.new()\n\1json\.parse(\3)\n\1var \2 = json\.get_data\(\)/g' "$f"
perl -i -pe 's/= (.*)\.xform_inv\((.*)\)\./= \(\2 * \1\)\./g' "$f"
perl -i -pe 's/= (.*)\.xform_inv\((.*)\)/= \2 * \1/g' "$f"
perl -i -pe 's/Input\.get_action_strength\("([^"]+)"\) - Input\.get_action_strength\("([^"]+)"\)/Input.get_axis(&"\2", &"\1")/g' "$f"
perl -i -pe 's/Vector3(.*) # TODO: Vector3i/Vector3i\1/g' "$f"
perl -i -pe 's/\ translation/\ position/g' "$f"
perl -i -pe 's/\(translation/\(position/g' "$f"
perl -i -pe 's/\.empty\(/\.is_empty\(/g' "$f"
perl -i -pe 's/\.instance\(/\.instantiate\(/g' "$f"
perl -i -pe 's/\.invert\(/\.reverse\(/g' "$f"
perl -i -pe 's/\.translation/\.position/g' "$f"
perl -i -pe 's/\.xform\(/\ * \(/g' "$f"
perl -i -pe 's/\bBUTTON_/MOUSE_BUTTON_/g' "$f"
perl -i -pe 's/\bReference\b/RefCounted/g' "$f"
perl -i -pe 's/^export\(([^)]*)\) var ([a-zA-Z0-9_]*)/\@export var \2: \1/g' "$f"
perl -i -pe 's/^\@export var ([^:]*): ([^:^=]*):\=/\@export var \1 :\=/g' "$f"
perl -i -pe 's/connect\("([^"]+)", ([^,]+), "([^"]+)"/connect\(&"\1", \2\.\3/g' "$f"
perl -i -pe 's/Engine\.get_idle_frames/Engine.get_process_frames/g' "$f"
perl -i -pe 's/export\(String, File, ([^)]*)\)/@export_file\(\1\)/g' "$f"
perl -i -pe 's/export\(float, ([^,]*), ([^,]*)\) var ([a-zA-Z0-9_]*)(: float)?/@export_range\(\1, \2\) var \3: float/g' "$f"
perl -i -pe 's/get_camera\(\)/get_camera_3d()/g' "$f"
perl -i -pe 's/get_node\(\@?\"/get_node\(\^\"/g' "$f"
perl -i -pe 's/get_position_in_parent/get_index/g' "$f"
perl -i -pe 's/get_rotation_quat/get_rotation_quaternion/g' "$f"
perl -i -pe 's/get_world\(\)/get_world_3d()/g' "$f"
perl -i -pe 's/if !/if not /g' "$f"
perl -i -pe 's/(\t+)linear_velocity\ \=\ move_and_slide\(linear_velocity([^)]*)(\)+)/\1# TODO: This information should be set to the CharacterBody properties instead of arguments: \2\n\1move_and_slide()/g' "$f"
perl -i -pe 's/(\t+)linear_velocity\ \=\ move_and_slide_with_snap\(linear_velocity([^)]*)(\)+)/\1# TODO: This information should be set to the CharacterBody properties instead of arguments: snap\2\n\1move_and_slide()/g' "$f"
perl -i -pe 's/rand_range/randf_range/g' "$f"
perl -i -pe 's/sort_custom\(([^)]*), "([^"]*)"\)/sort_custom(Callable(\1, &"\2"))/g' "$f"
perl -i -pe 's/stepify/snapped/g' "$f"
perl -i -pe 's/to_json\(/JSON\.new\(\)\.stringify\(/g' "$f"
perl -i -pe 's/track_remove_key_at_position/track_remove_key_at_time/g' "$f"
perl -i -pe 's/translation\ \+\=/position\ \+\=/g' "$f"
perl -i -pe 's/translation\ \=/position\ \=/g' "$f"
perl -i -pe 's/(\t+)_*velocity\ \=\ move_and_slide\(_*velocity([^)]*)(\)+)/\1# TODO: This information should be set to the CharacterBody properties instead of arguments: \2\n\1# TODO: Rename velocity to linear_velocity in the rest of the script.\n\1move_and_slide()/g' "$f"
perl -i -pe 's/(\t+)_*velocity\ \=\ move_and_slide_with_snap\(_*velocity([^)]*)(\)+)/\1# TODO: This information should be set to the CharacterBody properties instead of arguments: snap\2\n\1# TODO: Rename velocity to linear_velocity in the rest of the script.\n\1move_and_slide()/g' "$f"
perl -i -pe 's/yield\(get_tree\(\)\,\ \"idle_frame\"\)/await\ get_tree\(\)\.process_frame/g' "$f"
# Converts things like 'yield($MessageTimer, "timeout")' to 'await $MessageTimer.timeout'
perl -i -pe 's/yield\((.*), "(.*)"\)/await\ \1\.\2/g' "$f"
# Capitalize Color constants like "Color.white" -> "Color.WHITE"
perl -i -pe 's/Color\.([a-z]+)/Color\.\U\1/g' "$f"
# Convert setgets to the 4.x syntax, but this can't be fully done with a regex so leave a TODO.
perl -i -pe 's/ setget ([^,\n]*), ([^\n]*)/\:\n\tget\:\n\t\t# TODO: Manually copy the code from this method.\n\t\treturn \2\(\)\n\tset\(value\)\:\n\t\t# TODO: Manually copy the code from this method.\n\t\t\1\(value\)/g' "$f"
perl -i -pe 's/ setget ([^,\n]*)/\:\n\tset\(value\)\:\n\t\t# TODO: Manually copy the code from this method.\n\t\t\1\(value\)/g' "$f"
# Keep these last.
perl -i -pe 's/(\t+)([^\t]+) = move_and_slide(_with_snap)*/\1# TODO: This information should be set to the CharacterBody properties instead of arguments.\n\1move_and_slide/g' "$f"
perl -i -pe 's/(\t+)([^\t]+)move_and_slide(_with_snap)*/\1# TODO: This information should be set to the CharacterBody properties instead of arguments.\n\1\2move_and_slide/g' "$f"
perl -i -pe 's/^export/\@export/g' "$f"
perl -i -pe 's/^onready/\@onready/g' "$f"
perl -i -pe 's/^tool/\@tool/g' "$f"
elif [[ "$f" == *"import" ]]; then
# Bulk actions for import files.
perl -i -pe 's/res\:\/\/\.import/res\:\/\/\.godot\/imported/g' "$f"
perl -i -pe 's/\[ /\[/g' "$f"
perl -i -pe 's/ \]/\]/g' "$f"
# Bulk-replace Godot 3 import settings with Godot 4 equivalents.
perl -0 -i -pe 's/compress\/hdr_mode\=0\ncompress\/bptc_ldr\=0\ncompress\/normal_map\=0\nflags\/repeat\=0\nflags\/filter\=true\nflags\/mipmaps\=false\nflags\/anisotropic\=false\nflags\/srgb\=2\nprocess\/fix_alpha_border\=true\nprocess\/premult_alpha\=false\nprocess\/HDR_as_SRGB\=false\nprocess\/invert_color\=false(process\/normal_map_invert_y\=false\n)*\nstream\=false\nsize_limit\=0\ndetect_3d\=true/compress\/hdr_compression\=1\ncompress\/bptc_ldr\=0\ncompress\/normal_map\=0\ncompress\/channel_pack\=0\ncompress\/streamed\=false\nmipmaps\/generate\=false\nmipmaps\/limit\=\-1\nroughness\/mode\=0\nroughness\/src_normal\=\"\"\nprocess\/fix_alpha_border\=true\nprocess\/premult_alpha\=false\nprocess\/normal_map_invert_y\=false\nprocess\/HDR_as_SRGB\=false\nprocess\/size_limit\=0\ndetect_3d\/compress_to\=1/g' "$f"
perl -0 -i -pe 's/compress\/hdr_mode\=0\ncompress\/bptc_ldr\=0\ncompress\/normal_map\=0\nflags\/repeat\=0\nflags\/filter\=false\nflags\/mipmaps\=false\nflags\/anisotropic\=false\nflags\/srgb\=2\nprocess\/fix_alpha_border\=true\nprocess\/premult_alpha\=false\nprocess\/HDR_as_SRGB\=false\nprocess\/invert_color\=false(process\/normal_map_invert_y\=false\n)*\nstream\=false\nsize_limit\=0\ndetect_3d\=true/compress\/hdr_compression\=1\ncompress\/bptc_ldr\=0\ncompress\/normal_map\=0\ncompress\/channel_pack\=0\ncompress\/streamed\=false\nmipmaps\/generate\=false\nmipmaps\/limit\=\-1\nroughness\/mode\=0\nroughness\/src_normal\=""\nprocess\/fix_alpha_border\=true\nprocess\/premult_alpha\=false\nprocess\/normal_map_invert_y\=false\nprocess\/HDR_as_SRGB\=false\nprocess\/size_limit\=0\ndetect_3d\/compress_to\=1/g' "$f"
perl -0 -i -pe 's/compress\/hdr_mode\=0\ncompress\/bptc_ldr\=0\ncompress\/normal_map\=0\nflags\/repeat\=0\nflags\/filter\=false\nflags\/mipmaps\=false\nflags\/anisotropic\=false\nflags\/srgb\=2\nprocess\/fix_alpha_border\=true\nprocess\/premult_alpha\=false\nprocess\/HDR_as_SRGB\=false\nprocess\/invert_color\=false(process\/normal_map_invert_y\=false\n)*\nstream\=false\nsize_limit\=0\ndetect_3d\=false/compress\/hdr_compression\=1\ncompress\/bptc_ldr\=0\ncompress\/normal_map\=0\ncompress\/channel_pack\=0\ncompress\/streamed\=false\nmipmaps\/generate\=false\nmipmaps\/limit\=\-1\nroughness\/mode\=0\nroughness\/src_normal\=""\nprocess\/fix_alpha_border\=true\nprocess\/premult_alpha\=false\nprocess\/normal_map_invert_y\=false\nprocess\/HDR_as_SRGB\=false\nprocess\/size_limit\=0\ndetect_3d\/compress_to\=1/g' "$f"
#perl -0 -i -pe 's///g' "$f"
elif [[ "$f" == *"project.godot" ]]; then
# Bulk actions for project.godot files.
perl -i -pe 's/(Color|Vector[23]|Rect2|AABB|Basis|Plane|Quaternion|Transform[23]D|Packed[^(]*)\( ([^)]*) \)/\1\(\2\)/g' "$f"
perl -i -pe 's/\"class\"\: \"/\"class\"\: \&\"/g' "$f"
perl -i -pe 's/\"language\"\: \"/\"language\"\: \&\"/g' "$f"
perl -i -pe 's/\[ /\[/g' "$f"
perl -i -pe 's/ \]/\]/g' "$f"
# Bulk-replace 3.x style inputs with 4.x style ones.
perl -i -pe 's/Object\(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":(\d+),("physical_scancode":0,)*"unicode":0,"echo":false,"script":null\)/Object\(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":\1,"physical_keycode":0,"unicode":0,"echo":false,"script":null\)/g' "$f"
perl -i -pe 's/Object\(InputEventMouseButton,"resource_local_to_scene"\:false,"resource_name"\:"","device"\:0,"alt"\:false,"shift"\:false,"control"\:false,"meta"\:false,"command"\:false,"button_mask"\:0,"position"\:Vector2\(0, 0\),"global_position"\:Vector2\(0, 0\),"factor"\:1\.0,"button_index"\:(\d+),"pressed"\:false,"double_click"\:([a-z]+),"script"\:null\)/Object\(InputEventMouseButton,"resource_local_to_scene"\:false,"resource_name"\:"","device"\:0,"window_id"\:0,"store_command"\:true,"alt_pressed"\:false,"shift_pressed"\:false,"meta_pressed"\:false,"command_pressed"\:false,"button_mask"\:0,"position"\:Vector2\(0, 0\),"global_position"\:Vector2\(0, 0\),"factor"\:1\.0,"button_index"\:\1,"pressed"\:false,"double_click"\:\2,"script"\:null\)/g' "$f"
fi
done
@qarmin
Copy link

qarmin commented Jul 27, 2021

After using this script number of errors after importing this project(created in 3.4) - https://github.com/godotengine/godot-proposals/files/6888233/GDScript3.4.zip - decreased from 1400 to 700, still there is a lot of messages like

res://Resource/PanoramaSky.gd:18 - Parse Error: "PanoramaSky" was not found in the current scope.
res://Resource/PHashTranslation.gd:18 - Parse Error: "PHashTranslation" was not found in the current scope.
res://Resource/LargeTexture.gd:18 - Parse Error: "LargeTexture" was not found in the current scope.
res://Resource/TextureArray.gd:3 - Parse Error: Identifier "TextureArray" not declared in the current scope.
res://3D/ConeTwistJoint.gd:24 - Parse Error: "ConeTwistJoint" was not found in the current scope.
res://3D/Generic6DOFJoint.gd:24 - Parse Error: "Generic6DOFJoint" was not found in the current scope.
res://3D/MultiMeshInstance.gd:24 - Parse Error: "MultiMeshInstance" was not found in the current scope.
res://3D/SpotLight.gd:24 - Parse Error: "SpotLight" was not found in the current scope.

@Calinou
Copy link

Calinou commented Jul 27, 2021

Some renames aren't included in the script yet:

  • PanoramaSky -> PanoramaSkyMaterial
  • PHashTranslation -> OptimizedTranslation
  • TextureArray -> Texture2DArray
  • ConeTwistJoint -> ConeTwistJoint3D
  • Generic6DOFJoint -> Generic6DOFJoint3D
  • MultiMeshInstance -> MultiMeshInstance3D
  • SpotLight -> SpotLight3D

Also, LargeTexture was removed with no replacement.

@qarmin
Copy link

qarmin commented Jul 28, 2021

Here are probably all missing classes for now

Updated 20.08

Classes which starst with _ like _OS -> OS
BakedLightmapData
CubeMap
ExternalTexture
GIProbeData
Geometry
InterpolatedCamera3D
LargeTexture
LineShape2D
Node3DMesh
Node3DPolygon
Portal
RayShape2D
Room
RoomGroup
RoomManager
TextFile
VisualShaderNodeCubeMap
VisualShaderNodeCubeMapUniform
VisualShaderNodeScalarClamp
VisualShaderNodeScalarConstant
VisualShaderNodeScalarFunc
VisualShaderNodeScalarInterp
VisualShaderNodeScalarOp
VisualShaderNodeScalarSmoothStep
VisualShaderNodeScalarSwitch
VisualShaderNodeScalarUniform
VisualShaderNodeTransformMult
VisualShaderNodeVectorClamp
VisualShaderNodeVectorInterp
VisualShaderNodeVectorScalarMix
VisualShaderNodeVectorScalarSmoothStep
VisualShaderNodeVectorScalarStep
VisualShaderNodeVectorSmoothStep
WindowDialog

@qarmin
Copy link

qarmin commented Aug 20, 2021

I have strange git diff

-               q_KinematicBody2D.move_and_slide_with_snap(variable1, variable2, variable3, variable4, variable5, variable6, variable7)
+               # TODO: This information should be set to the CharacterBody properties instead of arguments.
+               move_and_slide(variable1, variable2, variable3, variable4, variable5, variable6, variable7)

@qarmin
Copy link

qarmin commented Aug 20, 2021

Why this is changed?

-       if !is_visible():
+       if not is_visible():

@qarmin
Copy link

qarmin commented Aug 20, 2021

Also broke one scene, because contained Resource.tscn

diff --git a/All.tscn b/All.tscn
index 174154b..9e6bc19 100644
--- a/All.tscn
+++ b/All.tscn
@@ -1,7 +1,7 @@
 [gd_scene load_steps=8 format=3 uid="uid://b3y5bqmqdgm06"]
 
 [ext_resource type="PackedScene" path="res://Resource.tscn" id="1"]
-[ext_resource type="PackedScene" path="res://Reference.tscn" id="2"]
+[ext_resource type="PackedScene" path="res://RefCounted.tscn" id="2"]
 [ext_resource type="PackedScene" path="res://Node.tscn" id="3"]
 [ext_resource type="PackedScene" path="res://Control.tscn" id="4"]
 [ext_resource type="PackedScene" path="res://3D.tscn" id="5"]
@@ -26,7 +26,7 @@ script = null
 [node name="Node" parent="." instance=ExtResource( "3" )]
 script = null
 
-[node name="Reference" parent="." instance=ExtResource( "2" )]
+[node name="RefCounted" parent="." instance=ExtResource( "2" )]
 script = null
 
 [node name="Resource" parent="." instance=ExtResource( "1" )]

Files after script execution

2D       3D       aa.sh     Control       logs  Node.tscn  Object.tscn    Reference       Resource       Self     Self.tscn
2D.tscn  3D.tscn  All.tscn  Control.tscn  Node  Object     project.godot  Reference.tscn  Resource.tscn  Self.gd

@qarmin
Copy link

qarmin commented Aug 20, 2021

I prepared also list of all enums - enums.zip

Example of missing enums(after conversion)

XRPositionalTracker.TRACKER_LEFT_HAND
Animation.TYPE_TRANSFORM
AnimationTree.NODE_ANIMATION

It is hard to find get list of all renamed enums, but I will try to do this

@AgentSmith0
Copy link

The replace of the remote Identifier is missing.

@tavurth
Copy link

tavurth commented Mar 11, 2022

  1. Missing Engine.get_idle_frames -> Engine.get_process_frames
  2. export(float, 0, 1) -> export_range(0, 1) var something: float
  3. export(String, File, "*.txt") -> @export_file("*.txt")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment