ID:138697
 
Code:
mob/proc/getPixelColors(path = "./", fileType = ".dmi")
set background = 1
var/p=0
for(var/i in flist("[path]"))if(length(i)>length(fileType)+1) if(lowertext(copytext(i,length(i)-length(fileType) + 1,length(i)+1))==fileType)p=1
if(p==1)
src<<path
sleep(1)
for(var/i in flist("[path]"))if(length(i)>length(fileType)+1) if(lowertext(copytext(i,length(i)-length(fileType) + 1,length(i)+1))==fileType)
src<<" - [i]"
mini_map_colors[i] = new/list()
var
list/colors[0]
color
for(var/r in icon_states(file("[path][i]")))
if(fileType == ".png")world<<"icon_state.png: [i]"
var
icon/e = icon(file("[path][i]"), r)
width = e.Width()
height = e.Height()
acc = accuracy//Higher = Faster = Lower Accuracy
for(var/x = 1 to width step acc)for(var/y = 1 to height step acc)
var/c = e.GetPixel(x, y)
if(c != null)colors[c]++// && c != "#000000" && c != "#050505")colors[c]++
var/list/l = mini_map_colors[i]

manualColor(r, i, l)

if(!l[r] && colors.len > 0)
color = colors[1]
if(colors.len > 1)for(var/n = 1 to colors.len)
if(n != colors.len && colors[color] < colors[colors[n + 1]])
color = colors[n + 1]
l[r] = color
color = null
colors = list()
for(var/i in flist("[path]"))if(i != "Minimap/")
if(copytext(i,length(i),length(i)+1)=="/")getPixelColors("[path][i]", fileType)

mob/proc/generateMiniMap()
if(!fexists("MiniMaps.dmi") && !generated_minimap)
var/a = alert(src, "MiniMaps.dmi does not exist, would you like to generate minimaps?", "Minimap Generator", "Yes", "No")
if(a == "No")return FALSE
else generated_minimap = TRUE
else
generated_minimap = TRUE
return TRUE
getFiles()
var/icon/emtpy_icon = new
emtpy_icon.Scale(world.maxx, world.maxy)
for(var/z = 1 to world.maxz)
var/icon/i = new('blank.dmi')//Has a blank icon_state in the file which is 1x1 in size
i.Scale(world.maxx, world.maxy)
for(var/x = 1 to world.maxx)
for(var/y = 1 to world.maxy)
var/turf/t = locate(x, y, z)
i.DrawBox(mini_map_colors["[t.icon]"][t.icon_state], x, y)//Draws a pixel with the most common color of the turf in location t at x,y on the new icon // <-- This is where it says the error is
for(var/obj/o in t)
i.DrawBox(mini_map_colors["[o.icon]"][o.icon_state], x, y)//Draws a pixel with the most common color of the obj in location t at x,y on the new icon
emtpy_icon.Insert(i, "[z]")
src<<"<tt>Minimap(\"[z]\") add to 'MiniMaps.dmi'."
src<<ftp(emtpy_icon,"MiniMaps.dmi")//Allows you to save the newly created icon.
src<<"<tt>If a minimap or objects on a minimap don't show up when running the showMap function, double check that the 'MiniMaps.dmi' icon files exists and/or restart Dream Seeker and try the showMap again. If it still doesn't show up get a hold of Zaltron."


Problem description: Every time I try to use Zaltron's minimap library, I get a bad index error and I'm not sure why. The link to the full library is here. Any suggestions?

Not sure, I just loaded it with no errors, try removing the whole library and download it again.

Documents\BYOND\lib\zaltron

That is where the folder lies ..

C:\Users\%your account username%\Documents\BYOND\lib\zaltron

See if that works?
In response to A.T.H.K
A.T.H.K wrote:
Not sure, I just loaded it with no errors, try removing the whole library and download it again.

Documents\BYOND\lib\zaltron

That is where the folder lies ..

C:\Users\%your account username%\Documents\BYOND\lib\zaltron

See if that works?

I already tried that. I already had to add if(length(i)>length(fileType)+1) to line line 215 - otherwise it gives a text out of bounds error. I tried using it with a different project and it works, I have no idea what could be different here - I have two projects it won't work for, and one that it will. Maybe it has something to do with PNG files?

Edit: Confirmed. I added a large PNG file to the library and it could no longer generate Minimaps.dmi.