Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | CluelessCoder |
I’m guessing this is a new update problem. I am getting this error and it will not let me run the game. I’ve seen people saying how to ignore it and the error code says I can ignore it with underscore but even when I do it will not run.
the error is in the func build_level( )
the error is with add_room(free_regions)
const TILE_SIZE = 32
const LEVEL_SIZES = [
Vector2(30,30),
Vector2(35,35),
Vector2(40,40),
Vector2(45,45),
Vector2(50,50),
]
class_name Game
const LEVEL_ROOM_COUNTS = [5, 7, 9, 12, 15]
const MIN_ROOM_DIMENSION = 5
const MAX_ROOM_DIMENSION = 8
enum Tile {Brick, Door, Ground, Ladder, Stone}
var level_num = 0
var map =
var rooms =
var level_size
onready var tile_map = $TileMap
onready var player = $Player
var player_tile
var score = 0
func _ready():
OS.set_window_size(Vector2(1280, 720))
randomize()
build_level()
func build_level():
rooms.clear()
map.clear()
tile_map.clear()
level_size = LEVEL_SIZES[level_num]
for x in range(level_size.x):
map.append([])
for y in range(level_size.y):
map[x].append(Tile.Stone)
tile_map.set_cell(x, y, Tile.Stone)
var free_regions = [Rect2(Vector2(2, 2), level_size - Vector2(4, 4))]
var num_rooms = LEVEL_ROOM_COUNTS[level_num]
for i in range(num_rooms):
add_room(free_regions)
if free_regions.empty():
break
Please post the relevant code, and format it via the { }
button in the forum editor.
jgodfrey | 2020-11-19 14:34
You can’t ignore it if the argument doesn’t have a default value to fallback on. The docs for the method will either say (type name) or (type name=default value)
for example the AnimationPlayer seek method is seek ( float seconds, bool update=false )
, seconds needs a value but update can be ignored.
Magso | 2020-11-19 18:22
I’ve uploaded the code now. any help would be much appreciated.
CluelessCoder | 2020-11-22 19:29
Can you please edit your post and format the code as I mentioned in an earlier response above? It makes it so much easier to read…
jgodfrey | 2020-11-22 19:31
And, you’re getting a specific error. What line of code is that error associated with? Godot should tell you that, so rather than us guessing, it’d be good if you just tell us…
*** EDIT ***
Ah, I see you mentioned in the OP that the error was with the add_room(free_regions)
call, so that’s really what I was looking for here…
Can you post the code for the add_room()
function also?
jgodfrey | 2020-11-22 19:34