Log In  

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!

/Sebastian

P#32004 2016-10-29 07:12 ( Edited 2016-10-29 12:05)

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!

P#32008 2016-10-29 07:42 ( Edited 2016-10-29 11:46)

Thanks I solved it because of your side note!

I spawned them on X and Y but I have to multiply their pos by 8 to get the real placement!

Thanks a lot qbicfeet!

P#32009 2016-10-29 08:05 ( Edited 2016-10-29 12:05)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-20 02:07:29 | 0.011s | Q:12