Creations Favorites Posts ID:149515
ID:149515

I am trying to make it so that when you create the world all the powerlines in the world will orient themselves depending on whether there are powerlines next to it.
It does not collaborate itself correctly. Instead it stays the default icon.

 ```atom proc Offset(D, xo, yo)//D = a directional number var/J = yo // yo is changed in some cases switch(D) // 1 North is excluded because it is unmodified. xo = xo;yo = yo if(2)//South xo = -xo yo = -yo // invert both variables -/+ factor if(4)//East yo = -xo xo = J //yo equals -xo, xo = initial yo if(8)//West yo = xo xo = -J//opposite of East return locate(x + xo, y + yo, 1)//return turf that is found using the new vars. IPL(T) if(T && istype(T, /turf/wall)) return 1 if(T && istype(T, /turf/floor)) return 1 for(var/obj/electronics/powerlines/O in world) if(istype(O, /obj/electronics/powerlines)) return 1 turf var powerlinesobj electronics powerlines layer = MOB_LAYER +1 icon = 'powerlines.dmi' New() ..() var I K for(K in nsew) if(!IPL(Offset(K, 0, 1))) I += K//for direction in cardinal directions. the offset returns immediatly surrounding with these args. If it is not a road + direction number to I. The master number if(I in list(3,12)) icon_state = num2text(I)// If I is 1,2,4,8 then create an icon_state ```
Well, this is a version I used for Ensya (slightly modified), so it should work, assuming you're using the same way I am.

 ```obj/powerlines New() sleep(5) // not sure, just have this in case. var/combine = 0 var/turf/N = get_step(src,NORTH) var/turf/E = get_step(src,EAST) var/turf/S = get_step(src,SOUTH) var/turf/W = get_step(src,WEST) for(var/obj/powerlines/P in N) combine += 1 for(var/obj/powerlines/P in E) combine += 2 for(var/obj/powerlines/P in S) combine += 4 for(var/obj/powerlines/P in W) combine += 8 icon_state = "[combine]" ```
In response to Foomer (#1)
I edited it a bit but it still does not work!
 ```atom proc Offset(D, xo, yo)//D = a directional number var/J = yo // yo is changed in some cases switch(D) // 1 North is excluded because it is unmodified. xo = xo;yo = yo if(2)//South xo = -xo yo = -yo // invert both variables -/+ factor if(4)//East yo = -xo xo = J //yo equals -xo, xo = initial yo if(8)//West yo = xo xo = -J//opposite of East return locate(x + xo, y + yo, 1)//return turf that is found using the new vars. IPL(T) if(T && istype(T, /turf/wall)) return 1 if(T && istype(T, /turf/floor)) return 1 for(var/obj/electronics/powerlines/O in world) if(istype(O, /obj/electronics/powerlines)) return 1turf var powerlinesobj electronics powerlines layer = MOB_LAYER +1 icon = 'powerlines.dmi' New() ..() var/combine = 0 var/turf/N = Offset(1,0,1) var/turf/E = Offset(4,0,1) var/turf/S = Offset(2,0,1) var/turf/W = Offset(8,0,1) if(istype(N,/turf/wall)) combine += 1 else for(var/obj/electronics/powerlines/P in N) combine += 1 break if(istype(S,/turf/wall)) combine += 2 else for(var/obj/electronics/powerlines/P in S) combine += 2 break if(istype(E,/turf/wall)) combine += 4 else for(var/obj/electronics/powerlines/P in E) combine += 4 break if(istype(W,/turf/wall)) combine += 8 else for(var/obj/electronics/powerlines/P in W) combine += 8 break icon_state = num2text(combine) ```
 #3 Apr 12 2002, 1:47 pm I suppose it's time to release my Atom Merging library. I wanted to stick a couple of hooks in it for special situations, but it's fine for general purposes as it is now. Look for it on BYONDscape soon. :) If you can't wait, or you don't have a BYONDscape subscription you could go to Pmikell's site ( http://www.pmikell.freeserve.co.uk/byond/examples/ autojoin.html ) for a very similar routine. Note that his icon_states don't correspond to the icon_states in my library.
 #4 Apr 12 2002, 1:55 pm In response to Exadv1 (#2) instead of Offset() jsut use the built in get_step() proc. var/turf/N = get_step(src,NORTH)
 #5 Apr 12 2002, 1:55 pm In response to Shadowdarke (#3) Shadowdarke wrote: I suppose it's time to release my Atom Merging library. I wanted to stick a couple of hooks in it for special situations, but it's fine for general purposes as it is now. Look for it on BYONDscape soon. :) If you can't wait, or you don't have a BYONDscape subscription you could go to Pmikell's site ( http://www.pmikell.freeserve.co.uk/byond/examples/ autojoin.html ) for a very similar routine. Note that his icon_states don't correspond to the icon_states in my library. I use a modified version of his library that allows you to autojoin all kindsof atoms instead of just turfs. I wonder what ever happened to that guy.
 #6 Apr 12 2002, 2:01 pm In response to Ebonshadow (#5) Ebonshadow wrote: I use a modified version of his library that allows you to autojoin all kindsof atoms instead of just turfs. I wonder what ever happened to that guy. One of my recent projects was a large amorphous multi-tile slime mob that auto-merges. I may even get around to finishing it one of these days. :P I miss Pmikell too. He was always doing interesting experiments with the BYOND engine.
 #7 Apr 13 2002, 10:43 pm In response to Shadowdarke (#6) I miss Pmikell too. He was always doing interesting experiments with the BYOND engine. He was here posting not too long ago (relatively speaking). He posted in General this February. Anyway, either he has been busy with other projects, or he has some kind of really nifty library up his sleeve. ;-)
 #8 Apr 14 2002, 5:20 am In response to Shadowdarke (#3) Thank you very much it hyas been very helpful.