Okay, I tried making it, and if you print all the files concatenated together it's a perfectly valid graphics file, but for some insane reason it refuses to actually write the file:
local generated_graphics_file=dfhack.getSavePath()..'/raw/graphics/graphics_procedural.txt'
if dfhack.filesystem.exists(generated_graphics_file) and not ...=='force' then qerror('Procedural graphics already exist!') end
local titans={} --also FBs
local demons={}
local angels={}
for k,v in ipairs(df.global.world.raws.creatures.all) do
if v.flags.GENERATED then
if v.flags.CASTE_TITAN or v.flags.CASTE_FEATURE_BEAST then
table.insert(titans,v)
elseif v.flags.CASTE_DEMON or v.flags.CASTE_UNIQUE_DEMON then
table.insert(demons,v)
elseif v.source_hfid~=-1 then
table.insert(angels,v)
else
table.insert(titans,v) --in the weird case
end
end
end
local tile_pages={
angel={
name="angels",
file="placeholder/placeholder.png",
TILE_DIM={16,16},
PAGE_DIM={15,15}
},
demon={
name="demons",
file="placeholder/placeholder.png",
TILE_DIM={16,16},
PAGE_DIM={15,15}
},
titan={
name="titans",
file="placeholder/placeholder.png",
TILE_DIM={16,16},
PAGE_DIM={15,15}
}
}
local graphics_file_1=[[graphics_generated
[OBJECT:GRAPHICS] ]]
for k,v in pairs(tile_pages) do
graphics_file_1=graphics_file_1..'\n\n[TILE_PAGE:'..v.name..[[]
[FILE:]]..v.file..[[]
[TILE_DIM:]]..v.TILE_DIM[1]..':'..v.TILE_DIM[2]..[[]
[PAGE_DIM:]]..v.PAGE_DIM[1]..':'..v.PAGE_DIM[2]..']'
end
local rng=dfhack.random.new()
local graphics_file_2=''
for k,v in ipairs(titans) do
graphics_file_2=graphics_file_2..'\n\n[CREATURE_GRAPHICS:'..v.creature_id..']\n'
graphics_file_2=graphics_file_2..' [DEFAULT:'..tile_pages.titan.name..':'..rng:random(tile_pages.titan.PAGE_DIM[1])..':'..rng:random(tile_pages.titan.PAGE_DIM[2])..':AS_IS]'
end
local graphics_file_3=''
for k,v in ipairs(angels) do
graphics_file_3=graphics_file_3..'\n\n[CREATURE_GRAPHICS:'..v.creature_id..']\n'
graphics_file_3=graphics_file_3..' [DEFAULT:'..tile_pages.angel.name..':'..rng:random(tile_pages.angel.PAGE_DIM[1])..':'..rng:random(tile_pages.angel.PAGE_DIM[2])..':AS_IS]'
end
local graphics_file_4=''
for k,v in ipairs(demons) do
graphics_file_4=graphics_file_4..'\n\n[CREATURE_GRAPHICS:'..v.creature_id..']\n'
graphics_file_4=graphics_file_4..' [DEFAULT:'..tile_pages.demon.name..':'..rng:random(tile_pages.demon.PAGE_DIM[1])..':'..rng:random(tile_pages.demon.PAGE_DIM[2])..':AS_IS]'
end
actual_graphics_file=io.open(generated_graphics_file,'w')
actual_graphics_file:write('')
actual_graphics_file=io.open(generated_graphics_file,'a')
actual_graphics_file:write(graphics_file_1)
actual_graphics_file:write(graphics_file_2)
actual_graphics_file:write(graphics_file_3)
actual_graphics_file:write(graphics_file_4)
The splitting of the graphics file string into four parts was my insane attempt to try to get it not to do what it was doing, but it didn't work; regardless, this happens every time:
graphics_generated
[OBJECT:GRAPHICS]
[TILE_PAGE:angels]
[FILE:placeholder/placeholder.png]
[TILE_DIM:16:16]
[PAGE_DIM:15:15]
[TILE_PAGE:titans]
[FILE:placeholder/placeholder.png]
[TILE_DIM:16:16]
[PAGE_DIM:15:15]
[TILE_PAGE:demons]
[FILE:placeholder/placeholder.png]
[TILE_DIM:16:16]
[PAGE_DIM:15:15]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_1]
[DEFAULT:titans:13:10:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_2]
[DEFAULT:titans:3:6:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_3]
[DEFAULT:titans:4:12:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_4]
[DEFAULT:titans:3:3:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_5]
[DEFAULT:titans:12:7:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_6]
[DEFAULT:titans:10:7:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_7]
[DEFAULT:titans:6:10:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_8]
[DEFAULT:titans:12:5:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_9]
[DEFAULT:titans:14:10:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_10]
[DEFAULT:titans:11:14:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_11]
[DEFAULT:titans:2:4:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_12]
[DEFAULT:titans:1:10:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_13]
[DEFAULT:titans:5:7:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_14]
[DEFAULT:titans:1:9:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_15]
[DEFAULT:titans:12:1:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_16]
[DEFAULT:titans:7:0:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_17]
[DEFAULT:titans:0:4:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_18]
[DEFAULT:titans:0:12:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_19]
[DEFAULT:titans:10:13:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_20]
[DEFAULT:titans:4:14:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_21]
[DEFAULT:titans:10:5:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_22]
[DEFAULT:titans:0:13:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_23]
[DEFAULT:titans:14:8:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_24]
[DEFAULT:titans:8:7:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_25]
[DEFAULT:titans:3:13:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_26]
[DEFAULT:titans:13:4:AS_IS]
[CREATURE_GRAPHICS:FORGOTTEN_BEAST_27]
[DEFAULT:titans:8:2:AS_IS]
[CREATURE_GRAPHICS:TITAN_1]
[DEFAULT:titans:0:14:AS_IS]
[CREATURE_GRAPHICS:TITAN_2]
[DEFAULT:titans:0:7:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_1]
[DEFAULT:titans:13:4:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_2]
[DEFAULT:titans:11:6:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_3]
[DEFAULT:titans:13:9:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_4]
[DEFAULT:titans:5:10:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_5]
[DEFAULT:titans:14:3:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_6]
[DEFAULT:titans:4:4:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_7]
[DEFAULT:titans:2:7:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_8]
[DEFAULT:titans:13:0:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_9]
[DEFAULT:titans:3:7:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_10]
[DEFAULT:titans:6:11:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_11]
[DEFAULT:titans:13:4:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_12]
[DEFAULT:titans:12:11:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_13]
[DEFAULT:titans:14:4:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_14]
[DEFAULT:titans:4:2:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_15]
[DEFAULT:titans:7:10:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_16]
[DEFAULT:titans:12:1:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_17]
[DEFAULT:titans:6:1:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_18]
[DEFAULT:titans:3:0:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_19]
[DEFAULT:titans:4:3:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_20]
[DEFAULT:titans:10:6:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_21]
[DEFAULT:titans:5:0:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_22]
[DEFAULT:titans:4:13:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_23]
[DEFAULT:titans:1:4:AS_IS]
[CREATURE_GRAPHICS:NIGHT_CREATURE_24]
[DEFAULT:titans:1:6:AS_IS]
[CREATURE_GRAPHI
As you can see, it cuts off near the end there, always part way through creature_graphics_2. To my incredible horror, removing creature_graphics_2 entirely from the listing (another insane piece of debugging work to figure out what exactly is going on) makes the file fail to write at all. I don't understand what's happening in the slightest. I thought it might be that DF is stopping it from writing, but then I put it into a folder that DF ought not be reading while a save's loaded and it continued to completely fail to work. I'm completely confused right now.
Also, you might notice night creatures get graphics, too; ain't that nice?