Anyway, I've searched the hub and the forum. AbyssDragon's BasicMath library has a nice line-finding algorithm, but it only works using tiles. I found an old post of Lummox's ([link]) that had an untested snippet in it; it works, with a bit of modification, except that there are odd pixels scattered here and there. Here's the code I'm using, complete with verb to test it out:
var/lasercache[0] mob/verb/makeline(dx as num, dy as num) var/L=CreateLine(dx,dy) for (var/X in L) var/turf/T=locate(text2num(X)+1,text2num(copytext(X,findtext (X,",")+1))+1,1) T.overlays+=L[X] proc/CreateLine(dx,dy) var/cachekey="[dx],[dy]" var/list/L=list() var/icon/lasershifted=new /icon('laser.dmi') var/unitstomove=max(dx,dy)*32 var/xinc1=0 var/yinc1=0 var/xinc2=0 var/yinc2=0 var/maindir=EAST var/sidedir=(dy>=0)?NORTH :SOUTH if(dx>dy) xinc1=1 yinc2=(dy>=0)?1:-1 else yinc1=(dy>=0)?1:-1 xinc2=1 maindir=sidedir sidedir=EAST var/swap=dx dx=dy dy=swap var/mainsub=(dx>=0)?16:15 var/sidesub=(dy>=0)?16:15 dx=abs(dx) dy=abs(dy) var/centerx=0 // coords of current tile var/centery=0 var/aside=dx var/icon/current for(var/n=0,n<=unitstomove,++n) current=L["[centerx],[centery]"] if(!current) current=new /icon(lasershifted) L["[centerx],[centery]"]=current else current.Blend(lasershifted,ICON_OVERLAY) lasershifted.Shift(maindir,1,1) // wrap aside+=dy mainsub=(mainsub+1)&31 if(!mainsub) centerx+=xinc1 centery+=yinc1 if(aside>dx+dx) aside%=dx lasershifted.Shift(sidedir,1,1) // wrap sidesub=(sidesub+1)&31 if(!sidesub) centerx+=xinc2 centery+=yinc2 lasercache[cachekey]=L return L
Any suggestions? As usual, I don't understand half of Lummox's code. =P
Siientx