ID:269820
 
Is there anyway to see all of the files in a directory?
I've tried:
var/d="C:\folder\anotherfolder"
for(var/i in d)
//etc.



Also, is there a way to put a picture into an icon file that's already been created? Such as:
var/icon/i='asdf.png'
var/icon/c='icon.dmi'
c<<i


(which obviously doesn't work).

Thanks for reading,
~Ramen
Hell Ramen wrote:
Is there anyway to see all of the files in a directory?
I've tried:
> var/d="C:\folder\anotherfolder"
> for(var/i in d)
> //etc.


flist()


Also, is there a way to put a picture into an icon file that's already been created? Such as:
> var/icon/i='asdf.png'
> var/icon/c='icon.dmi'
> c<<i


icon.Insert()
In response to Nadrew
I love you. >_>

Nah, I don't.

But thank you, very much. =p
Hell Ramen wrote:
Is there anyway to see all of the files in a directory?
I've tried:
var/d="C:\folder\anotherfolder"
for(var/i in d)
//etc.

Well it should have been obvious that wouldn't work, since d is a string.

The proc you're searching for is flist().

Also, is there a way to put a picture into an icon file that's already been created? Such as:
var/icon/i='asdf.png'
var/icon/c='icon.dmi'
c<<i


An icon and an /icon datum are two different things. If you're going to use the datum, you need to use new(icon_file) to set it up.

And if you want to add something to an /icon, you'll need to use Insert().

Lummox JR
In response to Lummox JR
Heh, thanks.
Seeing as I hate creating new topics, though:
mob/verb/test(directory as text)
for(var/i in flist("[directory]\\"))
if(i=="Thumbs.db")continue //I don't know why that was appearing.
var/icon/d=new('lawlerskates.dmi')
var/t=i
t=dd_replacetext(i,".bmp","")
var/icon/o=file(i)
d.Insert(o,t)

The folder is just pure 32x32 .bmps. So, anyways, I'm attempting to turn all of those bmps into one single icon with tons of icon_states. ;\

This is simple, I know. I've just never really experimented with icons in this way.
In response to Hell Ramen
Hell Ramen wrote:
Heh, thanks.
Seeing as I hate creating new topics, though:
mob/verb/test(directory as text)
> for(var/i in flist("[directory]\\"))
> if(i=="Thumbs.db")continue //I don't know why that was appearing.
> var/icon/d=new('lawlerskates.dmi')
> var/t=i
> t=dd_replacetext(i,".bmp","")
> var/icon/o=file(i)
> d.Insert(o,t)

The folder is just pure 32x32 .bmps. So, anyways, I'm attempting to turn all of those bmps into one single icon with tons of icon_states. ;\

This is simple, I know. I've just never really experimented with icons in this way.

Or loops, apparently. Clearly it's not a good idea to keep remaking d over and over in the loop, because it should be done just the first time.

Also, this pretty obviously isn't going to work:
var/icon/o=file(i)

Like I said in the previous post, if you're going to use an /icon datum, you have to initialize it properly. An /icon is not a file.

Lummox JR
In response to Lummox JR
How -do- I initialize it then?
var/icon/o=new(i) doesn't work, which is the way it showed how in the ref. :| (It causes more errors)

mob/verb/test(directory as text)
var/icon/d=new('lawlerskates.dmi')
for(var/i in flist("[directory]\\"))
if(i=="Thumbs.db")continue
var/t=i
t=dd_replacetext(i,".bmp","")
var/icon/o=new(i)
d.Insert(o,t)
In response to Hell Ramen
Hell Ramen wrote:
How -do- I initialize it then?
var/icon/o=new(i) doesn't work, which is the way it showed how in the ref. :| (It causes more errors)

Well, it's closer to correct; you just forgot to put the two together. Clearly the file(i) should go inside new(), if i is not a file already and is just text.

Lummox JR
In response to Lummox JR
I know your (robotic) cat can catch on quicker & is smarter than me, but, still, I get a bad icon operation for doing that. >_>
In response to Hell Ramen
After more experimenting, I've figured out all of my problems.
mob/verb/test(directory as text)
var/icon/d=new('lawlerskates.dmi')
for(var/i in flist("[directory]\\"))
if(i=="Thumbs.db")continue
var/t=i
t=dd_replacetext(i,".bmp","")
var/icon/o=new(file("[directory]/[i]"))
d.Insert(o,t)



Just it caused another problem...it's not getting added to the icon file. :\
In response to Hell Ramen
Hell Ramen wrote:
Just it caused another problem...it's not getting added to the icon file. :\

Are you checking the actual file, or the /icon datum to determine that? If you try to assign that /icon to an atom.icon and use one of those states, does it appear?

Lummox JR
In response to Lummox JR
Lummox JR wrote:
> Are you checking the actual file,

Actual file. :\ (which is the effect I'm going for. <_<)

>If you try to assign that /icon to an atom.icon and use one of those states, does it appear?

Yes. Does Shift() Make it -really- go into the icon file?
In response to Hell Ramen
Hell Ramen wrote:
Lummox JR wrote:
> Are you checking the actual file,

Actual file. :\ (which is the effect I'm going for. <_<)

An /icon datum is not the same as the file itself. It's a workspace icon stored in memory only, and if it's displayed at all it's merely cached as a temporary file.

If you want to actually modify the original icon file itself, you'll have to use fcopy_rsc() and then use something like ftp() to transfer your modified icon for saving.

>If you try to assign that /icon to an atom.icon and use one of those states, does it appear?

Yes.

Then at least you know now that Insert() and such are working. That's good.

Does Shift() Make it -really- go into the icon file?

No. Since Shift() is done on an /icon, which is a workspace copy, it will only shift over the pixels of the icon in memory.

Lummox JR