sorcery  Artifact [2e32b33984]

Artifact 2e32b33984a45238c8bacfe0a3c42ca247c160aef4dda09aaaa0052641bc8f6a:

  • File util/recgen.lua — part of check-in [ea6e475e44] at 2020-10-19 09:52:11 on branch trunk — continue dev on celestial mechanics, add melding+division spells (resonance), refine itemclasses, add keypunch and punchcards, add paper pulp, add a shitload of visuals, add convenience scripts for working with the wiki, make the flamebolt spell actually useful instead of just a pretty lightshow, add essences, inferno crystal, and other goodies; iterate on wands, lots of shit i can't remember, various bugfixes (user: lexi, size: 2236) [annotate] [blame] [check-ins using]

math.randomseed(os.time())
local str = dofile('lib/str.lua')
sorcery = { lib = { class = dofile('lib/class.lua') }}
local color = dofile('lib/color.lua')
local ingredients = {}
local key = ''
print('enter a list of ingredients')
local huepoint = math.random(0,360)
local newhue = function()
	local advance = (360/#ingredients)
	huepoint = math.floor(huepoint + advance) % 360
	return huepoint
end
local prompt = function(p)
	io.stdout:write(p)
	return io.stdin:read()
end
do local i = 1 while true do
	local ing = prompt(string.format('[%u]> ', i))
	if ing ~= '' then
		ingredients[i] = {
			name = ing;
			sym = string.upper(string.sub(ing,1,1));
		}
	else break end
	i = i + 1
end end

for i,struc in ipairs(ingredients) do
	ingredients[i].color = color {
		hue = newhue(); saturation = 1, luminosity = 0.7;
	};
	key = key .. string.format('\t\t<div style="background:%s;color:%s;padding:0.3em"><strong>[%s]</strong> %s</div>\n',
		struc.color:brighten(1.3):hex(), struc.color:darken(0.5):hex(),
		struc.sym,struc.name)
end
print('enter a recipe matrix')
local rows = {}
do local row = 1 while true do
	local r = prompt('# ')
	if r == '' then break end
	rows[row] = str.explode(r, '%s+', true)
	row = row + 1
end end

local tbl = ''
local maxcols = 0
for r,row in pairs(rows) do
	for c,idx in pairs(row) do
		if idx == '0' then
			tbl = tbl .. '\t\t<div style="height:1.5em"></div>\n'
		else
			local item = ingredients[tonumber(idx)]
			tbl = tbl .. string.format('\t\t<div style="background:%s;color:%s;height:1.5em;border:1px inset %s">%s</div>\n', item.color:hex(),item.color:darken(0.5):hex(),item.color:darken(0.3):hex(),item.sym)
		end
		if c > maxcols then maxcols = c end
	end
end
tbl = string.format(
	'<div style="border:1px outset #D6008A; background:black; width: 10em">\n' ..
		'\t<div style="background:#FF5EC6;color:#28001A;padding:0.3em;text-align:center"><strong>%s</strong></div>\n' ..
		'\t<div style="display:grid;grid:auto-flow / repeat(%u,1.5em);text-align:center;width:fit-content;margin:1em auto;gap:0.1em">\n' ..
			'%s' ..
		'\t</div>\n' ..
		'\t<div>\n' ..
			'%s' ..
		'\t</div>\n' ..
	'</div>',(...),maxcols,tbl,key)

print('<!-- automatically generated by util/recgen.lua, do not edit! -->')
print(tbl)