Trying to follow an old tutorial, how to use setget in godot 4?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Emor

Hi! I’m trying to follow How to make dynamic waves with water which was made in godot 3.3. I’ve been able to follow most of the tutorial, but I run in to trouble when trying to import the smoothpath script below. I’ve added @ to the export variables, but then I’m stuck.

Could I get any help with converting this script to get it to work in godot 4?

    class_name SmoothPath
extends Path2D

export var spline_length = 8
export(bool) var _smooth setget smooth
export(bool) var _straighten setget straighten
export(Color) var color = Color(1,1,1,1)
var width = 8

func straighten(value):
	if not value: return
	for i in range(curve.get_point_count()):
		curve.set_point_in(i, Vector2())
		curve.set_point_out(i, Vector2())

func smooth(value):
	if not value: return

	var point_count = curve.get_point_count()
	for i in point_count:
		if i >0 and i < point_count-1:
			var spline = _get_spline(i)
			curve.set_point_in(i, -spline)
			curve.set_point_out(i, spline)

func _get_spline(i):
	var last_point = _get_point(i - 1)
	var next_point = _get_point(i + 1)
	var spline = last_point.direction_to(next_point) * spline_length
	return spline

func _get_point(i):
	var point_count = curve.get_point_count()
	i = wrapi(i, 0, point_count )
	if i >1 and i < point_count-1:
		return curve.get_point_position(i)
	elif i <= 1:
		return Vector2(curve.get_point_position(1).x - spline_length,curve.get_point_position(1).y)
	elif i >= point_count-1:
		return Vector2(curve.get_point_position(point_count-1).x + spline_length,curve.get_point_position(point_count-1).y)

func _draw():
	var points = curve.get_baked_points()
	if points:
		draw_polyline(points, color, width, true)
:bust_in_silhouette: Reply From: aidave

It’s like this now:

var my_prop: get = get_my_prop, set = set_my_prop