ID:270837
 
How do i make it delete the picture?
proc
tilePNG(var/atom/tile,width,height,var/atom/location)
width /= 32
height /= 32
var/x = location.x
var/y = location.y
var/z = location.z
for(var/widthprog = 0,widthprog < width,widthprog ++)
for(var/heightprog = 0,heightprog < height,heightprog ++)
var/atom/temp = new tile(locate(x+widthprog,y+heightprog,z))
temp.icon_state = "[widthprog],[heightprog]"


You could either use block() to delete all of the pictures in a block of turfs, but since you're using /atom there's no good way of insuring it's actually the picture, except for checking its icon.
    deletePNG(del_icon)
for(var/atom/A)
if(A.icon == del_icon) del(A)


This is just an example, you'd call this delPNG('icon.dmi') to remove all of the atoms with the icon 'icon.dmi'.
In response to Nadrew
Nice for() Nadrew..

Hn, do you think NRP should make a new type path so it would make it easier to find and delete the tiled PNG?

Example of what I mean:
tiles
parent_type=/atom


Now there's a path /tiles which has the same capabilities of /atom but it would be easier to search for and delete:
...
tilePNG(...)
var/tiles/temp = new tile(locate(x+widthprog,y+heightprog,z))
...

removePNG(lowerloc,higherloc)//just an example
for(var/tiles/T in block(lowerloc,higherloc))//loops through lowerloc to higherloc (look at <tt>block()</tt> if you don't know/remember), looking for object with the path /tiles
del(T)//deletes it


- GhostAnime - ???
In response to GhostAnime
I was just giving him a starting point. I was actually going to mention that looping over all atoms is a bad idea and that he should make a child-type or datum for it after the code itself, but I got in a hurry and just submitted after the code was typed up. Thanks for covering me, I hate when life makes me hurry, I have too much on my mind to remember things when I have to hurry.
In response to Nadrew
Ah I see >_>

- GhostAnime - !_!
In response to GhostAnime
ym gohost can you explain your code
In response to NR Productions
Hn, I'll try.

You know there's the default: /datum,/sound,/icon,/image,/atom,/area,/turf,/atom/movable,/ obj,/mob

You can have your own /path by doing this:
Path_name_here
parent_type=/pick/default/path/here


Lets say I want the path /item as a /obj
item
parent_type=/obj//this makes 'item' a path and it falls under the obj herarchy (sp?)



And let's say I have a path set up as /mob/NPC/Enemies/Special and I want to make it shortened down to /SEnemy without losing the path that has been set up:
SEnemy
parent_type=/mob/NPC/Enemies/Special


------------------------

- GhostAnime - Um, is this any clearer? >_>;;
In response to GhostAnime
i mean a better example for making the picture disspear XD
In response to GhostAnime
GhostAnime wrote:
Hn, I'll try.

You know there's the default: /dantum,/sound...

i lold
In response to DivineO'peanut
Fine, *changes /dantum to /datum... there, fixed ... I don't know why I keep saying datum as dantum >_>''

And NRP, I can't think of a better example, a worse one (well, not really) is something like the following:
for(var/tiles/T in world) del T


It looks for all /tiles types and deletes them.. >_>

- GhostAnime
In response to GhostAnime
You don't get it. dan-tum. Dantom? >.>
In response to DivineO'peanut
Now you made me feel dumb :/

- GhostAnime
/dantom
parent_type=/datum
:P
Since you're using code I gave you, here's an updated version of the same procedure.

proc
ceil(n, div) return n + n % div


tilePNG(atom/tile,width,height,turf/location,x,y,z,save)
width = ceil(width, 32) / 32
height = ceil(height, 32) / 32
var/list/L

if(save)
L = list()

if(isturf(location))
x = location.x
y = location.y
z = location.z
for(var/widthprog = 0,widthprog < width,widthprog ++)
for(var/heightprog = 0,heightprog < height,heightprog ++)
var/atom/temp = new tile(locate(x+widthprog,y+heightprog,z))
temp.icon_state = "[widthprog],[heightprog]"
if(save)
L += temp

if(save)
if(save==1)
return L
save += L



tilePNG(atom/tile,width,height,turf/location,x,y,z,save)

atom/tile = any atom that's icon is a png
width = width in pixels of that png
height = height in pixels of that png
turf/location = a turf to where it will place the bottom-left most corner of the image
x, y, z = the x, y and z of where it will place the bottom-left most corner of the image. If location is set to null it will use these instead
save = if this is set to null then it will not keep a list of the atoms used to make the png. if this is set to 1 then it will return a list of the atoms used to make the png. if this is set to an existing list it will add the atoms used to make the png to the existing list.



Examples of how to delete the picture:

var/list/thepicture = list()
tilePNG(turf/picture,200,1337,null,1,1,1,thepicture)
sleep(100)
for(var/turf/T in thepicture)
del(T)

or
mob
var/painting = list()
verb
paintMasterPeice()
painting = tilePNG(turf/painting,640,640,locate(src),1,1,1,1)

stunYourCritics()
for(var/turf/T in painting)
del(T)
painting = list()
turf
painting
icon = 'monalisa.png'


That, uh, should work. If anyone can see any rubbishness in my code, please point it out.