Skip to content

Commit 9886148

Browse files
committed
fix oneperrow builder
1 parent 6dad20c commit 9886148

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

World.gd

+18-9
Original file line numberDiff line numberDiff line change
@@ -101,31 +101,40 @@ func pOneElemPerRowWithRandomX(world, blueprint):
101101
var structure = blueprint[2]
102102
var rx = []
103103
var foundPlace = true
104+
var foundx
104105
for row in range(len(world)):
105-
foundPlace = true
106106
for x in range(chunkWidth):
107107
rx.append(x)
108108
rx.shuffle()
109109
for x in rx:
110+
foundPlace = true
111+
#print("checking ", row, " x = ", x)
110112
for i in range(len(structure)):
111113
for j in range(len(structure[0])):
112114
if row+i < chunkHeight and x+j < chunkWidth:
113115
if typeof(world[row+i][x+j]) != 2:
114116
foundPlace = false
117+
foundx = null
115118
else:
116119
foundPlace = false
120+
foundx = null
117121
if !foundPlace:
118122
break
123+
foundx = null
119124
if foundPlace:
120-
for i in range(len(structure)):
121-
for j in range(len(structure[0])):
122-
if structure[i][j] != null:
123-
if typeof(structure[i][j]) != 2:
124-
world[row+i][x+j] = [] + structure[i][j]
125-
else:
126-
world[row+i][x+j] = 0
125+
foundx = x
126+
break
127+
if foundx != null:
128+
#print("found place ", row, " ", foundx)
129+
for i in range(len(structure)):
130+
for j in range(len(structure[0])):
131+
if structure[i][j] != null:
132+
if typeof(structure[i][j]) != 2:
133+
world[row+i][foundx+j] = [] + structure[i][j]
127134
else:
128-
world[row+i][x+j] = null
135+
world[row+i][foundx+j] = 0
136+
else:
137+
world[row+i][foundx+j] = null
129138
return world
130139

131140
func newData(region):

0 commit comments

Comments
 (0)