Object attribute not being recognized?
TheRealAnimeSpot
07 Jun 2020, 15:30I'm trying to proc gen a world in Quest. There are region objects and each have coordinates assigned to them. The coordinates are separate x and y integer attributes.
There's a specific function where I need to access region.x and region.y but it acts like the attributes don't exist. The attributes show up when I look at the debugger though.
This is where the function is first called. I apologize for how the code looks, I couldn't figure out how to format it properly. The min_rainfall / max_rainfall are used when generating each region's rainfall and tile_num determines how many tiles (rooms) are in each region.
foreach (i, region_list) {
assign_rainfall(i, min_rainfall, max_rainfall)
assign_biome(i)
initialize_tiles(i, tile_num)
assign_coordinates_tile(i, World.region_num)
}
</function>
This is the function itself. Each region has a list of tiles, which are basically the rooms that the player will be moving through. This is supposed to assign each tile's coordinates based on its region coordinates. After this, exits are created based on the tile's coordinates.
x = region.x * num
y = region.y * num
foreach (i, region.tiles) {
i.x = x
i.y = y
x = x + 1
if (x = max_x) {
y = y + 1
x = region.x * num
}
}
</function>
TheRealAnimeSpot
07 Jun 2020, 15:40I figured out how to format the code correctly but the site won't let me update it so I'll just post it here.
This where the function is first called.
<function name="generate_regions" parameters="region_list">
min_rainfall = get_min_attr_list(Reference.biome_list, "min_rainfall")
max_rainfall = get_max_attr_list(Reference.biome_list, "max_rainfall")
tile_num = World.tile_num * World.tile_num
foreach (i, region_list) {
assign_rainfall(i, min_rainfall, max_rainfall)
assign_biome(i)
initialize_tiles(i, tile_num)
assign_coordinates_tile(i, World.region_num)
}
</function>
This is the actual function.
<function name="assign_coordinates_tile" parameters="region, num">
if (HasAttribute(region,"x")) {
msg("Yes!")
}
else {
msg("No!")
}
max_x = (region.x * num) + num
x = region.x * num
y = region.y * num
foreach (i, region.tiles) {
i.x = x
i.y = y
x = x + 1
if (x = max_x) {
y = y + 1
x = region.x * num
}
}
</function>
mrangel
07 Jun 2020, 15:42What's the actual error message? Are you sure it's those lines hat are the problem? Are you sure you know which region is causing the error? I'd check to see if one of them has an attribute missing for some reason; or double-check the code that sets those attributes.
TheRealAnimeSpot
07 Jun 2020, 16:23A function was in the wrong place. Thanks for your help!