EDIT: In Python.
Alright. In the code below I am trying to take a (multi-line) .txt file, stored in my_heightmap, and turn it into a list, which I then reformat as an array (such that heightarray is separately holding every value in each row of what will become a two-dimensional, text-based heightmap.) I'm getting the "not subscriptable" error on this line:
heightarray[y[x]] = heightlist[count + x]
I'm not sure where I messed up, but as I understand it, the code should take each line of the .txt file and convert it into its own list within heightarray. I'm not sure why I can't take a single instance of a list of values and turn it into a single instance of an array (which is just a list within a list)?
This is possibly woefully inefficient, but I'm just trying to earn my chops on a project that interests me.
#converting the heightmap into an array
heightlist = list(my_heightmap)
heightarray = []
count = 0
for y in range(0,self.size):
for x in range(0, self.size):
heightarray[y[x]] = heightlist[count + x]
count += self.size
#peak generation
for peaks in range(0, round(self.size/30)):
y = random.randomint(0,size + 1)
x = random.randomint(0,size + 1)
for dist in range(0, random.randomint(size/50, size/10)):
heightarray[y[x]] = 9
y += random.randomint(-1,2)
x += random.randomint(-1,2)
my_heightmap.write(heightarray)
my_heightmap.close()
My apologies if this is a fairly simple fix (I didn't really find another similar question that made sense to me) and I'm probably not using the correct jargon. Thank you for any and all help!
P.S. I hope I've explained the situation enough. I am happy to post more code or explain further if needed!