I making a spawner that I could place anywere on my map.
The code is looking like this:
for x=0 ,512 do for y=0,512 do val = mget(x,y) -- spawner if (fget(val, 1)) then spawnscrubs(x,y,14,2) end end end
The code picks up that there is spawners on the map(and the amount), but not the location, all scrubs are spawning at x= 0, y = 0 .
Can not figure out the problem with the code...
Can someone figure it out?
Thanks a lot!
Are you sure you are looking at the right sprite flag? The flags are numbered from 0 to 7, so the red flag is 0, orange is 1 and so on.
I loaded up a new project, made a quick sprite with the red flag set and placed it in the map and the following code worked:
for x=0,127 do for y=0,31 do val = mget(x,y) -- spawner if fget(val,0) then -- check the red flag print("found a spawner!") print("x: "..x..", y: "..y) end end end
(Side note: the map is only 128 * 32, so while it won't cause any problems the loop will be finished a lot quicker if you cap x at 127 and y at 31)
Hope this helps!
[Please log in to post a comment]