Browse Source

[YQTemplate] added class image detection

main
Annwan 4 months ago
parent
commit
81de74d723
  1. 32
      yqform.etlua
  2. 31
      yqtemplate.lua

32
yqform.etlua

@ -15,7 +15,27 @@
<dt>Avatar</dt> <dt>Avatar</dt>
<dd><img src="data:<%= args.avatar.t -%>;base64,<%= encoder(args.avatar.v) %>" /></dd> <dd><img src="data:<%= args.avatar.t -%>;base64,<%= encoder(args.avatar.v) %>" /></dd>
<dt>Is Leader</dt> <dt>Is Leader</dt>
<dd><%= args.is_leader and args.is_leader.v %></dd>
<dd>
<% if args.is_leader and args.is_leader.v == "on" then %>
<img src="data:image/png;base64,<%= encoder(readfile('yqtemplate/basic_blank.png')) %>" />
<% else %>
<img src="data:image/png;base64,<%= encoder(readfile('yqtemplate/basic_blank.png')) %>" />
<% end %>c
</dd>
</dl>
<h3>Classes and Levels</h3>
<dl>
<dt>Class 1</dt>
<dd>
<img src="data:image/png;base64,<%= encoder(readfile('yqtemplate/'..classes[args.class1].f)) %>" />
Lvl <%= args.class1_lvl %>
</dd>
<dt>Class 2</dt>
<dd>
<img src="data:image/png;base64,<%= encoder(readfile('yqtemplate/'..classes[args.class2].f)) %>" />
Lvl <%= args.class2_lvl %>
</dd>
<dt>Class leaning</dt><dd><%= args.class_leaning %></dd>
</dl> </dl>
<% end %> <% end %>
<form method="POST" action="/cgi/yqtemplate" enctype="multipart/form-data"> <form method="POST" action="/cgi/yqtemplate" enctype="multipart/form-data">
@ -29,20 +49,20 @@
<h2>Classes and Levels</h2> <h2>Classes and Levels</h2>
<label for="class1">Class 1:</label> <label for="class1">Class 1:</label>
<select name="class1"> <select name="class1">
<% for _, v in ipairs(classes) do %>
<option value="<%= v %>"><%= v %></option>
<% for k, v in ipairs(classes) do %>
<option value="<%= k %>"><%= v.n %></option>
<% end %> <% end %>
</select> </select>
<label for="class1_lvl">Level:</label> <label for="class1_lvl">Level:</label>
<input type="number" name="class1_lvl" min="1"/><br/> <input type="number" name="class1_lvl" min="1"/><br/>
<label for="class2">Class2:</label> <label for="class2">Class2:</label>
<select name="class2"> <select name="class2">
<% for _, v in ipairs(classes) do %>
<option value="<%= v %>"><%= v %></option>
<% for k, v in ipairs(classes) do -%>
<option value="<%= k %>"><%= v.n %></option>
<% end %> <% end %>
</select> </select>
<label for="class2_lvl">Level:</label> <label for="class2_lvl">Level:</label>
<input type="number"name="class2_lvl" min="1"/><br/>
<input type="number" name="class2_lvl" min="1"/><br/>
<label for="class_leaning"> <label for="class_leaning">
Class leaning (0 for completely class 1, 100 for completely class 2): Class leaning (0 for completely class 1, 100 for completely class 2):
</label> </label>

31
yqtemplate.lua

@ -4,6 +4,20 @@ local utils = require "utils"
local yqtemplateform = utils.readfile("yqform.etlua") local yqtemplateform = utils.readfile("yqform.etlua")
local form = etlua.compile(yqtemplateform) local form = etlua.compile(yqtemplateform)
--- @type [table]
local classes = {
{ n = "Beast", f = "c01.beast.png" },
{ n = "Swordsman", f = "c02.swordsman.png" },
{ n = "Spirit Bird", f = "c03.spirit-bird.png" },
{ n = "Twin Blades", f = "c04.twin-blades.png" },
{ n = "Healer", f = "c05.healer.png" },
{ n = "Summoner", f = "c06.summoner.png" },
{ n = "Tamer", f = "c07.tamer.png" },
{ n = "Pugilist", f = "c08.pugilist.png" },
{ n = "Mounted Fighter", f = "c09.mounted-fighter.png" },
{ n = "Fruit Animal", f = "c10.fruit-animal.png" },
{ n = "Spellcaster", f = "c11.spellcaster.png" }
}
return { return {
desc = "Creates Yokoka’s quest-style personal status page", desc = "Creates Yokoka’s quest-style personal status page",
@ -33,21 +47,10 @@ return {
end end
fcgi.print( fcgi.print(
form { form {
encoder = require"base64".encode,
encoder = require "base64".encode,
readfile = utils.readfile,
args = args, args = args,
classes = {
"Beast",
"Swordsman",
"Spirit Bird",
"Twin Blades",
"Healer",
"Summoner",
"Tamer",
"Pugilist",
"Mounted Fighter",
"Fruit Animal",
"Spellcaster"
},
classes = classes
elements = { elements = {
"Fire", "Water", "Earth", "Air", "Fire", "Water", "Earth", "Air",
"Wood", "Electricity", "Metals", "Dreams", "Wood", "Electricity", "Metals", "Dreams",

Loading…
Cancel
Save