I've figured it out. Item modifications are userdata tables stored in df (the table, not the game). Searching through there, I could easily find what I had to do in order to add a modification. Calling df.new() generates a table of that type for me, and all I had to do was assign the values. Here's the script I've made, it's a little rough around the edges and doesn't apply the table to the item yet (as it's not finished) but it's a good proof of concept.
function matTest(args)
local item = load("return "..tostring(args[1]))()
local matType = args[2]
local matIndex = string.upper(tostring(args[3]))
local itemQuality = string.lower(tostring(args[4]))
local skill = string.lower(tostring(args[5]))
local shape = string.lower(tostring(args[6]))
local qualityTable = {["ordinary"] = 0, ["wellcrafted"] = 1, ["finelycrafted"] = 2, ["superior"] = 3, ["exceptional"] = 4, ["masterful"] = 5, ["artifact"] = 6}
local skillTable = {["dabbling"] = 0, ["novice"] = 1, ["adequate"] = 2, ["competent"] = 3, ["skilled"] = 4, ["proficient"] = 5, ["talented"] = 6, ["adept"] = 7, ["expert"] = 8, ["professional"] = 9, ["accomplished"] = 10, ["great"] = 11, ["master"] = 12, ["highmaster"] = 13, ["grandmaster"] = 14, ["legendary"] = 15, ["legendary1"] = 16, ["legendary2"] = 17, ["legendary3"] = 18, ["legendary4"] = 19, ["legendary5"] = 20}
local shapeTable = {["star"] = 0, ["crescent"] = 1, ["cross"] = 2, ["square"] = 3, ["circle"] = 4, ["diamond"] = 5, ["sun"] = 6, ["moon"] = 7, ["wave"] = 8, ["mountain"] = 9, ["cloud"] = 10, ["gizzard_stone"] = 11, ["smooth_pebble"] = 12, ["oval_cabochon"] = 13, ["round_cabochon"] = 14, ["cushion_cabochon"] = 15, ["rectangular_cabochon"] = 16, ["point_cut_gem"] = 17, ["table_cut_gem"] = 18, ["single_cut_gem"] = 19, ["rose_cut_gem"] = 20, ["briolette_cut_gem"] = 21, ["emerald_cut_gem"] = 22, ["marquise_cut_gem"] = 23, ["oval_cut_gem"] = 24, ["pear_cut_gem"] = 25, ["square_brilliant_cut_gem"] = 26, ["radiant_cut_gem"] = 27, ["trillion_cut_gem"] = 28, ["round_brilliant_cut_gem"] = 29, ["baguette_cut_gem"] = 30, ["tapered_baguette_cut_gem"] = 31, ["cushion_cut_gem"] = 32, ["octagon_cut_gem"] = 33, ["square_cut_gem"] = 34}
local errorString = ''
for k,v in ipairs(df.global.world.raws.inorganics) do
if v.id == matIndex then
matIndex = k
end
end
local function generateErrorString(tbl, argToUse, stringToUse)
if tbl[argToUse] == nil then
errorString = errorString..stringToUse.." '"..tostring(argToUse).."' is invalid! Args are not case sensitive, no need to worry about that. Valid "..stringToUse:lower().." levels are: \n"
for k,v in pairs(tbl) do
errorString = errorString..k.." \n"
end
return errorString
else
return nil
end
end
local skillErr = generateErrorString(skillTable, skill, "Skill")
local qualityErr = generateErrorString(qualityTable, itemQuality, "Quality")
local shapeErr;
if matType == "cover" then
shapeErr = generateErrorString(shapeTable, shape, "Shape")
if shapeErr ~= nil then
qerror(errorString)
end
end
if skillErr ~= nil or qualityErr ~= nil then
qerror(errorString)
end
local newImprovement;
if matType == "cover" then
newImprovement = df.new(df.itemimprovement_coveredst)
newImprovement.mat_type = 0
newImprovement.mat_index = matIndex
newImprovement.maker = -1
newImprovement.masterpiece_event = -1
newImprovement.quality = tonumber(qualityTable[string.lower(tostring(itemQuality))])
newImprovement.skill_rating = tonumber(skillTable[string.lower(tostring(skill))])
newImprovement.anon_1 = 0
newImprovement.shape = tonumber(shapeTable[string.lower(tostring(shape))])
for k,v in pairs(newImprovement) do
print(v)
print(k)
end
elseif matType = "spikes" then
newImprovement = df.new(df.itemimprovement_spikesst)
newImprovement.mat_type = 0
newImprovement.mat_index = matIndex
newImprovement.maker = -1
newImprovement.masterpiece_event = -1
newImprovement.quality = tonumber(qualityTable[string.lower(tostring(itemQuality))])
newImprovement.skill_rating = tonumber(skillTable[string.lower(tostring(skill))])
newImprovement.anon_1 = 0
end
end