ID:158533
 
Basically I need to know how to dynamically assign a dmi in the resource file to a mob.

mob/verb/Test1(var/a as text)usr.icon=file("[a].dmi")

This is one of many attempts at it but it fails without the orignal and if the original is there it adds a duplicate to the resource cache which is a considerable amount of waste because of the large number of icons I have.

An associative list would also fail because it needs to be dynamic.

Heres some methods I have tried
Testing Method
mob
verb
TestA()
icon = fcopy_rsc("1.dmi")
if(icon)
world<<"Pass"
return
icon = file("1.dmi")
if(icon)
world<<"Pass"
return


Method 1: The force into resource cache theory.
ZZSX
var/A
verb/z()
return 0
A=list(
'1.dmi','2.dmi','3.dmi','4.dmi','5.dmi','6.dmi',
'7.dmi','8.dmi','9.dmi','10.dmi','11.dmi','12.dmi',
'13.dmi','14.dmi','15.dmi','16.dmi','17.dmi','18.dmi',
'19.dmi','20.dmi','21.dmi','22.dmi','23.dmi','24.dmi',
'25.dmi','26.dmi','27.dmi','28.dmi','29.dmi','30.dmi',
'31.dmi','32.dmi','33.dmi','34.dmi','35.dmi','36.dmi',
'37.dmi','38.dmi','39.dmi','40.dmi','41.dmi','42.dmi',
'43.dmi','44.dmi','45.dmi','46.dmi','47.dmi','48.dmi',
'49.dmi','50.dmi','51.dmi','52.dmi','53.dmi','54.dmi',
'55.dmi','56.dmi','57.dmi','58.dmi','59.dmi','60.dmi',
'61.dmi','62.dmi','63.dmi','64.dmi','65.dmi','66.dmi',
'67.dmi','68.dmi','69.dmi','70.dmi','71.dmi','72.dmi',
'73.dmi','74.dmi','75.dmi','76.dmi','77.dmi','78.dmi',
'79.dmi','80.dmi','81.dmi','82.dmi','83.dmi','84.dmi',
'85.dmi','86.dmi','87.dmi','88.dmi','89.dmi','90.dmi',
'91.dmi','92.dmi','93.dmi','94.dmi','95.dmi','96.dmi',
'97.dmi','98.dmi','99.dmi','100.dmi','101.dmi','102.dmi',
'103.dmi','104.dmi','105.dmi','106.dmi','107.dmi','108.dmi',
'109.dmi','110.dmi','111.dmi','112.dmi','113.dmi','114.dmi',
'115.dmi','116.dmi','117.dmi','118.dmi','119.dmi','120.dmi',
'121.dmi','122.dmi','123.dmi','124.dmi','125.dmi','126.dmi',
'127.dmi','128.dmi','129.dmi','130.dmi','131.dmi','132.dmi',
'133.dmi','134.dmi','135.dmi','136.dmi','137.dmi','138.dmi',
'139.dmi','140.dmi','141.dmi','142.dmi','143.dmi','144.dmi',
'145.dmi','146.dmi','147.dmi','148.dmi','149.dmi','150.dmi',
'151.dmi'
)

Fails Test

Method 2: Load into Dynamic Cache
mob/verb
Load()
Fa()
proc/Fa(var/LastDir)
var/LDir=LastDir
if(!LastDir)
LastDir=flist("Icons/")
LDir="Icons/"
else
LastDir=flist("[LastDir]")
for(var/File in LastDir)
if(findtext(File,"/"))
Fa("[LDir][File]")
else
if(findtext(File,".dmi"))
var/B=fcopy_rsc("[LDir][File]")
world<<"[LDir][File]"
var/mob/C=new()
C.icon=B
C.loc=locate(1,1,1)
sleep(1)
del(C)

Fails Test

Remember All my icons are located in subdirectorys and are not included with the final product so in other words after compiling or loading into the dynamic memory you must remove the icons first or you will have false positives when you run the test. You also need a few icons one named "1.dmi" so you don't have false negatives.