Tilemaplayer question

Godot 4 newest version

English is not my first language so if theres mistakes in grammar please comprehend,thanks
I followed the <Map Generation In Godot 4.0 (FastNoiseLite)>from YouTube, Heres my code:

extends TileMapLayer

var fnl := FastNoiseLite.new()

func _ready() → void:
randomize()
fnl.seed = randi()
fnl.noise_type = FastNoiseLite.TYPE_CELLULAR
fnl.fractal_octaves = 8
fnl.domain_warp_fractal_lacunarity = 12.0
generateMap()

func generateMap() → void:
for x in 900:
for y in 500:
var noiseVal :float= abs(fnl.get_noise_2d(x,y))
if noiseVal < 0.55:
set_cell(0, Vector2i(x,y), 0, Vector2(0,1))
else:
set_cell(0, Vector2i(x,y), 0, Vector2(12,11))

func _input(event: InputEvent) → void:
if event.is_action_pressed(“restart”):
get_tree().reload_current_scene()
It looks very similar to the tutorial,but theres a lot of error report:
Line 18: Cannot pass a value of type “int” as “Vector2i”.
Line 18: Invalid argument for “set_cell()” function: argument 1 should be “Vector2i” but is “int”.
Line 18: Invalid argument for “set_cell()” function: argument 2 should be “int” but is “Vector2i”.
Line 18: Cannot pass a value of type “int” as “Vector2i”.
Line 18: Invalid argument for “set_cell()” function: argument 3 should be “Vector2i” but is “int”.
Line 18: Cannot pass a value of type “Vector2” as “int”.
Line 18: Invalid argument for “set_cell()” function: argument 4 should be “int” but is “Vector2”.
Line 20: Cannot pass a value of type “int” as “Vector2i”.
Line 20: Invalid argument for “set_cell()” function: argument 1 should be “Vector2i” but is “int”.
Line 20: Invalid argument for “set_cell()” function: argument 2 should be “int” but is “Vector2i”.
Line 20: Cannot pass a value of type “int” as “Vector2i”.
Line 20: Invalid argument for “set_cell()” function: argument 3 should be “Vector2i” but is “int”.
Line 20: Cannot pass a value of type “Vector2” as “int”.
Line 20: Invalid argument for “set_cell()” function: argument 4 should be “int” but is “Vector2”.

Can someone tell me how to fix it?

You mixed up the order of the set_cell-method
try this:

if noiseVal < 0.55:
    set_cell(Vector2i(x, y), 0, Vector2(0,1), 0
else:
    set_cell(Vector2i(x, y), 0, Vector2i(12,11), 0)
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.